summaryrefslogtreecommitdiffstats
path: root/gui/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'gui/dialogs')
-rw-r--r--gui/dialogs/OneSixModEditDialog.cpp13
-rw-r--r--gui/dialogs/OneSixModEditDialog.h1
-rw-r--r--gui/dialogs/OneSixModEditDialog.ui14
-rw-r--r--gui/dialogs/SettingsDialog.cpp49
-rw-r--r--gui/dialogs/SettingsDialog.h2
-rw-r--r--gui/dialogs/SettingsDialog.ui30
6 files changed, 107 insertions, 2 deletions
diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp
index d8b84d3e..3982f17d 100644
--- a/gui/dialogs/OneSixModEditDialog.cpp
+++ b/gui/dialogs/OneSixModEditDialog.cpp
@@ -97,6 +97,7 @@ void OneSixModEditDialog::updateVersionControls()
ui->revertBtn->setEnabled(customVersion);
ui->forgeBtn->setEnabled(true);
ui->liteloaderBtn->setEnabled(LiteLoaderInstaller(m_inst->intendedVersionId()).canApply());
+ ui->customEditorBtn->setEnabled(customVersion);
}
void OneSixModEditDialog::disableVersionControls()
@@ -105,6 +106,7 @@ void OneSixModEditDialog::disableVersionControls()
ui->revertBtn->setEnabled(false);
ui->forgeBtn->setEnabled(false);
ui->liteloaderBtn->setEnabled(false);
+ ui->customEditorBtn->setEnabled(false);
}
void OneSixModEditDialog::on_customizeBtn_clicked()
@@ -134,6 +136,17 @@ void OneSixModEditDialog::on_revertBtn_clicked()
}
}
+void OneSixModEditDialog::on_customEditorBtn_clicked()
+{
+ if (m_inst->versionIsCustom())
+ {
+ if (!MMC->openJsonEditor(m_inst->instanceRoot() + "/custom.json"))
+ {
+ QMessageBox::warning(this, tr("Error"), tr("Unable to open custom.json, check the settings"));
+ }
+ }
+}
+
void OneSixModEditDialog::on_forgeBtn_clicked()
{
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
diff --git a/gui/dialogs/OneSixModEditDialog.h b/gui/dialogs/OneSixModEditDialog.h
index 09bd7946..2510c59c 100644
--- a/gui/dialogs/OneSixModEditDialog.h
+++ b/gui/dialogs/OneSixModEditDialog.h
@@ -47,6 +47,7 @@ slots:
void on_liteloaderBtn_clicked();
void on_customizeBtn_clicked();
void on_revertBtn_clicked();
+ void on_customEditorBtn_clicked();
void updateVersionControls();
void disableVersionControls();
diff --git a/gui/dialogs/OneSixModEditDialog.ui b/gui/dialogs/OneSixModEditDialog.ui
index ad20cd73..899e0cbf 100644
--- a/gui/dialogs/OneSixModEditDialog.ui
+++ b/gui/dialogs/OneSixModEditDialog.ui
@@ -144,6 +144,20 @@
</widget>
</item>
<item>
+ <widget class="Line" name="line_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="customEditorBtn">
+ <property name="text">
+ <string>Open custom.json</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp
index 131cb5c3..30a973da 100644
--- a/gui/dialogs/SettingsDialog.cpp
+++ b/gui/dialogs/SettingsDialog.cpp
@@ -40,6 +40,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se
ui->sortingModeGroup->setId(ui->sortByNameBtn, Sort_Name);
ui->sortingModeGroup->setId(ui->sortLastLaunchedBtn, Sort_LastLaunch);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
+ ui->jsonEditorTextBox->setClearButtonEnabled(true);
+#endif
+
loadSettings(MMC->settings().get());
updateCheckboxStuff();
}
@@ -125,6 +129,36 @@ void SettingsDialog::on_lwjglDirBrowseBtn_clicked()
}
}
+void SettingsDialog::on_jsonEditorBrowseBtn_clicked()
+{
+ QString raw_file = QFileDialog::getOpenFileName(
+ this, tr("JSON Editor"),
+ ui->jsonEditorTextBox->text().isEmpty()
+ #if defined(Q_OS_LINUX)
+ ? QString("/usr/bin")
+ #else
+ ? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first()
+ #endif
+ : ui->jsonEditorTextBox->text());
+ QString cooked_file = NormalizePath(raw_file);
+
+ if (cooked_file.isEmpty())
+ {
+ return;
+ }
+
+ // it has to exist and be an executable
+ if (QFileInfo(cooked_file).exists() &&
+ QFileInfo(cooked_file).isExecutable())
+ {
+ ui->jsonEditorTextBox->setText(cooked_file);
+ }
+ else
+ {
+ QMessageBox::warning(this, tr("Invalid"), tr("The file chosen does not seem to be an executable"));
+ }
+}
+
void SettingsDialog::on_maximizedCheckBox_clicked(bool checked)
{
Q_UNUSED(checked);
@@ -172,6 +206,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 +272,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());
diff --git a/gui/dialogs/SettingsDialog.h b/gui/dialogs/SettingsDialog.h
index 36fc4797..01357c91 100644
--- a/gui/dialogs/SettingsDialog.h
+++ b/gui/dialogs/SettingsDialog.h
@@ -55,6 +55,8 @@ slots:
void on_lwjglDirBrowseBtn_clicked();
+ void on_jsonEditorBrowseBtn_clicked();
+
void on_maximizedCheckBox_clicked(bool checked);
void on_buttonBox_accepted();
diff --git a/gui/dialogs/SettingsDialog.ui b/gui/dialogs/SettingsDialog.ui
index 4d06d1f8..4c05b883 100644
--- a/gui/dialogs/SettingsDialog.ui
+++ b/gui/dialogs/SettingsDialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>526</width>
- <height>599</height>
+ <height>628</height>
</rect>
</property>
<property name="sizePolicy">
@@ -39,7 +39,7 @@
<attribute name="title">
<string>General</string>
</attribute>
- <layout class="QVBoxLayout" name="generalTabLayout">
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="sortingModeBox">
<property name="enabled">
@@ -237,6 +237,32 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="editorsBox">
+ <property name="title">
+ <string>External Editors (leave empty for system default)</string>
+ </property>
+ <layout class="QGridLayout" name="foldersBoxLayout_2">
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="jsonEditorTextBox"/>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelJsonEditor">
+ <property name="text">
+ <string>JSON Editor:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QToolButton" name="jsonEditorBrowseBtn">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="generalTabSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>