diff options
author | Philip Kaufmann <phil.kaufmann@t-online.de> | 2013-08-02 13:53:03 +0200 |
---|---|---|
committer | Philip Kaufmann <phil.kaufmann@t-online.de> | 2013-08-23 09:10:31 +0200 |
commit | dbc0a6aba2cf94aa1b167145a18e0b9c671aef5b (patch) | |
tree | 88a2ba112bc8c6fb3353327c5579c830f7868ff4 /src/qt/walletstack.cpp | |
parent | e62f8d72f349aec0865268c089ae99fedd314af1 (diff) |
Bitcoin-Qt: tweak Qt walletXXX.cpp/h code
WalletView:
- add new signal showNormalIfMinimized()
- emit the new signal in handleURI() to fix a bug, preventing the main
window to show up when using bitcoin: URIs
WalletStack:
- connect the showNormalIfMinimized() signal from WalletView with the
showNormalIfMinimized() slot in BitcoinGUI
- rework setCurrentWallet() to return a bool
- add check for valid walletModel in addWallet()
- add missing gui attribute initialisation in constructor
WalletFrame:
- remove unused or unneded class attributes gui and clientModel
- add a check for valid clientModel in setClientModel()
General:
- small code formatting changes
Diffstat (limited to 'src/qt/walletstack.cpp')
-rw-r--r-- | src/qt/walletstack.cpp | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/src/qt/walletstack.cpp b/src/qt/walletstack.cpp index 6cc73358a4..4ef87aed52 100644 --- a/src/qt/walletstack.cpp +++ b/src/qt/walletstack.cpp @@ -13,6 +13,7 @@ WalletStack::WalletStack(QWidget *parent) : QStackedWidget(parent), + gui(0), clientModel(0), bOutOfSync(true) { @@ -25,7 +26,7 @@ WalletStack::~WalletStack() bool WalletStack::addWallet(const QString& name, WalletModel *walletModel) { - if (!gui || !clientModel || mapWalletViews.count(name) > 0) + if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0) return false; WalletView *walletView = new WalletView(this, gui); @@ -35,12 +36,18 @@ bool WalletStack::addWallet(const QString& name, WalletModel *walletModel) walletView->showOutOfSyncWarning(bOutOfSync); addWidget(walletView); mapWalletViews[name] = walletView; + + // Ensure a walletView is able to show the main window + connect(walletView, SIGNAL(showNormalIfMinimized()), gui, SLOT(showNormalIfMinimized())); + return true; } bool WalletStack::removeWallet(const QString& name) { - if (mapWalletViews.count(name) == 0) return false; + if (mapWalletViews.count(name) == 0) + return false; + WalletView *walletView = mapWalletViews.take(name); removeWidget(walletView); return true; @@ -57,7 +64,8 @@ void WalletStack::removeAllWallets() bool WalletStack::handlePaymentRequest(const SendCoinsRecipient &recipient) { WalletView *walletView = (WalletView*)currentWidget(); - if (!walletView) return false; + if (!walletView) + return false; return walletView->handlePaymentRequest(recipient); } @@ -108,49 +116,59 @@ void WalletStack::gotoSendCoinsPage(QString addr) void WalletStack::gotoSignMessageTab(QString addr) { WalletView *walletView = (WalletView*)currentWidget(); - if (walletView) walletView->gotoSignMessageTab(addr); + if (walletView) + walletView->gotoSignMessageTab(addr); } void WalletStack::gotoVerifyMessageTab(QString addr) { WalletView *walletView = (WalletView*)currentWidget(); - if (walletView) walletView->gotoVerifyMessageTab(addr); + if (walletView) + walletView->gotoVerifyMessageTab(addr); } void WalletStack::encryptWallet(bool status) { WalletView *walletView = (WalletView*)currentWidget(); - if (walletView) walletView->encryptWallet(status); + if (walletView) + walletView->encryptWallet(status); } void WalletStack::backupWallet() { WalletView *walletView = (WalletView*)currentWidget(); - if (walletView) walletView->backupWallet(); + if (walletView) + walletView->backupWallet(); } void WalletStack::changePassphrase() { WalletView *walletView = (WalletView*)currentWidget(); - if (walletView) walletView->changePassphrase(); + if (walletView) + walletView->changePassphrase(); } void WalletStack::unlockWallet() { WalletView *walletView = (WalletView*)currentWidget(); - if (walletView) walletView->unlockWallet(); + if (walletView) + walletView->unlockWallet(); } void WalletStack::setEncryptionStatus() { WalletView *walletView = (WalletView*)currentWidget(); - if (walletView) walletView->setEncryptionStatus(); + if (walletView) + walletView->setEncryptionStatus(); } -void WalletStack::setCurrentWallet(const QString& name) +bool WalletStack::setCurrentWallet(const QString& name) { - if (mapWalletViews.count(name) == 0) return; + if (mapWalletViews.count(name) == 0) + return false; + WalletView *walletView = mapWalletViews.value(name); setCurrentWidget(walletView); walletView->setEncryptionStatus(); + return true; } |