-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSettingsForm.cpp
More file actions
73 lines (63 loc) · 2.02 KB
/
SettingsForm.cpp
File metadata and controls
73 lines (63 loc) · 2.02 KB
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
#include <QFileDialog>
#include <QDir>
#include "SettingsForm.h"
#include "mpq/MPQ.h"
#include "dbc/DBC.h"
SettingsForm::SettingsForm(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
connect(mpqDir, SIGNAL(editingFinished()), this, SLOT(slotEditMPQ()));
connect(mpqButton, SIGNAL(clicked()), this, SLOT(slotMPQ()));
connect(dbcButton, SIGNAL(clicked()), this, SLOT(slotDBC()));
mpqDir->setText(MPQ::mpqDir());
dbcDir->setText(DBC::dbcDir());
slotEditMPQ();
mpqLocale->setCurrentIndex(mpqLocale->findText(MPQ::localeDir()));
show();
}
void SettingsForm::slotEditMPQ()
{
if (!mpqDir->text().isEmpty()) {
QDir dir(mpqDir->text());
if (dir.exists()) {
mpqDir->setText(dir.absolutePath());
dbcDir->setText("DBFilesClient");
mpqLocale->clear();
QStringList localeDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
foreach (QString str, localeDirs) {
QString localeDir = str.section("\\", -1);
if (localeDir.size() == 4) {
mpqLocale->addItem(localeDir);
}
}
mpqLocale->addItem("");
}
} else {
mpqLocale->clear();
dbcDir->setText("");
}
}
void SettingsForm::slotMPQ()
{
QDir dir(QFileDialog::getExistingDirectory(this, "Set MPQ directory", mpqDir->text()));
if (dir.exists()) {
mpqDir->setText(dir.absolutePath());
dbcDir->setText("DBFilesClient");
mpqLocale->clear();
QStringList localeDirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
foreach (QString str, localeDirs) {
QString localeDir = str.section("\\", -1);
if (localeDir.size() == 4) {
mpqLocale->addItem(localeDir);
}
}
mpqLocale->addItem("");
}
}
void SettingsForm::slotDBC()
{
QString dir = QFileDialog::getExistingDirectory(this, "Set DBC directory", dbcDir->text());
if (!dir.isEmpty())
dbcDir->setText(dir);
}