@ -57,7 +57,7 @@
const QString BitcoinGUI : : DEFAULT_WALLET = " ~Default " ;
const QString BitcoinGUI : : DEFAULT_WALLET = " ~Default " ;
BitcoinGUI : : BitcoinGUI ( QWidget * parent ) :
BitcoinGUI : : BitcoinGUI ( bool fIsTestnet , QWidget * parent ) :
QMainWindow ( parent ) ,
QMainWindow ( parent ) ,
clientModel ( 0 ) ,
clientModel ( 0 ) ,
encryptWalletAction ( 0 ) ,
encryptWalletAction ( 0 ) ,
@ -69,14 +69,30 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
prevBlocks ( 0 )
prevBlocks ( 0 )
{
{
restoreWindowGeometry ( ) ;
restoreWindowGeometry ( ) ;
setWindowTitle ( tr ( " Bitcoin " ) + " - " + tr ( " Wallet " ) ) ;
# ifndef Q_OS_MAC
# ifndef Q_OS_MAC
if ( ! fIsTestnet )
{
setWindowTitle ( tr ( " Bitcoin " ) + " - " + tr ( " Wallet " ) ) ;
QApplication : : setWindowIcon ( QIcon ( " :icons/bitcoin " ) ) ;
QApplication : : setWindowIcon ( QIcon ( " :icons/bitcoin " ) ) ;
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
# else
setUnifiedTitleAndToolBarOnMac ( true ) ;
setUnifiedTitleAndToolBarOnMac ( true ) ;
QApplication : : setAttribute ( Qt : : AA_DontShowIconsInMenus ) ;
QApplication : : setAttribute ( Qt : : AA_DontShowIconsInMenus ) ;
if ( ! fIsTestnet )
MacDockIconHandler : : instance ( ) - > setIcon ( QIcon ( " :icons/bitcoin " ) ) ;
else
MacDockIconHandler : : instance ( ) - > setIcon ( QIcon ( " :icons/bitcoin_testnet " ) ) ;
# endif
# endif
// Create wallet frame and make it the central widget
// Create wallet frame and make it the central widget
walletFrame = new WalletFrame ( this ) ;
walletFrame = new WalletFrame ( this ) ;
setCentralWidget ( walletFrame ) ;
setCentralWidget ( walletFrame ) ;
@ -86,7 +102,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
// Create actions for the toolbar, menu bar and tray/dock icon
// Create actions for the toolbar, menu bar and tray/dock icon
// Needs walletFrame to be initialized
// Needs walletFrame to be initialized
createActions ( ) ;
createActions ( fIsTestnet ) ;
// Create application menu bar
// Create application menu bar
createMenuBar ( ) ;
createMenuBar ( ) ;
@ -95,7 +111,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
createToolBars ( ) ;
createToolBars ( ) ;
// Create system tray icon and notification
// Create system tray icon and notification
createTrayIcon ( ) ;
createTrayIcon ( fIsTestnet ) ;
// Create status bar
// Create status bar
statusBar ( ) ;
statusBar ( ) ;
@ -159,7 +175,7 @@ BitcoinGUI::~BitcoinGUI()
# endif
# endif
}
}
void BitcoinGUI : : createActions ( )
void BitcoinGUI : : createActions ( bool fIsTestnet )
{
{
QActionGroup * tabGroup = new QActionGroup ( this ) ;
QActionGroup * tabGroup = new QActionGroup ( this ) ;
@ -213,7 +229,10 @@ void BitcoinGUI::createActions()
quitAction - > setStatusTip ( tr ( " Quit application " ) ) ;
quitAction - > setStatusTip ( tr ( " Quit application " ) ) ;
quitAction - > setShortcut ( QKeySequence ( Qt : : CTRL + Qt : : Key_Q ) ) ;
quitAction - > setShortcut ( QKeySequence ( Qt : : CTRL + Qt : : Key_Q ) ) ;
quitAction - > setMenuRole ( QAction : : QuitRole ) ;
quitAction - > setMenuRole ( QAction : : QuitRole ) ;
if ( ! fIsTestnet )
aboutAction = new QAction ( QIcon ( " :/icons/bitcoin " ) , tr ( " &About Bitcoin " ) , this ) ;
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 - > setStatusTip ( tr ( " Show information about Bitcoin " ) ) ;
aboutAction - > setMenuRole ( QAction : : AboutRole ) ;
aboutAction - > setMenuRole ( QAction : : AboutRole ) ;
aboutQtAction = new QAction ( QIcon ( " :/trolltech/qmessagebox/images/qtlogo-64.png " ) , tr ( " About &Qt " ) , this ) ;
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 = new QAction ( QIcon ( " :/icons/options " ) , tr ( " &Options... " ) , this ) ;
optionsAction - > setStatusTip ( tr ( " Modify configuration options for Bitcoin " ) ) ;
optionsAction - > setStatusTip ( tr ( " Modify configuration options for Bitcoin " ) ) ;
optionsAction - > setMenuRole ( QAction : : PreferencesRole ) ;
optionsAction - > setMenuRole ( QAction : : PreferencesRole ) ;
if ( ! fIsTestnet )
toggleHideAction = new QAction ( QIcon ( " :/icons/bitcoin " ) , tr ( " &Show / Hide " ) , this ) ;
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 " ) ) ;
toggleHideAction - > setStatusTip ( tr ( " Show or hide the main Window " ) ) ;
encryptWalletAction = new QAction ( QIcon ( " :/icons/lock_closed " ) , tr ( " &Encrypt Wallet... " ) , this ) ;
encryptWalletAction = new QAction ( QIcon ( " :/icons/lock_closed " ) , tr ( " &Encrypt Wallet... " ) , this ) ;
@ -299,27 +321,6 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
this - > clientModel = clientModel ;
this - > clientModel = clientModel ;
if ( 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,
// 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
// while the client has not yet fully loaded
createTrayIconMenu ( ) ;
createTrayIconMenu ( ) ;
@ -354,13 +355,22 @@ void BitcoinGUI::removeAllWallets()
walletFrame - > removeAllWallets ( ) ;
walletFrame - > removeAllWallets ( ) ;
}
}
void BitcoinGUI : : createTrayIcon ( )
void BitcoinGUI : : createTrayIcon ( bool fIsTestnet )
{
{
# ifndef Q_OS_MAC
# ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon ( this ) ;
trayIcon = new QSystemTrayIcon ( this ) ;
if ( ! fIsTestnet )
{
trayIcon - > setToolTip ( tr ( " Bitcoin client " ) ) ;
trayIcon - > setToolTip ( tr ( " Bitcoin client " ) ) ;
trayIcon - > setIcon ( QIcon ( " :/icons/toolbar " ) ) ;
trayIcon - > setIcon ( QIcon ( " :/icons/toolbar " ) ) ;
}
else
{
trayIcon - > setToolTip ( tr ( " Bitcoin client " ) + " " + tr ( " [testnet] " ) ) ;
trayIcon - > setIcon ( QIcon ( " :/icons/toolbar_testnet " ) ) ;
}
trayIcon - > show ( ) ;
trayIcon - > show ( ) ;
# endif
# endif