Merge pull request #3392

b7f4b6d GUI for --disable-wallet compiles and -disablewallet mode (Wladimir J. van der Laan)
ec41342 build: pass correct defs and include path to moc (Wladimir J. van der Laan)
This commit is contained in:
Wladimir J. van der Laan 2014-01-11 12:51:03 +01:00
commit 061aff4c46
No known key found for this signature in database
GPG key ID: 74810B012346C9A6
9 changed files with 244 additions and 77 deletions

View file

@ -567,9 +567,6 @@ if test x$bitcoin_enable_qt != xno; then
AC_MSG_ERROR("QT Test lib not found. Use --disable-tests or --without-qt.") AC_MSG_ERROR("QT Test lib not found. Use --disable-tests or --without-qt.")
fi fi
fi fi
if test x$enable_wallet == xno; then
AC_MSG_ERROR([Cannot currently build Qt GUI with wallet disabled. Use --without-qt.])
fi
fi fi
if test x$use_tests = xyes; then if test x$use_tests = xyes; then

View file

@ -12,6 +12,7 @@ LIBBITCOIN_CLI=$(top_builddir)/src/libbitcoin_cli.a
LIBLEVELDB=$(top_builddir)/src/leveldb/libleveldb.a LIBLEVELDB=$(top_builddir)/src/leveldb/libleveldb.a
LIBMEMENV=$(top_builddir)/src/leveldb/libmemenv.a LIBMEMENV=$(top_builddir)/src/leveldb/libmemenv.a
LIBBITCOINQT=$(top_builddir)/src/qt/libbitcoinqt.a LIBBITCOINQT=$(top_builddir)/src/qt/libbitcoinqt.a
MOC_DEFS=$(DEFS) -I$(top_srcdir)/src
$(LIBBITCOIN): $(LIBBITCOIN):
$(MAKE) -C $(top_builddir)/src $(@F) $(MAKE) -C $(top_builddir)/src $(@F)

View file

