From 5072a14dd6ad982bdb77c6a7ce4b911de04c438b Mon Sep 17 00:00:00 2001 From: SergiySW Date: Wed, 21 Jun 2017 02:57:40 +0300 Subject: [PATCH 1/4] Warnings for backup/import Seed --- rai/qt/qt.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index 6d722dce54..5e5dff3ec7 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -22,6 +22,18 @@ void show_label_ok (QLabel & label) { label.setStyleSheet ("QLabel { color: black }"); } +void show_button_error (QPushButton & button) +{ + button.setStyleSheet ("QPushButton { color: red }"); +} +void show_button_ok (QPushButton & button) +{ + button.setStyleSheet ("QPushButton { color: black }"); +} +void show_button_success (QPushButton & button) +{ + button.setStyleSheet ("QPushButton { color: blue }"); +} } bool rai_qt::eventloop_processor::event (QEvent * event_a) @@ -157,6 +169,8 @@ wallet (wallet_a) QObject::connect (back, &QPushButton::clicked, [this] () { this->wallet.pop_main_stack (); + show_button_ok (*backup_seed); + backup_seed->setText ("Backup/Clipboard wallet seed"); }); QObject::connect (create_account, &QPushButton::released, [this] () { @@ -175,10 +189,14 @@ wallet (wallet_a) { this->wallet.wallet_m->store.seed (seed, transaction); 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"); } else { this->wallet.application.clipboard ()->setText (""); + show_button_error (*backup_seed); + backup_seed->setText ("Wallet is locked, unlock it to enable the backup"); } }); } @@ -242,6 +260,7 @@ wallet (wallet_a) layout->addWidget (seed); layout->addWidget (clear_label); layout->addWidget (clear_line); + clear_line->setPlaceholderText ("clear keys"); layout->addWidget (import_seed); layout->addWidget (separator); layout->addWidget (filename_label); @@ -281,6 +300,7 @@ wallet (wallet_a) QObject::connect (back, &QPushButton::released, [this] () { this->wallet.pop_main_stack (); + seed->clear (); }); QObject::connect (import_seed, &QPushButton::released, [this] () { @@ -301,6 +321,7 @@ wallet (wallet_a) else { show_line_error (*seed); + seed->setText ("Wallet is locked, unlock it to enable the import"); } } if (successful) From a4b0002fc44d3243d07302ba00ba2f6179094ed9 Mon Sep 17 00:00:00 2001 From: SergiySW Date: Wed, 21 Jun 2017 16:27:37 +0300 Subject: [PATCH 2/4] Timer for warnings --- rai/qt/qt.cpp | 83 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index 5e5dff3ec7..f23b27ab81 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -14,6 +14,10 @@ void show_line_ok (QLineEdit & line) { line.setStyleSheet ("QLineEdit { color: black }"); } +void show_line_success (QLineEdit & line) +{ + line.setStyleSheet ("QLineEdit { color: blue }"); +} void show_label_error (QLabel & label) { label.setStyleSheet ("QLabel { color: red }"); @@ -169,8 +173,6 @@ wallet (wallet_a) QObject::connect (back, &QPushButton::clicked, [this] () { this->wallet.pop_main_stack (); - show_button_ok (*backup_seed); - backup_seed->setText ("Backup/Clipboard wallet seed"); }); QObject::connect (create_account, &QPushButton::released, [this] () { @@ -191,12 +193,22 @@ 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"); + wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this] () + { + show_button_ok (*backup_seed); + backup_seed->setText ("Backup/Clipboard wallet seed"); + }); } else { this->wallet.application.clipboard ()->setText (""); show_button_error (*backup_seed); backup_seed->setText ("Wallet is locked, unlock it to enable the backup"); + wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this] () + { + show_button_ok (*backup_seed); + backup_seed->setText ("Backup/Clipboard wallet seed"); + }); } }); } @@ -300,7 +312,6 @@ wallet (wallet_a) QObject::connect (back, &QPushButton::released, [this] () { this->wallet.pop_main_stack (); - seed->clear (); }); QObject::connect (import_seed, &QPushButton::released, [this] () { @@ -321,7 +332,14 @@ wallet (wallet_a) else { show_line_error (*seed); - seed->setText ("Wallet is locked, unlock it to enable the import"); + show_button_error (*import_seed); + import_seed->setText ("Wallet is locked, unlock it to enable the import"); + wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (10), [this] () + { + show_line_ok (*seed); + show_button_ok (*import_seed); + import_seed->setText ("Import seed"); + }); } } if (successful) @@ -330,7 +348,14 @@ wallet (wallet_a) seed->clear (); clear_line->clear (); show_line_ok (*seed); + show_button_success (*import_seed); + import_seed->setText ("Successful import of seed"); this->wallet.refresh (); + wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this] () + { + show_button_ok (*import_seed); + import_seed->setText ("Import seed"); + }); } } else @@ -1329,34 +1354,34 @@ wallet (wallet_a) show_line_error (*bootstrap_line); } }); - QObject::connect (peers_refresh, &QPushButton::released, [this] () - { - refresh_peers (); - }); - QObject::connect (ledger_refresh, &QPushButton::released, [this] () - { - refresh_ledger (); - }); - QObject::connect (ledger_back, &QPushButton::released, [this] () - { + QObject::connect (peers_refresh, &QPushButton::released, [this] () + { + refresh_peers (); + }); + QObject::connect (ledger_refresh, &QPushButton::released, [this] () + { + refresh_ledger (); + }); + QObject::connect (ledger_back, &QPushButton::released, [this] () + { this->wallet.pop_main_stack (); - }); - QObject::connect (search_for_receivables, &QPushButton::released, [this] () - { + }); + QObject::connect (search_for_receivables, &QPushButton::released, [this] () + { this->wallet.wallet_m->search_pending (); - }); - QObject::connect (bootstrap, &QPushButton::released, [this] () - { + }); + QObject::connect (bootstrap, &QPushButton::released, [this] () + { this->wallet.node.bootstrap_initiator.bootstrap (); - }); - QObject::connect (create_block, &QPushButton::released, [this] () - { + }); + QObject::connect (create_block, &QPushButton::released, [this] () + { this->wallet.push_main_stack (this->wallet.block_creation.window); - }); - QObject::connect (enter_block, &QPushButton::released, [this] () - { + }); + QObject::connect (enter_block, &QPushButton::released, [this] () + { this->wallet.push_main_stack (this->wallet.block_entry.window); - }); + }); QObject::connect (block_viewer, &QPushButton::released, [this] () { this->wallet.push_main_stack (this->wallet.block_viewer.window); @@ -1365,9 +1390,9 @@ wallet (wallet_a) { this->wallet.push_main_stack (this->wallet.account_viewer.window); }); - refresh_ledger (); + refresh_ledger (); refresh_count (); - block_count->setToolTip ("Block count (blocks downloaded)"); + block_count->setToolTip ("Block count (blocks downloaded)"); } void rai_qt::advanced_actions::refresh_count () From 3eb2a8e99d9f323c0e4822bd1755215658d91393 Mon Sep 17 00:00:00 2001 From: SergiySW Date: Wed, 21 Jun 2017 16:57:57 +0300 Subject: [PATCH 3/4] Tooltips for several buttons --- rai/qt/qt.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index f23b27ab81..2fc99a2a87 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -545,6 +545,7 @@ wallet (wallet_a) } } }); + rebroadcast->setToolTip ("Rebroadcast block into the network"); } void rai_qt::block_viewer::rebroadcast_action (rai::uint256_union const & hash_a) @@ -1018,6 +1019,7 @@ void rai_qt::wallet::start () })); } }; + settings_button->setToolTip ("Unlock wallet, set password, change representative"); } void rai_qt::wallet::refresh () @@ -1393,6 +1395,10 @@ wallet (wallet_a) refresh_ledger (); refresh_count (); block_count->setToolTip ("Block count (blocks downloaded)"); + bootstrap->setToolTip ("Multi-connection bootstrap to random peers"); + search_for_receivables->setToolTip ("Search for pending blocks"); + create_block->setToolTip ("Create block in JSON format"); + enter_block->setToolTip ("Enter block in JSON format"); } void rai_qt::advanced_actions::refresh_count () From 945e3f16a738b6e7904c647d63593f3b171366d6 Mon Sep 17 00:00:00 2001 From: SergiySW Date: Wed, 21 Jun 2017 17:54:10 +0300 Subject: [PATCH 4/4] Balance in account viewer --- rai/qt/qt.cpp | 16 ++++++++++++++++ rai/qt/qt.hpp | 3 +++ 2 files changed, 19 insertions(+) diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index 2fc99a2a87..e41e713250 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -578,6 +578,9 @@ layout (new QVBoxLayout), account_label (new QLabel ("Account:")), account_line (new QLineEdit), refresh (new QPushButton ("Refresh")), +balance_window (new QWidget), +balance_layout (new QHBoxLayout), +balance_label (new QLabel), history (wallet_a.wallet_m->node.ledger, account, wallet_a.rendering_ratio), back (new QPushButton ("Back")), account (wallet_a.account), @@ -586,6 +589,11 @@ wallet (wallet_a) layout->addWidget (account_label); layout->addWidget (account_line); layout->addWidget (refresh); + balance_layout->addWidget (balance_label); + balance_layout->addStretch (); + balance_layout->setContentsMargins (0, 0, 0, 0); + balance_window->setLayout (balance_layout); + layout->addWidget (balance_window); layout->addWidget (history.window); layout->addWidget (back); window->setLayout (layout); @@ -600,10 +608,18 @@ wallet (wallet_a) { show_line_ok (*account_line); this->history.refresh (); + auto balance (wallet.node.balance_pending (account)); + auto final_text (std::string ("Balance (XRB): ") + (balance.first / wallet.rendering_ratio).convert_to ()); + if (!balance.second.is_zero ()) + { + final_text += "\nPending: " + (balance.second / wallet.rendering_ratio).convert_to (); + } + balance_label->setText (QString (final_text.c_str ())); } else { show_line_error (*account_line); + balance_label->clear (); } }); } diff --git a/rai/qt/qt.hpp b/rai/qt/qt.hpp index c3a3164d30..8b58c0ea5c 100644 --- a/rai/qt/qt.hpp +++ b/rai/qt/qt.hpp @@ -248,6 +248,9 @@ namespace rai_qt { QLabel * account_label; QLineEdit * account_line; QPushButton * refresh; + QWidget * balance_window; + QHBoxLayout * balance_layout; + QLabel * balance_label; rai_qt::history history; QPushButton * back; rai::account account;