34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#include <GeneralSettings.hpp>
|
|
#include <Options.hpp>
|
|
#include <QSettings>
|
|
#include <QFileDialog>
|
|
#include <QCoreApplication>
|
|
#include <log.hpp>
|
|
|
|
GeneralSettings::GeneralSettings() {
|
|
QSettings settings;
|
|
description = new QLabel("Path:");
|
|
description->setToolTip("Path where game saves are stored.");
|
|
selectedFolderLabel = new QLabel(Options::GetSavesPath().c_str());
|
|
selectedFolderLabel->setDisabled(true);
|
|
folderSelectButton = new QPushButton("Choose...");
|
|
|
|
connect(folderSelectButton, &QPushButton::clicked, this, [&] {
|
|
auto dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), QCoreApplication::applicationDirPath(),
|
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
|
selectedFolderLabel->setText(dir);
|
|
Options::SetSavesPath(dir.toStdString());
|
|
settings.setValue("general/savesPath", dir);
|
|
});
|
|
|
|
h = new QHBoxLayout();
|
|
|
|
h->addWidget(description);
|
|
h->addWidget(selectedFolderLabel);
|
|
h->addWidget(folderSelectButton);
|
|
|
|
v = new QVBoxLayout(this);
|
|
v->addLayout(h);
|
|
setLayout(v);
|
|
}
|