GUI for --disable-wallet compiles and -disablewallet mode
There is not much in the GUI to be done without wallet, though it's possible to change options, watch the sync process, and use the debug console. So embed the debug console in the main window.
This commit is contained in:
@@ -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";
|
||||
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) :
|
||||
{
|
||||
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) :
|
||||
}
|
||||
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) :
|
||||
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) :
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
#endif
|
||||
|
||||
// Create wallet frame and make it the central widget
|
||||
walletFrame = new WalletFrame(this);
|
||||
setCentralWidget(walletFrame);
|
||||
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) :
|
||||
|
||||
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,14 +315,19 @@ 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()));
|
||||
connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
|
||||
connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
|
||||
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
|
||||
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
|
||||
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
|
||||
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
|
||||
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
|
||||
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
|
||||
#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()));
|
||||
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
|
||||
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
|
||||
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,38 +342,50 @@ void BitcoinGUI::createMenuBar()
|
||||
|
||||
// Configure the menus
|
||||
QMenu *file = appMenuBar->addMenu(tr("&File"));
|
||||
file->addAction(openAction);
|
||||
file->addAction(backupWalletAction);
|
||||
file->addAction(signMessageAction);
|
||||
file->addAction(verifyMessageAction);
|
||||
file->addSeparator();
|
||||
file->addAction(usedSendingAddressesAction);
|
||||
file->addAction(usedReceivingAddressesAction);
|
||||
file->addSeparator();
|
||||
if(walletFrame)
|
||||
{
|
||||
file->addAction(openAction);
|
||||
file->addAction(backupWalletAction);
|
||||
file->addAction(signMessageAction);
|
||||
file->addAction(verifyMessageAction);
|
||||
file->addSeparator();
|
||||
file->addAction(usedSendingAddressesAction);
|
||||
file->addAction(usedReceivingAddressesAction);
|
||||
file->addSeparator();
|
||||
}
|
||||
file->addAction(quitAction);
|
||||
|
||||
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
|
||||
settings->addAction(encryptWalletAction);
|
||||
settings->addAction(changePassphraseAction);
|
||||
settings->addSeparator();
|
||||
if(walletFrame)
|
||||
{
|
||||
settings->addAction(encryptWalletAction);
|
||||
settings->addAction(changePassphraseAction);
|
||||
settings->addSeparator();
|
||||
}
|
||||
settings->addAction(optionsAction);
|
||||
|
||||
QMenu *help = appMenuBar->addMenu(tr("&Help"));
|
||||
help->addAction(openRPCConsoleAction);
|
||||
help->addSeparator();
|
||||
if(walletFrame)
|
||||
{
|
||||
help->addAction(openRPCConsoleAction);
|
||||
help->addSeparator();
|
||||
}
|
||||
help->addAction(aboutAction);
|
||||
help->addAction(aboutQtAction);
|
||||
}
|
||||
|
||||
void BitcoinGUI::createToolBars()
|
||||
{
|
||||
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
|
||||
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
toolbar->addAction(overviewAction);
|
||||
toolbar->addAction(sendCoinsAction);
|
||||
toolbar->addAction(receiveCoinsAction);
|
||||
toolbar->addAction(historyAction);
|
||||
overviewAction->setChecked(true);
|
||||
if(walletFrame)
|
||||
{
|
||||
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
|
||||
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
toolbar->addAction(overviewAction);
|
||||
toolbar->addAction(sendCoinsAction);
|
||||
toolbar->addAction(receiveCoinsAction);
|
||||
toolbar->addAction(historyAction);
|
||||
overviewAction->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
walletFrame->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()
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
void BitcoinGUI::openClicked()
|
||||
{
|
||||
OpenURIDialog dlg(this);
|
||||
@@ -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)
|
||||
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
|
||||
labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
|
||||
|
||||
walletFrame->showOutOfSyncWarning(false);
|
||||
#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)
|
||||
syncIconMovie->jumpToNextFrame();
|
||||
prevBlocks = count;
|
||||
|
||||
walletFrame->showOutOfSyncWarning(true);
|
||||
#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)
|
||||
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
|
||||
.arg(type)
|
||||
.arg(address), CClientUIInterface::MSG_INFORMATION);
|
||||
}
|
||||
#endif
|
||||
|
||||
void BitcoinGUI::dragEnterEvent(QDragEnterEvent *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)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user