mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 11:32:46 +01:00
Merge bitcoin-core/gui#517: refactor, qt: Use std::chrono for parameters of QTimer methods
51250b0906e56b39488304208ad119c951b4ae7d refactor, qt: Use std::chrono for input_filter_delay constant (Hennadii Stepanov) f3bdc143b67e8a5e763071a0774f6d994ca35c57 refactor, qt: Add SHUTDOWN_POLLING_DELAY constant (Hennadii Stepanov) 0e193deb523a4fa04e0ee69bd66f917895802ac9 refactor, qt: Use std::chrono for non-zero arguments in QTimer methods (Hennadii Stepanov) 6f0da958116ecc0e06332fad2f490e37b6884166 refactor, qt: Use std::chrono in ConfirmMessage parameter (Hennadii Stepanov) 33d520ac538fcd6285fd958578f1bd26295592e4 refactor, qt: Use std::chrono for MODEL_UPDATE_DELAY constant (Hennadii Stepanov) Pull request description: Since Qt 5.8 `QTimer` methods have overloads that accept `std::chrono::milliseconds` arguments: - [`QTimer::singleShot`](https://doc.qt.io/archives/qt-5.9/qtimer.html#singleShot-8) - [`QTimer::start`](https://doc.qt.io/archives/qt-5.9/qtimer.html#start-2) ACKs for top commit: promag: Code review ACK 51250b0906e56b39488304208ad119c951b4ae7d. shaavan: reACK 51250b0906e56b39488304208ad119c951b4ae7d Tree-SHA512: aa843bb2322a84c0c2bb113d3b48d7bf02d7f09a770779dcde312c32887f973ef9445cdef42f39edaa599ff0f3d0457454f6153aa130efadd989e413d39c6062
This commit is contained in:
parent
b212ca0515
commit
f16265dd50
@ -44,6 +44,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>
|
||||||
@ -398,10 +399,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(SHUTDOWN_POLLING_DELAY);
|
||||||
} 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
|
||||||
quit(); // Exit first main loop invocation
|
quit(); // Exit first main loop invocation
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <netbase.h>
|
#include <netbase.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
#include <util/threadnames.h>
|
#include <util/threadnames.h>
|
||||||
|
#include <util/time.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -323,7 +324,7 @@ static void BlockTipChanged(ClientModel* clientmodel, SynchronizationState sync_
|
|||||||
const bool throttle = (sync_state != SynchronizationState::POST_INIT && !fHeader) || sync_state == SynchronizationState::INIT_REINDEX;
|
const bool throttle = (sync_state != SynchronizationState::POST_INIT && !fHeader) || sync_state == SynchronizationState::INIT_REINDEX;
|
||||||
const int64_t now = throttle ? GetTimeMillis() : 0;
|
const int64_t now = throttle ? GetTimeMillis() : 0;
|
||||||
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
|
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
|
||||||
if (throttle && now < nLastUpdateNotification + MODEL_UPDATE_DELAY) {
|
if (throttle && now < nLastUpdateNotification + count_milliseconds(MODEL_UPDATE_DELAY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,16 @@
|
|||||||
#ifndef BITCOIN_QT_GUICONSTANTS_H
|
#ifndef BITCOIN_QT_GUICONSTANTS_H
|
||||||
#define BITCOIN_QT_GUICONSTANTS_H
|
#define BITCOIN_QT_GUICONSTANTS_H
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
/* Milliseconds between model updates */
|
using namespace std::chrono_literals;
|
||||||
static const int MODEL_UPDATE_DELAY = 250;
|
|
||||||
|
/* A delay between model updates */
|
||||||
|
static constexpr auto MODEL_UPDATE_DELAY{250ms};
|
||||||
|
|
||||||
|
/* A delay between shutdown pollings */
|
||||||
|
static constexpr auto SHUTDOWN_POLLING_DELAY{200ms};
|
||||||
|
|
||||||
/* AskPassphraseDialog -- Maximum passphrase length */
|
/* AskPassphraseDialog -- Maximum passphrase length */
|
||||||
static const int MAX_PASSPHRASE_SIZE = 1024;
|
static const int MAX_PASSPHRASE_SIZE = 1024;
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <util/underlying.h>
|
#include <util/underlying.h>
|
||||||
|
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <QDataWidgetMapper>
|
#include <QDataWidgetMapper>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QIntValidator>
|
#include <QIntValidator>
|
||||||
@ -457,7 +459,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,11 @@
|
|||||||
#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 <array>
|
#include <array>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -1080,7 +1081,7 @@ SendConfirmationDialog::SendConfirmationDialog(const QString& title, const QStri
|
|||||||
int SendConfirmationDialog::exec()
|
int SendConfirmationDialog::exec()
|
||||||
{
|
{
|
||||||
updateYesButton();
|
updateYesButton();
|
||||||
countDownTimer.start(1000);
|
countDownTimer.start(1s);
|
||||||
return QMessageBox::exec();
|
return QMessageBox::exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
#include <walletinitinterface.h>
|
#include <walletinitinterface.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -39,7 +41,7 @@ void EditAddressAndSubmit(
|
|||||||
dialog->findChild<QLineEdit*>("labelEdit")->setText(label);
|
dialog->findChild<QLineEdit*>("labelEdit")->setText(label);
|
||||||
dialog->findChild<QValidatedLineEdit*>("addressEdit")->setText(address);
|
dialog->findChild<QValidatedLineEdit*>("addressEdit")->setText(address);
|
||||||
|
|
||||||
ConfirmMessage(&warning_text, 5);
|
ConfirmMessage(&warning_text, 5ms);
|
||||||
dialog->accept();
|
dialog->accept();
|
||||||
QCOMPARE(warning_text, expected_msg);
|
QCOMPARE(warning_text, expected_msg);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@ -9,7 +11,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
void ConfirmMessage(QString* text, int msec)
|
void ConfirmMessage(QString* text, std::chrono::milliseconds msec)
|
||||||
{
|
{
|
||||||
QTimer::singleShot(msec, [text]() {
|
QTimer::singleShot(msec, [text]() {
|
||||||
for (QWidget* widget : QApplication::topLevelWidgets()) {
|
for (QWidget* widget : QApplication::topLevelWidgets()) {
|
||||||
|
@ -5,7 +5,11 @@
|
|||||||
#ifndef BITCOIN_QT_TEST_UTIL_H
|
#ifndef BITCOIN_QT_TEST_UTIL_H
|
||||||
#define BITCOIN_QT_TEST_UTIL_H
|
#define BITCOIN_QT_TEST_UTIL_H
|
||||||
|
|
||||||
#include <QString>
|
#include <chrono>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QString;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Press "Ok" button in message box dialog.
|
* Press "Ok" button in message box dialog.
|
||||||
@ -13,6 +17,6 @@
|
|||||||
* @param text - Optionally store dialog text.
|
* @param text - Optionally store dialog text.
|
||||||
* @param msec - Number of milliseconds to pause before triggering the callback.
|
* @param msec - Number of milliseconds to pause before triggering the callback.
|
||||||
*/
|
*/
|
||||||
void ConfirmMessage(QString* text = nullptr, int msec = 0);
|
void ConfirmMessage(QString* text, std::chrono::milliseconds msec);
|
||||||
|
|
||||||
#endif // BITCOIN_QT_TEST_UTIL_H
|
#endif // BITCOIN_QT_TEST_UTIL_H
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <qt/recentrequeststablemodel.h>
|
#include <qt/recentrequeststablemodel.h>
|
||||||
#include <qt/receiverequestdialog.h>
|
#include <qt/receiverequestdialog.h>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include <QCalendarWidget>
|
#include <QCalendarWidget>
|
||||||
|
#include <chrono>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDateTimeEdit>
|
#include <QDateTimeEdit>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
@ -114,8 +115,8 @@ TransactionView::TransactionView(QWidget* parent) :
|
|||||||
amountWidget->setObjectName("amountWidget");
|
amountWidget->setObjectName("amountWidget");
|
||||||
hlayout->addWidget(amountWidget);
|
hlayout->addWidget(amountWidget);
|
||||||
|
|
||||||
// Delay before filtering transactions in ms
|
// Delay before filtering transactions
|
||||||
static const int input_filter_delay = 200;
|
static constexpr auto input_filter_delay{200ms};
|
||||||
|
|
||||||
QTimer* amount_typing_delay = new QTimer(this);
|
QTimer* amount_typing_delay = new QTimer(this);
|
||||||
amount_typing_delay->setSingleShot(true);
|
amount_typing_delay->setSingleShot(true);
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -271,12 +272,12 @@ void CreateWalletActivity::createWallet()
|
|||||||
flags |= WALLET_FLAG_DESCRIPTORS;
|
flags |= WALLET_FLAG_DESCRIPTORS;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user