-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paste button in Open URI dialog #319
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
While this looks ok on Linux:
macOS behaves differently when appropriate maximumSize
property with values for width
and height
are not set on Qt > 5.9, iirc correctly from my testing this was not a problem when we were using Qt 5.9.8:
You'll want to play around with width
and height
until you get something that looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
The icon is set both in the *.ui
and in the *.cpp
files. Is this required?
I don't have a Mac where to test that. |
Btw, the following patch --- a/src/qt/forms/openuridialog.ui
+++ b/src/qt/forms/openuridialog.ui
@@ -81,7 +81,9 @@
<header>qt/qvalidatedlineedit.h</header>
</customwidget>
</customwidgets>
- <resources/>
+ <resources>
+ <include location="../bitcoin.qrc"/>
+ </resources>
<connections>
<connection>
<sender>buttonBox</sender> makes the added icon available in Qt Designer. |
This issue could be fixed by replacing In total: diff --git a/src/qt/forms/openuridialog.ui b/src/qt/forms/openuridialog.ui
index 981d9255e..15c0a440e 100644
--- a/src/qt/forms/openuridialog.ui
+++ b/src/qt/forms/openuridialog.ui
@@ -31,7 +31,7 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="pasteButton">
+ <widget class="QToolButton" name="pasteButton">
<property name="toolTip">
<string>Paste address from clipboard</string>
</property>
@@ -41,10 +41,16 @@
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/editpaste</normaloff>:/icons/editpaste</iconset>
- </property>
- <property name="shortcut">
- <string>Alt+P</string>
- </property>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="shortcut">
+ <string>Alt+P</string>
+ </property>
</widget>
</item>
</layout>
diff --git a/src/qt/openuridialog.cpp b/src/qt/openuridialog.cpp
index ef4678a6a..131be0f4f 100644
--- a/src/qt/openuridialog.cpp
+++ b/src/qt/openuridialog.cpp
@@ -8,7 +8,9 @@
#include <qt/guiutil.h>
#include <qt/sendcoinsrecipient.h>
+#include <QAbstractButton>
#include <QClipboard>
+#include <QLineEdit>
#include <QUrl>
OpenURIDialog::OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent) :
@@ -16,8 +18,7 @@ OpenURIDialog::OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent
ui(new Ui::OpenURIDialog)
{
ui->setupUi(this);
- ui->pasteButton->setIcon(platformStyle->SingleColorIcon(":/icons/editpaste"));
- QObject::connect(ui->pasteButton, &QPushButton::clicked, ui->uriEdit, &QLineEdit::paste);
+ QObject::connect(ui->pasteButton, &QAbstractButton::clicked, ui->uriEdit, &QLineEdit::paste);
GUIUtil::handleCloseWindowShortcut(this);
} On macOS Big Sur 11.3.1 (20E241): |
It may be useful to truncate the send value so that the user still has to manually input a send value. I am also wondering if there is a way to block access to this dialogue from AppleScript events. May be a security issue? |
@hebasto In regards to #319 (comment) I like the approach, except the part where we remove the following line: - ui->pasteButton->setIcon(platformStyle->SingleColorIcon(":/icons/editpaste")); Without the above line and using: - <resources/>
+ <resources>
+ <include location="../bitcoin.qrc"/>
+ </resources> The icon will not be colorized white when using macOS dark mode If we keep the line, the icon will be colorized white when starting in macOS dark mode I would suggest to change the shortcut to <property name="shortcut">
- <string>Alt+P</string>
+ <string>Ctrl+v</string>
</property> |
Why add any shortcut to the button, if |
right 🤦. Let's remove the shortcut on the |
Addressed review comments above, this is ready for another review. |
@RandyMcMillan Your comment is out of scope of this PR, this just adds visual button to existing paste functionality. |
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: bitcoin-core/gui#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
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: bitcoin-core/gui#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
b14c6fc
to
980adfe
Compare
Modified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in regards to #319 (comment):
Modified changeEvent to match #366.
This doesn't include #275. Can you rebase to include this. This allows for easier testing and might be a cause for the CI failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Successfully compiled and tested on Ubuntu 20.04
This PR adds a button to the openbitcoinuri dialog box that allows the pasting of URI in the QLineEdit box. This is done by adding a button to the openbitcoinuri dialog box, an object of the platformStyle class, which allows setting a custom icon on the button. Finally, the pasting of URI is connected with pressing of this button, resulting in given the button its functionality.
I am adding a screenshot to show the correct working of PR.
As already mentioned by @jarolrod, OP should fix the CI formatting. Also, OP should rebase this PR on the current master head to allow the proper test of the UI changing on macOS
Co-authored-by: Emil Engler <me@emilengler.com> Co-authored-by: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= <joao.paulo.barbosa@gmail.com> Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
5062565
to
dbde055
Compare
Addressed additional review comments, this ready for another review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK dbde055
Changes since my last review:
- The formatting of the code has been fixed
- The PR is rebased over the current master
I retested this PR, and the paste button is working perfectly.
Though it might just be because of the screenshot software difference, but the paste button looks slightly different since I last reviewed this PR.
Old Commit | Latest Commit |
---|---|
Btw if it is a deliberate change, the new button looks a lot better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK dbde055
Tested on macOS 12 and on Ubuntu. Confirmed that this works as intended. Also confirmed that this responds to macOS theme switching.
Start Dark | Switch to Light |
---|---|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK dbde055.
Picking up bitcoin/bitcoin#17955, with some review comments addressed.