Skip to content

Commit 69fd180

Browse files
committed
Merge e033ca1 into merged_master (Bitcoin PR bitcoin-core/gui#29)
2 parents 9e27d6c + e033ca1 commit 69fd180

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

src/qt/bitcoingui.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
105105
{
106106
/** Create wallet frame and make it the central widget */
107107
walletFrame = new WalletFrame(_platformStyle, this);
108+
connect(walletFrame, &WalletFrame::createWalletButtonClicked, [this] {
109+
auto activity = new CreateWalletActivity(getWalletController(), this);
110+
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
111+
activity->create();
112+
});
108113
setCentralWidget(walletFrame);
109114
} else
110115
#endif // ENABLE_WALLET
@@ -666,7 +671,10 @@ WalletController* BitcoinGUI::getWalletController()
666671
void BitcoinGUI::addWallet(WalletModel* walletModel)
667672
{
668673
if (!walletFrame) return;
669-
if (!walletFrame->addWallet(walletModel)) return;
674+
675+
WalletView* wallet_view = new WalletView(platformStyle, walletFrame);
676+
if (!walletFrame->addWallet(walletModel, wallet_view)) return;
677+
670678
rpcConsole->addWallet(walletModel);
671679
if (m_wallet_selector->count() == 0) {
672680
setWalletActionsEnabled(true);
@@ -676,6 +684,18 @@ void BitcoinGUI::addWallet(WalletModel* walletModel)
676684
}
677685
const QString display_name = walletModel->getDisplayName();
678686
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
687+
688+
connect(wallet_view, &WalletView::outOfSyncWarningClicked, walletFrame, &WalletFrame::outOfSyncWarningClicked);
689+
connect(wallet_view, &WalletView::transactionClicked, this, &BitcoinGUI::gotoHistoryPage);
690+
connect(wallet_view, &WalletView::coinsSent, this, &BitcoinGUI::gotoHistoryPage);
691+
connect(wallet_view, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {
692+
this->message(title, message, style);
693+
});
694+
connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus);
695+
connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction);
696+
connect(wallet_view, &WalletView::hdEnabledStatusChanged, this, &BitcoinGUI::updateWalletStatus);
697+
connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy);
698+
wallet_view->setPrivacy(isPrivacyModeActivated());
679699
}
680700

681701
void BitcoinGUI::removeWallet(WalletModel* walletModel)

src/qt/walletframe.cpp

+5-26
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
#include <qt/walletframe.h>
66

7-
#include <qt/bitcoingui.h>
8-
#include <qt/createwalletdialog.h>
97
#include <qt/overviewpage.h>
10-
#include <qt/walletcontroller.h>
118
#include <qt/walletmodel.h>
129
#include <qt/walletview.h>
1310

@@ -19,9 +16,8 @@
1916
#include <QPushButton>
2017
#include <QVBoxLayout>
2118

22-
WalletFrame::WalletFrame(const PlatformStyle* _platformStyle, BitcoinGUI* _gui)
23-
: QFrame(_gui),
24-
gui(_gui),
19+
WalletFrame::WalletFrame(const PlatformStyle* _platformStyle, QWidget* parent)
20+
: QFrame(parent),
2521
platformStyle(_platformStyle),
2622
m_size_hint(OverviewPage{platformStyle, nullptr}.sizeHint())
2723
{
@@ -42,11 +38,7 @@ WalletFrame::WalletFrame(const PlatformStyle* _platformStyle, BitcoinGUI* _gui)
4238

4339
// A button for create wallet dialog
4440
QPushButton* create_wallet_button = new QPushButton(tr("Create a new wallet"), walletStack);
45-
connect(create_wallet_button, &QPushButton::clicked, [this] {
46-
auto activity = new CreateWalletActivity(gui->getWalletController(), this);
47-
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
48-
activity->create();
49-
});
41+
connect(create_wallet_button, &QPushButton::clicked, this, &WalletFrame::createWalletButtonClicked);
5042
no_wallet_layout->addWidget(create_wallet_button, 0, Qt::AlignHCenter | Qt::AlignTop);
5143
no_wallet_group->setLayout(no_wallet_layout);
5244

@@ -66,17 +58,15 @@ void WalletFrame::setClientModel(ClientModel *_clientModel)
6658
}
6759
}
6860

