diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -85,8 +85,8 @@ tr("Choose the address to receive coins with")); break; } - connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, - SLOT(accept())); + connect(ui->tableView, &QTableView::doubleClicked, this, + &QDialog::accept); ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->tableView->setFocus(); ui->closeButton->setText(tr("C&hoose")); @@ -139,18 +139,19 @@ contextMenu->addSeparator(); // Connect signals for context menu actions - connect(copyAddressAction, SIGNAL(triggered()), this, - SLOT(on_copyAddress_clicked())); - connect(copyLabelAction, SIGNAL(triggered()), this, - SLOT(onCopyLabelAction())); - connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction())); - connect(deleteAction, SIGNAL(triggered()), this, - SLOT(on_deleteAddress_clicked())); - - connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(contextualMenu(QPoint))); - - connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept())); + connect(copyAddressAction, &QAction::triggered, this, + &AddressBookPage::on_copyAddress_clicked); + connect(copyLabelAction, &QAction::triggered, this, + &AddressBookPage::onCopyLabelAction); + connect(editAction, &QAction::triggered, this, + &AddressBookPage::onEditAction); + connect(deleteAction, &QAction::triggered, this, + &AddressBookPage::on_deleteAddress_clicked); + + connect(ui->tableView, &QWidget::customContextMenuRequested, this, + &AddressBookPage::contextualMenu); + + connect(ui->closeButton, &QPushButton::clicked, this, &QDialog::accept); } AddressBookPage::~AddressBookPage() { @@ -168,8 +169,8 @@ proxyModel = new AddressBookSortFilterProxyModel(type, this); proxyModel->setSourceModel(_model); - connect(ui->searchLineEdit, SIGNAL(textChanged(QString)), proxyModel, - SLOT(setFilterWildcard(QString))); + connect(ui->searchLineEdit, &QLineEdit::textChanged, proxyModel, + &QSortFilterProxyModel::setFilterWildcard); ui->tableView->setModel(proxyModel); ui->tableView->sortByColumn(0, Qt::AscendingOrder); @@ -181,12 +182,12 @@ AddressTableModel::Address, QHeaderView::ResizeToContents); connect(ui->tableView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, - SLOT(selectionChanged())); + &QItemSelectionModel::selectionChanged, this, + &AddressBookPage::selectionChanged); // Select row for newly created address - connect(_model, SIGNAL(rowsInserted(QModelIndex, int, int)), this, - SLOT(selectNewAddress(QModelIndex, int, int))); + connect(_model, &AddressTableModel::rowsInserted, this, + &AddressBookPage::selectNewAddress); selectionChanged(); } diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -70,14 +70,14 @@ break; } textChanged(); - connect(ui->toggleShowPasswordButton, SIGNAL(toggled(bool)), this, - SLOT(toggleShowPassword(bool))); - connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, - SLOT(textChanged())); - connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, - SLOT(textChanged())); - connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, - SLOT(textChanged())); + connect(ui->toggleShowPasswordButton, &QPushButton::toggled, this, + &AskPassphraseDialog::toggleShowPassword); + connect(ui->passEdit1, &QLineEdit::textChanged, this, + &AskPassphraseDialog::textChanged); + connect(ui->passEdit2, &QLineEdit::textChanged, this, + &AskPassphraseDialog::textChanged); + connect(ui->passEdit3, &QLineEdit::textChanged, this, + &AskPassphraseDialog::textChanged); } AskPassphraseDialog::~AskPassphraseDialog() { diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -355,8 +355,8 @@ window = new BitcoinGUI(m_node, config, platformStyle, networkStyle, 0); pollShutdownTimer = new QTimer(window); - connect(pollShutdownTimer, SIGNAL(timeout()), window, - SLOT(detectShutdown())); + connect(pollShutdownTimer, &QTimer::timeout, window, + &BitcoinGUI::detectShutdown); } void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle) { @@ -365,9 +365,10 @@ // the splash screen will take care of deleting itself when slotFinish // happens. splash->show(); - connect(this, SIGNAL(splashFinished(QWidget *)), splash, - SLOT(slotFinish(QWidget *))); - connect(this, SIGNAL(requestedShutdown()), splash, SLOT(close())); + connect(this, &BitcoinApplication::splashFinished, splash, + &SplashScreen::slotFinish); + connect(this, &BitcoinApplication::requestedShutdown, splash, + &QWidget::close); } void BitcoinApplication::startThread() { @@ -379,11 +380,12 @@ executor->moveToThread(coreThread); /* communication to and from thread */ - connect(executor, SIGNAL(initializeResult(bool)), this, - SLOT(initializeResult(bool))); - connect(executor, SIGNAL(shutdownResult()), this, SLOT(shutdownResult())); - connect(executor, SIGNAL(runawayException(QString)), this, - SLOT(handleRunawayException(QString))); + connect(executor, &BitcoinABC::initializeResult, this, + &BitcoinApplication::initializeResult); + connect(executor, &BitcoinABC::shutdownResult, this, + &BitcoinApplication::shutdownResult); + connect(executor, &BitcoinABC::runawayException, this, + &BitcoinApplication::handleRunawayException); // Note on how Qt works: it tries to directly invoke methods if the signal // is emitted on the same thread that the target object 'lives' on. @@ -398,16 +400,15 @@ // temporary (eg it lives somewhere aside from the stack) or this will // crash because initialize() gets executed in another thread at some // unspecified time (after) requestedInitialize() is emitted! - connect(this, - SIGNAL(requestedInitialize(Config *, RPCServer *, - HTTPRPCRequestProcessor *)), - executor, - SLOT(initialize(Config *, RPCServer *, HTTPRPCRequestProcessor *))); + connect(this, &BitcoinApplication::requestedInitialize, executor, + &BitcoinABC::initialize); - connect(this, SIGNAL(requestedShutdown()), executor, SLOT(shutdown())); + connect(this, &BitcoinApplication::requestedShutdown, executor, + &BitcoinABC::shutdown); /* make sure executor object is deleted in its own thread */ - connect(this, SIGNAL(stopThread()), executor, SLOT(deleteLater())); - connect(this, SIGNAL(stopThread()), coreThread, SLOT(quit())); + connect(this, &BitcoinApplication::stopThread, executor, + &QObject::deleteLater); + connect(this, &BitcoinApplication::stopThread, coreThread, &QThread::quit); coreThread->start(); } @@ -464,12 +465,10 @@ window->setCurrentWallet(walletModel->getWalletName()); } - connect(walletModel, - SIGNAL(coinsSent(WalletModel *, SendCoinsRecipient, QByteArray)), - paymentServer, - SLOT(fetchPaymentACK(WalletModel *, const SendCoinsRecipient &, - QByteArray))); - connect(walletModel, SIGNAL(unload()), this, SLOT(removeWallet())); + connect(walletModel, &WalletModel::coinsSent, paymentServer, + &PaymentServer::fetchPaymentACK); + connect(walletModel, &WalletModel::unload, this, + &BitcoinApplication::removeWallet); m_wallet_models.push_back(walletModel); #endif @@ -535,13 +534,15 @@ #ifdef ENABLE_WALLET // Now that initialization/startup is done, process any command-line // bitcoincash: URIs or payment requests: - connect(paymentServer, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), - window, SLOT(handlePaymentRequest(SendCoinsRecipient))); - connect(window, SIGNAL(receivedURI(QString)), paymentServer, - SLOT(handleURIOrFile(QString))); - connect(paymentServer, SIGNAL(message(QString, QString, unsigned int)), - window, SLOT(message(QString, QString, unsigned int))); - QTimer::singleShot(100, paymentServer, SLOT(uiReady())); + connect(paymentServer, &PaymentServer::receivedPaymentRequest, window, + &BitcoinGUI::handlePaymentRequest); + connect(window, &BitcoinGUI::receivedURI, paymentServer, + &PaymentServer::handleURIOrFile); + connect( + paymentServer, &PaymentServer::message, + [this](const QString &title, const QString &message, + unsigned int style) { window->message(title, message, style); }); + QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady); #endif pollShutdownTimer->start(200); diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -27,8 +27,8 @@ singleStep(100000 * SATOSHI) { setAlignment(Qt::AlignRight); - connect(lineEdit(), SIGNAL(textEdited(QString)), this, - SIGNAL(valueChanged())); + connect(lineEdit(), &QLineEdit::textEdited, this, + &AmountSpinBox::valueChanged); } QValidator::State validate(QString &text, int &pos) const override { @@ -215,9 +215,12 @@ setFocusProxy(amount); // If one if the widgets changes, the combined content changes as well - connect(amount, SIGNAL(valueChanged()), this, SIGNAL(valueChanged())); - connect(unit, SIGNAL(currentIndexChanged(int)), this, - SLOT(unitChanged(int))); + connect(amount, &AmountSpinBox::valueChanged, this, + &BitcoinAmountField::valueChanged); + connect( + unit, + static_cast(&QComboBox::currentIndexChanged), + this, &BitcoinAmountField::unitChanged); // Set default based on configuration unitChanged(unit->currentIndex()); 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. diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -40,7 +40,7 @@ peerTableModel = new PeerTableModel(m_node, this); banTableModel = new BanTableModel(m_node, this); pollTimer = new QTimer(this); - connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer())); + connect(pollTimer, &QTimer::timeout, this, &ClientModel::updateTimer); pollTimer->start(MODEL_UPDATE_DELAY); subscribeToCoreSignals(); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -72,15 +72,20 @@ contextMenu->addAction(unlockAction); // context menu signals - connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(showMenu(QPoint))); - connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); - connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); - connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); - connect(copyTransactionHashAction, SIGNAL(triggered()), this, - SLOT(copyTransactionHash())); - connect(lockAction, SIGNAL(triggered()), this, SLOT(lockCoin())); - connect(unlockAction, SIGNAL(triggered()), this, SLOT(unlockCoin())); + connect(ui->treeWidget, &QWidget::customContextMenuRequested, this, + &CoinControlDialog::showMenu); + connect(copyAddressAction, &QAction::triggered, this, + &CoinControlDialog::copyAddress); + connect(copyLabelAction, &QAction::triggered, this, + &CoinControlDialog::copyLabel); + connect(copyAmountAction, &QAction::triggered, this, + &CoinControlDialog::copyAmount); + connect(copyTransactionHashAction, &QAction::triggered, this, + &CoinControlDialog::copyTransactionHash); + connect(lockAction, &QAction::triggered, this, + &CoinControlDialog::lockCoin); + connect(unlockAction, &QAction::triggered, this, + &CoinControlDialog::unlockCoin); // clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); @@ -91,20 +96,20 @@ QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); - connect(clipboardQuantityAction, SIGNAL(triggered()), this, - SLOT(clipboardQuantity())); - connect(clipboardAmountAction, SIGNAL(triggered()), this, - SLOT(clipboardAmount())); - connect(clipboardFeeAction, SIGNAL(triggered()), this, - SLOT(clipboardFee())); - connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, - SLOT(clipboardAfterFee())); - connect(clipboardBytesAction, SIGNAL(triggered()), this, - SLOT(clipboardBytes())); - connect(clipboardLowOutputAction, SIGNAL(triggered()), this, - SLOT(clipboardLowOutput())); - connect(clipboardChangeAction, SIGNAL(triggered()), this, - SLOT(clipboardChange())); + connect(clipboardQuantityAction, &QAction::triggered, this, + &CoinControlDialog::clipboardQuantity); + connect(clipboardAmountAction, &QAction::triggered, this, + &CoinControlDialog::clipboardAmount); + connect(clipboardFeeAction, &QAction::triggered, this, + &CoinControlDialog::clipboardFee); + connect(clipboardAfterFeeAction, &QAction::triggered, this, + &CoinControlDialog::clipboardAfterFee); + connect(clipboardBytesAction, &QAction::triggered, this, + &CoinControlDialog::clipboardBytes); + connect(clipboardLowOutputAction, &QAction::triggered, this, + &CoinControlDialog::clipboardLowOutput); + connect(clipboardChangeAction, &QAction::triggered, this, + &CoinControlDialog::clipboardChange); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); ui->labelCoinControlAmount->addAction(clipboardAmountAction); @@ -115,27 +120,27 @@ ui->labelCoinControlChange->addAction(clipboardChangeAction); // toggle tree/list mode - connect(ui->radioTreeMode, SIGNAL(toggled(bool)), this, - SLOT(radioTreeMode(bool))); - connect(ui->radioListMode, SIGNAL(toggled(bool)), this, - SLOT(radioListMode(bool))); + connect(ui->radioTreeMode, &QRadioButton::toggled, this, + &CoinControlDialog::radioTreeMode); + connect(ui->radioListMode, &QRadioButton::toggled, this, + &CoinControlDialog::radioListMode); // click on checkbox - connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, - SLOT(viewItemChanged(QTreeWidgetItem *, int))); + connect(ui->treeWidget, &QTreeWidget::itemChanged, this, + &CoinControlDialog::viewItemChanged); // click on header ui->treeWidget->header()->setSectionsClickable(true); - connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, - SLOT(headerSectionClicked(int))); + connect(ui->treeWidget->header(), &QHeaderView::sectionClicked, this, + &CoinControlDialog::headerSectionClicked); // ok button - connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton *)), this, - SLOT(buttonBoxClicked(QAbstractButton *))); + connect(ui->buttonBox, &QDialogButtonBox::clicked, this, + &CoinControlDialog::buttonBoxClicked); // (un)select all - connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, - SLOT(buttonSelectAllClicked())); + connect(ui->pushButtonSelectAll, &QPushButton::clicked, this, + &CoinControlDialog::buttonSelectAllClicked); ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 84); ui->treeWidget->setColumnWidth(COLUMN_AMOUNT, 110); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -419,22 +419,20 @@ } void TableViewLastColumnResizingFixer::connectViewHeadersSignals() { - connect(tableView->horizontalHeader(), - SIGNAL(sectionResized(int, int, int)), this, - SLOT(on_sectionResized(int, int, int))); - connect(tableView->horizontalHeader(), SIGNAL(geometriesChanged()), this, - SLOT(on_geometriesChanged())); + connect(tableView->horizontalHeader(), &QHeaderView::sectionResized, this, + &TableViewLastColumnResizingFixer::on_sectionResized); + connect(tableView->horizontalHeader(), &QHeaderView::geometriesChanged, + this, &TableViewLastColumnResizingFixer::on_geometriesChanged); } // We need to disconnect these while handling the resize events, otherwise we // can enter infinite loops. void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals() { - disconnect(tableView->horizontalHeader(), - SIGNAL(sectionResized(int, int, int)), this, - SLOT(on_sectionResized(int, int, int))); - disconnect(tableView->horizontalHeader(), SIGNAL(geometriesChanged()), this, - SLOT(on_geometriesChanged())); -} + disconnect(tableView->horizontalHeader(), &QHeaderView::sectionResized, + this, &TableViewLastColumnResizingFixer::on_sectionResized); + disconnect(tableView->horizontalHeader(), &QHeaderView::geometriesChanged, + this, &TableViewLastColumnResizingFixer::on_geometriesChanged); +} // namespace GUIUtil // Setup the resize mode, handles compatibility for Qt5 and below as the method // signatures changed. diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -299,12 +299,11 @@ FreespaceChecker *executor = new FreespaceChecker(this); executor->moveToThread(thread); - connect(executor, SIGNAL(reply(int, QString, quint64)), this, - SLOT(setStatus(int, QString, quint64))); - connect(this, SIGNAL(requestCheck()), executor, SLOT(check())); + connect(executor, &FreespaceChecker::reply, this, &Intro::setStatus); + connect(this, &Intro::requestCheck, executor, &FreespaceChecker::check); /* make sure executor object is deleted in its own thread */ - connect(this, SIGNAL(stopThread()), executor, SLOT(deleteLater())); - connect(this, SIGNAL(stopThread()), thread, SLOT(quit())); + connect(this, &Intro::stopThread, executor, &QObject::deleteLater); + connect(this, &Intro::stopThread, thread, &QThread::quit); thread->start(); } diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp --- a/src/qt/modaloverlay.cpp +++ b/src/qt/modaloverlay.cpp @@ -15,7 +15,8 @@ : QWidget(parent), ui(new Ui::ModalOverlay), bestHeaderHeight(0), bestHeaderDate(QDateTime()), layerIsVisible(false), userClosed(false) { ui->setupUi(this); - connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(closeClicked())); + connect(ui->closeButton, &QPushButton::clicked, this, + &ModalOverlay::closeClicked); if (parent) { parent->installEventFilter(this); raise(); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -44,8 +44,8 @@ ui->pruneWarning->setStyleSheet("QLabel { color: red; }"); ui->pruneSize->setEnabled(false); - connect(ui->prune, SIGNAL(toggled(bool)), ui->pruneSize, - SLOT(setEnabled(bool))); + connect(ui->prune, &QPushButton::toggled, ui->pruneSize, + &QWidget::setEnabled); /* Network elements init */ #ifndef USE_UPNP @@ -60,21 +60,21 @@ ui->proxyPortTor->setEnabled(false); ui->proxyPortTor->setValidator(new QIntValidator(1, 65535, this)); - connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, - SLOT(setEnabled(bool))); - connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, - SLOT(setEnabled(bool))); - connect(ui->connectSocks, SIGNAL(toggled(bool)), this, - SLOT(updateProxyValidationState())); - - connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyIpTor, - SLOT(setEnabled(bool))); - connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyPortTor, - SLOT(setEnabled(bool))); - connect(ui->connectSocksTor, SIGNAL(toggled(bool)), this, - SLOT(updateProxyValidationState())); - -/* Window elements init */ + connect(ui->connectSocks, &QPushButton::toggled, ui->proxyIp, + &QWidget::setEnabled); + connect(ui->connectSocks, &QPushButton::toggled, ui->proxyPort, + &QWidget::setEnabled); + connect(ui->connectSocks, &QPushButton::toggled, this, + &OptionsDialog::updateProxyValidationState); + + connect(ui->connectSocksTor, &QPushButton::toggled, ui->proxyIpTor, + &QWidget::setEnabled); + connect(ui->connectSocksTor, &QPushButton::toggled, ui->proxyPortTor, + &QWidget::setEnabled); + connect(ui->connectSocksTor, &QPushButton::toggled, this, + &OptionsDialog::updateProxyValidationState); + + /* Window elements init */ #ifdef Q_OS_MAC /* remove Window tab on Mac */ ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWindow)); @@ -130,14 +130,14 @@ /* setup/change UI elements when proxy IPs are invalid/valid */ ui->proxyIp->setCheckValidator(new ProxyAddressValidator(parent)); ui->proxyIpTor->setCheckValidator(new ProxyAddressValidator(parent)); - connect(ui->proxyIp, SIGNAL(validationDidChange(QValidatedLineEdit *)), - this, SLOT(updateProxyValidationState())); - connect(ui->proxyIpTor, SIGNAL(validationDidChange(QValidatedLineEdit *)), - this, SLOT(updateProxyValidationState())); - connect(ui->proxyPort, SIGNAL(textChanged(const QString &)), this, - SLOT(updateProxyValidationState())); - connect(ui->proxyPortTor, SIGNAL(textChanged(const QString &)), this, - SLOT(updateProxyValidationState())); + connect(ui->proxyIp, &QValidatedLineEdit::validationDidChange, this, + &OptionsDialog::updateProxyValidationState); + connect(ui->proxyIpTor, &QValidatedLineEdit::validationDidChange, this, + &OptionsDialog::updateProxyValidationState); + connect(ui->proxyPort, &QLineEdit::textChanged, this, + &OptionsDialog::updateProxyValidationState); + connect(ui->proxyPortTor, &QLineEdit::textChanged, this, + &OptionsDialog::updateProxyValidationState); } OptionsDialog::~OptionsDialog() { @@ -166,29 +166,36 @@ * here so init via mapper doesn't trigger them) */ /* Main */ - connect(ui->prune, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); - connect(ui->prune, SIGNAL(clicked(bool)), this, - SLOT(togglePruneWarning(bool))); - connect(ui->pruneSize, SIGNAL(valueChanged(int)), this, - SLOT(showRestartWarning())); - connect(ui->databaseCache, SIGNAL(valueChanged(int)), this, - SLOT(showRestartWarning())); - connect(ui->threadsScriptVerif, SIGNAL(valueChanged(int)), this, - SLOT(showRestartWarning())); + connect(ui->prune, &QCheckBox::clicked, this, + &OptionsDialog::showRestartWarning); + connect(ui->prune, &QCheckBox::clicked, this, + &OptionsDialog::togglePruneWarning); + connect(ui->pruneSize, + static_cast(&QSpinBox::valueChanged), this, + &OptionsDialog::showRestartWarning); + connect(ui->databaseCache, + static_cast(&QSpinBox::valueChanged), this, + &OptionsDialog::showRestartWarning); + connect(ui->threadsScriptVerif, + static_cast(&QSpinBox::valueChanged), this, + &OptionsDialog::showRestartWarning); /* Wallet */ - connect(ui->spendZeroConfChange, SIGNAL(clicked(bool)), this, - SLOT(showRestartWarning())); + connect(ui->spendZeroConfChange, &QCheckBox::clicked, this, + &OptionsDialog::showRestartWarning); /* Network */ - connect(ui->allowIncoming, SIGNAL(clicked(bool)), this, - SLOT(showRestartWarning())); - connect(ui->connectSocks, SIGNAL(clicked(bool)), this, - SLOT(showRestartWarning())); - connect(ui->connectSocksTor, SIGNAL(clicked(bool)), this, - SLOT(showRestartWarning())); + connect(ui->allowIncoming, &QCheckBox::clicked, this, + &OptionsDialog::showRestartWarning); + connect(ui->connectSocks, &QCheckBox::clicked, this, + &OptionsDialog::showRestartWarning); + connect(ui->connectSocksTor, &QCheckBox::clicked, this, + &OptionsDialog::showRestartWarning); /* Display */ - connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning())); - connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, - SLOT(showRestartWarning())); + connect( + ui->lang, + static_cast(&QValueComboBox::valueChanged), + [this] { showRestartWarning(); }); + connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, + [this] { showRestartWarning(); }); } void OptionsDialog::setCurrentTab(OptionsDialog::Tab tab) { @@ -316,7 +323,7 @@ // clear non-persistent status label after 10 seconds // TODO: should perhaps be a class attribute, if we extend the use of // statusLabel - QTimer::singleShot(10000, this, SLOT(clearStatusLabel())); + QTimer::singleShot(10000, this, &OptionsDialog::clearStatusLabel); } } diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -136,15 +136,15 @@ ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false); - connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, - SLOT(handleTransactionClicked(QModelIndex))); + connect(ui->listTransactions, &QListView::clicked, this, + &OverviewPage::handleTransactionClicked); // start with displaying the "out of sync" warnings showOutOfSyncWarning(true); - connect(ui->labelWalletStatus, SIGNAL(clicked()), this, - SLOT(handleOutOfSyncWarningClicks())); - connect(ui->labelTransactionsStatus, SIGNAL(clicked()), this, - SLOT(handleOutOfSyncWarningClicks())); + connect(ui->labelWalletStatus, &QPushButton::clicked, this, + &OverviewPage::handleOutOfSyncWarningClicks); + connect(ui->labelTransactionsStatus, &QPushButton::clicked, this, + &OverviewPage::handleOutOfSyncWarningClicks); } void OverviewPage::handleTransactionClicked(const QModelIndex &index) { @@ -227,8 +227,8 @@ this->clientModel = model; if (model) { // Show warning if this is a prerelease version - connect(model, SIGNAL(alertsChanged(QString)), this, - SLOT(updateAlerts(QString))); + connect(model, &ClientModel::alertsChanged, this, + &OverviewPage::updateAlerts); updateAlerts(model->getStatusBarWarnings()); } } @@ -252,15 +252,15 @@ interfaces::Wallet &wallet = model->wallet(); interfaces::WalletBalances balances = wallet.getBalances(); setBalance(balances); - connect(model, SIGNAL(balanceChanged(interfaces::WalletBalances)), this, - SLOT(setBalance(interfaces::WalletBalances))); + connect(model, &WalletModel::balanceChanged, this, + &OverviewPage::setBalance); - connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, - SLOT(updateDisplayUnit())); + connect(model->getOptionsModel(), &OptionsModel::displayUnitChanged, + this, &OverviewPage::updateDisplayUnit); updateWatchOnlyLabels(wallet.haveWatchOnly()); - connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, - SLOT(updateWatchOnlyLabels(bool))); + connect(model, &WalletModel::notifyWatchonlyChanged, this, + &OverviewPage::updateWatchOnlyLabels); } // update the display unit, to not use the default ("BCH") diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -355,10 +355,10 @@ QMessageBox::critical(0, tr("Payment request error"), tr("Cannot start click-to-pay handler")); } else { - connect(uriServer, SIGNAL(newConnection()), this, - SLOT(handleURIConnection())); - connect(this, SIGNAL(receivedPaymentACK(QString)), this, - SLOT(handlePaymentACK(QString))); + connect(uriServer, &QLocalServer::newConnection, this, + &PaymentServer::handleURIConnection); + connect(this, &PaymentServer::receivedPaymentACK, this, + &PaymentServer::handlePaymentACK); } } } @@ -411,11 +411,10 @@ << "PaymentServer::initNetManager: No active proxy server found."; } - connect(netManager, SIGNAL(finished(QNetworkReply *)), this, - SLOT(netRequestFinished(QNetworkReply *))); - connect(netManager, - SIGNAL(sslErrors(QNetworkReply *, const QList &)), this, - SLOT(reportSslErrors(QNetworkReply *, const QList &))); + connect(netManager, &QNetworkAccessManager::finished, this, + &PaymentServer::netRequestFinished); + connect(netManager, &QNetworkAccessManager::sslErrors, this, + &PaymentServer::reportSslErrors); } void PaymentServer::uiReady() { @@ -516,8 +515,8 @@ clientConnection->waitForReadyRead(); } - connect(clientConnection, SIGNAL(disconnected()), clientConnection, - SLOT(deleteLater())); + connect(clientConnection, &QLocalSocket::disconnected, clientConnection, + &QLocalSocket::deleteLater); QDataStream in(clientConnection); in.setVersion(QDataStream::Qt_4_0); diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -104,7 +104,7 @@ // set up timer for auto refresh timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), SLOT(refresh())); + connect(timer, &QTimer::timeout, this, &PeerTableModel::refresh); timer->setInterval(MODEL_UPDATE_DELAY); // load initial data diff --git a/src/qt/qvalidatedlineedit.cpp b/src/qt/qvalidatedlineedit.cpp --- a/src/qt/qvalidatedlineedit.cpp +++ b/src/qt/qvalidatedlineedit.cpp @@ -9,7 +9,8 @@ QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) : QLineEdit(parent), valid(true), checkValidator(0) { - connect(this, SIGNAL(textChanged(QString)), this, SLOT(markValid())); + connect(this, &QValidatedLineEdit::textChanged, this, + &QValidatedLineEdit::markValid); } void QValidatedLineEdit::setValid(bool _valid) { diff --git a/src/qt/qvaluecombobox.cpp b/src/qt/qvaluecombobox.cpp --- a/src/qt/qvaluecombobox.cpp +++ b/src/qt/qvaluecombobox.cpp @@ -6,8 +6,10 @@ QValueComboBox::QValueComboBox(QWidget *parent) : QComboBox(parent), role(Qt::UserRole) { - connect(this, SIGNAL(currentIndexChanged(int)), this, - SLOT(handleSelectionChanged(int))); + connect( + this, + static_cast(&QComboBox::currentIndexChanged), + this, &QValueComboBox::handleSelectionChanged); } QVariant QValueComboBox::value() const { diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -60,14 +60,19 @@ contextMenu->addAction(copyAmountAction); // context menu signals - connect(ui->recentRequestsView, SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(showMenu(QPoint))); - connect(copyURIAction, SIGNAL(triggered()), this, SLOT(copyURI())); - connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); - connect(copyMessageAction, SIGNAL(triggered()), this, SLOT(copyMessage())); - connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); - - connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(ui->recentRequestsView, &QWidget::customContextMenuRequested, this, + &ReceiveCoinsDialog::showMenu); + connect(copyURIAction, &QAction::triggered, this, + &ReceiveCoinsDialog::copyURI); + connect(copyLabelAction, &QAction::triggered, this, + &ReceiveCoinsDialog::copyLabel); + connect(copyMessageAction, &QAction::triggered, this, + &ReceiveCoinsDialog::copyMessage); + connect(copyAmountAction, &QAction::triggered, this, + &ReceiveCoinsDialog::copyAmount); + + connect(ui->clearButton, &QPushButton::clicked, this, + &ReceiveCoinsDialog::clear); } void ReceiveCoinsDialog::setModel(WalletModel *_model) { @@ -76,8 +81,8 @@ if (_model && _model->getOptionsModel()) { _model->getRecentRequestsTableModel()->sort( RecentRequestsTableModel::Date, Qt::DescendingOrder); - connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), - this, SLOT(updateDisplayUnit())); + connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, + this, &ReceiveCoinsDialog::updateDisplayUnit); updateDisplayUnit(); QTableView *tableView = ui->recentRequestsView; @@ -96,9 +101,8 @@ AMOUNT_MINIMUM_COLUMN_WIDTH); connect(tableView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, - SLOT(recentRequestsView_selectionChanged(QItemSelection, - QItemSelection))); + &QItemSelectionModel::selectionChanged, this, + &ReceiveCoinsDialog::recentRequestsView_selectionChanged); // Last 2 columns are set by the columnResizingFixer, when the table // geometry is ready. columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer( diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp --- a/src/qt/receiverequestdialog.cpp +++ b/src/qt/receiverequestdialog.cpp @@ -30,10 +30,12 @@ QRImageWidget::QRImageWidget(QWidget *parent) : QLabel(parent), contextMenu(0) { contextMenu = new QMenu(this); QAction *saveImageAction = new QAction(tr("&Save Image..."), this); - connect(saveImageAction, SIGNAL(triggered()), this, SLOT(saveImage())); + connect(saveImageAction, &QAction::triggered, this, + &QRImageWidget::saveImage); contextMenu->addAction(saveImageAction); QAction *copyImageAction = new QAction(tr("&Copy Image"), this); - connect(copyImageAction, SIGNAL(triggered()), this, SLOT(copyImage())); + connect(copyImageAction, &QAction::triggered, this, + &QRImageWidget::copyImage); contextMenu->addAction(copyImageAction); } @@ -92,7 +94,8 @@ ui->lblQRCode->setVisible(false); #endif - connect(ui->btnSaveAs, SIGNAL(clicked()), ui->lblQRCode, SLOT(saveImage())); + connect(ui->btnSaveAs, &QPushButton::clicked, ui->lblQRCode, + &QRImageWidget::saveImage); } ReceiveRequestDialog::~ReceiveRequestDialog() { @@ -103,8 +106,8 @@ this->model = _model; if (_model) { - connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), - this, SLOT(update())); + connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, + this, &ReceiveRequestDialog::update); } // update the display unit if necessary diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp --- a/src/qt/recentrequeststablemodel.cpp +++ b/src/qt/recentrequeststablemodel.cpp @@ -23,8 +23,8 @@ /* These columns must match the indices in the ColumnIndex enumeration */ columns << tr("Date") << tr("Label") << tr("Message") << getAmountTitle(); - connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), - this, SLOT(updateDisplayUnit())); + connect(walletModel->getOptionsModel(), &OptionsModel::displayUnitChanged, + this, &RecentRequestsTableModel::updateDisplayUnit); } RecentRequestsTableModel::~RecentRequestsTableModel() { diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -99,7 +99,10 @@ void fontSmaller(); void setFontSize(int newSize); /** Append the message to the message widget */ - void message(int category, const QString &message, bool html = false); + void message(int category, const QString &msg) { + message(category, msg, false); + } + void message(int category, const QString &message, bool html); /** Set number of connections shown in the UI */ void setNumConnections(int count); /** Set network state shown in the UI */ diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -99,12 +99,10 @@ public: QtRPCTimerBase(std::function &_func, int64_t millis) : func(_func) { timer.setSingleShot(true); - connect(&timer, SIGNAL(timeout()), this, SLOT(timeout())); + connect(&timer, &QTimer::timeout, [this] { func(); }); timer.start(millis); } ~QtRPCTimerBase() {} -private Q_SLOTS: - void timeout() { func(); } private: QTimer timer; @@ -547,12 +545,13 @@ ui->lineEdit->installEventFilter(this); ui->messagesWidget->installEventFilter(this); - connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); - connect(ui->fontBiggerButton, SIGNAL(clicked()), this, SLOT(fontBigger())); - connect(ui->fontSmallerButton, SIGNAL(clicked()), this, - SLOT(fontSmaller())); - connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, - SLOT(clear())); + connect(ui->clearButton, &QPushButton::clicked, this, &RPCConsole::clear); + connect(ui->fontBiggerButton, &QPushButton::clicked, this, + &RPCConsole::fontBigger); + connect(ui->fontSmallerButton, &QPushButton::clicked, this, + &RPCConsole::fontSmaller); + connect(ui->btnClearTrafficGraph, &QPushButton::clicked, ui->trafficGraph, + &TrafficGraphWidget::clear); // disable the wallet selector by default ui->WalletSelector->setVisible(false); @@ -652,26 +651,26 @@ clientModel->getBanTableModel()) { // Keep up to date with client setNumConnections(model->getNumConnections()); - connect(model, SIGNAL(numConnectionsChanged(int)), this, - SLOT(setNumConnections(int))); + connect(model, &ClientModel::numConnectionsChanged, this, + &RPCConsole::setNumConnections); interfaces::Node &node = clientModel->node(); setNumBlocks(node.getNumBlocks(), QDateTime::fromTime_t(node.getLastBlockTime()), node.getVerificationProgress(), false); - connect(model, SIGNAL(numBlocksChanged(int, QDateTime, double, bool)), - this, SLOT(setNumBlocks(int, QDateTime, double, bool))); + connect(model, &ClientModel::numBlocksChanged, this, + &RPCConsole::setNumBlocks); updateNetworkState(); - connect(model, SIGNAL(networkActiveChanged(bool)), this, - SLOT(setNetworkActive(bool))); + connect(model, &ClientModel::networkActiveChanged, this, + &RPCConsole::setNetworkActive); updateTrafficStats(node.getTotalBytesRecv(), node.getTotalBytesSent()); - connect(model, SIGNAL(bytesChanged(quint64, quint64)), this, - SLOT(updateTrafficStats(quint64, quint64))); + connect(model, &ClientModel::bytesChanged, this, + &RPCConsole::updateTrafficStats); - connect(model, SIGNAL(mempoolSizeChanged(long, size_t)), this, - SLOT(setMempoolSize(long, size_t))); + connect(model, &ClientModel::mempoolSizeChanged, this, + &RPCConsole::setMempoolSize); // set up peer table ui->peerWidget->setModel(model->getPeerTableModel()); @@ -715,35 +714,38 @@ signalMapper->setMapping(banAction24h, 60 * 60 * 24); signalMapper->setMapping(banAction7d, 60 * 60 * 24 * 7); signalMapper->setMapping(banAction365d, 60 * 60 * 24 * 365); - connect(banAction1h, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(banAction24h, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(banAction7d, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(banAction365d, SIGNAL(triggered()), signalMapper, SLOT(map())); - connect(signalMapper, SIGNAL(mapped(int)), this, - SLOT(banSelectedNode(int))); + connect(banAction1h, &QAction::triggered, signalMapper, + static_cast(&QSignalMapper::map)); + connect(banAction24h, &QAction::triggered, signalMapper, + static_cast(&QSignalMapper::map)); + connect(banAction7d, &QAction::triggered, signalMapper, + static_cast(&QSignalMapper::map)); + connect(banAction365d, &QAction::triggered, signalMapper, + static_cast(&QSignalMapper::map)); + connect( + signalMapper, + static_cast(&QSignalMapper::mapped), + this, &RPCConsole::banSelectedNode); // peer table context menu signals - connect(ui->peerWidget, - SIGNAL(customContextMenuRequested(const QPoint &)), this, - SLOT(showPeersTableContextMenu(const QPoint &))); - connect(disconnectAction, SIGNAL(triggered()), this, - SLOT(disconnectSelectedNode())); + connect(ui->peerWidget, &QTableView::customContextMenuRequested, this, + &RPCConsole::showPeersTableContextMenu); + connect(disconnectAction, &QAction::triggered, this, + &RPCConsole::disconnectSelectedNode); // peer table signal handling - update peer details when selecting new // node - connect( - ui->peerWidget->selectionModel(), - SIGNAL(selectionChanged(const QItemSelection &, - const QItemSelection &)), - this, - SLOT(peerSelected(const QItemSelection &, const QItemSelection &))); + connect(ui->peerWidget->selectionModel(), + &QItemSelectionModel::selectionChanged, this, + &RPCConsole::peerSelected); // peer table signal handling - update peer details when new nodes are // added to the model - connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, - SLOT(peerLayoutChanged())); + connect(model->getPeerTableModel(), &PeerTableModel::layoutChanged, + this, &RPCConsole::peerLayoutChanged); // peer table signal handling - cache selected node ids - connect(model->getPeerTableModel(), SIGNAL(layoutAboutToBeChanged()), - this, SLOT(peerLayoutAboutToChange())); + connect(model->getPeerTableModel(), + &PeerTableModel::layoutAboutToBeChanged, this, + &RPCConsole::peerLayoutAboutToChange); // set up ban table ui->banlistWidget->setModel(model->getBanTableModel()); @@ -766,20 +768,19 @@ banTableContextMenu->addAction(unbanAction); // ban table context menu signals - connect(ui->banlistWidget, - SIGNAL(customContextMenuRequested(const QPoint &)), this, - SLOT(showBanTableContextMenu(const QPoint &))); - connect(unbanAction, SIGNAL(triggered()), this, - SLOT(unbanSelectedNode())); + connect(ui->banlistWidget, &QTableView::customContextMenuRequested, + this, &RPCConsole::showBanTableContextMenu); + connect(unbanAction, &QAction::triggered, this, + &RPCConsole::unbanSelectedNode); // ban table signal handling - clear peer details when clicking a peer // in the ban table - connect(ui->banlistWidget, SIGNAL(clicked(const QModelIndex &)), this, - SLOT(clearSelectedNode())); + connect(ui->banlistWidget, &QTableView::clicked, this, + &RPCConsole::clearSelectedNode); // ban table signal handling - ensure ban table is shown or hidden (if // empty) - connect(model->getBanTableModel(), SIGNAL(layoutChanged()), this, - SLOT(showOrHideBanTableIfRequired())); + connect(model->getBanTableModel(), &BanTableModel::layoutChanged, this, + &RPCConsole::showOrHideBanTableIfRequired); showOrHideBanTableIfRequired(); // Provide initial values @@ -1122,17 +1123,18 @@ executor->moveToThread(&thread); // Replies from executor object must go to this object - connect(executor, SIGNAL(reply(int, QString)), this, - SLOT(message(int, QString))); + connect(executor, &RPCExecutor::reply, this, + static_cast( + &RPCConsole::message)); + // Requests from this object must go to executor - connect(this, SIGNAL(cmdRequest(QString, QString)), executor, - SLOT(request(QString, QString))); + connect(this, &RPCConsole::cmdRequest, executor, &RPCExecutor::request); // On stopExecutor signal // - quit the Qt event loop in the execution thread - connect(this, SIGNAL(stopExecutor()), &thread, SLOT(quit())); + connect(this, &RPCConsole::stopExecutor, &thread, &QThread::quit); // - queue executor for deletion (in execution thread) - connect(&thread, SIGNAL(finished()), executor, SLOT(deleteLater()), + connect(&thread, &QThread::finished, executor, &RPCExecutor::deleteLater, Qt::DirectConnection); // Default implementation of QThread::run() simply spins up an event loop in diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -51,16 +51,18 @@ addEntry(); - connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); - connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(ui->addButton, &QPushButton::clicked, this, + &SendCoinsDialog::addEntry); + connect(ui->clearButton, &QPushButton::clicked, this, + &SendCoinsDialog::clear); // Coin Control - connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, - SLOT(coinControlButtonClicked())); - connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, - SLOT(coinControlChangeChecked(int))); - connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), - this, SLOT(coinControlChangeEdited(const QString &))); + connect(ui->pushButtonCoinControl, &QPushButton::clicked, this, + &SendCoinsDialog::coinControlButtonClicked); + connect(ui->checkBoxCoinControlChange, &QCheckBox::stateChanged, this, + &SendCoinsDialog::coinControlChangeChecked); + connect(ui->lineEditCoinControlChange, &QValidatedLineEdit::textEdited, + this, &SendCoinsDialog::coinControlChangeEdited); // Coin Control: clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); @@ -70,20 +72,20 @@ QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this); QAction *clipboardLowOutputAction = new QAction(tr("Copy dust"), this); QAction *clipboardChangeAction = new QAction(tr("Copy change"), this); - connect(clipboardQuantityAction, SIGNAL(triggered()), this, - SLOT(coinControlClipboardQuantity())); - connect(clipboardAmountAction, SIGNAL(triggered()), this, - SLOT(coinControlClipboardAmount())); - connect(clipboardFeeAction, SIGNAL(triggered()), this, - SLOT(coinControlClipboardFee())); - connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, - SLOT(coinControlClipboardAfterFee())); - connect(clipboardBytesAction, SIGNAL(triggered()), this, - SLOT(coinControlClipboardBytes())); - connect(clipboardLowOutputAction, SIGNAL(triggered()), this, - SLOT(coinControlClipboardLowOutput())); - connect(clipboardChangeAction, SIGNAL(triggered()), this, - SLOT(coinControlClipboardChange())); + connect(clipboardQuantityAction, &QAction::triggered, this, + &SendCoinsDialog::coinControlClipboardQuantity); + connect(clipboardAmountAction, &QAction::triggered, this, + &SendCoinsDialog::coinControlClipboardAmount); + connect(clipboardFeeAction, &QAction::triggered, this, + &SendCoinsDialog::coinControlClipboardFee); + connect(clipboardAfterFeeAction, &QAction::triggered, this, + &SendCoinsDialog::coinControlClipboardAfterFee); + connect(clipboardBytesAction, &QAction::triggered, this, + &SendCoinsDialog::coinControlClipboardBytes); + connect(clipboardLowOutputAction, &QAction::triggered, this, + &SendCoinsDialog::coinControlClipboardLowOutput); + connect(clipboardChangeAction, &QAction::triggered, this, + &SendCoinsDialog::coinControlClipboardChange); ui->labelCoinControlQuantity->addAction(clipboardQuantityAction); ui->labelCoinControlAmount->addAction(clipboardAmountAction); ui->labelCoinControlFee->addAction(clipboardFeeAction); @@ -148,9 +150,8 @@ this->clientModel = _clientModel; if (_clientModel) { - connect(_clientModel, - SIGNAL(numBlocksChanged(int, QDateTime, double, bool)), this, - SLOT(updateSmartFeeLabel())); + connect(_clientModel, &ClientModel::numBlocksChanged, this, + &SendCoinsDialog::updateSmartFeeLabel); } } @@ -168,37 +169,43 @@ interfaces::WalletBalances balances = _model->wallet().getBalances(); setBalance(balances); - connect(_model, SIGNAL(balanceChanged(interfaces::WalletBalances)), - this, SLOT(setBalance(interfaces::WalletBalances))); - connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), - this, SLOT(updateDisplayUnit())); + connect(_model, &WalletModel::balanceChanged, this, + &SendCoinsDialog::setBalance); + connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, + this, &SendCoinsDialog::updateDisplayUnit); updateDisplayUnit(); // Coin Control - connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), - this, SLOT(coinControlUpdateLabels())); + connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, + this, &SendCoinsDialog::coinControlUpdateLabels); connect(_model->getOptionsModel(), - SIGNAL(coinControlFeaturesChanged(bool)), this, - SLOT(coinControlFeatureChanged(bool))); + &OptionsModel::coinControlFeaturesChanged, this, + &SendCoinsDialog::coinControlFeatureChanged); ui->frameCoinControl->setVisible( _model->getOptionsModel()->getCoinControlFeatures()); coinControlUpdateLabels(); // fee section - connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, - SLOT(updateFeeSectionControls())); - connect(ui->groupFee, SIGNAL(buttonClicked(int)), this, - SLOT(coinControlUpdateLabels())); - connect(ui->groupCustomFee, SIGNAL(buttonClicked(int)), this, - SLOT(coinControlUpdateLabels())); - connect(ui->customFee, SIGNAL(valueChanged()), this, - SLOT(coinControlUpdateLabels())); - connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, - SLOT(setMinimumFee())); - connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, - SLOT(updateFeeSectionControls())); - connect(ui->checkBoxMinimumFee, SIGNAL(stateChanged(int)), this, - SLOT(coinControlUpdateLabels())); + connect(ui->groupFee, + static_cast( + &QButtonGroup::buttonClicked), + this, &SendCoinsDialog::updateFeeSectionControls); + connect(ui->groupFee, + static_cast( + &QButtonGroup::buttonClicked), + this, &SendCoinsDialog::coinControlUpdateLabels); + connect(ui->groupCustomFee, + static_cast( + &QButtonGroup::buttonClicked), + this, &SendCoinsDialog::coinControlUpdateLabels); + connect(ui->customFee, &BitcoinAmountField::valueChanged, this, + &SendCoinsDialog::coinControlUpdateLabels); + connect(ui->checkBoxMinimumFee, &QCheckBox::stateChanged, this, + &SendCoinsDialog::setMinimumFee); + connect(ui->checkBoxMinimumFee, &QCheckBox::stateChanged, this, + &SendCoinsDialog::updateFeeSectionControls); + connect(ui->checkBoxMinimumFee, &QCheckBox::stateChanged, this, + &SendCoinsDialog::coinControlUpdateLabels); ui->customFee->setSingleStep(model->wallet().getRequiredFee(1000)); updateFeeSectionControls(); @@ -427,14 +434,14 @@ SendCoinsEntry *SendCoinsDialog::addEntry() { SendCoinsEntry *entry = new SendCoinsEntry(platformStyle, model, this); ui->entries->addWidget(entry); - connect(entry, SIGNAL(removeEntry(SendCoinsEntry *)), this, - SLOT(removeEntry(SendCoinsEntry *))); - connect(entry, SIGNAL(useAvailableBalance(SendCoinsEntry *)), this, - SLOT(useAvailableBalance(SendCoinsEntry *))); - connect(entry, SIGNAL(payAmountChanged()), this, - SLOT(coinControlUpdateLabels())); - connect(entry, SIGNAL(subtractFeeFromAmountChanged()), this, - SLOT(coinControlUpdateLabels())); + connect(entry, &SendCoinsEntry::removeEntry, this, + &SendCoinsDialog::removeEntry); + connect(entry, &SendCoinsEntry::useAvailableBalance, this, + &SendCoinsDialog::useAvailableBalance); + connect(entry, &SendCoinsEntry::payAmountChanged, this, + &SendCoinsDialog::coinControlUpdateLabels); + connect(entry, &SendCoinsEntry::subtractFeeFromAmountChanged, this, + &SendCoinsDialog::coinControlUpdateLabels); // Focus the field, so that entry can start immediately entry->clear(); @@ -916,7 +923,8 @@ setDefaultButton(QMessageBox::Cancel); yesButton = button(QMessageBox::Yes); updateYesButton(); - connect(&countDownTimer, SIGNAL(timeout()), this, SLOT(countDown())); + connect(&countDownTimer, &QTimer::timeout, this, + &SendConfirmationDialog::countDown); } int SendConfirmationDialog::exec() { diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -46,16 +46,18 @@ ui->payTo_is->setFont(GUIUtil::fixedPitchFont()); // Connect signals - connect(ui->payAmount, SIGNAL(valueChanged()), this, - SIGNAL(payAmountChanged())); - connect(ui->checkboxSubtractFeeFromAmount, SIGNAL(toggled(bool)), this, - SIGNAL(subtractFeeFromAmountChanged())); - connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked())); - connect(ui->deleteButton_is, SIGNAL(clicked()), this, - SLOT(deleteClicked())); - connect(ui->deleteButton_s, SIGNAL(clicked()), this, SLOT(deleteClicked())); - connect(ui->useAvailableBalanceButton, SIGNAL(clicked()), this, - SLOT(useAvailableBalanceClicked())); + connect(ui->payAmount, &BitcoinAmountField::valueChanged, this, + &SendCoinsEntry::payAmountChanged); + connect(ui->checkboxSubtractFeeFromAmount, &QCheckBox::toggled, this, + &SendCoinsEntry::subtractFeeFromAmountChanged); + connect(ui->deleteButton, &QPushButton::clicked, this, + &SendCoinsEntry::deleteClicked); + connect(ui->deleteButton_is, &QPushButton::clicked, this, + &SendCoinsEntry::deleteClicked); + connect(ui->deleteButton_s, &QPushButton::clicked, this, + &SendCoinsEntry::deleteClicked); + connect(ui->useAvailableBalanceButton, &QPushButton::clicked, this, + &SendCoinsEntry::useAvailableBalanceClicked); // Set the model properly. setModel(model); @@ -100,8 +102,8 @@ } if (_model && _model->getOptionsModel()) { - connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), - this, SLOT(updateDisplayUnit())); + connect(_model->getOptionsModel(), &OptionsModel::displayUnitChanged, + this, &SendCoinsEntry::updateDisplayUnit); } clear(); diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp --- a/src/qt/test/paymentservertests.cpp +++ b/src/qt/test/paymentservertests.cpp @@ -36,8 +36,8 @@ static SendCoinsRecipient handleRequest(PaymentServer *server, std::vector &data) { RecipientCatcher sigCatcher; - QObject::connect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), - &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); + QObject::connect(server, &PaymentServer::receivedPaymentRequest, + &sigCatcher, &RecipientCatcher::getRecipient); // Write data to a temp file: QTemporaryFile f; @@ -54,9 +54,8 @@ // will lead to a test failure anyway. QCoreApplication::sendEvent(&object, &event); - QObject::disconnect(server, - SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), - &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); + QObject::disconnect(server, &PaymentServer::receivedPaymentRequest, + &sigCatcher, &RecipientCatcher::getRecipient); // Return results from sigCatcher return sigCatcher.recipient; diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -22,7 +22,7 @@ : QWidget(parent), timer(0), fMax(0.0f), nMins(0), vSamplesIn(), vSamplesOut(), nLastBytesIn(0), nLastBytesOut(0), clientModel(0) { timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), SLOT(updateRates())); + connect(timer, &QTimer::timeout, this, &TrafficGraphWidget::updateRates); } void TrafficGraphWidget::setClientModel(ClientModel *model) { diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -219,8 +219,8 @@ walletModel->getOptionsModel()->getDisplayUnit()); priv->refreshWallet(walletModel->wallet()); - connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), - this, SLOT(updateDisplayUnit())); + connect(walletModel->getOptionsModel(), &OptionsModel::displayUnitChanged, + this, &TransactionTableModel::updateDisplayUnit); subscribeToCoreSignals(); } diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -182,37 +182,56 @@ mapperThirdPartyTxUrls = new QSignalMapper(this); // Connect actions - connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, - SLOT(openThirdPartyTxUrl(QString))); - - connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); - connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); - connect(watchOnlyWidget, SIGNAL(activated(int)), this, - SLOT(chooseWatchonly(int))); - connect(amountWidget, SIGNAL(textChanged(QString)), amount_typing_delay, - SLOT(start())); - connect(amount_typing_delay, SIGNAL(timeout()), this, - SLOT(changedAmount())); - connect(search_widget, SIGNAL(textChanged(QString)), prefix_typing_delay, - SLOT(start())); - connect(prefix_typing_delay, SIGNAL(timeout()), this, - SLOT(changedSearch())); - - connect(view, SIGNAL(doubleClicked(QModelIndex)), this, - SIGNAL(doubleClicked(QModelIndex))); - connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(contextualMenu(QPoint))); - - connect(abandonAction, SIGNAL(triggered()), this, SLOT(abandonTx())); - connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); - connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); - connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); - connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); - connect(copyTxHexAction, SIGNAL(triggered()), this, SLOT(copyTxHex())); - connect(copyTxPlainText, SIGNAL(triggered()), this, - SLOT(copyTxPlainText())); - connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); - connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); + connect(mapperThirdPartyTxUrls, + static_cast( + &QSignalMapper::mapped), + this, &TransactionView::openThirdPartyTxUrl); + + connect(dateWidget, + static_cast(&QComboBox::activated), this, + &TransactionView::chooseDate); + connect(typeWidget, + static_cast(&QComboBox::activated), this, + &TransactionView::chooseType); + connect(watchOnlyWidget, + static_cast(&QComboBox::activated), this, + &TransactionView::chooseWatchonly); + connect(amountWidget, &QLineEdit::textChanged, amount_typing_delay, + static_cast(&QTimer::start)); + connect(amount_typing_delay, &QTimer::timeout, this, + &TransactionView::changedAmount); + connect(search_widget, &QLineEdit::textChanged, prefix_typing_delay, + static_cast(&QTimer::start)); + connect(prefix_typing_delay, &QTimer::timeout, this, + &TransactionView::changedSearch); + + connect(view, &QTableView::doubleClicked, this, + &TransactionView::doubleClicked); + connect(view, &QTableView::customContextMenuRequested, this, + &TransactionView::contextualMenu); + + connect(abandonAction, &QAction::triggered, this, + &TransactionView::abandonTx); + connect(copyAddressAction, &QAction::triggered, this, + &TransactionView::copyAddress); + connect(copyLabelAction, &QAction::triggered, this, + &TransactionView::copyLabel); + connect(copyAmountAction, &QAction::triggered, this, + &TransactionView::copyAmount); + connect(copyTxIDAction, &QAction::triggered, this, + &TransactionView::copyTxID); + connect(copyTxHexAction, &QAction::triggered, this, + &TransactionView::copyTxHex); + connect(copyTxPlainText, &QAction::triggered, this, + &TransactionView::copyTxPlainText); + connect(editLabelAction, &QAction::triggered, this, + &TransactionView::editLabel); + connect(showDetailsAction, &QAction::triggered, this, + &TransactionView::showDetails); + // Double-clicking on a transaction on the transaction history page shows + // details + connect(this, &TransactionView::doubleClicked, this, + &TransactionView::showDetails); } void TransactionView::setModel(WalletModel *_model) { @@ -267,8 +286,10 @@ contextMenu->addSeparator(); } contextMenu->addAction(thirdPartyTxUrlAction); - connect(thirdPartyTxUrlAction, SIGNAL(triggered()), - mapperThirdPartyTxUrls, SLOT(map())); + connect(thirdPartyTxUrlAction, &QAction::triggered, + mapperThirdPartyTxUrls, + static_cast( + &QSignalMapper::map)); mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, listUrls[i].trimmed()); } @@ -279,8 +300,8 @@ updateWatchOnlyColumn(_model->wallet().haveWatchOnly()); // Watch-only signal - connect(_model, SIGNAL(notifyWatchonlyChanged(bool)), this, - SLOT(updateWatchOnlyColumn(bool))); + connect(_model, &WalletModel::notifyWatchonlyChanged, this, + &TransactionView::updateWatchOnlyColumn); } } @@ -595,9 +616,10 @@ dateRangeWidget->setVisible(false); // Notify on change - connect(dateFrom, SIGNAL(dateChanged(QDate)), this, - SLOT(dateRangeChanged())); - connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); + connect(dateFrom, &QDateTimeEdit::dateChanged, this, + &TransactionView::dateRangeChanged); + connect(dateTo, &QDateTimeEdit::dateChanged, this, + &TransactionView::dateRangeChanged); return dateRangeWidget; } diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -60,11 +60,11 @@ mapWalletViews[name] = walletView; // Ensure a walletView is able to show the main window - connect(walletView, SIGNAL(showNormalIfMinimized()), gui, - SLOT(showNormalIfMinimized())); + connect(walletView, &WalletView::showNormalIfMinimized, + [this] { gui->showNormalIfMinimized(); }); - connect(walletView, SIGNAL(outOfSyncWarningClicked()), this, - SLOT(outOfSyncWarningClicked())); + connect(walletView, &WalletView::outOfSyncWarningClicked, this, + &WalletFrame::outOfSyncWarningClicked); return true; } diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -39,7 +39,8 @@ // This timer will be fired repeatedly to update the balance pollTimer = new QTimer(this); - connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged())); + connect(pollTimer, &QTimer::timeout, this, + &WalletModel::pollBalanceChanged); pollTimer->start(MODEL_UPDATE_DELAY); subscribeToCoreSignals(); diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -69,30 +69,28 @@ // Clicking on a transaction on the overview pre-selects the transaction on // the transaction history page - connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), - transactionView, SLOT(focusTransaction(QModelIndex))); - connect(overviewPage, SIGNAL(outOfSyncWarningClicked()), this, - SLOT(requestedSyncWarningInfo())); + connect(overviewPage, &OverviewPage::transactionClicked, transactionView, + static_cast( + &TransactionView::focusTransaction)); - // Highlight transaction after send - connect(sendCoinsPage, SIGNAL(coinsSent(uint256)), transactionView, - SLOT(focusTransaction(uint256))); + connect(overviewPage, &OverviewPage::outOfSyncWarningClicked, this, + &WalletView::requestedSyncWarningInfo); - // Double-clicking on a transaction on the transaction history page shows - // details - connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), - transactionView, SLOT(showDetails())); + // Highlight transaction after send + connect(sendCoinsPage, &SendCoinsDialog::coinsSent, transactionView, + static_cast( + &TransactionView::focusTransaction)); // Clicking on "Export" allows to export the transaction list - connect(exportButton, SIGNAL(clicked()), transactionView, - SLOT(exportClicked())); + connect(exportButton, &QPushButton::clicked, transactionView, + &TransactionView::exportClicked); // Pass through messages from sendCoinsPage - connect(sendCoinsPage, SIGNAL(message(QString, QString, unsigned int)), - this, SIGNAL(message(QString, QString, unsigned int))); + connect(sendCoinsPage, &SendCoinsDialog::message, this, + &WalletView::message); // Pass through messages from transactionView - connect(transactionView, SIGNAL(message(QString, QString, unsigned int)), - this, SIGNAL(message(QString, QString, unsigned int))); + connect(transactionView, &TransactionView::message, this, + &WalletView::message); // Set the model properly. setWalletModel(walletModel); @@ -104,32 +102,30 @@ if (gui) { // Clicking on a transaction on the overview page simply sends you to // transaction history page - connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), gui, - SLOT(gotoHistoryPage())); + connect(overviewPage, &OverviewPage::transactionClicked, gui, + &BitcoinGUI::gotoHistoryPage); // Navigate to transaction history page after send - connect(sendCoinsPage, SIGNAL(coinsSent(uint256)), gui, - SLOT(gotoHistoryPage())); + connect(sendCoinsPage, &SendCoinsDialog::coinsSent, gui, + &BitcoinGUI::gotoHistoryPage); // Receive and report messages - connect(this, SIGNAL(message(QString, QString, unsigned int)), gui, - SLOT(message(QString, QString, unsigned int))); + connect( + this, &WalletView::message, + [gui](const QString &title, const QString &message, + unsigned int style) { gui->message(title, message, style); }); // Pass through encryption status changed signals - connect(this, SIGNAL(encryptionStatusChanged()), gui, - SLOT(updateWalletStatus())); + connect(this, &WalletView::encryptionStatusChanged, gui, + &BitcoinGUI::updateWalletStatus); // Pass through transaction notifications - connect(this, - SIGNAL(incomingTransaction(QString, int, Amount, QString, - QString, QString, QString)), - gui, - SLOT(incomingTransaction(QString, int, Amount, QString, QString, - QString, QString))); + connect(this, &WalletView::incomingTransaction, gui, + &BitcoinGUI::incomingTransaction); // Connect HD enabled state signal - connect(this, SIGNAL(hdEnabledStatusChanged()), gui, - SLOT(updateWalletStatus())); + connect(this, &WalletView::hdEnabledStatusChanged, gui, + &BitcoinGUI::updateWalletStatus); } } @@ -155,12 +151,12 @@ if (_walletModel) { // Receive and pass through messages from wallet model - connect(_walletModel, SIGNAL(message(QString, QString, unsigned int)), - this, SIGNAL(message(QString, QString, unsigned int))); + connect(_walletModel, &WalletModel::message, this, + &WalletView::message); // Handle changes in encryption status - connect(_walletModel, SIGNAL(encryptionStatusChanged()), this, - SIGNAL(encryptionStatusChanged())); + connect(_walletModel, &WalletModel::encryptionStatusChanged, this, + &WalletView::encryptionStatusChanged); updateEncryptionStatus(); // update HD status @@ -168,16 +164,16 @@ // Balloon pop-up for new transaction connect(_walletModel->getTransactionTableModel(), - SIGNAL(rowsInserted(QModelIndex, int, int)), this, - SLOT(processNewTransaction(QModelIndex, int, int))); + &TransactionTableModel::rowsInserted, this, + &WalletView::processNewTransaction); // Ask for passphrase if needed - connect(_walletModel, SIGNAL(requireUnlock()), this, - SLOT(unlockWallet())); + connect(_walletModel, &WalletModel::requireUnlock, this, + &WalletView::unlockWallet); // Show progress dialog - connect(_walletModel, SIGNAL(showProgress(QString, int)), this, - SLOT(showProgress(QString, int))); + connect(_walletModel, &WalletModel::showProgress, this, + &WalletView::showProgress); } }