@ -14,8 +14,10 @@
@@ -14,8 +14,10 @@
# include "optionsdialog.h"
# include "optionsmodel.h"
# include "rpcconsole.h"
# ifdef ENABLE_WALLET
# include "walletframe.h"
# include "walletmodel.h"
# endif
# ifdef Q_OS_MAC
# include "macdockiconhandler.h"
@ -59,6 +61,7 @@ const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
@@ -59,6 +61,7 @@ const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
BitcoinGUI : : BitcoinGUI ( bool fIsTestnet , QWidget * parent ) :
QMainWindow ( parent ) ,
clientModel ( 0 ) ,
walletFrame ( 0 ) ,
encryptWalletAction ( 0 ) ,
changePassphraseAction ( 0 ) ,
aboutQtAction ( 0 ) ,
@ -69,9 +72,22 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
@@ -69,9 +72,22 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
{
GUIUtil : : restoreWindowGeometry ( " nWindow " , QSize ( 850 , 550 ) , this ) ;
QString windowTitle = tr ( " Bitcoin Core " ) + " - " ;
# ifdef ENABLE_WALLET
/* if compiled with wallet support, -disablewallet can still disable the wallet */
bool enableWallet = ! GetBoolArg ( " -disablewallet " , false ) ;
# else
bool enableWallet = false ;
# endif
if ( enableWallet )
{
windowTitle + = tr ( " Wallet " ) ;
} else {
windowTitle + = tr ( " Node " ) ;
}
if ( ! fIsTestnet )
{
setWindowTitle ( tr ( " Bitcoin Core " ) + " - " + tr ( " Wallet " ) ) ;
# ifndef Q_OS_MAC
QApplication : : setWindowIcon ( QIcon ( " :icons/bitcoin " ) ) ;
setWindowIcon ( QIcon ( " :icons/bitcoin " ) ) ;
@ -81,7 +97,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
@@ -81,7 +97,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
}
else
{
setWindowTitle ( tr ( " Bitcoin Core " ) + " - " + tr ( " Wallet " ) + " " + tr ( " [testnet] " ) ) ;
windowTitle + = " " + tr ( " [testnet] " ) ;
# ifndef Q_OS_MAC
QApplication : : setWindowIcon ( QIcon ( " :icons/bitcoin_testnet " ) ) ;
setWindowIcon ( QIcon ( " :icons/bitcoin_testnet " ) ) ;
@ -89,6 +105,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
@@ -89,6 +105,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
MacDockIconHandler : : instance ( ) - > setIcon ( QIcon ( " :icons/bitcoin_testnet " ) ) ;
# endif
}
setWindowTitle ( windowTitle ) ;
# if defined(Q_OS_MAC) && QT_VERSION < 0x050000
// This property is not implemented in Qt 5. Setting it has no effect.
@ -96,9 +113,21 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
@@ -96,9 +113,21 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
setUnifiedTitleAndToolBarOnMac ( true ) ;
# endif
// Create wallet frame and make it the central widget
rpcConsole = new RPCConsole ( enableWallet ? this : 0 ) ;
# ifdef ENABLE_WALLET
if ( enableWallet )
{
/** Create wallet frame and make it the central widget */
walletFrame = new WalletFrame ( this ) ;
setCentralWidget ( walletFrame ) ;
} else
# endif
{
/* When compiled without wallet or -disablewallet is provided,
* the central widget is the rpc console .
*/
setCentralWidget ( rpcConsole ) ;
}
// Accept D&D of URIs
setAcceptDrops ( true ) ;
@ -160,8 +189,8 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
@@ -160,8 +189,8 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
syncIconMovie = new QMovie ( " :/movies/update_spinner " , " mng " , this ) ;
rpcConsole = new RPCConsole ( this ) ;
connect ( openRPCConsoleAction , SIGNAL ( triggered ( ) ) , rpcConsole , SLOT ( show ( ) ) ) ;
// prevents an oben debug window from becoming stuck/unusable on client shutdown
connect ( quitAction , SIGNAL ( triggered ( ) ) , rpcConsole , SLOT ( hide ( ) ) ) ;
@ -286,6 +315,9 @@ void BitcoinGUI::createActions(bool fIsTestnet)
@@ -286,6 +315,9 @@ void BitcoinGUI::createActions(bool fIsTestnet)
connect ( aboutQtAction , SIGNAL ( triggered ( ) ) , qApp , SLOT ( aboutQt ( ) ) ) ;
connect ( optionsAction , SIGNAL ( triggered ( ) ) , this , SLOT ( optionsClicked ( ) ) ) ;
connect ( toggleHideAction , SIGNAL ( triggered ( ) ) , this , SLOT ( toggleHidden ( ) ) ) ;
# ifdef ENABLE_WALLET
if ( walletFrame )
{
connect ( encryptWalletAction , SIGNAL ( triggered ( bool ) ) , walletFrame , SLOT ( encryptWallet ( bool ) ) ) ;
connect ( backupWalletAction , SIGNAL ( triggered ( ) ) , walletFrame , SLOT ( backupWallet ( ) ) ) ;
connect ( changePassphraseAction , SIGNAL ( triggered ( ) ) , walletFrame , SLOT ( changePassphrase ( ) ) ) ;
@ -294,6 +326,8 @@ void BitcoinGUI::createActions(bool fIsTestnet)
@@ -294,6 +326,8 @@ void BitcoinGUI::createActions(bool fIsTestnet)
connect ( usedSendingAddressesAction , SIGNAL ( triggered ( ) ) , walletFrame , SLOT ( usedSendingAddresses ( ) ) ) ;
connect ( usedReceivingAddressesAction , SIGNAL ( triggered ( ) ) , walletFrame , SLOT ( usedReceivingAddresses ( ) ) ) ;
connect ( openAction , SIGNAL ( triggered ( ) ) , this , SLOT ( openClicked ( ) ) ) ;
}
# endif
}
void BitcoinGUI : : createMenuBar ( )
@ -308,6 +342,8 @@ void BitcoinGUI::createMenuBar()
@@ -308,6 +342,8 @@ void BitcoinGUI::createMenuBar()
// Configure the menus
QMenu * file = appMenuBar - > addMenu ( tr ( " &File " ) ) ;
if ( walletFrame )
{
file - > addAction ( openAction ) ;
file - > addAction ( backupWalletAction ) ;
file - > addAction ( signMessageAction ) ;
@ -316,23 +352,32 @@ void BitcoinGUI::createMenuBar()
@@ -316,23 +352,32 @@ void BitcoinGUI::createMenuBar()
file - > addAction ( usedSendingAddressesAction ) ;
file - > addAction ( usedReceivingAddressesAction ) ;
file - > addSeparator ( ) ;
}
file - > addAction ( quitAction ) ;
QMenu * settings = appMenuBar - > addMenu ( tr ( " &Settings " ) ) ;
if ( walletFrame )
{
settings - > addAction ( encryptWalletAction ) ;
settings - > addAction ( changePassphraseAction ) ;
settings - > addSeparator ( ) ;
}
settings - > addAction ( optionsAction ) ;
QMenu * help = appMenuBar - > addMenu ( tr ( " &Help " ) ) ;
if ( walletFrame )
{
help - > addAction ( openRPCConsoleAction ) ;
help - > addSeparator ( ) ;
}
help - > addAction ( aboutAction ) ;
help - > addAction ( aboutQtAction ) ;
}
void BitcoinGUI : : createToolBars ( )
{
if ( walletFrame )
{
QToolBar * toolbar = addToolBar ( tr ( " Tabs toolbar " ) ) ;
toolbar - > setToolButtonStyle ( Qt : : ToolButtonTextBesideIcon ) ;
toolbar - > addAction ( overviewAction ) ;
@ -340,6 +385,7 @@ void BitcoinGUI::createToolBars()
@@ -340,6 +385,7 @@ void BitcoinGUI::createToolBars()
toolbar - > addAction ( receiveCoinsAction ) ;
toolbar - > addAction ( historyAction ) ;
overviewAction - > setChecked ( true ) ;
}
}
void BitcoinGUI : : setClientModel ( ClientModel * clientModel )
@ -362,26 +408,39 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
@@ -362,26 +408,39 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
connect ( clientModel , SIGNAL ( message ( QString , QString , unsigned int ) ) , this , SLOT ( message ( QString , QString , unsigned int ) ) ) ;
rpcConsole - > setClientModel ( clientModel ) ;
# ifdef ENABLE_WALLET
if ( walletFrame )
{
walletFrame - > setClientModel ( clientModel ) ;
}
# endif
}
}
# ifdef ENABLE_WALLET
bool BitcoinGUI : : addWallet ( const QString & name , WalletModel * walletModel )
{
if ( ! walletFrame )
return false ;
setWalletActionsEnabled ( true ) ;
return walletFrame - > addWallet ( name , walletModel ) ;
}
bool BitcoinGUI : : setCurrentWallet ( const QString & name )
{
if ( ! walletFrame )
return false ;
return walletFrame - > setCurrentWallet ( name ) ;
}
void BitcoinGUI : : removeAllWallets ( )
{
if ( ! walletFrame )
return ;
setWalletActionsEnabled ( false ) ;
walletFrame - > removeAllWallets ( ) ;
}
# endif
void BitcoinGUI : : setWalletActionsEnabled ( bool enabled )
{
@ -489,6 +548,7 @@ void BitcoinGUI::aboutClicked()
@@ -489,6 +548,7 @@ void BitcoinGUI::aboutClicked()
dlg . exec ( ) ;
}
# ifdef ENABLE_WALLET
void BitcoinGUI : : openClicked ( )
{
OpenURIDialog dlg ( this ) ;
@ -531,6 +591,7 @@ void BitcoinGUI::gotoVerifyMessageTab(QString addr)
@@ -531,6 +591,7 @@ void BitcoinGUI::gotoVerifyMessageTab(QString addr)
{
if ( walletFrame ) walletFrame - > gotoVerifyMessageTab ( addr ) ;
}
# endif
void BitcoinGUI : : setNumConnections ( int count )
{
@ -591,7 +652,10 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
@@ -591,7 +652,10 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
tooltip = tr ( " Up to date " ) + QString ( " .<br> " ) + tooltip ;
labelBlocksIcon - > setPixmap ( QIcon ( " :/icons/synced " ) . pixmap ( STATUSBAR_ICONSIZE , STATUSBAR_ICONSIZE ) ) ;
# ifdef ENABLE_WALLET
if ( walletFrame )
walletFrame - > showOutOfSyncWarning ( false ) ;
# endif
progressBarLabel - > setVisible ( false ) ;
progressBar - > setVisible ( false ) ;
@ -625,7 +689,10 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
@@ -625,7 +689,10 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
syncIconMovie - > jumpToNextFrame ( ) ;
prevBlocks = count ;
# ifdef ENABLE_WALLET
if ( walletFrame )
walletFrame - > showOutOfSyncWarning ( true ) ;
# endif
tooltip + = QString ( " <br> " ) ;
tooltip + = tr ( " Last received block was generated %1 ago. " ) . arg ( timeBehindText ) ;
@ -738,6 +805,7 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
@@ -738,6 +805,7 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
QMainWindow : : closeEvent ( event ) ;
}
# ifdef ENABLE_WALLET
void BitcoinGUI : : incomingTransaction ( const QString & date , int unit , qint64 amount , const QString & type , const QString & address )
{
// On new transaction, make an info balloon
@ -751,6 +819,7 @@ void BitcoinGUI::incomingTransaction(const QString& date, int unit, qint64 amoun
@@ -751,6 +819,7 @@ void BitcoinGUI::incomingTransaction(const QString& date, int unit, qint64 amoun
. arg ( type )
. arg ( address ) , CClientUIInterface : : MSG_INFORMATION ) ;
}
# endif
void BitcoinGUI : : dragEnterEvent ( QDragEnterEvent * event )
{
@ -783,10 +852,11 @@ bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
@@ -783,10 +852,11 @@ bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
return QMainWindow : : eventFilter ( object , event ) ;
}
# ifdef ENABLE_WALLET
bool BitcoinGUI : : handlePaymentRequest ( const SendCoinsRecipient & recipient )
{
// URI has to be valid
if ( walletFrame - > handlePaymentRequest ( recipient ) )
if ( walletFrame & & walletFrame - > handlePaymentRequest ( recipient ) )
{
showNormalIfMinimized ( ) ;
gotoSendCoinsPage ( ) ;
@ -824,6 +894,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
@@ -824,6 +894,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
break ;
}
}
# endif
void BitcoinGUI : : showNormalIfMinimized ( bool fToggleHidden )
{