@ -150,24 +150,56 @@ RES_ICONS = res/icons/bitcoin.png res/icons/address-book.png \
res/icons/qrcode.png res/icons/debugwindow.png res/icons/bitcoin.ico \ res/icons/qrcode.png res/icons/debugwindow.png res/icons/bitcoin.ico \
res/icons/bitcoin_testnet.ico res/icons/bitcoin_testnet.ico
BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \ BITCOIN_QT_CPP = \
addresstablemodel.cpp askpassphrasedialog.cpp bitcoinaddressvalidator.cpp \ aboutdialog.cpp \
bitcoinamountfield.cpp bitcoin.cpp bitcoingui.cpp \ bitcoinaddressvalidator.cpp \
bitcoinunits.cpp clientmodel.cpp \ bitcoinamountfield.cpp \
bitcoin.cpp \
bitcoingui.cpp \
bitcoinunits.cpp \
clientmodel.cpp \
csvmodelwriter.cpp \
guiutil.cpp \
intro.cpp \
monitoreddatamapper.cpp \
notificator.cpp \
optionsdialog.cpp \
optionsmodel.cpp \
qvalidatedlineedit.cpp \
qvaluecombobox.cpp \
rpcconsole.cpp \
signverifymessagedialog.cpp \
splashscreen.cpp \
trafficgraphwidget.cpp
if ENABLE_WALLET
BITCOIN_QT_CPP += \
addressbookpage.cpp \
addresstablemodel.cpp \
askpassphrasedialog.cpp \
coincontroldialog.cpp \ coincontroldialog.cpp \
coincontroltreewidget.cpp \ coincontroltreewidget.cpp \
csvmodelwriter.cpp editaddressdialog.cpp \ editaddressdialog.cpp \
guiutil.cpp intro.cpp monitoreddatamapper.cpp notificator.cpp \
openuridialog.cpp \ openuridialog.cpp \
optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \ overviewpage.cpp \
paymentserver.cpp qvalidatedlineedit.cpp qvaluecombobox.cpp \ paymentrequestplus.cpp \
receivecoinsdialog.cpp receiverequestdialog.cpp \ paymentserver.cpp \
receivecoinsdialog.cpp \
receiverequestdialog.cpp \
recentrequeststablemodel.cpp \ recentrequeststablemodel.cpp \
rpcconsole.cpp sendcoinsdialog.cpp sendcoinsentry.cpp \ sendcoinsdialog.cpp \
signverifymessagedialog.cpp splashscreen.cpp trafficgraphwidget.cpp transactiondesc.cpp \ sendcoinsentry.cpp \
transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \ transactiondesc.cpp \
transactiontablemodel.cpp transactionview.cpp walletframe.cpp \ transactiondescdialog.cpp \
walletmodel.cpp walletmodeltransaction.cpp walletview.cpp transactionfilterproxy.cpp \
transactionrecord.cpp \
transactiontablemodel.cpp \
transactionview.cpp \
walletframe.cpp \
walletmodel.cpp \
walletmodeltransaction.cpp \
walletview.cpp
endif
RES_IMAGES = res/images/about.png res/images/splash.png \ RES_IMAGES = res/images/about.png res/images/splash.png \
res/images/splash_testnet.png res/images/splash_testnet.png
@ -203,7 +235,11 @@ endif
bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) \ bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) \
-I$(top_srcdir)/src/qt/forms -I$(top_srcdir)/src/qt/forms
bitcoin_qt_SOURCES = bitcoin.cpp bitcoin_qt_SOURCES = bitcoin.cpp
bitcoin_qt_LDADD = libbitcoinqt.a $(LIBBITCOIN_SERVER) $(LIBBITCOIN_WALLET) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) $(LIBMEMENV) \ bitcoin_qt_LDADD = libbitcoinqt.a $(LIBBITCOIN_SERVER)
if ENABLE_WALLET
bitcoin_qt_LDADD += $(LIBBITCOIN_WALLET)
endif
bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) $(LIBMEMENV) \
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS)
# forms/foo.h -> forms/ui_foo.h # forms/foo.h -> forms/ui_foo.h

View file

