]> Git Repo - VerusCoin.git/blob - src/qt/walletframe.cpp
Merge pull request #3099 from laanwj/2013_10_new_receive_flow
[VerusCoin.git] / src / qt / walletframe.cpp
1 /*
2  * Qt4 bitcoin GUI.
3  *
4  * W.J. van der Laan 2011-2012
5  * The Bitcoin Developers 2011-2013
6  */
7 #include "walletframe.h"
8 #include "walletview.h"
9 #include "bitcoingui.h"
10
11 #include <QHBoxLayout>
12 #include <QMessageBox>
13 #include <QStackedWidget>
14
15 WalletFrame::WalletFrame(BitcoinGUI *_gui) :
16     QFrame(_gui),
17     gui(_gui)
18 {
19     // Leave HBox hook for adding a list view later
20     QHBoxLayout *walletFrameLayout = new QHBoxLayout(this);
21     setContentsMargins(0,0,0,0);
22     walletStack = new QStackedWidget(this);
23     walletFrameLayout->setContentsMargins(0,0,0,0);
24     walletFrameLayout->addWidget(walletStack);
25 }
26
27 WalletFrame::~WalletFrame()
28 {
29 }
30
31 void WalletFrame::setClientModel(ClientModel *clientModel)
32 {
33     this->clientModel = clientModel;
34 }
35
36 bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
37 {
38     if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0)
39         return false;
40
41     WalletView *walletView = new WalletView(this);
42     walletView->setBitcoinGUI(gui);
43     walletView->setClientModel(clientModel);
44     walletView->setWalletModel(walletModel);
45     walletView->showOutOfSyncWarning(bOutOfSync);
46
47      /* TODO we should goto the currently selected page once dynamically adding wallets is supported */
48     walletView->gotoOverviewPage();
49     walletStack->addWidget(walletView);
50     mapWalletViews[name] = walletView;
51
52     // Ensure a walletView is able to show the main window
53     connect(walletView, SIGNAL(showNormalIfMinimized()), gui, SLOT(showNormalIfMinimized()));
54
55     return true;
56 }
57
58 bool WalletFrame::setCurrentWallet(const QString& name)
59 {
60     if (mapWalletViews.count(name) == 0)
61         return false;
62
63     WalletView *walletView = mapWalletViews.value(name);
64     walletStack->setCurrentWidget(walletView);
65     walletView->setEncryptionStatus();
66     return true;
67 }
68
69 bool WalletFrame::removeWallet(const QString &name)
70 {
71     if (mapWalletViews.count(name) == 0)
72         return false;
73
74     WalletView *walletView = mapWalletViews.take(name);
75     walletStack->removeWidget(walletView);
76     return true;
77 }
78
79 void WalletFrame::removeAllWallets()
80 {
81     QMap<QString, WalletView*>::const_iterator i;
82     for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
83         walletStack->removeWidget(i.value());
84     mapWalletViews.clear();
85 }
86
87 bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient)
88 {
89     WalletView *walletView = (WalletView*)walletStack->currentWidget();
90     if (!walletView)
91         return false;
92
93     return walletView->handlePaymentRequest(recipient);
94 }
95
96 void WalletFrame::showOutOfSyncWarning(bool fShow)
97 {
98     bOutOfSync = fShow;
99     QMap<QString, WalletView*>::const_iterator i;
100     for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
101         i.value()->showOutOfSyncWarning(fShow);
102 }
103
104 void WalletFrame::gotoOverviewPage()
105 {
106     QMap<QString, WalletView*>::const_iterator i;
107     for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
108         i.value()->gotoOverviewPage();
109 }
110
111 void WalletFrame::gotoHistoryPage()
112 {
113     QMap<QString, WalletView*>::const_iterator i;
114     for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
115         i.value()->gotoHistoryPage();
116 }
117
118 void WalletFrame::gotoReceiveCoinsPage()
119 {
120     QMap<QString, WalletView*>::const_iterator i;
121     for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
122         i.value()->gotoReceiveCoinsPage();
123 }
124
125 void WalletFrame::gotoSendCoinsPage(QString addr)
126 {
127     QMap<QString, WalletView*>::const_iterator i;
128     for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
129         i.value()->gotoSendCoinsPage(addr);
130 }
131
132 void WalletFrame::gotoSignMessageTab(QString addr)
133 {
134     WalletView *walletView = (WalletView*)walletStack->currentWidget();
135     if (walletView)
136         walletView->gotoSignMessageTab(addr);
137 }
138
139 void WalletFrame::gotoVerifyMessageTab(QString addr)
140 {
141     WalletView *walletView = (WalletView*)walletStack->currentWidget();
142     if (walletView)
143         walletView->gotoVerifyMessageTab(addr);
144 }
145
146 void WalletFrame::encryptWallet(bool status)
147 {
148     WalletView *walletView = (WalletView*)walletStack->currentWidget();
149     if (walletView)
150         walletView->encryptWallet(status);
151 }
152
153 void WalletFrame::backupWallet()
154 {
155     WalletView *walletView = (WalletView*)walletStack->currentWidget();
156     if (walletView)
157         walletView->backupWallet();
158 }
159
160 void WalletFrame::changePassphrase()
161 {
162     WalletView *walletView = (WalletView*)walletStack->currentWidget();
163     if (walletView)
164         walletView->changePassphrase();
165 }
166
167 void WalletFrame::unlockWallet()
168 {
169     WalletView *walletView = (WalletView*)walletStack->currentWidget();
170     if (walletView)
171         walletView->unlockWallet();
172 }
173
174 void WalletFrame::setEncryptionStatus()
175 {
176     WalletView *walletView = (WalletView*)walletStack->currentWidget();
177     if (walletView)
178         walletView->setEncryptionStatus();
179 }
180
181 void WalletFrame::usedSendingAddresses()
182 {
183     WalletView *walletView = (WalletView*)walletStack->currentWidget();
184     if (walletView)
185         walletView->usedSendingAddresses();
186 }
187
188 void WalletFrame::usedReceivingAddresses()
189 {
190     WalletView *walletView = (WalletView*)walletStack->currentWidget();
191     if (walletView)
192         walletView->usedReceivingAddresses();
193 }
This page took 0.034461 seconds and 4 git commands to generate.