Menu

[efa3d9]: / src / default-map-settings-dialog.cpp  Maximize  Restore  History

Download this file

75 lines (62 with data), 2.3 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
74
#include "default-map-settings-dialog.h"
#include <QFileDialog>
#include "mainwindow.h"
extern Settings settings;
extern Main *mainWindow;
extern QString vymName;
DefaultMapSettingsDialog::DefaultMapSettingsDialog(QWidget *parent) : QDialog(parent)
{
ui.setupUi(this);
initInputs();
connect(ui.autoCheckBox, SIGNAL(clicked()), this, SLOT(autoToggled()));
connect(ui.setPathPushButton, SIGNAL(clicked()), this, SLOT(setPathClicked()));
connect(this, &QDialog::accepted, this, &DefaultMapSettingsDialog::updateSettings);
}
void DefaultMapSettingsDialog::initInputs()
{
if (settings.value("/system/defaultMap/auto", true).toBool()) {
ui.autoCheckBox->setCheckState(Qt::Checked);
ui.pathLineEdit->setText(mainWindow->defaultMapPath());
ui.pathLineEdit->setEnabled(false);
ui.setPathPushButton->setEnabled(false);
} else {
ui.autoCheckBox->setCheckState(Qt::Unchecked);
ui.pathLineEdit->setText(
settings.value("/system/defaultMap/path", mainWindow->newMapPath()).toString());
ui.pathLineEdit->setEnabled(true);
ui.setPathPushButton->setEnabled(true);
}
}
void DefaultMapSettingsDialog::autoToggled()
{
if (ui.autoCheckBox->isChecked())
settings.setValue("/system/defaultMap/auto", true);
else
settings.setValue("/system/defaultMap/auto", false);
initInputs();
}
void DefaultMapSettingsDialog::setPathClicked()
{
QStringList filters;
filters << "VYM defaults map (*.vym)";
QFileDialog fd;
fd.setDirectory(dirname(mainWindow->defaultMapPath()));
fd.selectFile(basename(mainWindow->defaultMapPath()));
fd.setFileMode(QFileDialog::ExistingFile);
fd.setNameFilters(filters);
fd.setWindowTitle(vymName + " - " +
tr("Set vym default map to be loaded on startup"));
fd.setAcceptMode(QFileDialog::AcceptOpen);
QString fn;
if (fd.exec() == QDialog::Accepted) {
settings.setValue("/system/defaultMap/path", fd.selectedFiles().first());
initInputs();
}
}
void DefaultMapSettingsDialog::updateSettings()
{
settings.beginGroup("/system/defaultMap");
settings.setValue("auto", ui.autoCheckBox->isChecked());
settings.setValue("path", ui.pathLineEdit->text());
settings.endGroup();
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.