69-
bool WalletFrame::addWallet(WalletModel *walletModel)
61+
bool WalletFrame::addWallet(WalletModel* walletModel, WalletView* walletView)
7062
{
71-
if (!gui || !clientModel || !walletModel) return false;
63+
if (!clientModel || !walletModel) return false;
7264

7365
if (mapWalletViews.count(walletModel) > 0) return false;
7466

75-
WalletView *walletView = new WalletView(platformStyle, this);
7667
walletView->setClientModel(clientModel);
7768
walletView->setWalletModel(walletModel);
7869
walletView->showOutOfSyncWarning(bOutOfSync);
79-
walletView->setPrivacy(gui->isPrivacyModeActivated());
8070

8171
WalletView* current_wallet_view = currentWalletView();
8272
if (current_wallet_view) {
@@ -88,17 +78,6 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
8878
walletStack->addWidget(walletView);
8979
mapWalletViews[walletModel] = walletView;
9080

91-
connect(walletView, &WalletView::outOfSyncWarningClicked, this, &WalletFrame::outOfSyncWarningClicked);
92-
connect(walletView, &WalletView::transactionClicked, gui, &BitcoinGUI::gotoHistoryPage);
93-
connect(walletView, &WalletView::coinsSent, gui, &BitcoinGUI::gotoHistoryPage);
94-
connect(walletView, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {
95-
gui->message(title, message, style);
96-
});
97-
connect(walletView, &WalletView::encryptionStatusChanged, gui, &BitcoinGUI::updateWalletStatus);
98-
connect(walletView, &WalletView::incomingTransaction, gui, &BitcoinGUI::incomingTransaction);
99-
connect(walletView, &WalletView::hdEnabledStatusChanged, gui, &BitcoinGUI::updateWalletStatus);
100-
connect(gui, &BitcoinGUI::setPrivacy, walletView, &WalletView::setPrivacy);
101-
10281
return true;
10382
}
10483

src/qt/walletframe.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <QFrame>
99
#include <QMap>
1010

11-
class BitcoinGUI;
1211
class ClientModel;
1312
class PlatformStyle;
1413
class SendCoinsRecipient;
@@ -31,12 +30,12 @@ class WalletFrame : public QFrame
3130
Q_OBJECT
3231

3332
public:
34-
explicit WalletFrame(const PlatformStyle *platformStyle, BitcoinGUI *_gui = nullptr);
33+
explicit WalletFrame(const PlatformStyle* platformStyle, QWidget* parent);
3534
~WalletFrame();
3635

3736
void setClientModel(ClientModel *clientModel);
3837

39-
bool addWallet(WalletModel *walletModel);
38+
bool addWallet(WalletModel* walletModel, WalletView* walletView);
4039
void setCurrentWallet(WalletModel* wallet_model);
4140
void removeWallet(WalletModel* wallet_model);
4241
void removeAllWallets();
@@ -51,9 +50,10 @@ class WalletFrame : public QFrame
5150
/** Notify that the user has requested more information about the out-of-sync warning */
5251
void requestedSyncWarningInfo();
5352

53+
void createWalletButtonClicked();
54+
5455
private:
5556
QStackedWidget *walletStack;
56-
BitcoinGUI *gui;
5757
ClientModel *clientModel;
5858
QMap<WalletModel*, WalletView*> mapWalletViews;
5959

test/lint/lint-circular-dependencies.sh

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
1717
"index/coinstatsindex -> node/coinstats -> index/coinstatsindex"
1818
"policy/fees -> txmempool -> policy/fees"
1919
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
20-
"qt/bitcoingui -> qt/walletframe -> qt/bitcoingui"
2120
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
2221
"qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog"
2322
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel"

0 commit comments

Comments
 (0)