|
1 | 1 | #include "keychain_gui_win.h"
|
| 2 | +#include "cmd.hpp" |
2 | 3 |
|
3 | 4 | keychain_gui_win::keychain_gui_win(Transaction &transaction, QWidget *parent)
|
4 | 5 | : QDialog(parent)
|
5 | 6 | {
|
6 | 7 | ui.setupUi(this);
|
7 | 8 | setWindowFlags(Qt::FramelessWindowHint);
|
8 | 9 | setFixedSize(600, 347);
|
9 |
| - |
| 10 | + passClearOnExit = true; |
| 11 | + send_msg = true; |
10 | 12 | }
|
11 | 13 |
|
12 | 14 | void keychain_gui_win::refresh(Transaction& transaction)
|
@@ -161,25 +163,16 @@ void keychain_gui_win::refresh(Transaction& transaction)
|
161 | 163 | else
|
162 | 164 | lockIcon->move(width() - 55, 28);
|
163 | 165 | lockIcon->setMouseTracking(true);
|
164 |
| - this->connect(OKButton, &QPushButton::released, this, &keychain_gui_win::transaction_sign); |
165 |
| - this->connect(CancelButton, &QPushButton::released, this, &keychain_gui_win::cancel_sign); |
| 166 | + this->connect(OKButton, &QPushButton::released, this, &keychain_gui_win::found_pass); |
| 167 | + this->connect(OKButton, &QPushButton::released, this, &keychain_gui_win::close); |
| 168 | + this->connect(CancelButton, &QPushButton::released, this, &keychain_gui_win::close); |
166 | 169 | _roundCorners();
|
167 | 170 | password->setValueFocus();
|
168 |
| - connect(password, &PasswordEnterElement::finishEnterPassword, this, &keychain_gui_win::transaction_sign); |
| 171 | + //connect(password, &PasswordEnterElement::finishEnterPassword, this, &keychain_gui_win::transaction_sign); |
169 | 172 | //if (transaction.isCreatePassword())
|
170 | 173 | // connect(password, &PasswordEnterElement::changePassword, this, &keychain_gui_win::_disableSignButton);
|
171 | 174 | }
|
172 | 175 |
|
173 |
| -void keychain_gui_win::transaction_sign() { |
174 |
| - QString passPhrase(""); |
175 |
| - passPhrase = password->GetValue(); |
176 |
| - if (passPhrase.isEmpty()) { |
177 |
| - serviceExchange->EncodeError(L"empty_password", 14); |
178 |
| - return; |
179 |
| - } |
180 |
| - serviceExchange->EncodeSuccess(passPhrase.toStdWString(), passPhrase.length()); |
181 |
| - this->close(); |
182 |
| -} |
183 | 176 |
|
184 | 177 | void keychain_gui_win::cancel_sign() {
|
185 | 178 | serviceExchange->EncodeCancel();
|
@@ -251,11 +244,41 @@ void keychain_gui_win::keyPressEvent(QKeyEvent *event)
|
251 | 244 | }
|
252 | 245 | }
|
253 | 246 |
|
254 |
| - |
| 247 | +/* |
255 | 248 | void keychain_gui_win::closeEvent(QCloseEvent * event)
|
256 | 249 | {
|
257 | 250 | serviceExchange->EncodeCancel();
|
258 | 251 | this->close();
|
259 | 252 | }
|
| 253 | +*/ |
260 | 254 |
|
| 255 | +void keychain_gui_win::closeEvent(QCloseEvent *event) |
| 256 | +{ |
| 257 | + if (send_msg) |
| 258 | + { |
| 259 | + passClearOnExit ? |
| 260 | + send(fc_light::json::to_string(fc_light::variant( master::cmd<( master::cmds::cancel)>().base))) : |
| 261 | + send(fc_light::json::to_string(fc_light::variant( master::cmd<( master::cmds::ok)>().base))); |
| 262 | + } |
261 | 263 |
|
| 264 | + event->accept(); |
| 265 | +} |
| 266 | + |
| 267 | + |
| 268 | +void keychain_gui_win::found_pass() { |
| 269 | + //QString passPhrase(""); |
| 270 | + //passPhrase = password->GetValue(); |
| 271 | + //if (passPhrase.isEmpty()) { |
| 272 | + // serviceExchange->EncodeError(L"empty_password", 14); |
| 273 | + // return; |
| 274 | + //} |
| 275 | + //serviceExchange->EncodeSuccess(passPhrase.toStdWString(), passPhrase.length()); |
| 276 | + passClearOnExit = false; |
| 277 | + //this->close(); |
| 278 | +} |
| 279 | + |
| 280 | +void keychain_gui_win::send(std::string a) |
| 281 | +{ |
| 282 | + if ( write(STDIN_FILENO, a.c_str(), a.length() ) != a.length() ) |
| 283 | + close(); |
| 284 | +} |
0 commit comments