Skip to content

Commit

Permalink
Add warning messages to the debug window
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Dec 17, 2018
1 parent bfd7e54 commit e4fb571
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/qt/forms/debugwindow.ui
Expand Up @@ -14,6 +14,25 @@
<string>Debug window</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_alerts">
<property name="visible">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QLabel { background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop:0 #F0D0A0, stop:1 #F8D488); color:#000000; }</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>3</number>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
Expand Down
22 changes: 20 additions & 2 deletions src/qt/rpcconsole.cpp
Expand Up @@ -12,7 +12,7 @@
#include <qt/bantablemodel.h>
#include <qt/clientmodel.h>
#include <qt/platformstyle.h>
#include <qt/walletmodel.h>

#include <chainparams.h>
#include <interfaces/node.h>
#include <netbase.h>
Expand All @@ -26,8 +26,9 @@

#ifdef ENABLE_WALLET
#include <db_cxx.h>
#include <qt/walletmodel.h>
#include <wallet/wallet.h>
#endif
#endif // ENABLE_WALLET

#include <QDesktopWidget>
#include <QKeyEvent>
Expand Down Expand Up @@ -563,6 +564,17 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
void RPCConsole::setClientModel(ClientModel *model)
{
clientModel = model;

auto wallet_enabled = false;
#ifdef ENABLE_WALLET
wallet_enabled = WalletModel::isWalletEnabled();
#endif // ENABLE_WALLET
if (model && !wallet_enabled) {
// Show warning 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
Expand Down Expand Up @@ -1289,3 +1301,9 @@ QString RPCConsole::tabTitle(TabTypes tab_type) const
{
return ui->tabWidget->tabText(tab_type);
}

void RPCConsole::updateAlerts(const QString& warnings)
{
this->ui->label_alerts->setVisible(!warnings.isEmpty());
this->ui->label_alerts->setText(warnings);
}
3 changes: 3 additions & 0 deletions src/qt/rpcconsole.h
Expand Up @@ -169,6 +169,9 @@ public Q_SLOTS:

/** Update UI with latest network info from model. */
void updateNetworkState();

private Q_SLOTS:
void updateAlerts(const QString& warnings);
};

#endif // BITCOIN_QT_RPCCONSOLE_H

0 comments on commit e4fb571

Please sign in to comment.