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