summaryrefslogtreecommitdiffstats
path: root/gui/dialogs/SettingsDialog.cpp
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-12-29 17:51:16 +0100
committerJan Dalheimer <jan@dalheimer.de>2013-12-29 17:51:16 +0100
commit3380bc75633c63e8569b76981ac29528c58943ce (patch)
tree50df3e448edcb6ecfc68702698b318609327f360 /gui/dialogs/SettingsDialog.cpp
parent654f444f55de58f5cf0477e3b08b8f18e8d60831 (diff)
downloadMultiMC-3380bc75633c63e8569b76981ac29528c58943ce.tar
MultiMC-3380bc75633c63e8569b76981ac29528c58943ce.tar.gz
MultiMC-3380bc75633c63e8569b76981ac29528c58943ce.tar.lz
MultiMC-3380bc75633c63e8569b76981ac29528c58943ce.tar.xz
MultiMC-3380bc75633c63e8569b76981ac29528c58943ce.zip
Launch an editor for the custom.json file. Also allow overriding of the system default editor
Diffstat (limited to 'gui/dialogs/SettingsDialog.cpp')
-rw-r--r--gui/dialogs/SettingsDialog.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp
index 131cb5c3..a95a8e83 100644
--- a/gui/dialogs/SettingsDialog.cpp
+++ b/gui/dialogs/SettingsDialog.cpp
@@ -125,6 +125,23 @@ void SettingsDialog::on_lwjglDirBrowseBtn_clicked()
}
}
+void SettingsDialog::on_jsonEditorBrowseBtn_clicked()
+{
+ QString raw_file = QFileDialog::getOpenFileName(
+ this, tr("JSON Editor"),
+ ui->jsonEditorTextBox->text().isEmpty()
+ ? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first()
+ : ui->jsonEditorTextBox->text());
+ QString cooked_file = NormalizePath(raw_file);
+
+ // it has to exist and be an executable
+ if (!cooked_file.isEmpty() && QFileInfo(cooked_file).exists() &&
+ QFileInfo(cooked_file).isExecutable())
+ {
+ ui->jsonEditorTextBox->setText(cooked_file);
+ }
+}
+
void SettingsDialog::on_maximizedCheckBox_clicked(bool checked)
{
Q_UNUSED(checked);
@@ -172,6 +189,18 @@ void SettingsDialog::applySettings(SettingsObject *s)
s->set("CentralModsDir", ui->modsDirTextBox->text());
s->set("LWJGLDir", ui->lwjglDirTextBox->text());
+ // Editors
+ QString jsonEditor = ui->jsonEditorTextBox->text();
+ if (!jsonEditor.isEmpty() && (!QFileInfo(jsonEditor).exists() || !QFileInfo(jsonEditor).isExecutable()))
+ {
+ QString found = QStandardPaths::findExecutable(jsonEditor);
+ if (!found.isEmpty())
+ {
+ jsonEditor = found;
+ }
+ }
+ s->set("JsonEditor", jsonEditor);
+
// Console
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked());
@@ -226,6 +255,9 @@ void SettingsDialog::loadSettings(SettingsObject *s)
ui->modsDirTextBox->setText(s->get("CentralModsDir").toString());
ui->lwjglDirTextBox->setText(s->get("LWJGLDir").toString());
+ // Editors
+ ui->jsonEditorTextBox->setText(s->get("JsonEditor").toString());
+
// Console
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool());