This repository has been archived by the owner on Nov 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.cpp
59 lines (50 loc) · 1.58 KB
/
settings.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
55
56
57
58
59
#include "settings.h"
#include "ui_settings.h"
Settings::Settings(QWidget *parent) :
QDialog(parent, Qt::WindowTitleHint | Qt::CustomizeWindowHint),
ui(new Ui::Settings)
{
ui->setupUi(this);
connect(ui->ok, SIGNAL(clicked()), this, SLOT(okClicked()));
connect(ui->cancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(ui->user, SIGNAL(textChanged(QString)), this, SLOT(userChanged(QString)));
connect(ui->pass, SIGNAL(textChanged(QString)), this, SLOT(passChanged(QString)));
connect(ui->user, SIGNAL(returnPressed()), this, SLOT(okClicked()));
connect(ui->pass, SIGNAL(returnPressed()), this, SLOT(okClicked()));
}
void Settings::set(QByteArray u, QByteArray p, bool bonusFirst, bool dontAsk, bool focus)
{
if (focus)
ui->pass->setFocus();
else
ui->user->setFocus();
ui->user->setText(QString(u));
ui->pass->setText(QString(p));
ui->bonus->setChecked(bonusFirst);
ui->warn->setChecked(dontAsk);
userOk = u.length() > 4;
passOk = p.length() > 5;
ui->ok->setEnabled(passOk && userOk);
}
void Settings::okClicked()
{
bonusFirst = ui->bonus->isChecked();
dontAsk = ui->warn->isChecked();
user = ui->user->text().toUtf8();
pass = ui->pass->text().toUtf8();
this->accept();
}
void Settings::userChanged(QString text)
{
userOk = text.length() > 4;
ui->ok->setEnabled(passOk && userOk);
}
void Settings::passChanged(QString text)
{
passOk = text.length() > 5;
ui->ok->setEnabled(passOk && userOk);
}
Settings::~Settings()
{
delete ui;
}