qt: add network-specific style object
Mainly cleanups: Gets rid of isTestNet everywhere, by keeping track of network-specific theming in a central place. Also makes GUI no longer dependent on the network ID enumeration, which alleviates concerns about #4802.
This commit is contained in:
committed by
jtimon
parent
dec58922d0
commit
6de50c3c9a
@@ -8,6 +8,7 @@
|
||||
#include "clientmodel.h"
|
||||
#include "guiconstants.h"
|
||||
#include "guiutil.h"
|
||||
#include "networkstyle.h"
|
||||
#include "notificator.h"
|
||||
#include "openuridialog.h"
|
||||
#include "optionsdialog.h"
|
||||
@@ -59,7 +60,7 @@
|
||||
|
||||
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
|
||||
|
||||
BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
|
||||
BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
clientModel(0),
|
||||
walletFrame(0),
|
||||
@@ -112,26 +113,13 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
|
||||
} else {
|
||||
windowTitle += tr("Node");
|
||||
}
|
||||
|
||||
if (!fIsTestnet)
|
||||
{
|
||||
windowTitle += " " + networkStyle->getTitleAddText();
|
||||
#ifndef Q_OS_MAC
|
||||
QApplication::setWindowIcon(QIcon(":icons/bitcoin"));
|
||||
setWindowIcon(QIcon(":icons/bitcoin"));
|
||||
QApplication::setWindowIcon(networkStyle->getAppIcon());
|
||||
setWindowIcon(networkStyle->getAppIcon());
|
||||
#else
|
||||
MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin"));
|
||||
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
windowTitle += " " + tr("[testnet]");
|
||||
#ifndef Q_OS_MAC
|
||||
QApplication::setWindowIcon(QIcon(":icons/bitcoin_testnet"));
|
||||
setWindowIcon(QIcon(":icons/bitcoin_testnet"));
|
||||
#else
|
||||
MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
|
||||
#endif
|
||||
}
|
||||
setWindowTitle(windowTitle);
|
||||
|
||||
#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
|
||||
@@ -161,7 +149,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
|
||||
|
||||
// Create actions for the toolbar, menu bar and tray/dock icon
|
||||
// Needs walletFrame to be initialized
|
||||
createActions(fIsTestnet);
|
||||
createActions(networkStyle);
|
||||
|
||||
// Create application menu bar
|
||||
createMenuBar();
|
||||
@@ -170,7 +158,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
|
||||
createToolBars();
|
||||
|
||||
// Create system tray icon and notification
|
||||
createTrayIcon(fIsTestnet);
|
||||
createTrayIcon(networkStyle);
|
||||
|
||||
// Create status bar
|
||||
statusBar();
|
||||
@@ -248,7 +236,7 @@ BitcoinGUI::~BitcoinGUI()
|
||||
#endif
|
||||
}
|
||||
|
||||
void BitcoinGUI::createActions(bool fIsTestnet)
|
||||
void BitcoinGUI::createActions(const NetworkStyle *networkStyle)
|
||||
{
|
||||
QActionGroup *tabGroup = new QActionGroup(this);
|
||||
|
||||
@@ -295,10 +283,7 @@ void BitcoinGUI::createActions(bool fIsTestnet)
|
||||
quitAction->setStatusTip(tr("Quit application"));
|
||||
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
|
||||
quitAction->setMenuRole(QAction::QuitRole);
|
||||
if (!fIsTestnet)
|
||||
aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About Bitcoin Core"), this);
|
||||
else
|
||||
aboutAction = new QAction(QIcon(":/icons/bitcoin_testnet"), tr("&About Bitcoin Core"), this);
|
||||
aboutAction = new QAction(networkStyle->getAppIcon(), tr("&About Bitcoin Core"), this);
|
||||
aboutAction->setStatusTip(tr("Show information about Bitcoin Core"));
|
||||
aboutAction->setMenuRole(QAction::AboutRole);
|
||||
#if QT_VERSION < 0x050000
|
||||
@@ -311,10 +296,7 @@ void BitcoinGUI::createActions(bool fIsTestnet)
|
||||
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
|
||||
optionsAction->setStatusTip(tr("Modify configuration options for Bitcoin"));
|
||||
optionsAction->setMenuRole(QAction::PreferencesRole);
|
||||
if (!fIsTestnet)
|
||||
toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
|
||||
else
|
||||
toggleHideAction = new QAction(QIcon(":/icons/bitcoin_testnet"), tr("&Show / Hide"), this);
|
||||
toggleHideAction = new QAction(networkStyle->getAppIcon(), tr("&Show / Hide"), this);
|
||||
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
|
||||
|
||||
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
|
||||
@@ -505,22 +487,13 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
|
||||
openAction->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void BitcoinGUI::createTrayIcon(bool fIsTestnet)
|
||||
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
|
||||
{
|
||||
#ifndef Q_OS_MAC
|
||||
trayIcon = new QSystemTrayIcon(this);
|
||||
|
||||
if (!fIsTestnet)
|
||||
{
|
||||
trayIcon->setToolTip(tr("Bitcoin Core client"));
|
||||
trayIcon->setIcon(QIcon(":/icons/bitcoin"));
|
||||
}
|
||||
else
|
||||
{
|
||||
trayIcon->setToolTip(tr("Bitcoin Core client") + " " + tr("[testnet]"));
|
||||
trayIcon->setIcon(QIcon(":/icons/bitcoin_testnet"));
|
||||
}
|
||||
|
||||
QString toolTip = tr("Bitcoin Core client") + " " + networkStyle->getTitleAddText();
|
||||
trayIcon->setToolTip(toolTip);
|
||||
trayIcon->setIcon(networkStyle->getAppIcon());
|
||||
trayIcon->show();
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user