Skip to content

Commit

Permalink
[Qt] Switch to newer connect syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzbawls committed Mar 23, 2020
1 parent c2ddd26 commit c54fd9d
Show file tree
Hide file tree
Showing 81 changed files with 429 additions and 392 deletions.
1 change: 1 addition & 0 deletions .travis/lint_06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ contrib/devtools/logprint-scanner.py

if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
contrib/devtools/lint-whitespace.sh
test/lint/lint-qt.sh
fi
20 changes: 10 additions & 10 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget* parent) : QDialog
setWindowTitle(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"));
Expand Down Expand Up @@ -91,14 +91,14 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget* parent) : QDialog
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(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, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
connect(ui->tableView, &QWidget::customContextMenuRequested, this, &AddressBookPage::contextualMenu);

connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->closeButton, &QPushButton::clicked, this, &QDialog::accept);
}

AddressBookPage::~AddressBookPage()
Expand Down Expand Up @@ -136,11 +136,11 @@ void AddressBookPage::setModel(AddressTableModel* model)
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);

connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(selectionChanged()));
connect(ui->tableView->selectionModel(), &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();
}
Expand Down
12 changes: 6 additions & 6 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
ui->labelTitle->setText(title);

textChanged();
connect(btnWatch, SIGNAL(clicked()), this, SLOT(onWatchClicked()));
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->pushButtonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->btnEsc, SIGNAL(clicked()), this, SLOT(close()));
connect(btnWatch, &QCheckBox::clicked, this, &AskPassphraseDialog::onWatchClicked);
connect(ui->passEdit1, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
connect(ui->passEdit2, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
connect(ui->passEdit3, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
connect(ui->pushButtonOk, &QPushButton::clicked, this, &AskPassphraseDialog::accept);
connect(ui->btnEsc, &QPushButton::clicked, this, &AskPassphraseDialog::close);
}

void AskPassphraseDialog::onWatchClicked()
Expand Down
6 changes: 3 additions & 3 deletions src/qt/bitcoinamountfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AmountSpinBox : public QAbstractSpinBox
{
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
Expand Down Expand Up @@ -212,8 +212,8 @@ BitcoinAmountField::BitcoinAmountField(QWidget* parent) : QWidget(parent),
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<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &BitcoinAmountField::unitChanged);

// Set default based on configuration
unitChanged(unit->currentIndex());
Expand Down
4 changes: 2 additions & 2 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ ClientModel::ClientModel(OptionsModel* optionsModel, QObject* parent) : QObject(
peerTableModel = new PeerTableModel(this);
banTableModel = new BanTableModel(this);
pollTimer = new QTimer(this);
connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer()));
connect(pollTimer, &QTimer::timeout, this, &ClientModel::updateTimer);
pollTimer->start(MODEL_UPDATE_DELAY);

pollMnTimer = new QTimer(this);
connect(pollMnTimer, SIGNAL(timeout()), this, SLOT(updateMnTimer()));
connect(pollMnTimer, &QTimer::timeout, this, &ClientModel::updateMnTimer);
// no need to update as frequent as data for balances/txes/blocks
pollMnTimer->start(MODEL_UPDATE_DELAY * 4);

Expand Down
2 changes: 1 addition & 1 deletion src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ClientModel : public QObject
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);

//! Fired when a message should be reported to the user
void message(const QString& title, const QString& message, unsigned int style);
void message(const QString& title, const QString& message, unsigned int style, bool* ret = nullptr);

// Show progress dialog e.g. for verifychain
void showProgress(const QString& title, int nProgress);
Expand Down
30 changes: 15 additions & 15 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ CoinControlDialog::CoinControlDialog(QWidget* parent, bool fMultisigEnabled) : Q
ui->btnEsc->setProperty("cssClass", "ic-close");
ui->pushButtonOk->setProperty("cssClass", "btn-primary");

connect(ui->btnEsc, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->btnEsc, &QPushButton::clicked, this, &CoinControlDialog::close);

this->fMultisigEnabled = fMultisigEnabled;

Expand All @@ -122,13 +122,13 @@ CoinControlDialog::CoinControlDialog(QWidget* parent, bool fMultisigEnabled) : Q
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
setCssProperty({
Expand Down Expand Up @@ -158,24 +158,24 @@ CoinControlDialog::CoinControlDialog(QWidget* parent, bool fMultisigEnabled) : Q
}

// 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->pushButtonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->pushButtonOk, &QPushButton::clicked, this, &CoinControlDialog::accept);

// (un)select all
connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(buttonSelectAllClicked()));
connect(ui->pushButtonSelectAll, &QPushButton::clicked, this, &CoinControlDialog::buttonSelectAllClicked);

// Toggle lock state
connect(ui->pushButtonToggleLock, SIGNAL(clicked()), this, SLOT(buttonToggleLockClicked()));
connect(ui->pushButtonToggleLock, &QPushButton::clicked, this, &CoinControlDialog::buttonToggleLockClicked);

// change coin control first column label due Qt4 bug.
// see https://github.com/bitcoin/bitcoin/issues/5716
Expand Down
2 changes: 1 addition & 1 deletion src/qt/governancepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GovernancePage::GovernancePage(QWidget* parent) : QWidget(parent),
ui->setupUi(this);

timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateProposalList()));
connect(timer, &QTimer::timeout, this, &GovernancePage::updateProposalList);
timer->start(100000);
fLockUpdating = false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,15 @@ bool ToolTipToRichTextFilter::eventFilter(QObject* obj, QEvent* evt)

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

// Setup the resize mode, handles compatibility for Qt5 and below as the method signatures changed.
Expand Down
12 changes: 6 additions & 6 deletions src/qt/intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ Intro::Intro(QWidget* parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::W
setCssBtnPrimary(ui->pushButtonOk);
setCssBtnSecondary(ui->pushButtonCancel);

connect(ui->pushButtonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->pushButtonCancel, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->pushButtonOk, &QPushButton::clicked, this, &Intro::accept);
connect(ui->pushButtonCancel, &QPushButton::clicked, this, &Intro::close);

ui->sizeWarningLabel->setText(ui->sizeWarningLabel->text().arg(BLOCK_CHAIN_SIZE / GB_BYTES));
startThread();
Expand Down Expand Up @@ -289,11 +289,11 @@ void Intro::startThread()
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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/qt/openuridialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ OpenURIDialog::OpenURIDialog(QWidget* parent) : QDialog(parent, Qt::WindowSystem
setCssProperty(ui->pushButtonCancel, "btn-dialog-cancel");

initCssEditLine(ui->uriEdit, true);
connect(ui->pushButtonOK, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->pushButtonCancel, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->pushButtonOK, &QPushButton::clicked, this, &OpenURIDialog::accept);
connect(ui->pushButtonCancel, &QPushButton::clicked, this, &OpenURIDialog::close);
}

void OpenURIDialog::showEvent(QShowEvent *event)
Expand Down
31 changes: 14 additions & 17 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) : QDialog(paren
ui->proxyPort->setEnabled(false);
ui->proxyPort->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, &QCheckBox::toggled, ui->proxyIp, &QWidget::setEnabled);
connect(ui->connectSocks, &QCheckBox::toggled, ui->proxyPort, &QWidget::setEnabled);

ui->proxyIp->installEventFilter(this);
ui->proxyPort->installEventFilter(this);
Expand Down Expand Up @@ -138,7 +138,7 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) : QDialog(paren
mapper->setOrientation(Qt::Vertical);

/* setup/change UI elements when proxy IP is invalid/valid */
connect(this, SIGNAL(proxyIpChecks(QValidatedLineEdit*, QLineEdit*)), this, SLOT(doProxyIpChecks(QValidatedLineEdit*, QLineEdit*)));
connect(this, &OptionsDialog::proxyIpChecks, this, &OptionsDialog::doProxyIpChecks);
}

OptionsDialog::~OptionsDialog()
Expand All @@ -164,27 +164,24 @@ void OptionsDialog::setModel(OptionsModel* model)
mapper->setModel(model);
setMapper();
mapper->toFirst();

/* keep consistency for action triggered elsewhere */
connect(model, SIGNAL(hideOrphansChanged(bool)), this, SLOT(updateHideOrphans(bool)));
}

/* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */

/* Main */
connect(ui->databaseCache, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
connect(ui->threadsScriptVerif, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
connect(ui->databaseCache, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &OptionsDialog::showRestartWarning);
connect(ui->threadsScriptVerif, static_cast<void (QSpinBox::*)(int)>(&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->allowIncoming, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
connect(ui->connectSocks, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
/* Display */
connect(ui->digits, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
connect(ui->theme, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString&)), this, SLOT(showRestartWarning()));
connect(ui->showMasternodesTab, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning()));
connect(ui->digits, static_cast<void (QValueComboBox::*)()>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
connect(ui->theme, static_cast<void (QValueComboBox::*)()>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
connect(ui->lang, static_cast<void (QValueComboBox::*)()>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); });
connect(ui->showMasternodesTab, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
}

void OptionsDialog::setMapper()
Expand Down Expand Up @@ -291,7 +288,7 @@ void OptionsDialog::showRestartWarning(bool fPersistent)
ui->statusLabel->setText(tr("This change would require a client restart."));
// 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);
}
}

Expand Down
13 changes: 5 additions & 8 deletions src/qt/paymentserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : QObject(p
QMessageBox::critical(0, tr("Payment request error"),
tr("Cannot start pivx: 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);
}
}
}
Expand Down Expand Up @@ -338,10 +338,8 @@ void PaymentServer::initNetManager()
} else
qDebug() << "PaymentServer::initNetManager : No active proxy server found.";

connect(netManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(netRequestFinished(QNetworkReply*)));
connect(netManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
this, SLOT(reportSslErrors(QNetworkReply*, const QList<QSslError>&)));
connect(netManager, &QNetworkAccessManager::finished, this, &PaymentServer::netRequestFinished);
connect(netManager, &QNetworkAccessManager::sslErrors, this, &PaymentServer::reportSslErrors);
}

void PaymentServer::uiReady()
Expand Down Expand Up @@ -424,8 +422,7 @@ void PaymentServer::handleURIConnection()
while (clientConnection->bytesAvailable() < (int)sizeof(quint32))
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);
Expand Down
Loading

0 comments on commit c54fd9d

Please sign in to comment.