refactor, qt: Use std::chrono for non-zero arguments in QTimer methods

This commit is contained in:
Hennadii Stepanov 2022-01-06 18:35:53 +02:00
parent 6f0da95811
commit 0e193deb52
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
4 changed files with 12 additions and 7 deletions

View file

@ -41,6 +41,7 @@
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
#include <boost/signals2/connection.hpp> #include <boost/signals2/connection.hpp>
#include <chrono>
#include <memory> #include <memory>
#include <QApplication> #include <QApplication>
@ -410,10 +411,10 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
connect(paymentServer, &PaymentServer::message, [this](const QString& title, const QString& message, unsigned int style) { connect(paymentServer, &PaymentServer::message, [this](const QString& title, const QString& message, unsigned int style) {
window->message(title, message, style); window->message(title, message, style);
}); });
QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady); QTimer::singleShot(100ms, paymentServer, &PaymentServer::uiReady);
} }
#endif #endif
pollShutdownTimer->start(200); pollShutdownTimer->start(200ms);
} else { } else {
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
requestShutdown(); requestShutdown();

View file

@ -19,6 +19,8 @@
#include <netbase.h> #include <netbase.h>
#include <txdb.h> // for -dbcache defaults #include <txdb.h> // for -dbcache defaults
#include <chrono>
#include <QDataWidgetMapper> #include <QDataWidgetMapper>
#include <QDir> #include <QDir>
#include <QIntValidator> #include <QIntValidator>
@ -362,7 +364,7 @@ void OptionsDialog::showRestartWarning(bool fPersistent)
ui->statusLabel->setText(tr("This change would require a client restart.")); ui->statusLabel->setText(tr("This change would require a client restart."));
// clear non-persistent status label after 10 seconds // clear non-persistent status label after 10 seconds
// Todo: should perhaps be a class attribute, if we extend the use of statusLabel // Todo: should perhaps be a class attribute, if we extend the use of statusLabel
QTimer::singleShot(10000, this, &OptionsDialog::clearStatusLabel); QTimer::singleShot(10s, this, &OptionsDialog::clearStatusLabel);
} }
} }

View file

@ -24,11 +24,12 @@
#include <node/ui_interface.h> #include <node/ui_interface.h>
#include <policy/fees.h> #include <policy/fees.h>
#include <txmempool.h> #include <txmempool.h>
#include <validation.h>
#include <wallet/coincontrol.h> #include <wallet/coincontrol.h>
#include <wallet/fees.h> #include <wallet/fees.h>
#include <wallet/wallet.h> #include <wallet/wallet.h>
#include <validation.h> #include <chrono>
#include <QFontMetrics> #include <QFontMetrics>
#include <QScrollBar> #include <QScrollBar>
@ -1060,7 +1061,7 @@ SendConfirmationDialog::SendConfirmationDialog(const QString& title, const QStri
int SendConfirmationDialog::exec() int SendConfirmationDialog::exec()
{ {
updateButtons(); updateButtons();
countDownTimer.start(1000); countDownTimer.start(1s);
return QMessageBox::exec(); return QMessageBox::exec();
} }

View file

@ -20,6 +20,7 @@
#include <wallet/wallet.h> #include <wallet/wallet.h>
#include <algorithm> #include <algorithm>
#include <chrono>
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
@ -254,12 +255,12 @@ void CreateWalletActivity::createWallet()
flags |= WALLET_FLAG_EXTERNAL_SIGNER; flags |= WALLET_FLAG_EXTERNAL_SIGNER;
} }
QTimer::singleShot(500, worker(), [this, name, flags] { QTimer::singleShot(500ms, worker(), [this, name, flags] {
std::unique_ptr<interfaces::Wallet> wallet = node().walletLoader().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message); std::unique_ptr<interfaces::Wallet> wallet = node().walletLoader().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message);
if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet)); if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet));
QTimer::singleShot(500, this, &CreateWalletActivity::finish); QTimer::singleShot(500ms, this, &CreateWalletActivity::finish);
}); });
} }