Skip to content

Commit c7c8420

Browse files
committed
Merge #15149: gui: Show current wallet name in window title
fe7048b gui: Show current wallet name in window title (João Barbosa) 8a79261 gui: Keep network style in BitcoinGUI (João Barbosa) f411c8b gui: Remove unused return type in some BitcoinGUI methods (João Barbosa) Pull request description: <img width="876" alt="screenshot 2019-01-11 at 23 58 26" src="https://user-images.githubusercontent.com/3534524/51065458-d7ebaf80-15fc-11e9-9162-e37e9a10d448.png"> Tree-SHA512: 5c43f615834983bc1c5045e07c6e119044dd78ca947fd2679d302b519d5ce1d08d29ca00b1c11e88c4bbc4d56f2e6f4a8adc42084f3503e751e642e8a13112dc
2 parents 82ffd4d + fe7048b commit c7c8420

File tree

4 files changed

+53
-36
lines changed

4 files changed

+53
-36
lines changed

src/qt/bitcoingui.cpp

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,21 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
7777
QMainWindow(parent),
7878
m_node(node),
7979
trayIconMenu{new QMenu()},
80-
platformStyle(_platformStyle)
80+
platformStyle(_platformStyle),
81+
m_network_style(networkStyle)
8182
{
8283
QSettings settings;
8384
if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
8485
// Restore failed (perhaps missing setting), center the window
8586
move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
8687
}
8788

88-
QString windowTitle = tr(PACKAGE_NAME) + " - ";
8989
#ifdef ENABLE_WALLET
9090
enableWallet = WalletModel::isWalletEnabled();
9191
#endif // ENABLE_WALLET
92-
if(enableWallet)
93-
{
94-
windowTitle += tr("Wallet");
95-
} else {
96-
windowTitle += tr("Node");
97-
}
98-
windowTitle += " " + networkStyle->getTitleAddText();
99-
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
100-
setWindowIcon(networkStyle->getTrayAndWindowIcon());
101-
setWindowTitle(windowTitle);
92+
QApplication::setWindowIcon(m_network_style->getTrayAndWindowIcon());
93+
setWindowIcon(m_network_style->getTrayAndWindowIcon());
94+
updateWindowTitle();
10295

10396
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
10497
helpMessageDialog = new HelpMessageDialog(node, this, false);
@@ -133,7 +126,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
133126

134127
// Create system tray icon and notification
135128
if (QSystemTrayIcon::isSystemTrayAvailable()) {
136-
createTrayIcon(networkStyle);
129+
createTrayIcon();
137130
}
138131
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
139132

@@ -572,10 +565,9 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
572565
}
573566

574567
#ifdef ENABLE_WALLET
575-
bool BitcoinGUI::addWallet(WalletModel *walletModel)
568+
void BitcoinGUI::addWallet(WalletModel* walletModel)
576569
{
577-
if(!walletFrame)
578-
return false;
570+
if (!walletFrame) return;
579571
const QString display_name = walletModel->getDisplayName();
580572
setWalletActionsEnabled(true);
581573
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
@@ -584,12 +576,12 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
584576
m_wallet_selector_action->setVisible(true);
585577
}
586578
rpcConsole->addWallet(walletModel);
587-
return walletFrame->addWallet(walletModel);
579+
walletFrame->addWallet(walletModel);
588580
}
589581

590-
bool BitcoinGUI::removeWallet(WalletModel* walletModel)
582+
void BitcoinGUI::removeWallet(WalletModel* walletModel)
591583
{
592-
if (!walletFrame) return false;
584+
if (!walletFrame) return;
593585
int index = m_wallet_selector->findData(QVariant::fromValue(walletModel));
594586
m_wallet_selector->removeItem(index);
595587
if (m_wallet_selector->count() == 0) {
@@ -599,20 +591,21 @@ bool BitcoinGUI::removeWallet(WalletModel* walletModel)
599591
m_wallet_selector_action->setVisible(false);
600592
}
601593
rpcConsole->removeWallet(walletModel);
602-
return walletFrame->removeWallet(walletModel);
594+
walletFrame->removeWallet(walletModel);
595+
updateWindowTitle();
603596
}
604597

605-
bool BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
598+
void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
606599
{
607-
if(!walletFrame)
608-
return false;
609-
return walletFrame->setCurrentWallet(wallet_model);
600+
if (!walletFrame) return;
601+
walletFrame->setCurrentWallet(wallet_model);
602+
updateWindowTitle();
610603
}
611604

612-
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
605+
void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
613606
{
614607
WalletModel* wallet_model = m_wallet_selector->itemData(index).value<WalletModel*>();
615-
return setCurrentWallet(wallet_model);
608+
setCurrentWallet(wallet_model);
616609
}
617610

618611
void BitcoinGUI::removeAllWallets()
@@ -642,14 +635,14 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
642635
openAction->setEnabled(enabled);
643636
}
644637

645-
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
638+
void BitcoinGUI::createTrayIcon()
646639
{
647640
assert(QSystemTrayIcon::isSystemTrayAvailable());
648641

649642
#ifndef Q_OS_MAC
650643
if (QSystemTrayIcon::isSystemTrayAvailable()) {
651-
trayIcon = new QSystemTrayIcon(networkStyle->getTrayAndWindowIcon(), this);
652-
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
644+
trayIcon = new QSystemTrayIcon(m_network_style->getTrayAndWindowIcon(), this);
645+
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + m_network_style->getTitleAddText();
653646
trayIcon->setToolTip(toolTip);
654647
}
655648
#endif
@@ -1208,6 +1201,21 @@ void BitcoinGUI::updateProxyIcon()
12081201
}
12091202
}
12101203

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+
12111219
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
12121220
{
12131221
if(!clientModel)

src/qt/bitcoingui.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class BitcoinGUI : public QMainWindow
8080
The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
8181
functionality.
8282
*/
83-
bool addWallet(WalletModel *walletModel);
84-
bool removeWallet(WalletModel* walletModel);
83+
void addWallet(WalletModel* walletModel);
84+
void removeWallet(WalletModel* walletModel);
8585
void removeAllWallets();
8686
#endif // ENABLE_WALLET
8787
bool enableWallet = false;
@@ -161,6 +161,7 @@ class BitcoinGUI : public QMainWindow
161161
int spinnerFrame = 0;
162162

163163
const PlatformStyle *platformStyle;
164+
const NetworkStyle* const m_network_style;
164165

165166
/** Create the main UI actions. */
166167
void createActions();
@@ -169,7 +170,7 @@ class BitcoinGUI : public QMainWindow
169170
/** Create the toolbars */
170171
void createToolBars();
171172
/** Create system tray icon and notification */
172-
void createTrayIcon(const NetworkStyle *networkStyle);
173+
void createTrayIcon();
173174
/** Create system tray menu (or setup the dock menu) */
174175
void createTrayIconMenu();
175176

@@ -213,8 +214,8 @@ public Q_SLOTS:
213214
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
214215

215216
#ifdef ENABLE_WALLET
216-
bool setCurrentWallet(WalletModel* wallet_model);
217-
bool setCurrentWalletBySelectorIndex(int index);
217+
void setCurrentWallet(WalletModel* wallet_model);
218+
void setCurrentWalletBySelectorIndex(int index);
218219
/** Set the UI status indicators based on the currently selected wallet.
219220
*/
220221
void updateWalletStatus();
@@ -242,6 +243,7 @@ public Q_SLOTS:
242243
private:
243244
/** Set the proxy-enabled icon as shown in the UI. */
244245
void updateProxyIcon();
246+
void updateWindowTitle();
245247

246248
public Q_SLOTS:
247249
#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)