Notify the user of any errors
This commit is contained in:
parent
c01678a3fa
commit
5d0868a056
@ -554,16 +554,16 @@ QString MultiMC::getExitUpdatePath() const
|
|||||||
return m_updateOnExitPath;
|
return m_updateOnExitPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiMC::openJsonEditor(const QString &filename)
|
bool MultiMC::openJsonEditor(const QString &filename)
|
||||||
{
|
{
|
||||||
const QString file = QDir::current().absoluteFilePath(filename);
|
const QString file = QDir::current().absoluteFilePath(filename);
|
||||||
if (m_settings->get("JsonEditor").toString().isEmpty())
|
if (m_settings->get("JsonEditor").toString().isEmpty())
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(file));
|
return QDesktopServices::openUrl(QUrl::fromLocalFile(file));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QProcess::startDetached(m_settings->get("JsonEditor").toString(),
|
return QProcess::startDetached(m_settings->get("JsonEditor").toString(),
|
||||||
QStringList() << file);
|
QStringList() << file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ public:
|
|||||||
* Opens a json file using either a system default editor, or, if note empty, the editor
|
* Opens a json file using either a system default editor, or, if note empty, the editor
|
||||||
* specified in the settings
|
* specified in the settings
|
||||||
*/
|
*/
|
||||||
void openJsonEditor(const QString &filename);
|
bool openJsonEditor(const QString &filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initLogger();
|
void initLogger();
|
||||||
|
@ -140,7 +140,10 @@ void OneSixModEditDialog::on_customEditorBtn_clicked()
|
|||||||
{
|
{
|
||||||
if (m_inst->versionIsCustom())
|
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"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,12 +142,21 @@ void SettingsDialog::on_jsonEditorBrowseBtn_clicked()
|
|||||||
: ui->jsonEditorTextBox->text());
|
: ui->jsonEditorTextBox->text());
|
||||||
QString cooked_file = NormalizePath(raw_file);
|
QString cooked_file = NormalizePath(raw_file);
|
||||||
|
|
||||||
|
if (cooked_file.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// it has to exist and be an executable
|
// 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())
|
QFileInfo(cooked_file).isExecutable())
|
||||||
{
|
{
|
||||||
ui->jsonEditorTextBox->setText(cooked_file);
|
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)
|
void SettingsDialog::on_maximizedCheckBox_clicked(bool checked)
|
||||||
|
Loading…
Reference in New Issue
Block a user