From 2026f8f81d5e4fe7958346a511e6878a71afbdd4 Mon Sep 17 00:00:00 2001 From: Cathal Tummon Date: Mon, 22 Jan 2018 03:17:45 +0000 Subject: [PATCH] Use QTimers in head code. Fixes #503 * Use QTimers in head code. Fixes #503 * Remove unneeded header. * Remove unnecessary QTimers. * Run clang-format-all. --- rai/qt/qt.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index 424fdc1b..db146dd8 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -95,7 +95,7 @@ wallet (wallet_a) QObject::connect (copy_button, &QPushButton::clicked, [this]() { this->wallet.application.clipboard ()->setText (QString (this->wallet.account.to_account ().c_str ())); copy_button->setText ("Copied!"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (2), [this]() { + QTimer::singleShot (std::chrono::milliseconds (2000).count (), [this]() { copy_button->setText ("Copy"); }); }); @@ -186,7 +186,7 @@ wallet (wallet_a) show_button_success (*create_account); create_account->setText ("New account was created"); refresh (); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*create_account); create_account->setText ("Create account"); }); @@ -195,7 +195,7 @@ wallet (wallet_a) { show_button_error (*create_account); create_account->setText ("Wallet is locked, unlock it to create account"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*create_account); create_account->setText ("Create account"); }); @@ -213,7 +213,7 @@ wallet (wallet_a) this->wallet.application.clipboard ()->setText (QString (seed.data.to_string ().c_str ())); show_button_success (*backup_seed); backup_seed->setText ("Seed was copied to clipboard"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*backup_seed); backup_seed->setText ("Copy wallet seed to clipboard"); }); @@ -223,7 +223,7 @@ wallet (wallet_a) this->wallet.application.clipboard ()->setText (""); show_button_error (*backup_seed); backup_seed->setText ("Wallet is locked, unlock it to enable the backup"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*backup_seed); backup_seed->setText ("Copy wallet seed to clipboard"); }); @@ -373,7 +373,7 @@ wallet (wallet_a) show_line_error (*seed); show_button_error (*import_seed); import_seed->setText ("Wallet is locked, unlock it to enable the import"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (10), [this]() { + QTimer::singleShot (std::chrono::milliseconds (10000).count (), [this]() { show_line_ok (*seed); show_button_ok (*import_seed); import_seed->setText ("Import seed"); @@ -410,7 +410,7 @@ wallet (wallet_a) show_button_success (*import_seed); import_seed->setText ("Successful import of seed"); this->wallet.refresh (); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*import_seed); import_seed->setText ("Import seed"); }); @@ -428,7 +428,7 @@ wallet (wallet_a) { import_seed->setText ("Incorrect seed. Only HEX characters allowed"); } - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*import_seed); import_seed->setText ("Import seed"); }); @@ -439,7 +439,7 @@ wallet (wallet_a) show_line_error (*clear_line); show_button_error (*import_seed); import_seed->setText ("Type words 'clear keys'"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*import_seed); import_seed->setText ("Import seed"); }); @@ -635,7 +635,7 @@ void rai_qt::block_viewer::rebroadcast_action (rai::uint256_union const & hash_a if (!successor.is_zero ()) { done = false; - wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (1), [this, successor]() { + QTimer::singleShot (std::chrono::milliseconds (1000).count (), [this, successor]() { rebroadcast_action (successor); }); } @@ -971,7 +971,7 @@ void rai_qt::wallet::start () { show_button_error (*this_l->send_blocks_send); this_l->send_blocks_send->setText ("Wallet is locked, unlock it to send"); - this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this_w]() { if (auto this_l = this_w.lock ()) { show_button_ok (*this_l->send_blocks_send); @@ -985,7 +985,7 @@ void rai_qt::wallet::start () show_line_error (*this_l->send_count); show_button_error (*this_l->send_blocks_send); this_l->send_blocks_send->setText ("Not enough balance"); - this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this_w]() { if (auto this_l = this_w.lock ()) { show_button_ok (*this_l->send_blocks_send); @@ -999,7 +999,7 @@ void rai_qt::wallet::start () show_line_error (*this_l->send_account); show_button_error (*this_l->send_blocks_send); this_l->send_blocks_send->setText ("Bad destination account"); - this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this_w]() { if (auto this_l = this_w.lock ()) { show_button_ok (*this_l->send_blocks_send); @@ -1013,7 +1013,7 @@ void rai_qt::wallet::start () show_line_error (*this_l->send_count); show_button_error (*this_l->send_blocks_send); this_l->send_blocks_send->setText ("Amount too big"); - this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this_w]() { if (auto this_l = this_w.lock ()) { show_line_ok (*this_l->send_account); @@ -1028,7 +1028,7 @@ void rai_qt::wallet::start () show_line_error (*this_l->send_count); show_button_error (*this_l->send_blocks_send); this_l->send_blocks_send->setText ("Bad amount number"); - this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this_w]() { if (auto this_l = this_w.lock ()) { show_button_ok (*this_l->send_blocks_send); @@ -1304,7 +1304,7 @@ wallet (wallet_a) show_button_success (*change); change->setText ("Password was changed"); update_locked (false, false); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*change); change->setText ("Set/Change password"); }); @@ -1320,7 +1320,7 @@ wallet (wallet_a) { show_button_error (*change); change->setText ("Wallet is locked, unlock it"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*change); change->setText ("Set/Change password"); }); @@ -1341,10 +1341,10 @@ wallet (wallet_a) auto block (this->wallet.wallet_m->change_sync (this->wallet.account, representative_l)); change_rep->setEnabled (true); show_button_success (*change_rep); - change_rep->setText ("Represenative was changed"); + change_rep->setText ("Representative was changed"); current_representative->setText (QString (representative_l.to_account_split ().c_str ())); new_representative->clear (); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::seconds (5000).count (), [this]() { show_button_ok (*change_rep); change_rep->setText ("Change representative"); }); @@ -1353,7 +1353,7 @@ wallet (wallet_a) { show_button_error (*change_rep); change_rep->setText ("Wallet is locked, unlock it"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_button_ok (*change_rep); change_rep->setText ("Change representative"); }); @@ -1364,7 +1364,7 @@ wallet (wallet_a) show_line_error (*new_representative); show_button_error (*change_rep); change_rep->setText ("Invalid account"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_line_ok (*new_representative); show_button_ok (*change_rep); change_rep->setText ("Change representative"); @@ -1401,7 +1401,7 @@ wallet (wallet_a) show_line_error (*password); show_button_error (*lock_toggle); lock_toggle->setText ("Invalid password"); - this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this]() { + QTimer::singleShot (std::chrono::milliseconds (5000).count (), [this]() { show_line_ok (*password); show_button_ok (*lock_toggle);