aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2013-05-19 20:20:06 +0200
committerPhilip Kaufmann <phil.kaufmann@t-online.de>2013-06-02 17:40:28 +0200
commit80fccb0eb3756af5385460d9008b9b8b17b7cda5 (patch)
tree0335a4ae78da38c39ef8447476686c003ee4ab67 /src/qt/bitcoingui.cpp
parent50b4086a4a4fbba8241c4b8807870d7b44c109fe (diff)
Bitcoin-Qt: setup testnet GUI directly
- this directly sets up all GUI elements that have testnet special-casing without first setting up main net stuff and changing afterwards (titles, icons etc.) - also fixes 2 wrong icons shown during testnet usage on our toolbar
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp76
1 files changed, 43 insertions, 33 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index a4589860bf..190da6caf8 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -57,7 +57,7 @@
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
-BitcoinGUI::BitcoinGUI(QWidget *parent) :
+BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
QMainWindow(parent),
clientModel(0),
encryptWalletAction(0),
@@ -69,14 +69,30 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
prevBlocks(0)
{
restoreWindowGeometry();
- setWindowTitle(tr("Bitcoin") + " - " + tr("Wallet"));
+
#ifndef Q_OS_MAC
- QApplication::setWindowIcon(QIcon(":icons/bitcoin"));
- setWindowIcon(QIcon(":icons/bitcoin"));
+ if (!fIsTestnet)
+ {
+ setWindowTitle(tr("Bitcoin") + " - " + tr("Wallet"));
+ QApplication::setWindowIcon(QIcon(":icons/bitcoin"));
+ setWindowIcon(QIcon(":icons/bitcoin"));
+ }
+ else
+ {
+ setWindowTitle(tr("Bitcoin") + " - " + tr("Wallet") + " " + tr("[testnet]"));
+ QApplication::setWindowIcon(QIcon(":icons/bitcoin_testnet"));
+ setWindowIcon(QIcon(":icons/bitcoin_testnet"));
+ }
#else
setUnifiedTitleAndToolBarOnMac(true);
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
+
+ if (!fIsTestnet)
+ MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin"));
+ else
+ MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
#endif
+
// Create wallet frame and make it the central widget
walletFrame = new WalletFrame(this);
setCentralWidget(walletFrame);
@@ -86,7 +102,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
// Create actions for the toolbar, menu bar and tray/dock icon
// Needs walletFrame to be initialized
- createActions();
+ createActions(fIsTestnet);
// Create application menu bar
createMenuBar();
@@ -95,7 +111,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
createToolBars();
// Create system tray icon and notification
- createTrayIcon();
+ createTrayIcon(fIsTestnet);
// Create status bar
statusBar();
@@ -159,7 +175,7 @@ BitcoinGUI::~BitcoinGUI()
#endif
}
-void BitcoinGUI::createActions()
+void BitcoinGUI::createActions(bool fIsTestnet)
{
QActionGroup *tabGroup = new QActionGroup(this);
@@ -213,7 +229,10 @@ void BitcoinGUI::createActions()
quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setMenuRole(QAction::QuitRole);
- aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About Bitcoin"), this);
+ if (!fIsTestnet)
+ aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About Bitcoin"), this);
+ else
+ aboutAction = new QAction(QIcon(":/icons/bitcoin_testnet"), tr("&About Bitcoin"), this);
aboutAction->setStatusTip(tr("Show information about Bitcoin"));
aboutAction->setMenuRole(QAction::AboutRole);
aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
@@ -222,7 +241,10 @@ void BitcoinGUI::createActions()
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
optionsAction->setStatusTip(tr("Modify configuration options for Bitcoin"));
optionsAction->setMenuRole(QAction::PreferencesRole);
- toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
+ 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->setStatusTip(tr("Show or hide the main Window"));
encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
@@ -299,27 +321,6 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
this->clientModel = clientModel;
if(clientModel)
{
- // Replace some strings and icons, when using the testnet
- if(clientModel->isTestNet())
- {
- setWindowTitle(windowTitle() + QString(" ") + 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
- if(trayIcon)
- {
- // Just attach " [testnet]" to the existing tooltip
- trayIcon->setToolTip(trayIcon->toolTip() + QString(" ") + tr("[testnet]"));
- trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
- }
-
- toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet"));
- aboutAction->setIcon(QIcon(":/icons/toolbar_testnet"));
- }
-
// Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
// while the client has not yet fully loaded
createTrayIconMenu();
@@ -354,13 +355,22 @@ void BitcoinGUI::removeAllWallets()
walletFrame->removeAllWallets();
}
-void BitcoinGUI::createTrayIcon()
+void BitcoinGUI::createTrayIcon(bool fIsTestnet)
{
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
- trayIcon->setToolTip(tr("Bitcoin client"));
- trayIcon->setIcon(QIcon(":/icons/toolbar"));
+ if (!fIsTestnet)
+ {
+ trayIcon->setToolTip(tr("Bitcoin client"));
+ trayIcon->setIcon(QIcon(":/icons/toolbar"));
+ }
+ else
+ {
+ trayIcon->setToolTip(tr("Bitcoin client") + " " + tr("[testnet]"));
+ trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
+ }
+
trayIcon->show();
#endif