Merge #15149: gui: Show current wallet name in window title

fe7048b39 gui: Show current wallet name in window title (João Barbosa)
8a7926112 gui: Keep network style in BitcoinGUI (João Barbosa)
f411c8b35 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
This commit is contained in:
Jonas Schnelli 2019-01-15 09:01:43 -10:00
commit c7c84209bb
No known key found for this signature in database
GPG key ID: 1EB776BB03C7922D
4 changed files with 53 additions and 36 deletions

View file

@ -77,7 +77,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
QMainWindow(parent),
m_node(node),
trayIconMenu{new QMenu()},
platformStyle(_platformStyle)
platformStyle(_platformStyle),
m_network_style(networkStyle)
{
QSettings settings;
if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
@ -85,20 +86,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 += " " + networkStyle->getTitleAddText();
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
setWindowIcon(networkStyle->getTrayAndWindowIcon());
setWindowTitle(windowTitle);
QApplication::setWindowIcon(m_network_style->getTrayAndWindowIcon());
setWindowIcon(m_network_style->getTrayAndWindowIcon());
updateWindowTitle();
rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
helpMessageDialog = new HelpMessageDialog(node, this, false);
@ -133,7 +126,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
// Create system tray icon and notification
if (QSystemTrayIcon::isSystemTrayAvailable()) {
createTrayIcon(networkStyle);
createTrayIcon();
}
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
@ -572,10 +565,9 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
}
#ifdef ENABLE_WALLET
bool BitcoinGUI::addWallet(WalletModel *walletModel)
void BitcoinGUI::addWallet(WalletModel* walletModel)
{
if(!walletFrame)
return false;
if (!walletFrame) return;
const QString display_name = walletModel->getDisplayName();
setWalletActionsEnabled(true);
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
@ -584,12 +576,12 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
m_wallet_selector_action->setVisible(true);
}
rpcConsole->addWallet(walletModel);
return walletFrame->addWallet(walletModel);
walletFrame->addWallet(walletModel);
}
bool BitcoinGUI::removeWallet(WalletModel* walletModel)
void BitcoinGUI::removeWallet(WalletModel* walletModel)
{
if (!walletFrame) return false;
if (!walletFrame) return;
int index = m_wallet_selector->findData(QVariant::fromValue(walletModel));
m_wallet_selector->removeItem(index);
if (m_wallet_selector->count() == 0) {
@ -599,20 +591,21 @@ bool BitcoinGUI::removeWallet(WalletModel* walletModel)
m_wallet_selector_action->setVisible(false);
}
rpcConsole->removeWallet(walletModel);
return walletFrame->removeWallet(walletModel);
walletFrame->removeWallet(walletModel);
updateWindowTitle();
}
bool BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
{
if(!walletFrame)
return false;
return walletFrame->setCurrentWallet(wallet_model);
if (!walletFrame) return;
walletFrame->setCurrentWallet(wallet_model);
updateWindowTitle();
}
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
{
WalletModel* wallet_model = m_wallet_selector->itemData(index).value<WalletModel*>();
return setCurrentWallet(wallet_model);
setCurrentWallet(wallet_model);
}
void BitcoinGUI::removeAllWallets()
@ -642,14 +635,14 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
openAction->setEnabled(enabled);
}
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
void BitcoinGUI::createTrayIcon()
{
assert(QSystemTrayIcon::isSystemTrayAvailable());
#ifndef Q_OS_MAC
if (QSystemTrayIcon::isSystemTrayAvailable()) {
trayIcon = new QSystemTrayIcon(networkStyle->getTrayAndWindowIcon(), this);
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
trayIcon = new QSystemTrayIcon(m_network_style->getTrayAndWindowIcon(), this);
QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + m_network_style->getTitleAddText();
trayIcon->setToolTip(toolTip);
}
#endif
@ -1208,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)

View file

@ -80,8 +80,8 @@ public:
The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
functionality.
*/
bool addWallet(WalletModel *walletModel);
bool removeWallet(WalletModel* walletModel);
void addWallet(WalletModel* walletModel);
void removeWallet(WalletModel* walletModel);
void removeAllWallets();
#endif // ENABLE_WALLET
bool enableWallet = false;
@ -161,6 +161,7 @@ private:
int spinnerFrame = 0;
const PlatformStyle *platformStyle;
const NetworkStyle* const m_network_style;
/** Create the main UI actions. */
void createActions();
@ -169,7 +170,7 @@ private:
/** Create the toolbars */
void createToolBars();
/** Create system tray icon and notification */
void createTrayIcon(const NetworkStyle *networkStyle);
void createTrayIcon();
/** Create system tray menu (or setup the dock menu) */
void createTrayIconMenu();
@ -213,8 +214,8 @@ public Q_SLOTS:
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
#ifdef ENABLE_WALLET
bool setCurrentWallet(WalletModel* wallet_model);
bool setCurrentWalletBySelectorIndex(int index);
void setCurrentWallet(WalletModel* wallet_model);
void setCurrentWalletBySelectorIndex(int index);
/** Set the UI status indicators based on the currently selected wallet.
*/
void updateWalletStatus();
@ -242,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

View file

@ -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();

View file

@ -60,7 +60,8 @@ private:
const PlatformStyle *platformStyle;
public:
WalletView *currentWalletView();
WalletView* currentWalletView() const;
WalletModel* currentWalletModel() const;
public Q_SLOTS:
/** Switch to overview (home) page */