qt: Use human-readable strings in preference to hard-coded integers

This is recommended by Qt docs.
See: https://doc.qt.io/qt-5/qkeysequence.html#details

Also this change avoids -Wdeprecated-enum-enum-conversion warnings.
24.x
Hennadii Stepanov 3 years ago
parent 91d12344b1
commit d8641f04e4
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F

@ -46,6 +46,7 @@
#include <QCursor>
#include <QDateTime>
#include <QDragEnterEvent>
#include <QKeySequence>
#include <QListWidget>
#include <QMenu>
#include <QMenuBar>
@ -251,28 +252,28 @@ void BitcoinGUI::createActions()
overviewAction->setStatusTip(tr("Show general overview of wallet"));
overviewAction->setToolTip(overviewAction->statusTip());
overviewAction->setCheckable(true);
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
overviewAction->setShortcut(QKeySequence(QStringLiteral("Alt+1")));
tabGroup->addAction(overviewAction);
sendCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/send"), tr("&Send"), this);
sendCoinsAction->setStatusTip(tr("Send coins to a Bitcoin address"));
sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
sendCoinsAction->setCheckable(true);
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
sendCoinsAction->setShortcut(QKeySequence(QStringLiteral("Alt+2")));
tabGroup->addAction(sendCoinsAction);
receiveCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and bitcoin: URIs)"));
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
receiveCoinsAction->setCheckable(true);
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
receiveCoinsAction->setShortcut(QKeySequence(QStringLiteral("Alt+3")));
tabGroup->addAction(receiveCoinsAction);
historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this);
historyAction->setStatusTip(tr("Browse transaction history"));
historyAction->setToolTip(historyAction->statusTip());
historyAction->setCheckable(true);
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
historyAction->setShortcut(QKeySequence(QStringLiteral("Alt+4")));
tabGroup->addAction(historyAction);
#ifdef ENABLE_WALLET
@ -290,7 +291,7 @@ void BitcoinGUI::createActions()
quitAction = new QAction(tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setShortcut(QKeySequence(tr("Ctrl+Q")));
quitAction->setMenuRole(QAction::QuitRole);
aboutAction = new QAction(tr("&About %1").arg(PACKAGE_NAME), this);
aboutAction->setStatusTip(tr("Show information about %1").arg(PACKAGE_NAME));
@ -472,7 +473,7 @@ void BitcoinGUI::createMenuBar()
QMenu* window_menu = appMenuBar->addMenu(tr("&Window"));
QAction* minimize_action = window_menu->addAction(tr("&Minimize"));
minimize_action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
minimize_action->setShortcut(QKeySequence(tr("Ctrl+M")));
connect(minimize_action, &QAction::triggered, [] {
QApplication::activeWindow()->showMinimized();
});

@ -47,6 +47,7 @@
#include <QGuiApplication>
#include <QJsonObject>
#include <QKeyEvent>
#include <QKeySequence>
#include <QLatin1String>
#include <QLineEdit>
#include <QList>
@ -414,7 +415,7 @@ void bringToFront(QWidget* w)
void handleCloseWindowShortcut(QWidget* w)
{
QObject::connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), w), &QShortcut::activated, w, &QWidget::close);
QObject::connect(new QShortcut(QKeySequence(QObject::tr("Ctrl+W")), w), &QShortcut::activated, w, &QWidget::close);
}
void openDebugLogfile()

@ -40,6 +40,7 @@
#include <QDateTime>
#include <QFont>
#include <QKeyEvent>
#include <QKeySequence>
#include <QLatin1String>
#include <QLocale>
#include <QMenu>
@ -1353,10 +1354,10 @@ QString RPCConsole::tabTitle(TabTypes tab_type) const
QKeySequence RPCConsole::tabShortcut(TabTypes tab_type) const
{
switch (tab_type) {
case TabTypes::INFO: return QKeySequence(Qt::CTRL + Qt::Key_I);
case TabTypes::CONSOLE: return QKeySequence(Qt::CTRL + Qt::Key_T);
case TabTypes::GRAPH: return QKeySequence(Qt::CTRL + Qt::Key_N);
case TabTypes::PEERS: return QKeySequence(Qt::CTRL + Qt::Key_P);
case TabTypes::INFO: return QKeySequence(tr("Ctrl+I"));
case TabTypes::CONSOLE: return QKeySequence(tr("Ctrl+T"));
case TabTypes::GRAPH: return QKeySequence(tr("Ctrl+N"));
case TabTypes::PEERS: return QKeySequence(tr("Ctrl+P"));
} // no default case, so the compiler can warn about missing cases
assert(false);

Loading…
Cancel
Save