Merge bitcoin/bitcoin#24624: qt: Avoid potential -Wdeprecated-enum-enum-conversion warnings

acd98adaf1 qt: Avoid potential -Wdeprecated-enum-enum-conversion warning (Hennadii Stepanov)
d8641f04e4 qt: Use human-readable strings in preference to hard-coded integers (Hennadii Stepanov)

Pull request description:

  This PR is related to bitcoin/bitcoin#24169. It adjusts code in order to avoid `-Wdeprecated-enum-enum-conversion` warnings instead of disabling them.

  Could be tested with gcc 11.2.

ACKs for top commit:
  MarcoFalke:
    Approach ACK acd98adaf1
  fanquake:
    untested ACK acd98adaf1 - thanks.
  promag:
    Code review ACK acd98adaf1.

Tree-SHA512: e8043d997d85f8dba0f37ca02f1c60eb756a1732cf76a75908b01eb2cf7a4c6d4aaf6007271a929c213de37a0c1d96bc25280f0ee9eca488f370904461222ede
This commit is contained in:
MarcoFalke 2022-03-22 13:39:50 +01:00
commit f05cf59d91
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
4 changed files with 15 additions and 12 deletions

View file

@ -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();
}); });

View file

@ -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()

View file

@ -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);

View file

@ -550,7 +550,7 @@ void TransactionView::openThirdPartyTxUrl(QString url)
QWidget *TransactionView::createDateRangeWidget() QWidget *TransactionView::createDateRangeWidget()
{ {
dateRangeWidget = new QFrame(); dateRangeWidget = new QFrame();
dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised); dateRangeWidget->setFrameStyle(static_cast<int>(QFrame::Panel) | static_cast<int>(QFrame::Raised));
dateRangeWidget->setContentsMargins(1,1,1,1); dateRangeWidget->setContentsMargins(1,1,1,1);
QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget); QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget);
layout->setContentsMargins(0,0,0,0); layout->setContentsMargins(0,0,0,0);