From 5d0868a056e3de295deaa94717b4023d07772c54 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 30 Dec 2013 14:45:59 +0100 Subject: Notify the user of any errors --- MultiMC.cpp | 8 ++++---- MultiMC.h | 2 +- gui/dialogs/OneSixModEditDialog.cpp | 5 ++++- gui/dialogs/SettingsDialog.cpp | 11 ++++++++++- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 24cdd077..865d0cf1 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -554,17 +554,17 @@ QString MultiMC::getExitUpdatePath() const return m_updateOnExitPath; } -void MultiMC::openJsonEditor(const QString &filename) +bool MultiMC::openJsonEditor(const QString &filename) { const QString file = QDir::current().absoluteFilePath(filename); if (m_settings->get("JsonEditor").toString().isEmpty()) { - QDesktopServices::openUrl(QUrl::fromLocalFile(file)); + return QDesktopServices::openUrl(QUrl::fromLocalFile(file)); } else { - QProcess::startDetached(m_settings->get("JsonEditor").toString(), - QStringList() << file); + return QProcess::startDetached(m_settings->get("JsonEditor").toString(), + QStringList() << file); } } diff --git a/MultiMC.h b/MultiMC.h index 17113181..602a4673 100644 --- a/MultiMC.h +++ b/MultiMC.h @@ -117,7 +117,7 @@ public: * Opens a json file using either a system default editor, or, if note empty, the editor * specified in the settings */ - void openJsonEditor(const QString &filename); + bool openJsonEditor(const QString &filename); private: void initLogger(); diff --git a/gui/dialogs/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index e575c868..3982f17d 100644 --- a/gui/dialogs/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -140,7 +140,10 @@ void OneSixModEditDialog::on_customEditorBtn_clicked() { if (m_inst->versionIsCustom()) { - MMC->openJsonEditor(m_inst->instanceRoot() + "/custom.json"); + if (!MMC->openJsonEditor(m_inst->instanceRoot() + "/custom.json")) + { + QMessageBox::warning(this, tr("Error"), tr("Unable to open custom.json, check the settings")); + } } } diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp index 2797fe4e..0d97a5a5 100644 --- a/gui/dialogs/SettingsDialog.cpp +++ b/gui/dialogs/SettingsDialog.cpp @@ -142,12 +142,21 @@ void SettingsDialog::on_jsonEditorBrowseBtn_clicked() : ui->jsonEditorTextBox->text()); QString cooked_file = NormalizePath(raw_file); + if (cooked_file.isEmpty()) + { + return; + } + // it has to exist and be an executable - if (!cooked_file.isEmpty() && QFileInfo(cooked_file).exists() && + if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable()) { ui->jsonEditorTextBox->setText(cooked_file); } + else + { + QMessageBox::warning(this, tr("Invalid"), tr("The file choosen does not seem to be an executable")); + } } void SettingsDialog::on_maximizedCheckBox_clicked(bool checked) -- cgit v1.2.3