Skip to content

Commit

Permalink
Merge #1049: [Qt] Switch to newer connect syntax
Browse files Browse the repository at this point in the history
c54fd9dfded28f2b4ff86914422fb592bd86f320 [Qt] Switch to newer connect syntax (Fuzzbawls)

Pull request description:

  Switch all Qt connections to the newer functor-based syntax.

  Marked [WIP] for now until larger PRs can be merged.

  Mostly ported from bitcoin/bitcoin#13529

  Requires the following PR to be merged first in order to adhere to standards:
  - [x] #1351

ACKs for top commit:
  furszy:
    ACK c54fd9d
  random-zebra:
    ACK c54fd9dfded28f2b4ff86914422fb592bd86f320 and merging...

Tree-SHA512: d5222264566a8920ab97e8c586f134156d9d0514d014b430bdd47a34b0620ab94a1c6d341b6a57322f1131a8fad91a5e1af907f3bd7112d0ab5e04c4cc9f5ae5

# Conflicts:
#	.travis/lint_06_script.sh
#	src/qt/optionsdialog.cpp
#	src/qt/rpcconsole.cpp
#	src/qt/vitae.cpp
#	src/qt/vitae/navmenuwidget.cpp
#	src/qt/vitae/privacywidget.cpp
#	src/qt/vitae/send.cpp
  • Loading branch information
random-zebra authored and wqking committed Aug 19, 2020
1 parent 41367de commit 2aad804
Show file tree
Hide file tree
Showing 81 changed files with 449 additions and 393 deletions.
19 changes: 19 additions & 0 deletions .travis/lint_06_script.sh
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
#
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

export LC_ALL=C


contrib/devtools/git-subtree-check.sh src/secp256k1
contrib/devtools/git-subtree-check.sh src/univalue
contrib/devtools/git-subtree-check.sh src/leveldb
contrib/devtools/check-doc.py
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
Expand Up @@ -48,7 +48,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 @@ -92,14 +92,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 @@ -137,11 +137,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
Expand Up @@ -130,12 +130,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
Expand Up @@ -31,7 +31,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 @@ -213,8 +213,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
Expand Up @@ -45,11 +45,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
Expand Up @@ -116,7 +116,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
Expand Up @@ -100,7 +100,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 @@ -123,13 +123,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 @@ -159,24 +159,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
Expand Up @@ -29,7 +29,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
Expand Up @@ -486,15 +486,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
Expand Up @@ -129,8 +129,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 @@ -290,11 +290,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
Expand Up @@ -32,8 +32,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
Expand Up @@ -55,8 +55,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 @@ -137,7 +137,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 @@ -163,27 +163,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->showFundamentalnodesTab, 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->showFundamentalnodesTab, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning);
}

void OptionsDialog::setMapper()
Expand Down Expand Up @@ -290,7 +287,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

0 comments on commit 2aad804

Please sign in to comment.