Skip to content

Commit 916f45e

Browse files
committed
Merge #329: Make console buttons look clickable
8b419b5 qt: make console buttons look clickable (Jarol Rodriguez) Pull request description: On master, for macOS, the console buttons' hitboxes are quite small. This makes clicking on the button with your mouse a little more tedious than it should be. The Issue is related to recent versions of Qt (>5.9.8) not playing so nice on macOS when there are "incorrect" `width` and `height` values set for a `QPushButton` (here is another example: #319 (review)). This fixes this small hitbox issue by converting the buttons from `QPushButton` to `QToolButton`, which in turn makes the buttons look explicitly clickable. This approach was chosen as it helps us avoid having to play around with `width` and `height` values until we find values that play nice with macOS and look good on Linux & Windows. Also, `QToolButton` is an appropriate class for these buttons. Per [Qt Docs](https://doc.qt.io/qt-5/qtoolbutton.html#details): > A tool button is a special button that provides quick-access to specific commands or options. As opposed to a normal command button, a tool button usually doesn't show a text label, but shows an icon instead. Since we are changing the type of the buttons, we need to change the respective actions connection logic in `rpcconsole`. Instead of plugging in `QToolButton`, we abstract it to the base class: `QAbstractButton`. per [Qt Dev Notes](https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Developer-Notes-for-Qt-Code#inherited-signals-and-slot) > Use base class functions as this makes the code more general, e.g., use QAbstractButton::clicked instead of QPushButton::clicked. While here, we also update the size of the icons to `22x22` to be consistent with other tool buttons. **macOS: Master vs PR:** | Master | PR | | ----------- | ----------- | | ![master-ss-macos](https://user-images.githubusercontent.com/23396902/118339460-e9079c80-b4e6-11eb-864b-d394aca5df61.png) | ![pr-ss-macos](https://user-images.githubusercontent.com/23396902/118339468-ec9b2380-b4e6-11eb-9a9e-30620216750e.png) | **Linux: Master vs PR:** | Master | PR | | ----------- | ----------- | | ![master-ss-linux](https://user-images.githubusercontent.com/23396902/118339520-13595a00-b4e7-11eb-86d0-96dd1264c198.png) | ![pr-ss-linux](https://user-images.githubusercontent.com/23396902/118339533-1c4a2b80-b4e7-11eb-8d7f-f733d999c8fd.png) | ACKs for top commit: hebasto: ACK 8b419b5, tested on Linux Mint 20.1 (Qt 5.12.8). promag: Tested ACK 8b419b5 on macOS Big Sur M1, this drops only relevant usages to `flat` buttons. Tree-SHA512: 3f3cdcbe83398136a1d1ee8fc2835be8681f2ed39e79db1e939cab6a00a779f528343d54992807a845cc84d9ef13591affb7a6dbca9e5753a2b8665b0af4d611
2 parents 38ab7d0 + 8b419b5 commit 916f45e

File tree

2 files changed

+17
-46
lines changed

2 files changed

+17
-46
lines changed

src/qt/forms/debugwindow.ui

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,7 @@
470470
</spacer>
471471
</item>
472472
<item>
473-
<widget class="QPushButton" name="fontSmallerButton">
474-
<property name="maximumSize">
475-
<size>
476-
<width>24</width>
477-
<height>24</height>
478-
</size>
479-
</property>
473+
<widget class="QToolButton" name="fontSmallerButton">
480474
<property name="toolTip">
481475
<string>Decrease font size</string>
482476
</property>
@@ -489,26 +483,14 @@
489483
</property>
490484
<property name="iconSize">
491485
<size>
492-
<width>24</width>
493-
<height>16</height>
486+
<width>22</width>
487+
<height>22</height>
494488
</size>
495489
</property>
496-
<property name="autoDefault">
497-
<bool>false</bool>
498-
</property>
499-
<property name="flat">
500-
<bool>true</bool>
501-
</property>
502490
</widget>
503491
</item>
504492
<item>
505-
<widget class="QPushButton" name="fontBiggerButton">
506-
<property name="maximumSize">
507-
<size>
508-
<width>24</width>
509-
<height>24</height>
510-
</size>
511-
</property>
493+
<widget class="QToolButton" name="fontBiggerButton">
512494
<property name="toolTip">
513495
<string>Increase font size</string>
514496
</property>
@@ -521,26 +503,14 @@
521503
</property>
522504
<property name="iconSize">
523505
<size>
524-
<width>24</width>
525-
<height>16</height>
506+
<width>22</width>
507+
<height>22</height>
526508
</size>
527509
</property>
528-
<property name="autoDefault">
529-
<bool>false</bool>
530-
</property>
531-
<property name="flat">
532-
<bool>true</bool>
533-
</property>
534510
</widget>
535511
</item>
536512
<item>
537-
<widget class="QPushButton" name="clearButton">
538-
<property name="maximumSize">
539-
<size>
540-
<width>24</width>
541-
<height>24</height>
542-
</size>
543-
</property>
513+
<widget class="QToolButton" name="clearButton">
544514
<property name="toolTip">
545515
<string>Clear console</string>
546516
</property>
@@ -554,15 +524,15 @@
554524
<iconset resource="../bitcoin.qrc">
555525
<normaloff>:/icons/remove</normaloff>:/icons/remove</iconset>
556526
</property>
527+
<property name="iconSize">
528+
<size>
529+
<width>22</width>
530+
<height>22</height>
531+
</size>
532+
</property>
557533
<property name="shortcut">
558534
<string notr="true">Ctrl+L</string>
559535
</property>
560-
<property name="autoDefault">
561-
<bool>false</bool>
562-
</property>
563-
<property name="flat">
564-
<bool>true</bool>
565-
</property>
566536
</widget>
567537
</item>
568538
</layout>

src/qt/rpcconsole.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <wallet/wallet.h>
3535
#endif
3636

37+
#include <QAbstractButton>
3738
#include <QDateTime>
3839
#include <QFont>
3940
#include <QKeyEvent>
@@ -530,9 +531,9 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
530531
ui->lineEdit->setMaxLength(16 * 1024 * 1024);
531532
ui->messagesWidget->installEventFilter(this);
532533

533-
connect(ui->clearButton, &QPushButton::clicked, [this] { clear(); });
534-
connect(ui->fontBiggerButton, &QPushButton::clicked, this, &RPCConsole::fontBigger);
535-
connect(ui->fontSmallerButton, &QPushButton::clicked, this, &RPCConsole::fontSmaller);
534+
connect(ui->clearButton, &QAbstractButton::clicked, [this] { clear(); });
535+
connect(ui->fontBiggerButton, &QAbstractButton::clicked, this, &RPCConsole::fontBigger);
536+
connect(ui->fontSmallerButton, &QAbstractButton::clicked, this, &RPCConsole::fontSmaller);
536537
connect(ui->btnClearTrafficGraph, &QPushButton::clicked, ui->trafficGraph, &TrafficGraphWidget::clear);
537538

538539
// disable the wallet selector by default

0 commit comments

Comments
 (0)