Fix MCEdit on OSX

This commit is contained in:
Jan Dalheimer 2014-02-21 20:13:12 +01:00
parent 16d378687c
commit a354e8bfae
2 changed files with 17 additions and 2 deletions

View File

@ -623,7 +623,12 @@ void SettingsDialog::on_mceditPathBtn_clicked()
QString error; QString error;
do 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); raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Directory"), raw_dir);
#endif
if (raw_dir.isEmpty()) if (raw_dir.isEmpty())
{ {
break; break;

View File

@ -2,6 +2,8 @@
#include <QDir> #include <QDir>
#include <QProcess> #include <QProcess>
#include <QDesktopServices>
#include <QUrl>
#include "settingsobject.h" #include "settingsobject.h"
#include "logic/BaseInstance.h" #include "logic/BaseInstance.h"
@ -20,6 +22,13 @@ void MCEditTool::runImpl()
{ {
return; 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); QDir mceditDir(mceditPath);
QString program; QString program;
if (mceditDir.exists("mcedit.py")) if (mceditDir.exists("mcedit.py"))
@ -31,6 +40,7 @@ void MCEditTool::runImpl()
program = mceditDir.absoluteFilePath("mcedit.exe"); program = mceditDir.absoluteFilePath("mcedit.exe");
} }
QProcess::startDetached(program, QStringList() << save, mceditPath); QProcess::startDetached(program, QStringList() << save, mceditPath);
#endif
} }
void MCEditFactory::registerSettings(SettingsObject *settings) void MCEditFactory::registerSettings(SettingsObject *settings)
@ -58,9 +68,9 @@ bool MCEditFactory::check(const QString &path, QString *error)
*error = QObject::tr("Path does not exist"); *error = QObject::tr("Path does not exist");
return false; 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 false;
} }
return true; return true;