Skip to content

Commit fe7048b

Browse files
committed
gui: Show current wallet name in window title
1 parent 8a79261 commit fe7048b

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

src/qt/bitcoingui.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,12 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
8585
move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
8686
}
8787

88-
QString windowTitle = tr(PACKAGE_NAME) + " - ";
8988
#ifdef ENABLE_WALLET
9089
enableWallet = WalletModel::isWalletEnabled();
9190
#endif // ENABLE_WALLET
92-
if(enableWallet)
93-
{
94-
windowTitle += tr("Wallet");
95-
} else {
96-
windowTitle += tr("Node");
97-
}
98-
windowTitle += " " + m_network_style->getTitleAddText();
9991
QApplication::setWindowIcon(m_network_style->getTrayAndWindowIcon());
10092
setWindowIcon(m_network_style->getTrayAndWindowIcon());
101-
setWindowTitle(windowTitle);
93+
updateWindowTitle();
10294

10395
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
10496
helpMessageDialog = new HelpMessageDialog(node, this, false);
@@ -599,12 +591,14 @@ void BitcoinGUI::removeWallet(WalletModel* walletModel)
599591
}
600592
rpcConsole->removeWallet(walletModel);
601593
walletFrame->removeWallet(walletModel);
594+
updateWindowTitle();
602595
}
603596

604597
void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
605598
{
606599
if (!walletFrame) return;
607600
walletFrame->setCurrentWallet(wallet_model);
601+
updateWindowTitle();
608602
}
609603

610604
void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
@@ -1207,6 +1201,21 @@ void BitcoinGUI::updateProxyIcon()
12071201
}
12081202
}
12091203

1204+
void BitcoinGUI::updateWindowTitle()
1205+
{
1206+
QString window_title = tr(PACKAGE_NAME) + " - ";
1207+
#ifdef ENABLE_WALLET
1208+
if (walletFrame) {
1209+
WalletModel* const wallet_model = walletFrame->currentWalletModel();
1210+
if (wallet_model && !wallet_model->getWalletName().isEmpty()) {
1211+
window_title += wallet_model->getDisplayName() + " - ";
1212+
}
1213+
}
1214+
#endif
1215+
window_title += m_network_style->getTitleAddText();
1216+
setWindowTitle(window_title);
1217+
}
1218+
12101219
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
12111220
{
12121221
if(!clientModel)

src/qt/bitcoingui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public Q_SLOTS:
243243
private:
244244
/** Set the proxy-enabled icon as shown in the UI. */
245245
void updateProxyIcon();
246+
void updateWindowTitle();
246247

247248
public Q_SLOTS:
248249
#ifdef ENABLE_WALLET

src/qt/walletframe.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,17 @@ void WalletFrame::usedReceivingAddresses()
208208
walletView->usedReceivingAddresses();
209209
}
210210

211-
WalletView *WalletFrame::currentWalletView()
211+
WalletView* WalletFrame::currentWalletView() const
212212
{
213213
return qobject_cast<WalletView*>(walletStack->currentWidget());
214214
}
215215

216+
WalletModel* WalletFrame::currentWalletModel() const
217+
{
218+
WalletView* wallet_view = currentWalletView();
219+
return wallet_view ? wallet_view->getWalletModel() : nullptr;
220+
}
221+
216222
void WalletFrame::outOfSyncWarningClicked()
217223
{
218224
Q_EMIT requestedSyncWarningInfo();

src/qt/walletframe.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class WalletFrame : public QFrame
6060
const PlatformStyle *platformStyle;
6161

6262
public:
63-
WalletView *currentWalletView();
63+
WalletView* currentWalletView() const;
64+
WalletModel* currentWalletModel() const;
6465

6566
public Q_SLOTS:
6667
/** Switch to overview (home) page */

0 commit comments

Comments
 (0)