forked from westonmyers/Qt-CK2-Launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firstdialog.cpp
87 lines (68 loc) · 2.55 KB
/
firstdialog.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
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "firstdialog.h"
#include "ui_firstdialog.h"
FirstDialog::FirstDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FirstDialog)
{
ui->setupUi(this);
// Set default paths
ui->comboBoxPathSteam ->addItem(QDir::homePath()+"/.steam/steam/");
ui->comboBoxPathConfig ->addItem(QDir::homePath()+"/Paradox Interactive/Europa Universalis IV/");
}
void FirstDialog::checkedNoSteam(bool toggled)
{
ui->comboBoxPathSteam ->setDisabled(toggled);
ui->buttonBrowsePathSteam ->setDisabled(toggled);
}
void FirstDialog::indexChangedSteam(int newIndex)
{
QString newPath = ui->comboBoxPathSteam->itemText(newIndex)+"SteamApps/common/Europa Universalis IV/";
checkAddItem(ui->comboBoxPathGame, newPath);
}
void FirstDialog::buttonClickedBrowseSteam()
{
QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Directory"));
if (directory.length())
checkAddItem(ui->comboBoxPathSteam, directory);
}
void FirstDialog::buttonClickedBrowseGame()
{
QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Directory"));
if (directory.length())
checkAddItem(ui->comboBoxPathGame, directory);
}
void FirstDialog::buttonClickedBrowseConfig()
{
QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Directory"));
if (directory.length())
checkAddItem(ui->comboBoxPathConfig, directory);
}
void FirstDialog::buttonClickedOk()
{
QSettings settings;
settings.setValue("userOptions/isNoSteam", ui->checkBoxNoSteam->isChecked());
settings.setValue("userOptions/noAdvancedMode", ui->checkBoxAdvancedMode->isChecked());
settings.setValue("userOptions/pathSteam", ui->comboBoxPathSteam->currentText());
settings.setValue("userOptions/pathGame", ui->comboBoxPathGame->currentText());
settings.setValue("userOptions/pathConfig", ui->comboBoxPathConfig->currentText());
// Static parameters
settings.setValue("internal/isConfigured", true);
settings.setValue("internal/urlLauncher", "http://www.paradoxplaza.com/in-game/eu4/launcher.html");
settings.setValue("internal/urlRegister", "http://forum.paradoxplaza.com/forum/mygames.php");
settings.setValue("internal/executableName", "eu4");
dialogCompleted = true;
this->close();
}
void FirstDialog::checkAddItem(QComboBox* combo, QString text)
{
int index = combo->findText(text);
if (index == -1) {
combo->addItem(text);
index = combo->findText(text);
}
combo->setCurrentIndex(index);
}
FirstDialog::~FirstDialog()
{
delete ui;
}