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

@ -47,6 +47,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QJsonObject> #include <QJsonObject>
#include <QKeyEvent> #include <QKeyEvent>
#include <QKeySequence>
#include <QLatin1String> #include <QLatin1String>
#include <QLineEdit> #include <QLineEdit>
#include <QList> #include <QList>
@ -414,7 +415,7 @@ void bringToFront(QWidget* w)
void handleCloseWindowShortcut(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() void openDebugLogfile()

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

Loading…
Cancel
Save