Skip to content

Commit

Permalink
Change connect syntax to Qt 5 standard for bitcoingui.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Aug 15, 2021
1 parent 3349bd4 commit b7adb32
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 67 deletions.
141 changes: 75 additions & 66 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,26 @@ BitcoinGUI::BitcoinGUI(QWidget* parent)
statusBar()->setSizeGripEnabled(false);

// Clicking on a transaction on the overview page simply sends you to transaction history page
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));
connect(overviewPage, &OverviewPage::transactionClicked, this, &BitcoinGUI::gotoHistoryPage);
connect(overviewPage, &OverviewPage::transactionClicked, transactionView, &TransactionView::focusTransaction);

// Clicking on the current poll label on the overview page simply sends you to the voting page
connect(overviewPage, SIGNAL(pollLabelClicked()), this, SLOT(gotoVotingPage()));
connect(overviewPage, &OverviewPage::pollLabelClicked, this, &BitcoinGUI::gotoVotingPage);

// Double-clicking on a transaction on the transaction history page shows details
connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
connect(transactionView, &TransactionView::doubleClicked, transactionView, &TransactionView::showDetails);

rpcConsole = new RPCConsole(this);
connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));
connect(openRPCConsoleAction, &QAction::triggered, rpcConsole, &QWidget::show);

diagnosticsDialog = new DiagnosticsDialog(this);

// Clicking on "Verify Message" in the address book sends you to the verify message tab
connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString)));
connect(addressBookPage, &FavoritesPage::verifyMessage, this, &BitcoinGUI::gotoVerifyMessageTab);
// Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
connect(receiveCoinsPage, &ReceiveCoinsPage::signMessage, this, &BitcoinGUI::gotoSignMessageTab);

connect(openConfigAction, SIGNAL(triggered()), this, SLOT(openConfigClicked()));
connect(openConfigAction, &QAction::triggered, this, &BitcoinGUI::openConfigClicked);

