Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
if(enableWallet)
{
/** Create wallet frame and make it the central widget */
walletFrame = new WalletFrame(_platformStyle, this);
walletFrame = new WalletFrame(this);
setCentralWidget(walletFrame);
} else
#endif // ENABLE_WALLET
Expand Down Expand Up @@ -204,11 +204,6 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
modalOverlay = new ModalOverlay(enableWallet, this->centralWidget());
connect(labelBlocksIcon, &GUIUtil::ClickableLabel::clicked, this, &BitcoinGUI::showModalOverlay);
connect(progressBar, &GUIUtil::ClickableProgressBar::clicked, this, &BitcoinGUI::showModalOverlay);
#ifdef ENABLE_WALLET
if(enableWallet) {
connect(walletFrame, &WalletFrame::requestedSyncWarningInfo, this, &BitcoinGUI::showModalOverlay);
}
#endif

#ifdef Q_OS_MAC
m_app_nap_inhibitor = new CAppNapInhibitor;
Expand Down Expand Up @@ -651,7 +646,9 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
void BitcoinGUI::addWallet(WalletModel* walletModel)
{
if (!walletFrame) return;
if (!walletFrame->addWallet(walletModel)) return;
WalletView* walletView = new WalletView(platformStyle, walletFrame);
if (!walletFrame->addWallet(walletModel, walletView)) return;
walletView->setPrivacy(isPrivacyModeActivated());
const QString display_name = walletModel->getDisplayName();
setWalletActionsEnabled(true);
rpcConsole->addWallet(walletModel);
Expand All @@ -660,6 +657,17 @@ void BitcoinGUI::addWallet(WalletModel* walletModel)
m_wallet_selector_label_action->setVisible(true);
m_wallet_selector_action->setVisible(true);
}

connect(walletView, &WalletView::outOfSyncWarningClicked, this, &BitcoinGUI::showModalOverlay);
connect(walletView, &WalletView::transactionClicked, this, &BitcoinGUI::gotoHistoryPage);
connect(walletView, &WalletView::coinsSent, this, &BitcoinGUI::gotoHistoryPage);
connect(walletView, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {
this->message(title, message, style);
});
connect(walletView, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus);
connect(walletView, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction);
connect(walletView, &WalletView::hdEnabledStatusChanged, this, &BitcoinGUI::updateWalletStatus);
connect(this, &BitcoinGUI::setPrivacy, walletView, &WalletView::setPrivacy);
}

void BitcoinGUI::removeWallet(WalletModel* walletModel)
Expand Down
32 changes: 5 additions & 27 deletions src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <qt/walletframe.h>
#include <qt/walletmodel.h>

#include <qt/bitcoingui.h>
#include <qt/walletmodel.h>
#include <qt/walletview.h>

#include <cassert>

#include <QHBoxLayout>
#include <QLabel>

WalletFrame::WalletFrame(const PlatformStyle *_platformStyle, BitcoinGUI *_gui) :
QFrame(_gui),
gui(_gui),
platformStyle(_platformStyle)
WalletFrame::WalletFrame(QWidget* parent)
: QFrame(parent)
{
// Leave HBox hook for adding a list view later
QHBoxLayout *walletFrameLayout = new QHBoxLayout(this);
Expand All @@ -43,17 +40,15 @@ void WalletFrame::setClientModel(ClientModel *_clientModel)
}
}

bool WalletFrame::addWallet(WalletModel *walletModel)
bool WalletFrame::addWallet(WalletModel* walletModel, WalletView* walletView)
{
if (!gui || !clientModel || !walletModel) return false;
if (!clientModel || !walletModel) return false;

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

WalletView *walletView = new WalletView(platformStyle, this);
walletView->setClientModel(clientModel);
walletView->setWalletModel(walletModel);
walletView->showOutOfSyncWarning(bOutOfSync);
walletView->setPrivacy(gui->isPrivacyModeActivated());

WalletView* current_wallet_view = currentWalletView();
if (current_wallet_view) {
Expand All @@ -64,18 +59,6 @@ bool WalletFrame::addWallet(WalletModel *walletModel)

walletStack->addWidget(walletView);
mapWalletViews[walletModel] = walletView;

connect(walletView, &WalletView::outOfSyncWarningClicked, this, &WalletFrame::outOfSyncWarningClicked);
connect(walletView, &WalletView::transactionClicked, gui, &BitcoinGUI::gotoHistoryPage);
connect(walletView, &WalletView::coinsSent, gui, &BitcoinGUI::gotoHistoryPage);
connect(walletView, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {
gui->message(title, message, style);
});
connect(walletView, &WalletView::encryptionStatusChanged, gui, &BitcoinGUI::updateWalletStatus);
connect(walletView, &WalletView::incomingTransaction, gui, &BitcoinGUI::incomingTransaction);
connect(walletView, &WalletView::hdEnabledStatusChanged, gui, &BitcoinGUI::updateWalletStatus);
connect(gui, &BitcoinGUI::setPrivacy, walletView, &WalletView::setPrivacy);

return true;
}

Expand Down Expand Up @@ -225,8 +208,3 @@ WalletModel* WalletFrame::currentWalletModel() const
WalletView* wallet_view = currentWalletView();
return wallet_view ? wallet_view->getWalletModel() : nullptr;
}

