forked from InvictusInnovations/keyhotee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoginDialog.cpp
55 lines (47 loc) · 1.18 KB
/
LoginDialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "LoginDialog.hpp"
#include <ui_LoginDialog.h>
#include <bts/application.hpp>
#include <fc/log/logger.hpp>
#include <fc/thread/thread.hpp>
LoginDialog::LoginDialog(QWidget* parent)
: QDialog(parent)
{
ui.reset(new Ui::LoginDialog() );
ui->setupUi(this);
ui->password->setFocus();
connect(ui->login, &QPushButton::clicked, this, &LoginDialog::onLogin);
connect(ui->quit, &QPushButton::clicked, this, &LoginDialog::onQuit);
}
LoginDialog::~LoginDialog()
{}
void LoginDialog::onLogin()
{
try
{
password = ui->password->text().toStdString();
auto profile = bts::application::instance()->load_profile(password);
if (profile)
accept();
}
catch (const fc::exception& e)
{
wlog("error ${w}", ("w", e.to_detail_string()) );
}
ui->password->setText(QString());
shake();
}
void LoginDialog::shake()
{
move(pos() + QPoint(10, 0) );
fc::usleep(fc::microseconds(50 * 1000) );
move(pos() + QPoint(-20, 0) );
fc::usleep(fc::microseconds(50 * 1000) );
move(pos() + QPoint(20, 0) );
fc::usleep(fc::microseconds(50 * 1000) );
move(pos() + QPoint(-10, 0) );
}
void LoginDialog::onQuit()
{
qApp->quit();
reject();
}