-
Notifications
You must be signed in to change notification settings - Fork 0
/
settingsdialog.cpp
44 lines (37 loc) · 1.32 KB
/
settingsdialog.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
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include "tools.h"
#include <QSettings>
SettingsDialog::SettingsDialog(
const QString & organizationName,
const QString & appName,
QWidget * parent
) :
QDialog(parent),
ui(new Ui::SettingsDialog),
m_organizationName(organizationName),
m_appName(appName)
{
ui->setupUi(this);
// ui->apiKeyLineEdit->setValidator( new QRegExpValidator(QRegExp("\\S+"), this) );
// ui->locationLineEdit->setValidator( new QRegExpValidator( Tools::locationRegExp(), this) );
QSettings settings(m_organizationName, m_appName);
ui->apiKeyLineEdit->setText( settings.value("apiKey").toString() );
ui->locationLineEdit->setText( settings.value("location").toString() );
ui->radiusSpinBox->setValue( settings.value("radius", 25).toInt() );
ui->sensorCheckBox->setChecked( settings.value("sensor", false).toBool() );
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
void SettingsDialog::
accept()
{
QSettings settings(m_organizationName, m_appName);
settings.setValue("apiKey", ui->apiKeyLineEdit->text());
settings.setValue("location", ui->locationLineEdit->text());
settings.setValue("radius", ui->radiusSpinBox->value());
settings.setValue("sensor", ui->sensorCheckBox->isChecked());
QDialog::accept();
}