From 7150d90538f07864a892adfa4473c3fc7051e9a1 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 9 Jan 2020 12:39:41 +0200 Subject: [PATCH 1/3] qt: Add HighlightLabelWidget --- .../libbitcoin_qt/libbitcoin_qt.vcxproj | 2 + src/Makefile.qt.include | 3 + src/qt/highlightlabelwidget.cpp | 55 +++++++++++++++++++ src/qt/highlightlabelwidget.h | 44 +++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 src/qt/highlightlabelwidget.cpp create mode 100644 src/qt/highlightlabelwidget.h diff --git a/build_msvc/libbitcoin_qt/libbitcoin_qt.vcxproj b/build_msvc/libbitcoin_qt/libbitcoin_qt.vcxproj index 992f64ec2e01d..b49d64de89589 100644 --- a/build_msvc/libbitcoin_qt/libbitcoin_qt.vcxproj +++ b/build_msvc/libbitcoin_qt/libbitcoin_qt.vcxproj @@ -24,6 +24,7 @@ + @@ -76,6 +77,7 @@ + diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index cf09eee2cbdfb..30b72b864be11 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -45,6 +45,7 @@ QT_MOC_CPP = \ qt/moc_csvmodelwriter.cpp \ qt/moc_editaddressdialog.cpp \ qt/moc_guiutil.cpp \ + qt/moc_highlightlabelwidget.cpp \ qt/moc_intro.cpp \ qt/moc_macdockiconhandler.cpp \ qt/moc_macnotificationhandler.cpp \ @@ -113,6 +114,7 @@ BITCOIN_QT_H = \ qt/editaddressdialog.h \ qt/guiconstants.h \ qt/guiutil.h \ + qt/highlightlabelwidget.h \ qt/intro.h \ qt/macdockiconhandler.h \ qt/macnotificationhandler.h \ @@ -212,6 +214,7 @@ BITCOIN_QT_BASE_CPP = \ qt/clientmodel.cpp \ qt/csvmodelwriter.cpp \ qt/guiutil.cpp \ + qt/highlightlabelwidget.cpp \ qt/intro.cpp \ qt/modaloverlay.cpp \ qt/networkstyle.cpp \ diff --git a/src/qt/highlightlabelwidget.cpp b/src/qt/highlightlabelwidget.cpp new file mode 100644 index 0000000000000..fd6599f8d2c23 --- /dev/null +++ b/src/qt/highlightlabelwidget.cpp @@ -0,0 +1,55 @@ +// Copyright (c) 2020 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include +#include +#include +#include + +HighlightLabelWidget::HighlightLabelWidget(QWidget* parent) + : QLabel(parent) +{ + setCursor(Qt::IBeamCursor); + setFocusPolicy(Qt::StrongFocus); + setTextFormat(Qt::PlainText); + setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard | Qt::LinksAccessibleByKeyboard); +} + +void HighlightLabelWidget::setText(const QString& text) +{ + const bool selected = hasSelectedText(); + QLabel::setText(text); + if (selected) { + SelectAll(); + } +} + +void HighlightLabelWidget::focusInEvent(QFocusEvent* ev) +{ + if (ev->reason() == Qt::TabFocusReason || ev->reason() == Qt::BacktabFocusReason) { + // Highligt label when focused via keyboard. + SelectAll(); + } +} + +void HighlightLabelWidget::focusOutEvent(QFocusEvent* ev) +{ + if (ev->reason() != Qt::PopupFocusReason) { + Reset(); + } +} + +void HighlightLabelWidget::Reset() +{ + const QString content = text(); + clear(); + QLabel::setText(content); +} + +void HighlightLabelWidget::SelectAll() +{ + setSelection(0, text().size()); +} diff --git a/src/qt/highlightlabelwidget.h b/src/qt/highlightlabelwidget.h new file mode 100644 index 0000000000000..1d3144d8e3ade --- /dev/null +++ b/src/qt/highlightlabelwidget.h @@ -0,0 +1,44 @@ +// Copyright (c) 2020 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_HIGHLIGHTLABELWIDGET_H +#define BITCOIN_QT_HIGHLIGHTLABELWIDGET_H + +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QFocusEvent; +class QString; +class QWidget; +QT_END_NAMESPACE + +/** + * Widget for displaying bitcoin amounts with privacy facilities + */ +class HighlightLabelWidget : public QLabel +{ + Q_OBJECT + +public: + explicit HighlightLabelWidget(QWidget* parent = nullptr); + +public Q_SLOTS: + // Hide QLabel::setText(const QString&) + void setText(const QString& text); + +protected: + void focusInEvent(QFocusEvent* ev) override; + void focusOutEvent(QFocusEvent* ev) override; + +private: + // Prevent zombie cursor (|). + void Reset(); + // Select all the text (i.e., highlight it). + void SelectAll(); +}; + +#endif // BITCOIN_QT_HIGHLIGHTLABELWIDGET_H From 191187ca0c98ba96c21fa0b1efb47af3e980cffe Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 9 Jan 2020 12:41:22 +0200 Subject: [PATCH 2/3] qt: Make Information tab accessible via keyboard --- src/qt/forms/debugwindow.ui | 137 +++++------------------------------- src/qt/rpcconsole.cpp | 9 +-- 2 files changed, 22 insertions(+), 124 deletions(-) diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 8b70800838d98..f1c90c665e09c 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -67,19 +67,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -93,19 +84,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -119,19 +101,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -142,25 +115,16 @@ - - - IBeamCursor - + To specify a non-default location of the data directory use the '%1' option. N/A - - Qt::PlainText - true - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -171,25 +135,16 @@ - - - IBeamCursor - + To specify a non-default location of the blocks directory use the '%1' option. N/A - - Qt::PlainText - true - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -200,19 +155,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -236,19 +182,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -259,19 +196,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -295,19 +223,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -318,19 +237,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -354,19 +264,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -377,19 +278,10 @@ - - - IBeamCursor - + N/A - - Qt::PlainText - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -1565,6 +1457,11 @@ clear() + + HighlightLabelWidget + QLabel +
qt/highlightlabelwidget.h
+
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 0ffdc892c5a58..ce2802a2d67b3 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -9,15 +9,16 @@ #include #include +#include +#include +#include #include #include +#include #include #include -#include -#include -#include -#include #include +#include #include #include From 1bd1e604aebc0e1dd437cd294195332080596223 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 9 Jan 2020 13:14:08 +0200 Subject: [PATCH 3/3] qt: Make Overview tab accessible via keyboard --- src/qt/forms/overviewpage.ui | 90 ++++++++++++++---------------------- src/qt/overviewpage.cpp | 1 + 2 files changed, 35 insertions(+), 56 deletions(-) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index 710801ee96dfe..cad2498308501 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -72,6 +72,9 @@ 16777215 + + Qt::ClickFocus + The displayed information may be out of date. Your wallet automatically synchronizes with the Bitcoin network after a connection is established, but this process has not completed yet. @@ -115,16 +118,13 @@ 12 - + 75 true - - IBeamCursor - Unconfirmed transactions to watch-only addresses @@ -134,22 +134,16 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - + 75 true - - IBeamCursor - Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance @@ -159,22 +153,16 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - + 75 true - - IBeamCursor - Mined balance in watch-only addresses that has not yet matured @@ -184,9 +172,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -223,16 +208,13 @@ - + 75 true - - IBeamCursor - Mined balance that has not yet matured @@ -242,9 +224,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -268,16 +247,13 @@ - + 75 true - - IBeamCursor - Your current total balance @@ -287,22 +263,16 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - + 75 true - - IBeamCursor - Current total balance in watch-only addresses @@ -312,9 +282,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -335,16 +302,13 @@ - + 75 true - - IBeamCursor - Your current spendable balance @@ -354,22 +318,16 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - + 75 true - - IBeamCursor - Your current balance in watch-only addresses @@ -379,9 +337,6 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - @@ -458,6 +413,9 @@ 16777215 + + Qt::ClickFocus + The displayed information may be out of date. Your wallet automatically synchronizes with the Bitcoin network after a connection is established, but this process has not completed yet. @@ -497,6 +455,9 @@ + + Qt::ClickFocus + QListView { background: transparent; } @@ -536,6 +497,23 @@ + + + HighlightLabelWidget + QLabel +
qt/highlightlabelwidget.h
+
+
+ + labelBalance + labelUnconfirmed + labelImmature + labelTotal + labelWatchAvailable + labelWatchPending + labelWatchImmature + labelWatchTotal + diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index c376921b72f35..35d04e0589c1a 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include