Skip to content

Commit d26f064

Browse files
committed
Tell users how to load or create a wallet when no wallet is loaded
1 parent 1bee1e6 commit d26f064

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/qt/bitcoingui.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,11 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
660660
}
661661
}
662662

663+
WalletController* BitcoinGUI::getWalletController()
664+
{
665+
return m_wallet_controller;
666+
}
667+
663668
void BitcoinGUI::addWallet(WalletModel* walletModel)
664669
{
665670
if (!walletFrame) return;

src/qt/bitcoingui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class BitcoinGUI : public QMainWindow
7979
void setClientModel(ClientModel *clientModel = nullptr, interfaces::BlockAndHeaderTipInfo* tip_info = nullptr);
8080
#ifdef ENABLE_WALLET
8181
void setWalletController(WalletController* wallet_controller);
82+
WalletController* getWalletController();
8283
#endif
8384

8485
#ifdef ENABLE_WALLET

src/qt/walletframe.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#include <qt/createwalletdialog.h>
6+
#include <qt/walletcontroller.h>
57
#include <qt/walletframe.h>
68
#include <qt/walletmodel.h>
79

@@ -10,8 +12,11 @@
1012

1113
#include <cassert>
1214

15+
#include <QGroupBox>
1316
#include <QHBoxLayout>
1417
#include <QLabel>
18+
#include <QPushButton>
19+
#include <QVBoxLayout>
1520

1621
WalletFrame::WalletFrame(const PlatformStyle *_platformStyle, BitcoinGUI *_gui) :
1722
QFrame(_gui),
@@ -25,9 +30,25 @@ WalletFrame::WalletFrame(const PlatformStyle *_platformStyle, BitcoinGUI *_gui)
2530
walletFrameLayout->setContentsMargins(0,0,0,0);
2631
walletFrameLayout->addWidget(walletStack);
2732

28-
QLabel *noWallet = new QLabel(tr("No wallet has been loaded."));
33+
// hbox for no wallet
34+
QGroupBox* no_wallet_group = new QGroupBox(walletStack);
35+
QVBoxLayout* no_wallet_layout = new QVBoxLayout(no_wallet_group);
36+
37+
QLabel *noWallet = new QLabel(tr("No wallet has been loaded.\nGo to File > Open Wallet to load a wallet.\n- OR -"));
2938
noWallet->setAlignment(Qt::AlignCenter);
30-
walletStack->addWidget(noWallet);
39+
no_wallet_layout->addWidget(noWallet, 0, Qt::AlignHCenter | Qt::AlignBottom);
40+
41+
// A button for create wallet dialog
42+
QPushButton* create_wallet_button = new QPushButton(tr("Create a new wallet"), walletStack);
43+
connect(create_wallet_button, &QPushButton::clicked, [this] {
44+
auto activity = new CreateWalletActivity(gui->getWalletController(), this);
45+
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
46+
activity->create();
47+
});
48+
no_wallet_layout->addWidget(create_wallet_button, 0, Qt::AlignHCenter | Qt::AlignTop);
49+
no_wallet_group->setLayout(no_wallet_layout);
50+
51+
walletStack->addWidget(no_wallet_group);
3152
}
3253

3354
WalletFrame::~WalletFrame()

0 commit comments

Comments
 (0)