@ -10,9 +10,11 @@
#include "guiutil.h" #include "guiutil.h"
#include "intro.h" #include "intro.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "paymentserver.h"
#include "splashscreen.h" #include "splashscreen.h"
#ifdef ENABLE_WALLET
#include "paymentserver.h"
#include "walletmodel.h" #include "walletmodel.h"
#endif
#include "init.h" #include "init.h"
#include "main.h" #include "main.h"
@ -157,8 +159,10 @@ public:
explicit BitcoinApplication(int &argc, char **argv); explicit BitcoinApplication(int &argc, char **argv);
~BitcoinApplication(); ~BitcoinApplication();
#ifdef ENABLE_WALLET
/// Create payment server /// Create payment server
void createPaymentServer(); void createPaymentServer();
#endif
/// Create options model /// Create options model
void createOptionsModel(); void createOptionsModel();
/// Create main window /// Create main window
@ -188,12 +192,14 @@ signals:
private: private:
QThread *coreThread; QThread *coreThread;
PaymentServer* paymentServer;
OptionsModel *optionsModel; OptionsModel *optionsModel;
ClientModel *clientModel; ClientModel *clientModel;
BitcoinGUI *window; BitcoinGUI *window;
WalletModel *walletModel;
QTimer *pollShutdownTimer; QTimer *pollShutdownTimer;
#ifdef ENABLE_WALLET
PaymentServer* paymentServer;
WalletModel *walletModel;
#endif
int returnValue; int returnValue;
void startThread(); void startThread();
@ -246,12 +252,14 @@ void BitcoinCore::shutdown()
BitcoinApplication::BitcoinApplication(int &argc, char **argv): BitcoinApplication::BitcoinApplication(int &argc, char **argv):
QApplication(argc, argv), QApplication(argc, argv),
coreThread(0), coreThread(0),
paymentServer(0),
optionsModel(0), optionsModel(0),
clientModel(0), clientModel(0),
window(0), window(0),
walletModel(0),
pollShutdownTimer(0), pollShutdownTimer(0),
#ifdef ENABLE_WALLET
paymentServer(0),
walletModel(0),
#endif
returnValue(0) returnValue(0)
{ {
setQuitOnLastWindowClosed(false); setQuitOnLastWindowClosed(false);
@ -266,14 +274,21 @@ BitcoinApplication::~BitcoinApplication()
LogPrintf("Stopped thread\n"); LogPrintf("Stopped thread\n");
delete window; delete window;
window = 0;
#ifdef ENABLE_WALLET
delete paymentServer; delete paymentServer;
paymentServer = 0;
#endif
delete optionsModel; delete optionsModel;
optionsModel = 0;
} }
#ifdef ENABLE_WALLET
void BitcoinApplication::createPaymentServer() void BitcoinApplication::createPaymentServer()
{ {
paymentServer = new PaymentServer(this); paymentServer = new PaymentServer(this);
} }
#endif
void BitcoinApplication::createOptionsModel() void BitcoinApplication::createOptionsModel()
{ {
@ -327,11 +342,13 @@ void BitcoinApplication::requestShutdown()
LogPrintf("Requesting shutdown\n"); LogPrintf("Requesting shutdown\n");
window->hide(); window->hide();
window->setClientModel(0); window->setClientModel(0);
window->removeAllWallets();
pollShutdownTimer->stop(); pollShutdownTimer->stop();
#ifdef ENABLE_WALLET
window->removeAllWallets();
delete walletModel; delete walletModel;
walletModel = 0; walletModel = 0;
#endif
delete clientModel; delete clientModel;
clientModel = 0; clientModel = 0;
@ -362,14 +379,17 @@ void BitcoinApplication::initializeResult(int retval)
// Miscellaneous initialization after core is initialized // Miscellaneous initialization after core is initialized
optionsModel->Upgrade(); // Must be done after AppInit2 optionsModel->Upgrade(); // Must be done after AppInit2
#ifdef ENABLE_WALLET
PaymentServer::LoadRootCAs(); PaymentServer::LoadRootCAs();
paymentServer->setOptionsModel(optionsModel); paymentServer->setOptionsModel(optionsModel);
#endif
emit splashFinished(window); emit splashFinished(window);
clientModel = new ClientModel(optionsModel); clientModel = new ClientModel(optionsModel);
window->setClientModel(clientModel); window->setClientModel(clientModel);
#ifdef ENABLE_WALLET
if(pwalletMain) if(pwalletMain)
{ {
walletModel = new WalletModel(pwalletMain, optionsModel); walletModel = new WalletModel(pwalletMain, optionsModel);
@ -380,6 +400,7 @@ void BitcoinApplication::initializeResult(int retval)
connect(walletModel, SIGNAL(coinsSent(CWallet*,SendCoinsRecipient,QByteArray)), connect(walletModel, SIGNAL(coinsSent(CWallet*,SendCoinsRecipient,QByteArray)),
paymentServer, SLOT(fetchPaymentACK(CWallet*,const SendCoinsRecipient&,QByteArray))); paymentServer, SLOT(fetchPaymentACK(CWallet*,const SendCoinsRecipient&,QByteArray)));
} }
#endif
// If -min option passed, start window minimized. // If -min option passed, start window minimized.
if(GetBoolArg("-min", false)) if(GetBoolArg("-min", false))
@ -390,7 +411,7 @@ void BitcoinApplication::initializeResult(int retval)
{ {
window->show(); window->show();
} }
#ifdef ENABLE_WALLET
// Now that initialization/startup is done, process any command-line // Now that initialization/startup is done, process any command-line
// bitcoin: URIs or payment requests: // bitcoin: URIs or payment requests:
connect(paymentServer, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), connect(paymentServer, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)),
@ -400,7 +421,7 @@ void BitcoinApplication::initializeResult(int retval)
connect(paymentServer, SIGNAL(message(QString,QString,unsigned int)), connect(paymentServer, SIGNAL(message(QString,QString,unsigned int)),
window, SLOT(message(QString,QString,unsigned int))); window, SLOT(message(QString,QString,unsigned int)));
QTimer::singleShot(100, paymentServer, SLOT(uiReady())); QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
#endif
} else { } else {
quit(); // Exit main loop quit(); // Exit main loop
} }
@ -429,9 +450,11 @@ int main(int argc, char *argv[])
if (!SelectParamsFromCommandLine()) { if (!SelectParamsFromCommandLine()) {
fSelParFromCLFailed = true; fSelParFromCLFailed = true;
} }
#ifdef ENABLE_WALLET
// Parse URIs on command line -- this can affect TestNet() / RegTest() mode // Parse URIs on command line -- this can affect TestNet() / RegTest() mode
if (!PaymentServer::ipcParseCommandLine(argc, argv)) if (!PaymentServer::ipcParseCommandLine(argc, argv))
exit(0); exit(0);
#endif
bool isaTestNet = TestNet() || RegTest(); bool isaTestNet = TestNet() || RegTest();
@ -500,6 +523,7 @@ int main(int argc, char *argv[])
} }
ReadConfigFile(mapArgs, mapMultiArgs); ReadConfigFile(mapArgs, mapMultiArgs);
#ifdef ENABLE_WALLET
/// 7. URI IPC sending /// 7. URI IPC sending
// - Do this early as we don't want to bother initializing if we are just calling IPC // - Do this early as we don't want to bother initializing if we are just calling IPC
// - Do this *after* setting up the data directory, as the data directory hash is used in the name // - Do this *after* setting up the data directory, as the data directory hash is used in the name
@ -512,6 +536,7 @@ int main(int argc, char *argv[])
// Start up the payment server early, too, so impatient users that click on // Start up the payment server early, too, so impatient users that click on
// bitcoin: links repeatedly have their payment requests routed to this process: // bitcoin: links repeatedly have their payment requests routed to this process:
app.createPaymentServer(); app.createPaymentServer();
#endif
/// 8. Main GUI initialization /// 8. Main GUI initialization
// Install global event filter that makes sure that long tooltips can be word-wrapped // Install global event filter that makes sure that long tooltips can be word-wrapped

