Skip to content

Commit

Permalink
Use QT5 connect new syntax (#1186)
Browse files Browse the repository at this point in the history
* Use QT5 connect new syntax

* Fixing for double click -> show details

* Replacing missed overloads from static_cast to qOverload
  • Loading branch information
firstcryptoman authored Oct 18, 2022
1 parent 657d346 commit ad07bf8
Show file tree
Hide file tree
Showing 56 changed files with 512 additions and 615 deletions.
28 changes: 13 additions & 15 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
case SendingTab: setWindowTitle(tr("Choose the address to send coins to")); break;
case ReceivingTab: setWindowTitle(tr("Choose the address to receive coins with")); break;
}
connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));
connect(ui->tableViewPcodes, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept()));
connect(ui->tableView, &QTableView::doubleClicked, this, &QDialog::accept);
connect(ui->tableViewPcodes, &QTableView::doubleClicked, this, &QDialog::accept);
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->tableView->setFocus();
ui->closeButton->setText(tr("C&hoose"));
Expand All @@ -72,8 +72,8 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
case SendingTab:
ui->labelExplanation->setText(tr("These are your Firo addresses for sending payments. Always check the amount and the receiving address before sending coins."));
ui->deleteAddress->setVisible(true);
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(selectionChanged()));
connect(ui->tableViewPcodes, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));
connect(ui->tabWidget, &QTabWidget::currentChanged, this, &AddressBookPage::selectionChanged);
connect(ui->tableViewPcodes, &QWidget::customContextMenuRequested, this, &AddressBookPage::contextualMenu);
break;
case ReceivingTab:
ui->labelExplanation->setText(tr("These are your Firo addresses for receiving payments. It is recommended to use a new receiving address for each transaction."));
Expand All @@ -99,14 +99,14 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode,
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 @@ -145,8 +145,7 @@ void AddressBookPage::setModel(AddressTableModel *_model)
proxyModelPcode->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->tableViewPcodes->setModel(proxyModelPcode);
ui->tableViewPcodes->sortByColumn(0, Qt::AscendingOrder);
connect(ui->tableViewPcodes->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(selectionChanged()));
connect(ui->tableViewPcodes->selectionModel(), &QItemSelectionModel::selectionChanged, this, &AddressBookPage::selectionChanged);

#if QT_VERSION < 0x050000
ui->tableViewPcodes->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch);
Expand All @@ -169,11 +168,10 @@ void AddressBookPage::setModel(AddressTableModel *_model)
ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents);
#endif

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
6 changes: 3 additions & 3 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, const QStr
}
textChanged();
adjustSize();
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->passEdit1, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
connect(ui->passEdit2, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
connect(ui->passEdit3, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
}

AskPassphraseDialog::~AskPassphraseDialog()
Expand Down
12 changes: 4 additions & 8 deletions src/qt/automintmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ IncomingFundNotifier::IncomingFundNotifier(
timer = new QTimer(this);
timer->setSingleShot(true);

connect(timer,
SIGNAL(timeout()),
this,
SLOT(check()),
Qt::QueuedConnection);
connect(timer, &QTimer::timeout, this, &IncomingFundNotifier::check, Qt::QueuedConnection);

importTransactions();
subscribeToCoreSignals();
Expand Down Expand Up @@ -187,13 +183,13 @@ AutoMintModel::AutoMintModel(
autoMintCheckTimer = new QTimer(this);
autoMintCheckTimer->setSingleShot(false);

connect(autoMintCheckTimer, SIGNAL(timeout()), this, SLOT(checkAutoMint()));
connect(autoMintCheckTimer, &QTimer::timeout, [this]{ checkAutoMint(); });

notifier = new IncomingFundNotifier(wallet, this);

connect(notifier, SIGNAL(matureFund(CAmount)), this, SLOT(startAutoMint()));
connect(notifier, &IncomingFundNotifier::matureFund, this, &AutoMintModel::startAutoMint);

connect(optionsModel, SIGNAL(autoAnonymizeChanged(bool)), this, SLOT(updateAutoMintOption(bool)));
connect(optionsModel, &OptionsModel::autoAnonymizeChanged, this, &AutoMintModel::updateAutoMintOption);
}

AutoMintModel::~AutoMintModel()
Expand Down
3 changes: 1 addition & 2 deletions src/qt/automintnotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ void AutomintNotification::setModel(WalletModel *model)
return;
}

connect(this, SIGNAL(ackMintAll(AutoMintAck, CAmount, QString)),
automintModel, SLOT(ackMintAll(AutoMintAck, CAmount, QString)));
connect(this, &AutomintNotification::ackMintAll, automintModel, &AutoMintModel::ackMintAll);
}
}

Expand Down
36 changes: 17 additions & 19 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
window = new BitcoinGUI(platformStyle, networkStyle, 0);

pollShutdownTimer = new QTimer(window);
connect(pollShutdownTimer, SIGNAL(timeout()), window, SLOT(detectShutdown()));
connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);
pollShutdownTimer->start(200);
}

Expand All @@ -397,8 +397,8 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
// We don't hold a direct pointer to the splash screen after creation, but 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()
Expand All @@ -410,14 +410,14 @@ void BitcoinApplication::startThread()
executor->moveToThread(coreThread);

/* communication to and from thread */
connect(executor, SIGNAL(initializeResult(int)), this, SLOT(initializeResult(int)));
connect(executor, SIGNAL(shutdownResult(int)), this, SLOT(shutdownResult(int)));
connect(executor, SIGNAL(runawayException(QString)), this, SLOT(handleRunawayException(QString)));
connect(this, SIGNAL(requestedInitialize()), executor, SLOT(initialize()));
connect(this, SIGNAL(requestedShutdown()), executor, SLOT(shutdown()));
connect(executor, &BitcoinCore::initializeResult, this, &BitcoinApplication::initializeResult);
connect(executor, &BitcoinCore::shutdownResult, this, &BitcoinApplication::shutdownResult);
connect(executor, &BitcoinCore::runawayException, this, &BitcoinApplication::handleRunawayException);
connect(this, &BitcoinApplication::requestedInitialize, executor, &BitcoinCore::initialize);
connect(this, &BitcoinApplication::requestedShutdown, executor, &BitcoinCore::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();
}
Expand Down Expand Up @@ -487,8 +487,7 @@ void BitcoinApplication::initializeResult(int retval)
window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel);
window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET);

connect(walletModel, SIGNAL(coinsSent(CWallet*,SendCoinsRecipient,QByteArray)),
paymentServer, SLOT(fetchPaymentACK(CWallet*,const SendCoinsRecipient&,QByteArray)));
connect(walletModel, &WalletModel::coinsSent, paymentServer, &PaymentServer::fetchPaymentACK);

#endif

Expand All @@ -510,13 +509,12 @@ void BitcoinApplication::initializeResult(int retval)

// Now that initialization/startup is done, process any command-line
// firo: 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
} else {
quit(); // Exit main loop
Expand Down
6 changes: 3 additions & 3 deletions src/qt/bitcoinamountfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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 @@ -216,8 +216,8 @@ BitcoinAmountField::BitcoinAmountField(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, qOverload<int>(&QComboBox::currentIndexChanged), this, &BitcoinAmountField::unitChanged);

// Set default based on configuration
unitChanged(unit->currentIndex());
Expand Down
Loading

0 comments on commit ad07bf8

Please sign in to comment.