This repository has been archived by the owner on May 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
configdialog.cpp
62 lines (48 loc) · 1.96 KB
/
configdialog.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
#include "configdialog.h"
#include "ui_configdialog.h"
#include "downloaditem.h"
#include <QFileDialog>
#include <QSettings>
ConfigDialog::ConfigDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfigDialog)
{
ui->setupUi(this);
QSettings settings;
QString path = settings.value("downloadPath", DownloadItem::getPackageDir()).toString();
ui->downloadPathEdit->setText(QDir::toNativeSeparators(path));
int port = settings.value("proxyPort", 8888).toInt();
ui->proxySpinBox->setValue(port);
int maxTitles = settings.value("maxTitles", 10240).toInt();
ui->maxTitlesSpinBox->setValue(maxTitles);
int maxChecks = settings.value("maxChecks", 100).toInt();
ui->maxChecksSpinBox->setValue(maxChecks);
bool autostart = settings.value("autostartProxy", true).toBool();
ui->autoStartCheckBox->setChecked(autostart);
bool autocheck = settings.value("autoCheck", true).toBool();
ui->downloadCheckBox->setChecked(autocheck);
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(openFindDialog()));
}
void ConfigDialog::accept()
{
QSettings settings;
settings.setValue("downloadPath", QDir::fromNativeSeparators(ui->downloadPathEdit->text()));
settings.setValue("proxyPort", ui->proxySpinBox->value());
settings.setValue("maxTitles", ui->maxTitlesSpinBox->value());
settings.setValue("maxChecks", ui->maxChecksSpinBox->value());
settings.setValue("autostartProxy", ui->autoStartCheckBox->isChecked());
settings.setValue("autoCheck", ui->downloadCheckBox->isChecked());
settings.sync();
done(Accepted);
}
void ConfigDialog::openFindDialog()
{
QString msg = tr("Select the folder to be used to store game packages");
QString selected = QFileDialog::getExistingDirectory(this, msg, ui->downloadPathEdit->text(), QFileDialog::ShowDirsOnly);
if(!selected.isEmpty())
ui->downloadPathEdit->setText(QDir::toNativeSeparators((selected)));
}
ConfigDialog::~ConfigDialog()
{
delete ui;
}