View file

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

View file

@ -5,6 +5,10 @@
#ifndef BITCOINGUI_H #ifndef BITCOINGUI_H
#define BITCOINGUI_H #define BITCOINGUI_H
#if defined(HAVE_CONFIG_H)
#include "bitcoin-config.h"
#endif
#include <QMainWindow> #include <QMainWindow>
#include <QMap> #include <QMap>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
@ -43,14 +47,15 @@ public:
*/ */
void setClientModel(ClientModel *clientModel); void setClientModel(ClientModel *clientModel);
#ifdef ENABLE_WALLET
/** Set the wallet model. /** Set the wallet model.
The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
functionality. functionality.
*/ */
bool addWallet(const QString& name, WalletModel *walletModel); bool addWallet(const QString& name, WalletModel *walletModel);
bool setCurrentWallet(const QString& name); bool setCurrentWallet(const QString& name);
void removeAllWallets(); void removeAllWallets();
#endif
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
@ -125,11 +130,6 @@ public slots:
void setNumConnections(int count); void setNumConnections(int count);
/** Set number of blocks shown in the UI */ /** Set number of blocks shown in the UI */
void setNumBlocks(int count, int nTotalBlocks); void setNumBlocks(int count, int nTotalBlocks);
/** Set the encryption status as shown in the UI.
@param[in] status current encryption status
@see WalletModel::EncryptionStatus
*/
void setEncryptionStatus(int status);
/** Notify the user of an event from the core network or transaction handling code. /** Notify the user of an event from the core network or transaction handling code.
@param[in] title the message box / notification title @param[in] title the message box / notification title
@ -140,12 +140,21 @@ public slots:
*/ */
void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL); void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
#ifdef ENABLE_WALLET
/** Set the encryption status as shown in the UI.
@param[in] status current encryption status
@see WalletModel::EncryptionStatus
*/
void setEncryptionStatus(int status);
bool handlePaymentRequest(const SendCoinsRecipient& recipient); bool handlePaymentRequest(const SendCoinsRecipient& recipient);
/** Show incoming transaction notification for new transactions. */ /** Show incoming transaction notification for new transactions. */
void incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address); void incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address);
#endif
private slots: private slots:
#ifdef ENABLE_WALLET
/** Switch to overview (home) page */ /** Switch to overview (home) page */
void gotoOverviewPage(); void gotoOverviewPage();
/** Switch to history (transactions) page */ /** Switch to history (transactions) page */
@ -160,6 +169,9 @@ private slots:
/** Show Sign/Verify Message dialog and switch to verify message tab */ /** Show Sign/Verify Message dialog and switch to verify message tab */
void gotoVerifyMessageTab(QString addr = ""); void gotoVerifyMessageTab(QString addr = "");
/** Show open dialog */
void openClicked();
#endif
/** Show configuration dialog */ /** Show configuration dialog */
void optionsClicked(); void optionsClicked();
/** Show about dialog */ /** Show about dialog */
@ -168,8 +180,6 @@ private slots:
/** Handle tray icon clicked */ /** Handle tray icon clicked */
void trayIconActivated(QSystemTrayIcon::ActivationReason reason); void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
#endif #endif
/** Show open dialog */
void openClicked();
/** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */ /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */
void showNormalIfMinimized(bool fToggleHidden = false); void showNormalIfMinimized(bool fToggleHidden = false);

