From a354e8bfae812b23b85b65c4a5b7e860cb18080c Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Fri, 21 Feb 2014 20:13:12 +0100 Subject: [PATCH] Fix MCEdit on OSX --- gui/dialogs/SettingsDialog.cpp | 5 +++++ logic/tools/MCEditTool.cpp | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp index fd67b22f3..d79bb558e 100644 --- a/gui/dialogs/SettingsDialog.cpp +++ b/gui/dialogs/SettingsDialog.cpp @@ -623,7 +623,12 @@ void SettingsDialog::on_mceditPathBtn_clicked() QString error; do { +#ifdef Q_OS_OSX +#warning stuff + raw_dir = QFileDialog::getOpenFileName(this, tr("MCEdit Application"), raw_dir); +#else raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Directory"), raw_dir); +#endif if (raw_dir.isEmpty()) { break; diff --git a/logic/tools/MCEditTool.cpp b/logic/tools/MCEditTool.cpp index c4edece52..e22a5d4a8 100644 --- a/logic/tools/MCEditTool.cpp +++ b/logic/tools/MCEditTool.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include "settingsobject.h" #include "logic/BaseInstance.h" @@ -20,6 +22,13 @@ void MCEditTool::runImpl() { return; } +#ifdef Q_OS_OSX + QProcess *process = new QProcess(); + connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), process, SLOT(deleteLater())); + process->setProgram(mceditPath); + process->setArguments(QStringList() << save); + process->start(); +#else QDir mceditDir(mceditPath); QString program; if (mceditDir.exists("mcedit.py")) @@ -31,6 +40,7 @@ void MCEditTool::runImpl() program = mceditDir.absoluteFilePath("mcedit.exe"); } QProcess::startDetached(program, QStringList() << save, mceditPath); +#endif } void MCEditFactory::registerSettings(SettingsObject *settings) @@ -58,9 +68,9 @@ bool MCEditFactory::check(const QString &path, QString *error) *error = QObject::tr("Path does not exist"); return false; } - if (!dir.exists("mcedit.py") && !dir.exists("mcedit.exe")) + if (!dir.exists("mcedit.py") && !dir.exists("mcedit.exe") && !dir.exists("Contents")) { - *error = QObject::tr("Path does not contain mcedit.py"); + *error = QObject::tr("Path does not seem to be a MCEdit path"); return false; } return true;