From 8b0f3f7945ca68bb897e95060d65309012edd913 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 28 Aug 2019 16:02:31 -0400 Subject: [PATCH] Merge #14879: qt: Add warning messages to the debug window 593ba696fb32da558091ac02ad87c4893db4ce97 Add warning messages to the debug window (Hennadii Stepanov) Pull request description: Fix: #11016 This PR adds warning messages to the debug window in `-disablewallet` mode. ![screenshot from 2018-12-06 01-01-27](https://user-images.githubusercontent.com/32963518/49550070-413c1c80-f8f3-11e8-9865-efb49ea8da45.png) ACKs for top commit: jonasschnelli: utACK 593ba696fb32da558091ac02ad87c4893db4ce97 promag: ACK 593ba696fb32da558091ac02ad87c4893db4ce97, agree with @Sjors https://github.com/bitcoin/bitcoin/pull/14879#pullrequestreview-196433092 above. ryanofsky: utACK 593ba696fb32da558091ac02ad87c4893db4ce97 Tree-SHA512: a8ca78529bb16813ba7bfaf5ccd4349189979f08e78ea857746a6fb00fd9d7ed98d8f06f384830acba21dac57070060af23f6be8249398feb32a6efff1333de8 14879 followup: move label_alerts css styling into css files and align it with the style of labelAlerts on OverviewPage Co-authored-by: UdjinM6 --- src/qt/forms/debugwindow.ui | 16 ++++++++++++++++ src/qt/overviewpage.cpp | 5 ++--- src/qt/res/css/general.css | 7 +++++++ src/qt/res/css/traditional.css | 11 +++++++++++ src/qt/rpcconsole.cpp | 17 +++++++++++++++++ src/qt/rpcconsole.h | 3 +++ 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 9d99bff998..ecbec6794b 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -14,6 +14,22 @@ Tools window + + + + false + + + true + + + 3 + + + Qt::TextSelectableByMouse + + + diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 70ca03a1c3..6fc68a0be1 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -251,9 +251,8 @@ void OverviewPage::updateWatchOnlyLabels(bool showWatchOnly) void OverviewPage::setClientModel(ClientModel *model) { this->clientModel = model; - if(model) - { - // Show warning if this is a prerelease version + if (model) { + // Show warning, for example if this is a prerelease version connect(model, &ClientModel::alertsChanged, this, &OverviewPage::updateAlerts); updateAlerts(model->getStatusBarWarnings()); } diff --git a/src/qt/res/css/general.css b/src/qt/res/css/general.css index e104e92ae7..9c62c7651a 100644 --- a/src/qt/res/css/general.css +++ b/src/qt/res/css/general.css @@ -1586,6 +1586,13 @@ QWidget#RPCConsole QLabel#peerHeading, QWidget#RPCConsole QLabel#banHeading { } +QWidget#RPCConsole QLabel#label_alerts { + background-color: #c79304; + color: #222222; + border-radius: 5px; + padding: 5px; +} + QWidget#RPCConsole QLabel#labelNetwork, QWidget#RPCConsole QLabel#label_10, QWidget#RPCConsole QLabel#labelMempoolTitle { /* Margin between Network and Block Chain headers */ diff --git a/src/qt/res/css/traditional.css b/src/qt/res/css/traditional.css index cdafe03274..cd15a30d03 100644 --- a/src/qt/res/css/traditional.css +++ b/src/qt/res/css/traditional.css @@ -250,6 +250,17 @@ QWidget .QFrame#frame_2 QListView { /* Transaction List */ margin-right: 10px; } +/****************************************************** +RPCConsole +******************************************************/ + +QWidget#RPCConsole QLabel#label_alerts { + background-color: #c79304; + color: #222222; + border-radius: 5px; + padding: 5px; +} + /****************************************************** SendCoinsDialog ******************************************************/ diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 4e973d3c00..6afafb8476 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -583,6 +583,17 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event) void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_t bestblock_date, uint256 bestblock_hash, double verification_progress) { clientModel = model; + + bool wallet_enabled{false}; +#ifdef ENABLE_WALLET + wallet_enabled = WalletModel::isWalletEnabled(); +#endif // ENABLE_WALLET + if (model && !wallet_enabled) { + // Show warning, for example if this is a prerelease version + connect(model, &ClientModel::alertsChanged, this, &RPCConsole::updateAlerts); + updateAlerts(model->getStatusBarWarnings()); + } + ui->trafficGraph->setClientModel(model); if (model && clientModel->getPeerTableModel() && clientModel->getBanTableModel()) { // Keep up to date with client @@ -1441,3 +1452,9 @@ QKeySequence RPCConsole::tabShortcut(TabTypes tab_type) const assert(false); } + +void RPCConsole::updateAlerts(const QString& warnings) +{ + this->ui->label_alerts->setVisible(!warnings.isEmpty()); + this->ui->label_alerts->setText(warnings); +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 76456236db..a3019d528d 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -192,6 +192,9 @@ private: /** Update UI with latest network info from model. */ void updateNetworkState(); + +private Q_SLOTS: + void updateAlerts(const QString& warnings); }; #endif // BITCOIN_QT_RPCCONSOLE_H