View file

@ -14,8 +14,10 @@
#include "init.h" #include "init.h"
#include "main.h" #include "main.h"
#include "net.h" #include "net.h"
#ifdef ENABLE_WALLET
#include "wallet.h" #include "wallet.h"
#include "walletdb.h" #include "walletdb.h"
#endif
#include <QSettings> #include <QSettings>
#include <QStringList> #include <QStringList>
@ -67,8 +69,10 @@ void OptionsModel::Init()
// by command-line and show this in the UI. // by command-line and show this in the UI.
// Main // Main
#ifdef ENABLE_WALLET
if (!settings.contains("nTransactionFee")) if (!settings.contains("nTransactionFee"))
settings.setValue("nTransactionFee", 0); settings.setValue("nTransactionFee", 0);
#endif
if (!settings.contains("nDatabaseCache")) if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", 25); settings.setValue("nDatabaseCache", 25);
@ -137,6 +141,7 @@ void OptionsModel::Upgrade()
settings.setValue("bImportFinished", true); settings.setValue("bImportFinished", true);
#ifdef ENABLE_WALLET
// Move settings from old wallet.dat (if any): // Move settings from old wallet.dat (if any):
CWalletDB walletdb(strWalletFile); CWalletDB walletdb(strWalletFile);
@ -181,6 +186,7 @@ void OptionsModel::Upgrade()
walletdb.EraseSetting("addrProxy"); walletdb.EraseSetting("addrProxy");
} }
} }
#endif
Init(); Init();
} }
@ -227,6 +233,7 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
case ProxySocksVersion: case ProxySocksVersion:
return settings.value("nSocksVersion", 5); return settings.value("nSocksVersion", 5);
#ifdef ENABLE_WALLET
case Fee: case Fee:
// Attention: Init() is called before nTransactionFee is set in AppInit2()! // Attention: Init() is called before nTransactionFee is set in AppInit2()!
// To ensure we can change the fee on-the-fly update our QSetting when // To ensure we can change the fee on-the-fly update our QSetting when
@ -236,6 +243,7 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
// Todo: Consider to revert back to use just nTransactionFee here, if we don't want // Todo: Consider to revert back to use just nTransactionFee here, if we don't want
// -paytxfee to update our QSettings! // -paytxfee to update our QSettings!
return settings.value("nTransactionFee"); return settings.value("nTransactionFee");
#endif
case DisplayUnit: case DisplayUnit:
return nDisplayUnit; return nDisplayUnit;
case DisplayAddresses: case DisplayAddresses:
@ -318,13 +326,14 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
} }
} }
break; break;
#ifdef ENABLE_WALLET
case Fee: // core option - can be changed on-the-fly case Fee: // core option - can be changed on-the-fly
// Todo: Add is valid check and warn via message, if not // Todo: Add is valid check and warn via message, if not
nTransactionFee = value.toLongLong(); nTransactionFee = value.toLongLong();
settings.setValue("nTransactionFee", (qint64)nTransactionFee); settings.setValue("nTransactionFee", (qint64)nTransactionFee);
emit transactionFeeChanged(nTransactionFee); emit transactionFeeChanged(nTransactionFee);
break; break;
#endif
case DisplayUnit: case DisplayUnit:
nDisplayUnit = value.toInt(); nDisplayUnit = value.toInt();
settings.setValue("nDisplayUnit", nDisplayUnit); settings.setValue("nDisplayUnit", nDisplayUnit);

