Browse Source

qt: GUI support for -disablewallet mode

Rebased-from: 8121047b20f6486bf049e642c3e6ca61682ffdd9
0.8
Wladimir J. van der Laan 11 years ago committed by Warren Togami
parent
commit
99f3d18b62
  1. 12
      src/qt/bitcoin.cpp
  2. 19
      src/qt/bitcoingui.cpp
  3. 2
      src/qt/bitcoingui.h
  4. 48
      src/qt/walletframe.cpp
  5. 5
      src/qt/walletframe.h

12
src/qt/bitcoin.cpp

@ -254,11 +254,16 @@ int main(int argc, char *argv[]) @@ -254,11 +254,16 @@ int main(int argc, char *argv[])
splash.finish(&window);
ClientModel clientModel(&optionsModel);
WalletModel walletModel(pwalletMain, &optionsModel);
WalletModel *walletModel = 0;
if(pwalletMain)
walletModel = new WalletModel(pwalletMain, &optionsModel);
window.setClientModel(&clientModel);
window.addWallet("~Default", &walletModel);
window.setCurrentWallet("~Default");
if(walletModel)
{
window.addWallet("~Default", walletModel);
window.setCurrentWallet("~Default");
}
// If -min option passed, start window minimized.
if(GetBoolArg("-min"))
@ -281,6 +286,7 @@ int main(int argc, char *argv[]) @@ -281,6 +286,7 @@ int main(int argc, char *argv[])
window.setClientModel(0);
window.removeAllWallets();
guiref = 0;
delete walletModel;
}
// Shutdown the core and its threads, but don't exit Bitcoin-Qt here
threadGroup.interrupt_all();

19
src/qt/bitcoingui.cpp