gotoOverviewPage();
}
Expand Down Expand Up @@ -336,23 +336,23 @@ void BitcoinGUI::createActions()
boincAction->setStatusTip(tr("Gridcoin rewards distributed computing with BOINC"));
boincAction->setMenuRole(QAction::TextHeuristicRole);

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(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
connect(votingAction, SIGNAL(triggered()), this, SLOT(gotoVotingPage()));

connect(websiteAction, SIGNAL(triggered()), this, SLOT(websiteClicked()));
connect(bxAction, SIGNAL(triggered()), this, SLOT(bxClicked()));
connect(exchangeAction, SIGNAL(triggered()), this, SLOT(exchangeClicked()));
connect(boincAction, SIGNAL(triggered()), this, SLOT(boincStatsClicked()));
connect(chatAction, SIGNAL(triggered()), this, SLOT(chatClicked()));
connect(overviewAction, &QAction::triggered, this, &BitcoinGUI::showNormalIfMinimized);
connect(overviewAction, &QAction::triggered, this, &BitcoinGUI::gotoOverviewPage);
connect(sendCoinsAction, &QAction::triggered, this, &BitcoinGUI::showNormalIfMinimized);
connect(sendCoinsAction, &QAction::triggered, this, &BitcoinGUI::gotoSendCoinsPage);
connect(receiveCoinsAction, &QAction::triggered, this, &BitcoinGUI::showNormalIfMinimized);
connect(receiveCoinsAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage);
connect(historyAction, &QAction::triggered, this, &BitcoinGUI::showNormalIfMinimized);
connect(historyAction, &QAction::triggered, this, &BitcoinGUI::gotoHistoryPage);
connect(addressBookAction, &QAction::triggered, this, &BitcoinGUI::showNormalIfMinimized);
connect(addressBookAction, &QAction::triggered, this, &BitcoinGUI::gotoAddressBookPage);
connect(votingAction, &QAction::triggered, this, &BitcoinGUI::gotoVotingPage);

connect(websiteAction, &QAction::triggered, this, &BitcoinGUI::websiteClicked);
connect(bxAction, &QAction::triggered, this, &BitcoinGUI::bxClicked);
connect(exchangeAction, &QAction::triggered, this, &BitcoinGUI::exchangeClicked);
connect(boincAction, &QAction::triggered, this, &BitcoinGUI::boincStatsClicked);
connect(chatAction, &QAction::triggered, this, &BitcoinGUI::chatClicked);

quitAction = new QAction(tr("E&xit"), this);
quitAction->setToolTip(tr("Quit application"));
Expand Down Expand Up @@ -407,21 +407,21 @@ void BitcoinGUI::createActions()
resetblockchainAction = new QAction(tr("&Reset blockchain data"), this);
resetblockchainAction->setToolTip(tr("Remove blockchain data and start chain from zero"));

connect(quitAction, SIGNAL(triggered()), this, SLOT(tryQuit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
connect(researcherAction, SIGNAL(triggered()), this, SLOT(researcherClicked()));
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet()));
connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
connect(unlockWalletAction, SIGNAL(triggered()), this, SLOT(unlockWallet()));
connect(lockWalletAction, SIGNAL(triggered()), this, SLOT(lockWallet()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
connect(diagnosticsAction, SIGNAL(triggered()), this, SLOT(diagnosticsClicked()));
connect(snapshotAction, SIGNAL(triggered()), this, SLOT(snapshotClicked()));
connect(resetblockchainAction, SIGNAL(triggered()), this, SLOT(resetblockchainClicked()));
connect(quitAction, &QAction::triggered, this, &BitcoinGUI::tryQuit);
connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked);
connect(optionsAction, &QAction::triggered, this, &BitcoinGUI::optionsClicked);
connect(researcherAction, &QAction::triggered, this, &BitcoinGUI::researcherClicked);
connect(toggleHideAction, &QAction::triggered, this, &BitcoinGUI::toggleHidden);
connect(encryptWalletAction, &QAction::triggered, this, &BitcoinGUI::encryptWallet);
connect(backupWalletAction, &QAction::triggered, this, &BitcoinGUI::backupWallet);
connect(changePassphraseAction, &QAction::triggered, this, &BitcoinGUI::changePassphrase);
connect(unlockWalletAction, &QAction::triggered, this, &BitcoinGUI::unlockWallet);
connect(lockWalletAction, &QAction::triggered, this, &BitcoinGUI::lockWallet);
connect(signMessageAction, &QAction::triggered, this, &BitcoinGUI::gotoSignMessageTabDefault);
connect(verifyMessageAction, &QAction::triggered, this, &BitcoinGUI::gotoVerifyMesageTabDefault);
connect(diagnosticsAction, &QAction::triggered, this, &BitcoinGUI::diagnosticsClicked);
connect(snapshotAction, &QAction::triggered, this, &BitcoinGUI::snapshotClicked);
connect(resetblockchainAction, &QAction::triggered, this, &BitcoinGUI::resetblockchainClicked);
}

void BitcoinGUI::setIcons()
Expand Down Expand Up @@ -734,28 +734,28 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)

// set stylesheet
setOptionsStyleSheet(this->clientModel->getOptionsModel()->getCurrentStyle());
connect(this->clientModel->getOptionsModel(),SIGNAL(walletStylesheetChanged(QString)),this,SLOT(setOptionsStyleSheet(QString)));
connect(this->clientModel->getOptionsModel(), &OptionsModel::walletStylesheetChanged,
this, &BitcoinGUI::setOptionsStyleSheet);

// Keep up to date with client
setNumConnections(clientModel->getNumConnections());
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
connect(clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);

setNumBlocks(clientModel->getNumBlocks(), clientModel->getNumBlocksOfPeers());
connect(clientModel, SIGNAL(numBlocksChanged(int,int)), this, SLOT(setNumBlocks(int,int)));
connect(clientModel, &ClientModel::numBlocksChanged, this, &BitcoinGUI::setNumBlocks);

setDifficulty(clientModel->getDifficulty());
connect(clientModel, SIGNAL(difficultyChanged(double)), this, SLOT(setDifficulty(double)));
connect(clientModel, &ClientModel::difficultyChanged, this, &BitcoinGUI::setDifficulty);