View file

@ -8,16 +8,27 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \
bin_PROGRAMS = test_bitcoin-qt bin_PROGRAMS = test_bitcoin-qt
TESTS = test_bitcoin-qt TESTS = test_bitcoin-qt
TEST_QT_MOC_CPP = moc_uritests.cpp moc_paymentservertests.cpp TEST_QT_MOC_CPP = moc_uritests.cpp
if ENABLE_WALLET
TEST_QT_MOC_CPP += moc_paymentservertests.cpp
endif
TEST_QT_H = uritests.h paymentservertests.h paymentrequestdata.h TEST_QT_H = uritests.h paymentservertests.h paymentrequestdata.h
BUILT_SOURCES = $(TEST_QT_MOC_CPP) BUILT_SOURCES = $(TEST_QT_MOC_CPP)
test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) $(QT_TEST_INCLUDES) test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) $(QT_TEST_INCLUDES)
test_bitcoin_qt_SOURCES = test_main.cpp uritests.cpp paymentservertests.cpp $(TEST_QT_H) test_bitcoin_qt_SOURCES = test_main.cpp uritests.cpp $(TEST_QT_H)
if ENABLE_WALLET
test_bitcoin_qt_SOURCES += paymentservertests.cpp
endif
nodist_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP) nodist_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)
test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) $(LIBBITCOIN_WALLET) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) \ test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER)
if ENABLE_WALLET
test_bitcoin_qt_LDADD += $(LIBBITCOIN_WALLET)
endif
test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) \
$(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS)

View file

@ -1,5 +1,11 @@
#include "bitcoin-config.h" #include "bitcoin-config.h"
#if defined(HAVE_CONFIG_H)
#include "bitcoin-config.h"
#endif
#ifdef ENABLE_WALLET
#include "paymentservertests.h" #include "paymentservertests.h"
#endif
#include "uritests.h" #include "uritests.h"
#include <QCoreApplication> #include <QCoreApplication>
@ -27,10 +33,11 @@ int main(int argc, char *argv[])
URITests test1; URITests test1;
if (QTest::qExec(&test1) != 0) if (QTest::qExec(&test1) != 0)
fInvalid = true; fInvalid = true;
#ifdef ENABLE_WALLET
PaymentServerTests test2; PaymentServerTests test2;
if (QTest::qExec(&test2) != 0) if (QTest::qExec(&test2) != 0)
fInvalid = true; fInvalid = true;
#endif
return fInvalid; return fInvalid;
} }