@ -146,6 +146,9 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) : @@ -146,6 +146,9 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
// Install event filter to be able to catch status tip events (QEvent::StatusTip)
this->installEventFilter(this);
// Initially wallet actions should be disabled
setWalletActionsEnabled(false);
}
BitcoinGUI::~BitcoinGUI()
@ -341,6 +344,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) @@ -341,6 +344,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
{
setWalletActionsEnabled(true);
return walletFrame->addWallet(name, walletModel);
}
@ -351,9 +355,24 @@ bool BitcoinGUI::setCurrentWallet(const QString& name) @@ -351,9 +355,24 @@ bool BitcoinGUI::setCurrentWallet(const QString& name)
void BitcoinGUI::removeAllWallets()
{
setWalletActionsEnabled(false);
walletFrame->removeAllWallets();
}
void BitcoinGUI::setWalletActionsEnabled(bool enabled)
{
overviewAction->setEnabled(enabled);
sendCoinsAction->setEnabled(enabled);
receiveCoinsAction->setEnabled(enabled);
historyAction->setEnabled(enabled);
encryptWalletAction->setEnabled(enabled);
backupWalletAction->setEnabled(enabled);
changePassphraseAction->setEnabled(enabled);
signMessageAction->setEnabled(enabled);
verifyMessageAction->setEnabled(enabled);
addressBookAction->setEnabled(enabled);
}
void BitcoinGUI::createTrayIcon()
{
#ifndef Q_OS_MAC

2
src/qt/bitcoingui.h

@ -126,6 +126,8 @@ private: @@ -126,6 +126,8 @@ private:
void saveWindowGeometry();
/** Restore window size and position */
void restoreWindowGeometry();
/** Enable or disable all wallet-related actions */
void setWalletActionsEnabled(bool enabled);
public slots:
/** Set number of connections shown in the UI */

48
src/qt/walletframe.cpp

@ -7,9 +7,11 @@ @@ -7,9 +7,11 @@
#include "walletframe.h"
#include "bitcoingui.h"
#include "walletstack.h"
#include "walletview.h"
#include <QHBoxLayout>
#include <QMessageBox>
#include <QLabel>
WalletFrame::WalletFrame(BitcoinGUI *_gui) :
QFrame(_gui),
@ -23,6 +25,10 @@ WalletFrame::WalletFrame(BitcoinGUI *_gui) : @@ -23,6 +25,10 @@ WalletFrame::WalletFrame(BitcoinGUI *_gui) :
walletStack->setBitcoinGUI(gui);
walletFrameLayout->setContentsMargins(0,0,0,0);
walletFrameLayout->addWidget(walletStack);
QLabel *noWallet = new QLabel(tr("No wallet has been loaded."));
noWallet->setAlignment(Qt::AlignCenter);
walletStack->addWidget(noWallet);
}
WalletFrame::~WalletFrame()
@ -54,6 +60,10 @@ void WalletFrame::removeAllWallets() @@ -54,6 +60,10 @@ void WalletFrame::removeAllWallets()
bool WalletFrame::handleURI(const QString &uri)
{
WalletView *walletView = currentWalletView();
if (!walletView)
return false;
return walletStack->handleURI(uri);
}
@ -80,7 +90,9 @@ void WalletFrame::gotoHistoryPage() @@ -80,7 +90,9 @@ void WalletFrame::gotoHistoryPage()
void WalletFrame::gotoAddressBookPage()
{
walletStack->gotoAddressBookPage();
WalletView *walletView = currentWalletView();
if (walletView)
walletStack->gotoAddressBookPage();
}
void WalletFrame::gotoReceiveCoinsPage()
@ -95,35 +107,55 @@ void WalletFrame::gotoSendCoinsPage(QString addr) @@ -95,35 +107,55 @@ void WalletFrame::gotoSendCoinsPage(QString addr)
void WalletFrame::gotoSignMessageTab(QString addr)
{
walletStack->gotoSignMessageTab(addr);
WalletView *walletView = currentWalletView();
if (walletView)
walletView->gotoSignMessageTab(addr);
}
void WalletFrame::gotoVerifyMessageTab(QString addr)
{
walletStack->gotoSignMessageTab(addr);
WalletView *walletView = currentWalletView();
if (walletView)
walletView->gotoVerifyMessageTab(addr);
}
void WalletFrame::encryptWallet(bool status)
{
walletStack->encryptWallet(status);
WalletView *walletView = currentWalletView();
if (walletView)
walletView->encryptWallet(status);
}
void WalletFrame::backupWallet()
{
walletStack->backupWallet();
WalletView *walletView = currentWalletView();
if (walletView)
walletView->backupWallet();
}
void WalletFrame::changePassphrase()
{
walletStack->changePassphrase();
WalletView *walletView = currentWalletView();
if (walletView)
walletView->changePassphrase();
}
void WalletFrame::unlockWallet()
{
walletStack->unlockWallet();
WalletView *walletView = currentWalletView();
if (walletView)
walletView->unlockWallet();
}
void WalletFrame::setEncryptionStatus()
{
walletStack->setEncryptionStatus();
WalletView *walletView = currentWalletView();
if (walletView)
walletStack->setEncryptionStatus();
}
WalletView *WalletFrame::currentWalletView()
{
return qobject_cast<WalletView*>(walletStack->currentWidget());
}

5
src/qt/walletframe.h

@ -13,6 +13,7 @@ class BitcoinGUI; @@ -13,6 +13,7 @@ class BitcoinGUI;
class ClientModel;
class WalletModel;
class WalletStack;
class WalletView;
class WalletFrame : public QFrame
{
@ -38,6 +39,8 @@ private: @@ -38,6 +39,8 @@ private:
ClientModel *clientModel;
WalletStack *walletStack;
WalletView *currentWalletView();
public slots:
/** Switch to overview (home) page */
void gotoOverviewPage();
@ -71,4 +74,4 @@ public slots: @@ -71,4 +74,4 @@ public slots:
void setEncryptionStatus();
};
#endif // WALLETFRAME_H
#endif // WALLETFRAME_H

Loading…
Cancel
Save