-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbsettings.cpp
75 lines (62 loc) · 1.35 KB
/
dbsettings.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "dbsettings.h"
#include "ui_dbsettings.h"
DbSettings::DbSettings(QWidget *parent) :
QDialog(parent),
ui(new Ui::DbSettings)
{
ui->setupUi(this);
std::string name,pass,host,db;
int port;
std::ifstream ifs;
ifs.open("settings.ini");
if(ifs.is_open())
{
ifs >> name >> pass >> host >> db >> port;
ifs.close();
ui->le_username->setText(QString::fromStdString(name));
ui->le_password->setText(QString::fromStdString(pass));
ui->le_host->setText(QString::fromStdString(host));
ui->le_database->setText(QString::fromStdString(db));
ui->le_port->setText(QString::number(port));
}
}
DbSettings::~DbSettings()
{
delete ui;
}
QString DbSettings::password() const
{
return ui->le_password->text();
}
QString DbSettings::hostname() const
{
return ui->le_host->text();
}
QString DbSettings::username() const
{
return ui->le_username->text();
}
QString DbSettings::dbname() const
{
return ui->le_database->text();
}
int DbSettings::port() const
{
QString tmp;
tmp = ui->le_port->text();
bool ok;
int res = tmp.toInt(&ok,10);
return res;
}
void DbSettings::on_btn_set_app_clicked()
{
QString tmp;
tmp = ui->le_port->text();
bool ok;
tmp.toInt(&ok,10);
if(ok){
accept();
} else{
reject();
}
}