|
1 | 1 | #include "communityfundcreateproposaldialog.h" |
2 | | -#include "ui_communityfundcreateproposaldialog.h" |
3 | | -#include "sendcommunityfunddialog.h" |
4 | 2 | #include "communityfundsuccessdialog.h" |
| 3 | +#include "sendcommunityfunddialog.h" |
| 4 | +#include "ui_communityfundcreateproposaldialog.h" |
5 | 5 |
|
6 | | -#include <QMessageBox> |
7 | | -#include <QTextListFormat> |
8 | 6 | #include <QDialog> |
| 7 | +#include <QMessageBox> |
9 | 8 | #include <QSpinBox> |
| 9 | +#include <QTextListFormat> |
| 10 | +#include <string> |
10 | 11 |
|
| 12 | +#include "base58.h" |
11 | 13 | #include "guiconstants.h" |
12 | 14 | #include "guiutil.h" |
13 | | -#include "sync.h" |
14 | | -#include "wallet/wallet.h" |
15 | | -#include "base58.h" |
16 | 15 | #include "main.h" |
17 | | -#include <string> |
18 | 16 | #include "qvalidatedspinbox.h" |
| 17 | +#include "sync.h" |
| 18 | +#include "wallet/wallet.h" |
| 19 | +#include "walletmodel.h" |
19 | 20 |
|
20 | 21 | CommunityFundCreateProposalDialog::CommunityFundCreateProposalDialog(QWidget *parent) : |
21 | 22 | QDialog(parent), |
22 | | - ui(new Ui::CommunityFundCreateProposalDialog) |
| 23 | + ui(new Ui::CommunityFundCreateProposalDialog), |
| 24 | + model(0) |
23 | 25 | { |
24 | 26 | ui->setupUi(this); |
25 | 27 | GUIUtil::setupAddressWidget(ui->lineEditNavcoinAddress, this); |
@@ -57,6 +59,11 @@ CommunityFundCreateProposalDialog::CommunityFundCreateProposalDialog(QWidget *pa |
57 | 59 | ui->labelWarning->setText(QString::fromStdString(warning)); |
58 | 60 | } |
59 | 61 |
|
| 62 | +void CommunityFundCreateProposalDialog::setModel(WalletModel *model) |
| 63 | +{ |
| 64 | + this->model = model; |
| 65 | +} |
| 66 | + |
60 | 67 | // Validate input fields |
61 | 68 | bool CommunityFundCreateProposalDialog::validate() |
62 | 69 | { |
@@ -103,6 +110,9 @@ void CommunityFundCreateProposalDialog::click_spinBox() { |
103 | 110 |
|
104 | 111 | void CommunityFundCreateProposalDialog::click_pushButtonCreateProposal() |
105 | 112 | { |
| 113 | + if(!model) |
| 114 | + return; |
| 115 | + |
106 | 116 | if(this->validate()) |
107 | 117 | { |
108 | 118 | LOCK2(cs_main, pwalletMain->cs_wallet); |
@@ -147,24 +157,10 @@ void CommunityFundCreateProposalDialog::click_pushButtonCreateProposal() |
147 | 157 | } |
148 | 158 |
|
149 | 159 | // Ensure wallet is unlocked |
150 | | - if (pwalletMain->IsLocked()) { |
151 | | - QMessageBox msgBox(this); |
152 | | - std::string str = "Please unlock the wallet\n"; |
153 | | - msgBox.setText(tr(str.c_str())); |
154 | | - msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole); |
155 | | - msgBox.setIcon(QMessageBox::Warning); |
156 | | - msgBox.setWindowTitle("Error"); |
157 | | - msgBox.exec(); |
158 | | - return; |
159 | | - } |
160 | | - if (fWalletUnlockStakingOnly) { |
161 | | - QMessageBox msgBox(this); |
162 | | - std::string str = "Wallet is unlocked for staking only\n"; |
163 | | - msgBox.setText(tr(str.c_str())); |
164 | | - msgBox.addButton(tr("Ok"), QMessageBox::AcceptRole); |
165 | | - msgBox.setIcon(QMessageBox::Warning); |
166 | | - msgBox.setWindowTitle("Error"); |
167 | | - msgBox.exec(); |
| 160 | + WalletModel::UnlockContext ctx(model->requestUnlock()); |
| 161 | + if(!ctx.isValid()) |
| 162 | + { |
| 163 | + // Unlock wallet was cancelled |
168 | 164 | return; |
169 | 165 | } |
170 | 166 |
|
@@ -197,7 +193,6 @@ void CommunityFundCreateProposalDialog::click_pushButtonCreateProposal() |
197 | 193 | return; |
198 | 194 | } |
199 | 195 | else { |
200 | | - |
201 | 196 | // User accepted making the proposal |
202 | 197 | // Parse NavCoin address |
203 | 198 | CScript CFContributionScript; |
|
0 commit comments