Skip to content

Commit

Permalink
gui: Show current wallet name in window title
Browse files Browse the repository at this point in the history
  • Loading branch information
promag committed Jan 15, 2019
1 parent 8a79261 commit fe7048b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
27 changes: 18 additions & 9 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,12 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
}

QString windowTitle = tr(PACKAGE_NAME) + " - ";
#ifdef ENABLE_WALLET
enableWallet = WalletModel::isWalletEnabled();
#endif // ENABLE_WALLET
if(enableWallet)
{
windowTitle += tr("Wallet");
} else {
windowTitle += tr("Node");
}
windowTitle += " " + m_network_style->getTitleAddText();
QApplication::setWindowIcon(m_network_style->getTrayAndWindowIcon());
setWindowIcon(m_network_style->getTrayAndWindowIcon());
setWindowTitle(windowTitle);
updateWindowTitle();

rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
helpMessageDialog = new HelpMessageDialog(node, this, false);
Expand Down Expand Up @@ -599,12 +591,14 @@ void BitcoinGUI::removeWallet(WalletModel* walletModel)
}
rpcConsole->removeWallet(walletModel);
walletFrame->removeWallet(walletModel);
updateWindowTitle();
}

void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
{
if (!walletFrame) return;
walletFrame->setCurrentWallet(wallet_model);
updateWindowTitle();
}

void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
Expand Down Expand Up @@ -1207,6 +1201,21 @@ void BitcoinGUI::updateProxyIcon()
}
}

void BitcoinGUI::updateWindowTitle()
{
QString window_title = tr(PACKAGE_NAME) + " - ";
#ifdef ENABLE_WALLET
if (walletFrame) {
WalletModel* const wallet_model = walletFrame->currentWalletModel();
if (wallet_model && !wallet_model->getWalletName().isEmpty()) {
window_title += wallet_model->getDisplayName() + " - ";
}
}
#endif
window_title += m_network_style->getTitleAddText();
setWindowTitle(window_title);
}

void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
{
if(!clientModel)
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public Q_SLOTS:
private:
/** Set the proxy-enabled icon as shown in the UI. */
void updateProxyIcon();
void updateWindowTitle();

public Q_SLOTS:
#ifdef ENABLE_WALLET
Expand Down
8 changes: 7 additions & 1 deletion src/qt/walletframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,17 @@ void WalletFrame::usedReceivingAddresses()
walletView->usedReceivingAddresses();
}

WalletView *WalletFrame::currentWalletView()
WalletView* WalletFrame::currentWalletView() const
{
return qobject_cast<WalletView*>(walletStack->currentWidget());
}

WalletModel* WalletFrame::currentWalletModel() const
{
WalletView* wallet_view = currentWalletView();
return wallet_view ? wallet_view->getWalletModel() : nullptr;
}

void WalletFrame::outOfSyncWarningClicked()
{
Q_EMIT requestedSyncWarningInfo();
Expand Down
3 changes: 2 additions & 1 deletion src/qt/walletframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class WalletFrame : public QFrame
const PlatformStyle *platformStyle;

public:
WalletView *currentWalletView();
WalletView* currentWalletView() const;
WalletModel* currentWalletModel() const;

public Q_SLOTS:
/** Switch to overview (home) page */
Expand Down

0 comments on commit fe7048b

Please sign in to comment.