void WalletFrame::outOfSyncWarningClicked()
{
Q_EMIT requestedSyncWarningInfo();
}
16 changes: 2 additions & 14 deletions src/qt/walletframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include <QFrame>
#include <QMap>

class BitcoinGUI;
class ClientModel;
class PlatformStyle;
class SendCoinsRecipient;
class WalletModel;
class WalletView;
Expand All @@ -31,12 +29,12 @@ class WalletFrame : public QFrame
Q_OBJECT

public:
explicit WalletFrame(const PlatformStyle *platformStyle, BitcoinGUI *_gui = nullptr);
explicit WalletFrame(QWidget* parent);
~WalletFrame();

void setClientModel(ClientModel *clientModel);

bool addWallet(WalletModel *walletModel);
bool addWallet(WalletModel* walletModel, WalletView* walletView);
void setCurrentWallet(WalletModel* wallet_model);
void removeWallet(WalletModel* wallet_model);
void removeAllWallets();
Expand All @@ -45,20 +43,12 @@ class WalletFrame : public QFrame

void showOutOfSyncWarning(bool fShow);

Q_SIGNALS:
/** Notify that the user has requested more information about the out-of-sync warning */
void requestedSyncWarningInfo();

private:
QStackedWidget *walletStack;
BitcoinGUI *gui;
ClientModel *clientModel;
QMap<WalletModel*, WalletView*> mapWalletViews;

bool bOutOfSync;

const PlatformStyle *platformStyle;

public:
WalletView* currentWalletView() const;
WalletModel* currentWalletModel() const;
Expand Down Expand Up @@ -94,8 +84,6 @@ public Q_SLOTS:
void usedSendingAddresses();
/** Show used receiving addresses */
void usedReceivingAddresses();
/** Pass on signal over requested out-of-sync-warning information */
void outOfSyncWarningClicked();
};

#endif // BITCOIN_QT_WALLETFRAME_H
7 changes: 1 addition & 6 deletions src/qt/walletview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent):
// Clicking on a transaction on the overview pre-selects the transaction on the transaction history page
connect(overviewPage, &OverviewPage::transactionClicked, transactionView, static_cast<void (TransactionView::*)(const QModelIndex&)>(&TransactionView::focusTransaction));

connect(overviewPage, &OverviewPage::outOfSyncWarningClicked, this, &WalletView::requestedSyncWarningInfo);
connect(overviewPage, &OverviewPage::outOfSyncWarningClicked, this, &WalletView::outOfSyncWarningClicked);

connect(sendCoinsPage, &SendCoinsDialog::coinsSent, this, &WalletView::coinsSent);
// Highlight transaction after send
Expand Down Expand Up @@ -382,8 +382,3 @@ void WalletView::showProgress(const QString &title, int nProgress)
}
}
}

void WalletView::requestedSyncWarningInfo()
{
Q_EMIT outOfSyncWarningClicked();
}
3 changes: 0 additions & 3 deletions src/qt/walletview.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ public Q_SLOTS:
/** Show progress dialog e.g. for rescan */
void showProgress(const QString &title, int nProgress);

/** User has requested more information about the out of sync state */
void requestedSyncWarningInfo();

Q_SIGNALS:
void setPrivacy(bool privacy);
void transactionClicked();
Expand Down
1 change: 0 additions & 1 deletion test/lint/lint-circular-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
"index/txindex -> validation -> index/txindex"
"policy/fees -> txmempool -> policy/fees"
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
"qt/bitcoingui -> qt/walletframe -> qt/bitcoingui"
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
"qt/sendcoinsdialog -> qt/walletmodel -> qt/sendcoinsdialog"
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel"
Expand Down