setMinerStatus(false, 0.0, 0.0, 0.0);
connect(clientModel, SIGNAL(minerStatusChanged(bool, double, double, double)),
this, SLOT(setMinerStatus(bool, double, double, double)));
connect(clientModel, &ClientModel::minerStatusChanged, this, &BitcoinGUI::setMinerStatus);

// Start with out-of-sync message for scraper/NN.
updateScraperIcon((int)scrapereventtypes::OutOfSync, CT_UPDATING);
connect(clientModel, SIGNAL(updateScraperStatus(int, int)), this, SLOT(updateScraperIcon(int, int)));
connect(clientModel, &ClientModel::updateScraperStatus, this, &BitcoinGUI::updateScraperIcon);

// Report errors from network/worker thread
connect(clientModel, SIGNAL(error(QString,QString,bool)), this, SLOT(error(QString,QString,bool)));
connect(clientModel, &ClientModel::error, this, &BitcoinGUI::error);

rpcConsole->setClientModel(clientModel);
addressBookPage->setOptionsModel(clientModel->getOptionsModel());
Expand Down Expand Up @@ -786,14 +786,14 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel)
signVerifyMessageDialog->setModel(walletModel);

setEncryptionStatus(walletModel->getEncryptionStatus());
connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int)));
connect(walletModel, &WalletModel::encryptionStatusChanged, this, &BitcoinGUI::setEncryptionStatus);

// Balloon pop-up for new transaction
connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(incomingTransaction(QModelIndex,int,int)));
connect(walletModel->getTransactionTableModel(), &TransactionTableModel::rowsInserted,
this, &BitcoinGUI::incomingTransaction);

// Ask for passphrase if needed
connect(walletModel, SIGNAL(requireUnlock()), this, SLOT(unlockWallet()));
connect(walletModel, &WalletModel::requireUnlock, this, &BitcoinGUI::unlockWallet);
}
}

Expand All @@ -809,7 +809,7 @@ void BitcoinGUI::setResearcherModel(ResearcherModel *researcherModel)
diagnosticsDialog->SetResearcherModel(researcherModel);

updateBeaconIcon();
connect(researcherModel, SIGNAL(beaconChanged()), this, SLOT(updateBeaconIcon()));
connect(researcherModel, &ResearcherModel::beaconChanged, this, &BitcoinGUI::updateBeaconIcon);
}

void BitcoinGUI::setVotingModel(VotingModel *votingModel)
Expand All @@ -823,7 +823,7 @@ void BitcoinGUI::setVotingModel(VotingModel *votingModel)

overviewPage->setCurrentPollTitle(votingModel->getCurrentPollTitle());

connect(votingModel, SIGNAL(newPollReceived()), this, SLOT(handleNewPoll()));
connect(votingModel, &VotingModel::newPollReceived, this, &BitcoinGUI::handleNewPoll);
}

void BitcoinGUI::createTrayIcon()
Expand All @@ -848,8 +848,7 @@ void BitcoinGUI::createTrayIconMenu()
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();
Expand Down Expand Up @@ -1098,7 +1097,7 @@ void BitcoinGUI::update(const QString &title, const QString& version, const QStr
// Due to slight delay in gui load this could appear behind the gui ui
// The only other option available would make the message box stay on top of all applications

QTimer::singleShot(5000, updateMessageDialog.get(), SLOT(show()));
QTimer::singleShot(5000, updateMessageDialog.get(), [this]() { updateMessageDialog->show(); });
}

void BitcoinGUI::changeEvent(QEvent *e)
Expand Down Expand Up @@ -1347,7 +1346,7 @@ void BitcoinGUI::gotoOverviewPage()
centralWidget->setCurrentWidget(overviewPage);

exportAction->setEnabled(false);
disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr);
disconnect(exportAction, &QAction::triggered, nullptr, nullptr);
}

void BitcoinGUI::gotoHistoryPage()
Expand All @@ -1356,8 +1355,8 @@ void BitcoinGUI::gotoHistoryPage()
centralWidget->setCurrentWidget(transactionView);

