From 4ee9ee72363d46c5ba0c71b8d8283d9c5621e3ed Mon Sep 17 00:00:00 2001
From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Date: Sun, 18 Apr 2021 15:17:38 +0300
Subject: [PATCH 1/3] qt: Use native presentation of shortcut
---
src/qt/rpcconsole.cpp | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 34d055e5a53..2e29992c0e2 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -816,14 +816,8 @@ void RPCConsole::clear(bool clearHistory)
).arg(fixedFontInfo.family(), QString("%1pt").arg(consoleFontSize))
);
-#ifdef Q_OS_MAC
- QString clsKey = "(⌘)-L";
-#else
- QString clsKey = "Ctrl-L";
-#endif
-
message(CMD_REPLY, (tr("Welcome to the %1 RPC console.").arg(PACKAGE_NAME) + "
" +
- tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg(""+clsKey+"") + "
" +
+ tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg("" + ui->clearButton->shortcut().toString(QKeySequence::NativeText) + "") + "
" +
tr("Type %1 for an overview of available commands.").arg("help") + "
" +
tr("For more information on using this console type %1.").arg("help-console") +
"
" +
From a2e122f0fe72d695762db2b83905e246f451300c Mon Sep 17 00:00:00 2001
From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Date: Sun, 18 Apr 2021 15:21:57 +0300
Subject: [PATCH 2/3] qt: Add GUIUtil::AddButtonShortcut
Co-authored-by: Jarol Rodriguez
---
src/qt/guiutil.cpp | 6 ++++++
src/qt/guiutil.h | 10 ++++++++++
2 files changed, 16 insertions(+)
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index b4afdbcc22d..15146cfac4b 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -29,6 +29,7 @@
#include
#endif
+#include
#include
#include
#include
@@ -119,6 +120,11 @@ void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
widget->setCheckValidator(new BitcoinAddressCheckValidator(parent));
}
+void AddButtonShortcut(QAbstractButton* button, const QKeySequence& shortcut)
+{
+ QObject::connect(new QShortcut(shortcut, button), &QShortcut::activated, [button]() { button->animateClick(); });
+}
+
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
{
// return if URI is not valid or is no bitcoin: URI
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index 6395ec6abdd..972d6348fc6 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -31,10 +31,12 @@ namespace interfaces
}
QT_BEGIN_NAMESPACE
+class QAbstractButton;
class QAbstractItemView;
class QAction;
class QDateTime;
class QFont;
+class QKeySequence;
class QLineEdit;
class QMenu;
class QPoint;
@@ -60,6 +62,14 @@ namespace GUIUtil
// Set up widget for address
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent);
+ /**
+ * Connects an additional shortcut to a QAbstractButton. Works around the
+ * one shortcut limitation of the button's shortcut property.
+ * @param[in] button QAbstractButton to assign shortcut to
+ * @param[in] shortcut QKeySequence to use as shortcut
+ */
+ void AddButtonShortcut(QAbstractButton* button, const QKeySequence& shortcut);
+
// Parse "bitcoin:" URI into recipient object, return true on successful parsing
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out);
bool parseBitcoinURI(QString uri, SendCoinsRecipient *out);
From 2a45134b5694c12546d77cdff541612881f7e3e7 Mon Sep 17 00:00:00 2001
From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Date: Sun, 18 Apr 2021 15:25:56 +0300
Subject: [PATCH 3/3] qt: Add shortcuts for console font resize buttons
Co-authored-by: Jarol Rodriguez
---
src/qt/rpcconsole.cpp | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 2e29992c0e2..4bf661e92ad 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -486,8 +486,18 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
ui->openDebugLogfileButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
}
ui->clearButton->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
+
ui->fontBiggerButton->setIcon(platformStyle->SingleColorIcon(":/icons/fontbigger"));
+ //: Main shortcut to increase the RPC console font size.
+ ui->fontBiggerButton->setShortcut(tr("Ctrl++"));
+ //: Secondary shortcut to increase the RPC console font size.
+ GUIUtil::AddButtonShortcut(ui->fontBiggerButton, tr("Ctrl+="));
+
ui->fontSmallerButton->setIcon(platformStyle->SingleColorIcon(":/icons/fontsmaller"));
+ //: Main shortcut to decrease the RPC console font size.
+ ui->fontSmallerButton->setShortcut(tr("Ctrl+-"));
+ //: Secondary shortcut to decrease the RPC console font size.
+ GUIUtil::AddButtonShortcut(ui->fontSmallerButton, tr("Ctrl+_"));
// Install event filter for up and down arrow
ui->lineEdit->installEventFilter(this);
@@ -816,14 +826,23 @@ void RPCConsole::clear(bool clearHistory)
).arg(fixedFontInfo.family(), QString("%1pt").arg(consoleFontSize))
);
- message(CMD_REPLY, (tr("Welcome to the %1 RPC console.").arg(PACKAGE_NAME) + "
" +
- tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg("" + ui->clearButton->shortcut().toString(QKeySequence::NativeText) + "") + "
" +
- tr("Type %1 for an overview of available commands.").arg("help") + "
" +
- tr("For more information on using this console type %1.").arg("help-console") +
- "
" +
- tr("WARNING: Scammers have been active, telling users to type commands here, stealing their wallet contents. Do not use this console without fully understanding the ramifications of a command.") +
- ""),
- true);
+ message(CMD_REPLY,
+ tr("Welcome to the %1 RPC console.").arg(PACKAGE_NAME) +
+ "
" +
+ tr("Use up and down arrows to navigate history, and %1 to clear screen.")
+ .arg("" + ui->clearButton->shortcut().toString(QKeySequence::NativeText) + "") +
+ "
" +
+ tr("Use %1 and %2 to increase or decrease the font size.")
+ .arg("" + ui->fontBiggerButton->shortcut().toString(QKeySequence::NativeText) + "")
+ .arg("" + ui->fontSmallerButton->shortcut().toString(QKeySequence::NativeText) + "") +
+ "
" +
+ tr("Type %1 for an overview of available commands.").arg("help") +
+ "
" +
+ tr("For more information on using this console type %1.").arg("help-console") +
+ "
" +
+ tr("WARNING: Scammers have been active, telling users to type commands here, stealing their wallet contents. Do not use this console without fully understanding the ramifications of a command.") +
+ "",
+ true);
}
void RPCConsole::keyPressEvent(QKeyEvent *event)