diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -51,7 +51,8 @@ namespace GUIUtil { class ClickableLabel; -} +class ClickableProgressBar; +} // namespace GUIUtil /** * Bitcoin GUI main class. This class represents the main window of the Bitcoin @@ -108,9 +109,9 @@ QLabel *labelWalletHDStatusIcon = nullptr; GUIUtil::ClickableLabel *labelProxyIcon = nullptr; GUIUtil::ClickableLabel *connectionsControl = nullptr; - QLabel *labelBlocksIcon = nullptr; + GUIUtil::ClickableLabel *labelBlocksIcon = nullptr; QLabel *progressBarLabel = nullptr; - QProgressBar *progressBar = nullptr; + GUIUtil::ClickableProgressBar *progressBar = nullptr; QProgressDialog *progressDialog = nullptr; QMenuBar *appMenuBar = nullptr; @@ -242,7 +243,7 @@ /** Set the proxy-enabled icon as shown in the UI. */ void updateProxyIcon(); -private Q_SLOTS: +public Q_SLOTS: #ifdef ENABLE_WALLET /** Switch to overview (home) page */ void gotoOverviewPage(); @@ -278,7 +279,8 @@ /** Show window if hidden, unminimize when minimized, rise when obscured or * show if hidden and fToggleHidden is true */ - void showNormalIfMinimized(bool fToggleHidden = false); + void showNormalIfMinimized() { showNormalIfMinimized(false); } + void showNormalIfMinimized(bool fToggleHidden); /** Simply calls showNormalIfMinimized(true) for use in SLOT() macro */ void toggleHidden(); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -208,12 +208,12 @@ modalOverlay = new ModalOverlay(this->centralWidget()); #ifdef ENABLE_WALLET if (enableWallet) { - connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, - SLOT(showModalOverlay())); - connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, - SLOT(showModalOverlay())); - connect(progressBar, SIGNAL(clicked(QPoint)), this, - SLOT(showModalOverlay())); + connect(walletFrame, &WalletFrame::requestedSyncWarningInfo, this, + &BitcoinGUI::showModalOverlay); + connect(labelBlocksIcon, &GUIUtil::ClickableLabel::clicked, this, + &BitcoinGUI::showModalOverlay); + connect(progressBar, &GUIUtil::ClickableProgressBar::clicked, this, + &BitcoinGUI::showModalOverlay); } #endif } @@ -293,29 +293,36 @@ // These showNormalIfMinimized are needed because Send Coins and Receive // Coins can be triggered from the tray menu, and need to show the GUI to be // useful. - connect(overviewAction, SIGNAL(triggered()), this, - SLOT(showNormalIfMinimized())); - connect(overviewAction, SIGNAL(triggered()), this, - SLOT(gotoOverviewPage())); - connect(sendCoinsAction, SIGNAL(triggered()), this, - SLOT(showNormalIfMinimized())); - connect(sendCoinsAction, SIGNAL(triggered()), this, - SLOT(gotoSendCoinsPage())); - connect(sendCoinsMenuAction, SIGNAL(triggered()), this, - SLOT(showNormalIfMinimized())); - connect(sendCoinsMenuAction, SIGNAL(triggered()), this, - SLOT(gotoSendCoinsPage())); - connect(receiveCoinsAction, SIGNAL(triggered()), this, - SLOT(showNormalIfMinimized())); - connect(receiveCoinsAction, SIGNAL(triggered()), this, - SLOT(gotoReceiveCoinsPage())); - connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, - SLOT(showNormalIfMinimized())); - connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, - SLOT(gotoReceiveCoinsPage())); - connect(historyAction, SIGNAL(triggered()), this, - SLOT(showNormalIfMinimized())); - connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); + connect(overviewAction, &QAction::triggered, this, + static_cast( + &BitcoinGUI::showNormalIfMinimized)); + connect(overviewAction, &QAction::triggered, this, + &BitcoinGUI::gotoOverviewPage); + connect(sendCoinsAction, &QAction::triggered, this, + static_cast( + &BitcoinGUI::showNormalIfMinimized)); + connect(sendCoinsAction, &QAction::triggered, + [this] { gotoSendCoinsPage(); }); + connect(sendCoinsMenuAction, &QAction::triggered, this, + static_cast( + &BitcoinGUI::showNormalIfMinimized)); + connect(sendCoinsMenuAction, &QAction::triggered, + [this] { gotoSendCoinsPage(); }); + connect(receiveCoinsAction, &QAction::triggered, this, + static_cast( + &BitcoinGUI::showNormalIfMinimized)); + connect(receiveCoinsAction, &QAction::triggered, this, + &BitcoinGUI::gotoReceiveCoinsPage); + connect(receiveCoinsMenuAction, &QAction::triggered, this, + static_cast( + &BitcoinGUI::showNormalIfMinimized)); + connect(receiveCoinsMenuAction, &QAction::triggered, this, + &BitcoinGUI::gotoReceiveCoinsPage); + connect(historyAction, &QAction::triggered, this, + static_cast( + &BitcoinGUI::showNormalIfMinimized)); + connect(historyAction, &QAction::triggered, this, + &BitcoinGUI::gotoHistoryPage); #endif // ENABLE_WALLET quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), @@ -407,43 +414,47 @@ "command-line options") .arg(tr(PACKAGE_NAME))); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); - connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); - connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden())); - connect(showHelpMessageAction, SIGNAL(triggered()), this, - SLOT(showHelpMessageClicked())); - connect(openRPCConsoleAction, SIGNAL(triggered()), this, - SLOT(showDebugWindow())); + connect(quitAction, &QAction::triggered, qApp, QApplication::quit); + connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked); + connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt); + connect(optionsAction, &QAction::triggered, this, + &BitcoinGUI::optionsClicked); + connect(toggleHideAction, &QAction::triggered, this, + &BitcoinGUI::toggleHidden); + connect(showHelpMessageAction, &QAction::triggered, this, + &BitcoinGUI::showHelpMessageClicked); + connect(openRPCConsoleAction, &QAction::triggered, this, + &BitcoinGUI::showDebugWindow); // prevents an open debug window from becoming stuck/unusable on client // shutdown - connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide())); + connect(quitAction, &QAction::triggered, rpcConsole, &QWidget::hide); #ifdef ENABLE_WALLET if (walletFrame) { - connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, - SLOT(encryptWallet(bool))); - connect(backupWalletAction, SIGNAL(triggered()), walletFrame, - SLOT(backupWallet())); - connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, - SLOT(changePassphrase())); - connect(signMessageAction, SIGNAL(triggered()), this, - SLOT(gotoSignMessageTab())); - connect(verifyMessageAction, SIGNAL(triggered()), this, - SLOT(gotoVerifyMessageTab())); - connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, - SLOT(usedSendingAddresses())); - connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, - SLOT(usedReceivingAddresses())); - connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked())); + connect(encryptWalletAction, &QAction::triggered, walletFrame, + &WalletFrame::encryptWallet); + connect(backupWalletAction, &QAction::triggered, walletFrame, + &WalletFrame::backupWallet); + connect(changePassphraseAction, &QAction::triggered, walletFrame, + &WalletFrame::changePassphrase); + connect(signMessageAction, &QAction::triggered, + [this] { gotoSignMessageTab(); }); + connect(verifyMessageAction, &QAction::triggered, + [this] { gotoVerifyMessageTab(); }); + connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, + &WalletFrame::usedSendingAddresses); + connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, + &WalletFrame::usedReceivingAddresses); + connect(openAction, &QAction::triggered, this, + &BitcoinGUI::openClicked); } #endif // ENABLE_WALLET - new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this, - SLOT(showDebugWindowActivateConsole())); - new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this, - SLOT(showDebugWindow())); + connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this), + &QShortcut::activated, this, + &BitcoinGUI::showDebugWindowActivateConsole); + connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this), + &QShortcut::activated, this, &BitcoinGUI::showDebugWindow); } void BitcoinGUI::createMenuBar() { @@ -507,8 +518,10 @@ toolbar->addWidget(spacer); m_wallet_selector = new QComboBox(); - connect(m_wallet_selector, SIGNAL(currentIndexChanged(int)), this, - SLOT(setCurrentWalletBySelectorIndex(int))); + connect(m_wallet_selector, + static_cast( + &QComboBox::currentIndexChanged), + this, &BitcoinGUI::setCurrentWalletBySelectorIndex); m_wallet_selector_label = new QLabel(); m_wallet_selector_label->setText(tr("Wallet:") + " "); @@ -533,10 +546,10 @@ // Keep up to date with client updateNetworkState(); - connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, - SLOT(setNumConnections(int))); - connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, - SLOT(setNetworkActive(bool))); + connect(_clientModel, &ClientModel::numConnectionsChanged, this, + &BitcoinGUI::setNumConnections); + connect(_clientModel, &ClientModel::networkActiveChanged, this, + &BitcoinGUI::setNetworkActive); modalOverlay->setKnownBestHeight( _clientModel->getHeaderTipHeight(), @@ -544,17 +557,19 @@ setNumBlocks(m_node.getNumBlocks(), QDateTime::fromTime_t(m_node.getLastBlockTime()), m_node.getVerificationProgress(), false); - connect(_clientModel, - SIGNAL(numBlocksChanged(int, QDateTime, double, bool)), this, - SLOT(setNumBlocks(int, QDateTime, double, bool))); + connect(_clientModel, &ClientModel::numBlocksChanged, this, + &BitcoinGUI::setNumBlocks); // Receive and report messages from client model - connect(_clientModel, SIGNAL(message(QString, QString, unsigned int)), - this, SLOT(message(QString, QString, unsigned int))); + connect(_clientModel, &ClientModel::message, + [this](const QString &title, const QString &message, + unsigned int style) { + this->message(title, message, style); + }); // Show progress dialog - connect(_clientModel, SIGNAL(showProgress(QString, int)), this, - SLOT(showProgress(QString, int))); + connect(_clientModel, &ClientModel::showProgress, this, + &BitcoinGUI::showProgress); rpcConsole->setClientModel(_clientModel); @@ -571,8 +586,8 @@ if (optionsModel) { // be aware of the tray icon disable state change reported by the // OptionsModel object. - connect(optionsModel, SIGNAL(hideTrayIconChanged(bool)), this, - SLOT(setTrayIconVisible(bool))); + connect(optionsModel, &OptionsModel::hideTrayIconChanged, this, + &BitcoinGUI::setTrayIconVisible); // initialize the disable state of the tray icon with the current // value in the model. @@ -685,8 +700,8 @@ trayIconMenu = new QMenu(this); trayIcon->setContextMenu(trayIconMenu); - connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); + connect(trayIcon, &QSystemTrayIcon::activated, this, + &BitcoinGUI::trayIconActivated); #else // Note: On Mac, the dock icon is used to provide the tray's functionality. MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); @@ -1047,11 +1062,11 @@ QWindowStateChangeEvent *wsevt = static_cast(e); if (!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) { - QTimer::singleShot(0, this, SLOT(hide())); + QTimer::singleShot(0, this, &BitcoinGUI::hide); e->ignore(); } else if ((wsevt->oldState() & Qt::WindowMinimized) && !isMinimized()) { - QTimer::singleShot(0, this, SLOT(show())); + QTimer::singleShot(0, this, &BitcoinGUI::show); e->ignore(); } } @@ -1362,8 +1377,8 @@ menuAction->setData(QVariant(u)); menu->addAction(menuAction); } - connect(menu, SIGNAL(triggered(QAction *)), this, - SLOT(onMenuSelection(QAction *))); + connect(menu, &QMenu::triggered, this, + &UnitDisplayStatusBarControl::onMenuSelection); } /** Lets the control know about the Options Model (and its signals) */ @@ -1373,8 +1388,8 @@ // be aware of a display unit change reported by the OptionsModel // object. - connect(_optionsModel, SIGNAL(displayUnitChanged(int)), this, - SLOT(updateDisplayUnit(int))); + connect(_optionsModel, &OptionsModel::displayUnitChanged, this, + &UnitDisplayStatusBarControl::updateDisplayUnit); // initialize the display units label with the current value in the // model.