exportAction->setEnabled(true);
disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr);
connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked()));
disconnect(exportAction, &QAction::triggered, nullptr, nullptr);
connect(exportAction, &QAction::triggered, transactionView, &TransactionView::exportClicked);
}

void BitcoinGUI::gotoAddressBookPage()
Expand All @@ -1366,8 +1365,8 @@ void BitcoinGUI::gotoAddressBookPage()
centralWidget->setCurrentWidget(addressBookPage);

exportAction->setEnabled(true);
disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr);
connect(exportAction, SIGNAL(triggered()), addressBookPage, SLOT(exportClicked()));
disconnect(exportAction, &QAction::triggered, nullptr, nullptr);
connect(exportAction, &QAction::triggered, addressBookPage, &FavoritesPage::exportClicked);
}

void BitcoinGUI::gotoReceiveCoinsPage()
Expand All @@ -1376,8 +1375,8 @@ void BitcoinGUI::gotoReceiveCoinsPage()
centralWidget->setCurrentWidget(receiveCoinsPage);

exportAction->setEnabled(true);
disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr);
connect(exportAction, SIGNAL(triggered()), receiveCoinsPage, SLOT(exportClicked()));
disconnect(exportAction, &QAction::triggered, nullptr, nullptr);
connect(exportAction, &QAction::triggered, receiveCoinsPage, &ReceiveCoinsPage::exportClicked);
}

void BitcoinGUI::gotoSendCoinsPage()
Expand All @@ -1386,7 +1385,7 @@ void BitcoinGUI::gotoSendCoinsPage()
centralWidget->setCurrentWidget(sendCoinsPage);

exportAction->setEnabled(false);
disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr);
disconnect(exportAction, &QAction::triggered, nullptr, nullptr);
}

void BitcoinGUI::gotoVotingPage()
Expand All @@ -1395,7 +1394,7 @@ void BitcoinGUI::gotoVotingPage()
centralWidget->setCurrentWidget(votingPage);

exportAction->setEnabled(false);
disconnect(exportAction, SIGNAL(triggered()), nullptr, nullptr);
disconnect(exportAction, &QAction::triggered, nullptr, nullptr);
}

void BitcoinGUI::gotoSignMessageTab(QString addr)
Expand All @@ -1407,6 +1406,11 @@ void BitcoinGUI::gotoSignMessageTab(QString addr)
signVerifyMessageDialog->setAddress_SM(addr);
}

void BitcoinGUI::gotoSignMessageTabDefault()
{
gotoSignMessageTab(QString {});
}

void BitcoinGUI::gotoVerifyMessageTab(QString addr)
{
// call show() in showTab_VM()
Expand All @@ -1416,6 +1420,11 @@ void BitcoinGUI::gotoVerifyMessageTab(QString addr)
signVerifyMessageDialog->setAddress_VM(addr);
}

void BitcoinGUI::gotoVerifyMesageTabDefault()
{
gotoVerifyMessageTab(QString {});
}

void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
{
// Accept only URIs
Expand Down
5 changes: 5 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,13 @@ private slots:

/** Show Sign/Verify Message dialog and switch to sign message tab */
void gotoSignMessageTab(QString addr = "");
/** Show Sign/Verify Message dialog and switch to sign message tab with no address */
void gotoSignMessageTabDefault();

/** Show Sign/Verify Message dialog and switch to verify message tab */
void gotoVerifyMessageTab(QString addr = "");
/** Show Sign/Verify Message dialog and switch to verify message tab with no address */
void gotoVerifyMesageTabDefault();

/** Show configuration dialog */
void optionsClicked();
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class TransactionView : public QFrame
private slots:
void contextualMenu(const QPoint &);
void dateRangeChanged();
void showDetails();
void copyAddress();
void editLabel();
void copyLabel();
Expand All @@ -73,6 +72,7 @@ private slots:
void doubleClicked(const QModelIndex&);

public slots:
void showDetails();
void chooseDate(int idx);
void chooseType(int idx);
void changedPrefix(const QString &prefix);
Expand Down

0 comments on commit b7adb32

Please sign in to comment.