Skip to content

Commit 81d5172

Browse files
committed
GUI: Include alerts on "no wallet open" page
1 parent 30308cc commit 81d5172

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/qt/walletframe.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
#include <fstream>
1919
#include <string>
2020

21+
#include <Qt>
2122
#include <QApplication>
2223
#include <QClipboard>
23-
#include <QGroupBox>
2424
#include <QHBoxLayout>
2525
#include <QLabel>
2626
#include <QPushButton>
2727
#include <QVBoxLayout>
28+
#include <QWidget>
2829

2930
WalletFrame::WalletFrame(const PlatformStyle* _platformStyle, QWidget* parent)
3031
: QFrame(parent),
@@ -39,9 +40,17 @@ WalletFrame::WalletFrame(const PlatformStyle* _platformStyle, QWidget* parent)
3940
walletFrameLayout->addWidget(walletStack);
4041

4142
// hbox for no wallet
42-
QGroupBox* no_wallet_group = new QGroupBox(walletStack);
43+
QWidget* no_wallet_group = new QWidget(walletStack);
4344
QVBoxLayout* no_wallet_layout = new QVBoxLayout(no_wallet_group);
4445

46+
m_label_alerts = new QLabel(this);
47+
m_label_alerts->setVisible(false);
48+
m_label_alerts->setStyleSheet("QLabel { background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop:0 #F0D0A0, stop:1 #F8D488); color:#000000; }");
49+
m_label_alerts->setWordWrap(true);
50+
m_label_alerts->setMargin(3);
51+
m_label_alerts->setTextInteractionFlags(Qt::TextSelectableByMouse);
52+
no_wallet_layout->addWidget(m_label_alerts, 0, Qt::AlignTop);
53+
4554
QLabel *noWallet = new QLabel(tr("No wallet has been loaded.\nGo to File > Open Wallet to load a wallet.\n- OR -"));
4655
noWallet->setAlignment(Qt::AlignCenter);
4756
no_wallet_layout->addWidget(noWallet, 0, Qt::AlignHCenter | Qt::AlignBottom);
@@ -66,6 +75,11 @@ void WalletFrame::setClientModel(ClientModel *_clientModel)
6675
for (auto i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) {
6776
i.value()->setClientModel(_clientModel);
6877
}
78+
79+
if (_clientModel) {
80+
connect(_clientModel, &ClientModel::alertsChanged, this, &WalletFrame::updateAlerts);
81+
updateAlerts(_clientModel->getStatusBarWarnings());
82+
}
6983
}
7084

7185
bool WalletFrame::addView(WalletView* walletView)
@@ -276,6 +290,12 @@ WalletView* WalletFrame::currentWalletView() const
276290
return qobject_cast<WalletView*>(walletStack->currentWidget());
277291
}
278292

293+
void WalletFrame::updateAlerts(const QString &warnings)
294+
{
295+
m_label_alerts->setVisible(!warnings.isEmpty());
296+
m_label_alerts->setText(warnings);
297+
}
298+
279299
WalletModel* WalletFrame::currentWalletModel() const
280300
{
281301
WalletView* wallet_view = currentWalletView();

src/qt/walletframe.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class WalletModel;
1515
class WalletView;
1616

1717
QT_BEGIN_NAMESPACE
18+
class QLabel;
1819
class QStackedWidget;
1920
QT_END_NAMESPACE
2021

@@ -54,6 +55,7 @@ class WalletFrame : public QFrame
5455
private:
5556
QStackedWidget *walletStack;
5657
ClientModel *clientModel;
58+
QLabel* m_label_alerts;
5759
QMap<WalletModel*, WalletView*> mapWalletViews;
5860

5961
bool bOutOfSync;
@@ -97,6 +99,9 @@ public Q_SLOTS:
9799
void usedSendingAddresses();
98100
/** Show used receiving addresses */
99101
void usedReceivingAddresses();
102+
103+
private Q_SLOTS:
104+
void updateAlerts(const QString &warnings);
100105
};
101106

102107
#endif // BITCOIN_QT_WALLETFRAME_H

0 commit comments

Comments
 (0)