NOISSUE tabs -> spaces
This commit is contained in:
@ -10,7 +10,7 @@
|
||||
#include "BaseInstance.h"
|
||||
|
||||
BaseExternalTool::BaseExternalTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent)
|
||||
: QObject(parent), m_instance(instance), globalSettings(settings)
|
||||
: QObject(parent), m_instance(instance), globalSettings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
@ -19,14 +19,14 @@ BaseExternalTool::~BaseExternalTool()
|
||||
}
|
||||
|
||||
BaseDetachedTool::BaseDetachedTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent)
|
||||
: BaseExternalTool(settings, instance, parent)
|
||||
: BaseExternalTool(settings, instance, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BaseDetachedTool::run()
|
||||
{
|
||||
runImpl();
|
||||
runImpl();
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ BaseExternalToolFactory::~BaseExternalToolFactory()
|
||||
}
|
||||
|
||||
BaseDetachedTool *BaseDetachedToolFactory::createDetachedTool(InstancePtr instance,
|
||||
QObject *parent)
|
||||
QObject *parent)
|
||||
{
|
||||
return qobject_cast<BaseDetachedTool *>(createTool(instance, parent));
|
||||
return qobject_cast<BaseDetachedTool *>(createTool(instance, parent));
|
||||
}
|
||||
|
@ -11,50 +11,50 @@ class QProcess;
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT BaseExternalTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BaseExternalTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
virtual ~BaseExternalTool();
|
||||
explicit BaseExternalTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
virtual ~BaseExternalTool();
|
||||
|
||||
protected:
|
||||
InstancePtr m_instance;
|
||||
SettingsObjectPtr globalSettings;
|
||||
InstancePtr m_instance;
|
||||
SettingsObjectPtr globalSettings;
|
||||
};
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT BaseDetachedTool : public BaseExternalTool
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BaseDetachedTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
explicit BaseDetachedTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
public
|
||||
slots:
|
||||
void run();
|
||||
void run();
|
||||
|
||||
protected:
|
||||
virtual void runImpl() = 0;
|
||||
virtual void runImpl() = 0;
|
||||
};
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT BaseExternalToolFactory
|
||||
{
|
||||
public:
|
||||
virtual ~BaseExternalToolFactory();
|
||||
virtual ~BaseExternalToolFactory();
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual QString name() const = 0;
|
||||
|
||||
virtual void registerSettings(SettingsObjectPtr settings) = 0;
|
||||
virtual void registerSettings(SettingsObjectPtr settings) = 0;
|
||||
|
||||
virtual BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) = 0;
|
||||
virtual BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) = 0;
|
||||
|
||||
virtual bool check(QString *error) = 0;
|
||||
virtual bool check(const QString &path, QString *error) = 0;
|
||||
virtual bool check(QString *error) = 0;
|
||||
virtual bool check(const QString &path, QString *error) = 0;
|
||||
|
||||
protected:
|
||||
SettingsObjectPtr globalSettings;
|
||||
SettingsObjectPtr globalSettings;
|
||||
};
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT BaseDetachedToolFactory : public BaseExternalToolFactory
|
||||
{
|
||||
public:
|
||||
virtual BaseDetachedTool *createDetachedTool(InstancePtr instance, QObject *parent = 0);
|
||||
virtual BaseDetachedTool *createDetachedTool(InstancePtr instance, QObject *parent = 0);
|
||||
};
|
||||
|
@ -3,33 +3,33 @@
|
||||
#include <QProcess>
|
||||
|
||||
BaseProfiler::BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent)
|
||||
: BaseExternalTool(settings, instance, parent)
|
||||
: BaseExternalTool(settings, instance, parent)
|
||||
{
|
||||
}
|
||||
|
||||
void BaseProfiler::beginProfiling(std::shared_ptr<LaunchTask> process)
|
||||
{
|
||||
beginProfilingImpl(process);
|
||||
beginProfilingImpl(process);
|
||||
}
|
||||
|
||||
void BaseProfiler::abortProfiling()
|
||||
{
|
||||
abortProfilingImpl();
|
||||
abortProfilingImpl();
|
||||
}
|
||||
|
||||
void BaseProfiler::abortProfilingImpl()
|
||||
{
|
||||
if (!m_profilerProcess)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_profilerProcess->terminate();
|
||||
m_profilerProcess->deleteLater();
|
||||
m_profilerProcess = 0;
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
if (!m_profilerProcess)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_profilerProcess->terminate();
|
||||
m_profilerProcess->deleteLater();
|
||||
m_profilerProcess = 0;
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
}
|
||||
|
||||
BaseProfiler *BaseProfilerFactory::createProfiler(InstancePtr instance, QObject *parent)
|
||||
{
|
||||
return qobject_cast<BaseProfiler *>(createTool(instance, parent));
|
||||
return qobject_cast<BaseProfiler *>(createTool(instance, parent));
|
||||
}
|
||||
|
@ -11,28 +11,28 @@ class QProcess;
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT BaseProfiler : public BaseExternalTool
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
explicit BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
public
|
||||
slots:
|
||||
void beginProfiling(std::shared_ptr<LaunchTask> process);
|
||||
void abortProfiling();
|
||||
void beginProfiling(std::shared_ptr<LaunchTask> process);
|
||||
void abortProfiling();
|
||||
|
||||
protected:
|
||||
QProcess *m_profilerProcess;
|
||||
QProcess *m_profilerProcess;
|
||||
|
||||
virtual void beginProfilingImpl(std::shared_ptr<LaunchTask> process) = 0;
|
||||
virtual void abortProfilingImpl();
|
||||
virtual void beginProfilingImpl(std::shared_ptr<LaunchTask> process) = 0;
|
||||
virtual void abortProfilingImpl();
|
||||
|
||||
signals:
|
||||
void readyToLaunch(const QString &message);
|
||||
void abortLaunch(const QString &message);
|
||||
void readyToLaunch(const QString &message);
|
||||
void abortLaunch(const QString &message);
|
||||
};
|
||||
|
||||
class MULTIMC_LOGIC_EXPORT BaseProfilerFactory : public BaseExternalToolFactory
|
||||
{
|
||||
public:
|
||||
virtual BaseProfiler *createProfiler(InstancePtr instance, QObject *parent = 0);
|
||||
virtual BaseProfiler *createProfiler(InstancePtr instance, QObject *parent = 0);
|
||||
};
|
||||
|
@ -8,109 +8,109 @@
|
||||
|
||||
class JProfiler : public BaseProfiler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
JProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
JProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
private slots:
|
||||
void profilerStarted();
|
||||
void profilerFinished(int exit, QProcess::ExitStatus status);
|
||||
void profilerStarted();
|
||||
void profilerFinished(int exit, QProcess::ExitStatus status);
|
||||
|
||||
protected:
|
||||
void beginProfilingImpl(std::shared_ptr<LaunchTask> process);
|
||||
void beginProfilingImpl(std::shared_ptr<LaunchTask> process);
|
||||
|
||||
private:
|
||||
int listeningPort = 0;
|
||||
int listeningPort = 0;
|
||||
};
|
||||
|
||||
JProfiler::JProfiler(SettingsObjectPtr settings, InstancePtr instance,
|
||||
QObject *parent)
|
||||
: BaseProfiler(settings, instance, parent)
|
||||
QObject *parent)
|
||||
: BaseProfiler(settings, instance, parent)
|
||||
{
|
||||
}
|
||||
|
||||
void JProfiler::profilerStarted()
|
||||
{
|
||||
emit readyToLaunch(tr("Listening on port: %1").arg(listeningPort));
|
||||
emit readyToLaunch(tr("Listening on port: %1").arg(listeningPort));
|
||||
}
|
||||
|
||||
void JProfiler::profilerFinished(int exit, QProcess::ExitStatus status)
|
||||
{
|
||||
if (status == QProcess::CrashExit)
|
||||
{
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
}
|
||||
if (m_profilerProcess)
|
||||
{
|
||||
m_profilerProcess->deleteLater();
|
||||
m_profilerProcess = 0;
|
||||
}
|
||||
if (status == QProcess::CrashExit)
|
||||
{
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
}
|
||||
if (m_profilerProcess)
|
||||
{
|
||||
m_profilerProcess->deleteLater();
|
||||
m_profilerProcess = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void JProfiler::beginProfilingImpl(std::shared_ptr<LaunchTask> process)
|
||||
{
|
||||
listeningPort = globalSettings->get("JProfilerPort").toInt();
|
||||
QProcess *profiler = new QProcess(this);
|
||||
QStringList profilerArgs =
|
||||
{
|
||||
"-d", QString::number(process->pid()),
|
||||
"--gui",
|
||||
"-p", QString::number(listeningPort)
|
||||
};
|
||||
auto basePath = globalSettings->get("JProfilerPath").toString();
|
||||
listeningPort = globalSettings->get("JProfilerPort").toInt();
|
||||
QProcess *profiler = new QProcess(this);
|
||||
QStringList profilerArgs =
|
||||
{
|
||||
"-d", QString::number(process->pid()),
|
||||
"--gui",
|
||||
"-p", QString::number(listeningPort)
|
||||
};
|
||||
auto basePath = globalSettings->get("JProfilerPath").toString();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QString profilerProgram = QDir(basePath).absoluteFilePath("bin/jpenable.exe");
|
||||
QString profilerProgram = QDir(basePath).absoluteFilePath("bin/jpenable.exe");
|
||||
#else
|
||||
QString profilerProgram = QDir(basePath).absoluteFilePath("bin/jpenable");
|
||||
QString profilerProgram = QDir(basePath).absoluteFilePath("bin/jpenable");
|
||||
#endif
|
||||
|
||||
profiler->setArguments(profilerArgs);
|
||||
profiler->setProgram(profilerProgram);
|
||||
profiler->setArguments(profilerArgs);
|
||||
profiler->setProgram(profilerProgram);
|
||||
|
||||
connect(profiler, SIGNAL(started()), SLOT(profilerStarted()));
|
||||
connect(profiler, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(profilerFinished(int,QProcess::ExitStatus)));
|
||||
connect(profiler, SIGNAL(started()), SLOT(profilerStarted()));
|
||||
connect(profiler, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(profilerFinished(int,QProcess::ExitStatus)));
|
||||
|
||||
m_profilerProcess = profiler;
|
||||
profiler->start();
|
||||
m_profilerProcess = profiler;
|
||||
profiler->start();
|
||||
}
|
||||
|
||||
void JProfilerFactory::registerSettings(SettingsObjectPtr settings)
|
||||
{
|
||||
settings->registerSetting("JProfilerPath");
|
||||
settings->registerSetting("JProfilerPort", 42042);
|
||||
globalSettings = settings;
|
||||
settings->registerSetting("JProfilerPath");
|
||||
settings->registerSetting("JProfilerPort", 42042);
|
||||
globalSettings = settings;
|
||||
}
|
||||
|
||||
BaseExternalTool *JProfilerFactory::createTool(InstancePtr instance, QObject *parent)
|
||||
{
|
||||
return new JProfiler(globalSettings, instance, parent);
|
||||
return new JProfiler(globalSettings, instance, parent);
|
||||
}
|
||||
|
||||
bool JProfilerFactory::check(QString *error)
|
||||
{
|
||||
return check(globalSettings->get("JProfilerPath").toString(), error);
|
||||
return check(globalSettings->get("JProfilerPath").toString(), error);
|
||||
}
|
||||
|
||||
bool JProfilerFactory::check(const QString &path, QString *error)
|
||||
{
|
||||
if (path.isEmpty())
|
||||
{
|
||||
*error = QObject::tr("Empty path");
|
||||
return false;
|
||||
}
|
||||
QDir dir(path);
|
||||
if (!dir.exists())
|
||||
{
|
||||
*error = QObject::tr("Path does not exist");
|
||||
return false;
|
||||
}
|
||||
if (!dir.exists("bin") || !(dir.exists("bin/jprofiler") || dir.exists("bin/jprofiler.exe")) || !dir.exists("bin/agent.jar"))
|
||||
{
|
||||
*error = QObject::tr("Invalid JProfiler install");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (path.isEmpty())
|
||||
{
|
||||
*error = QObject::tr("Empty path");
|
||||
return false;
|
||||
}
|
||||
QDir dir(path);
|
||||
if (!dir.exists())
|
||||
{
|
||||
*error = QObject::tr("Path does not exist");
|
||||
return false;
|
||||
}
|
||||
if (!dir.exists("bin") || !(dir.exists("bin/jprofiler") || dir.exists("bin/jprofiler.exe")) || !dir.exists("bin/agent.jar"))
|
||||
{
|
||||
*error = QObject::tr("Invalid JProfiler install");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "JProfiler.moc"
|
||||
|
@ -7,9 +7,9 @@
|
||||
class MULTIMC_LOGIC_EXPORT JProfilerFactory : public BaseProfilerFactory
|
||||
{
|
||||
public:
|
||||
QString name() const override { return "JProfiler"; }
|
||||
void registerSettings(SettingsObjectPtr settings) override;
|
||||
BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override;
|
||||
bool check(QString *error) override;
|
||||
bool check(const QString &path, QString *error) override;
|
||||
QString name() const override { return "JProfiler"; }
|
||||
void registerSettings(SettingsObjectPtr settings) override;
|
||||
BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override;
|
||||
bool check(QString *error) override;
|
||||
bool check(const QString &path, QString *error) override;
|
||||
};
|
||||
|
@ -9,96 +9,96 @@
|
||||
|
||||
class JVisualVM : public BaseProfiler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
private slots:
|
||||
void profilerStarted();
|
||||
void profilerFinished(int exit, QProcess::ExitStatus status);
|
||||
void profilerStarted();
|
||||
void profilerFinished(int exit, QProcess::ExitStatus status);
|
||||
|
||||
protected:
|
||||
void beginProfilingImpl(std::shared_ptr<LaunchTask> process);
|
||||
void beginProfilingImpl(std::shared_ptr<LaunchTask> process);
|
||||
};
|
||||
|
||||
|
||||
JVisualVM::JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent)
|
||||
: BaseProfiler(settings, instance, parent)
|
||||
: BaseProfiler(settings, instance, parent)
|
||||
{
|
||||
}
|
||||
|
||||
void JVisualVM::profilerStarted()
|
||||
{
|
||||
emit readyToLaunch(tr("JVisualVM started"));
|
||||
emit readyToLaunch(tr("JVisualVM started"));
|
||||
}
|
||||
|
||||
void JVisualVM::profilerFinished(int exit, QProcess::ExitStatus status)
|
||||
{
|
||||
if (status == QProcess::CrashExit)
|
||||
{
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
}
|
||||
if (m_profilerProcess)
|
||||
{
|
||||
m_profilerProcess->deleteLater();
|
||||
m_profilerProcess = 0;
|
||||
}
|
||||
if (status == QProcess::CrashExit)
|
||||
{
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
}
|
||||
if (m_profilerProcess)
|
||||
{
|
||||
m_profilerProcess->deleteLater();
|
||||
m_profilerProcess = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void JVisualVM::beginProfilingImpl(std::shared_ptr<LaunchTask> process)
|
||||
{
|
||||
QProcess *profiler = new QProcess(this);
|
||||
QStringList profilerArgs =
|
||||
{
|
||||
"--openpid", QString::number(process->pid())
|
||||
};
|
||||
auto programPath = globalSettings->get("JVisualVMPath").toString();
|
||||
QProcess *profiler = new QProcess(this);
|
||||
QStringList profilerArgs =
|
||||
{
|
||||
"--openpid", QString::number(process->pid())
|
||||
};
|
||||
auto programPath = globalSettings->get("JVisualVMPath").toString();
|
||||
|
||||
profiler->setArguments(profilerArgs);
|
||||
profiler->setProgram(programPath);
|
||||
profiler->setArguments(profilerArgs);
|
||||
profiler->setProgram(programPath);
|
||||
|
||||
connect(profiler, SIGNAL(started()), SLOT(profilerStarted()));
|
||||
connect(profiler, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(profilerFinished(int,QProcess::ExitStatus)));
|
||||
connect(profiler, SIGNAL(started()), SLOT(profilerStarted()));
|
||||
connect(profiler, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(profilerFinished(int,QProcess::ExitStatus)));
|
||||
|
||||
profiler->start();
|
||||
m_profilerProcess = profiler;
|
||||
profiler->start();
|
||||
m_profilerProcess = profiler;
|
||||
}
|
||||
|
||||
void JVisualVMFactory::registerSettings(SettingsObjectPtr settings)
|
||||
{
|
||||
QString defaultValue = QStandardPaths::findExecutable("jvisualvm");
|
||||
if (defaultValue.isNull())
|
||||
{
|
||||
defaultValue = QStandardPaths::findExecutable("visualvm");
|
||||
}
|
||||
settings->registerSetting("JVisualVMPath", defaultValue);
|
||||
globalSettings = settings;
|
||||
QString defaultValue = QStandardPaths::findExecutable("jvisualvm");
|
||||
if (defaultValue.isNull())
|
||||
{
|
||||
defaultValue = QStandardPaths::findExecutable("visualvm");
|
||||
}
|
||||
settings->registerSetting("JVisualVMPath", defaultValue);
|
||||
globalSettings = settings;
|
||||
}
|
||||
|
||||
BaseExternalTool *JVisualVMFactory::createTool(InstancePtr instance, QObject *parent)
|
||||
{
|
||||
return new JVisualVM(globalSettings, instance, parent);
|
||||
return new JVisualVM(globalSettings, instance, parent);
|
||||
}
|
||||
|
||||
bool JVisualVMFactory::check(QString *error)
|
||||
{
|
||||
return check(globalSettings->get("JVisualVMPath").toString(), error);
|
||||
return check(globalSettings->get("JVisualVMPath").toString(), error);
|
||||
}
|
||||
|
||||
bool JVisualVMFactory::check(const QString &path, QString *error)
|
||||
{
|
||||
if (path.isEmpty())
|
||||
{
|
||||
*error = QObject::tr("Empty path");
|
||||
return false;
|
||||
}
|
||||
QFileInfo finfo(path);
|
||||
if (!finfo.isExecutable() || !finfo.fileName().contains("visualvm"))
|
||||
{
|
||||
*error = QObject::tr("Invalid path to JVisualVM");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (path.isEmpty())
|
||||
{
|
||||
*error = QObject::tr("Empty path");
|
||||
return false;
|
||||
}
|
||||
QFileInfo finfo(path);
|
||||
if (!finfo.isExecutable() || !finfo.fileName().contains("visualvm"))
|
||||
{
|
||||
*error = QObject::tr("Invalid path to JVisualVM");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "JVisualVM.moc"
|
||||
|
@ -7,9 +7,9 @@
|
||||
class MULTIMC_LOGIC_EXPORT JVisualVMFactory : public BaseProfilerFactory
|
||||
{
|
||||
public:
|
||||
QString name() const override { return "JVisualVM"; }
|
||||
void registerSettings(SettingsObjectPtr settings) override;
|
||||
BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override;
|
||||
bool check(QString *error) override;
|
||||
bool check(const QString &path, QString *error) override;
|
||||
QString name() const override { return "JVisualVM"; }
|
||||
void registerSettings(SettingsObjectPtr settings) override;
|
||||
BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override;
|
||||
bool check(QString *error) override;
|
||||
bool check(const QString &path, QString *error) override;
|
||||
};
|
||||
|
@ -10,68 +10,68 @@
|
||||
|
||||
MCEditTool::MCEditTool(SettingsObjectPtr settings)
|
||||
{
|
||||
settings->registerSetting("MCEditPath");
|
||||
m_settings = settings;
|
||||
settings->registerSetting("MCEditPath");
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
void MCEditTool::setPath(QString& path)
|
||||
{
|
||||
m_settings->set("MCEditPath", path);
|
||||
m_settings->set("MCEditPath", path);
|
||||
}
|
||||
|
||||
QString MCEditTool::path() const
|
||||
{
|
||||
return m_settings->get("MCEditPath").toString();
|
||||
return m_settings->get("MCEditPath").toString();
|
||||
}
|
||||
|
||||
bool MCEditTool::check(const QString& toolPath, QString& error)
|
||||
{
|
||||
if (toolPath.isEmpty())
|
||||
{
|
||||
error = QObject::tr("Path is empty");
|
||||
return false;
|
||||
}
|
||||
const QDir dir(toolPath);
|
||||
if (!dir.exists())
|
||||
{
|
||||
error = QObject::tr("Path does not exist");
|
||||
return false;
|
||||
}
|
||||
if (!dir.exists("mcedit.sh") && !dir.exists("mcedit.py") && !dir.exists("mcedit.exe") && !dir.exists("Contents") && !dir.exists("mcedit2.exe"))
|
||||
{
|
||||
error = QObject::tr("Path does not seem to be a MCEdit path");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (toolPath.isEmpty())
|
||||
{
|
||||
error = QObject::tr("Path is empty");
|
||||
return false;
|
||||
}
|
||||
const QDir dir(toolPath);
|
||||
if (!dir.exists())
|
||||
{
|
||||
error = QObject::tr("Path does not exist");
|
||||
return false;
|
||||
}
|
||||
if (!dir.exists("mcedit.sh") && !dir.exists("mcedit.py") && !dir.exists("mcedit.exe") && !dir.exists("Contents") && !dir.exists("mcedit2.exe"))
|
||||
{
|
||||
error = QObject::tr("Path does not seem to be a MCEdit path");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MCEditTool::getProgramPath()
|
||||
{
|
||||
#ifdef Q_OS_OSX
|
||||
return path();
|
||||
return path();
|
||||
#else
|
||||
const QString mceditPath = path();
|
||||
QDir mceditDir(mceditPath);
|
||||
const QString mceditPath = path();
|
||||
QDir mceditDir(mceditPath);
|
||||
#ifdef Q_OS_LINUX
|
||||
if (mceditDir.exists("mcedit.sh"))
|
||||
{
|
||||
return mceditDir.absoluteFilePath("mcedit.sh");
|
||||
}
|
||||
else if (mceditDir.exists("mcedit.py"))
|
||||
{
|
||||
return mceditDir.absoluteFilePath("mcedit.py");
|
||||
}
|
||||
return QString();
|
||||
if (mceditDir.exists("mcedit.sh"))
|
||||
{
|
||||
return mceditDir.absoluteFilePath("mcedit.sh");
|
||||
}
|
||||
else if (mceditDir.exists("mcedit.py"))
|
||||
{
|
||||
return mceditDir.absoluteFilePath("mcedit.py");
|
||||
}
|
||||
return QString();
|
||||
#elif defined(Q_OS_WIN32)
|
||||
if (mceditDir.exists("mcedit.exe"))
|
||||
{
|
||||
return mceditDir.absoluteFilePath("mcedit.exe");
|
||||
}
|
||||
else if (mceditDir.exists("mcedit2.exe"))
|
||||
{
|
||||
return mceditDir.absoluteFilePath("mcedit2.exe");
|
||||
}
|
||||
return QString();
|
||||
if (mceditDir.exists("mcedit.exe"))
|
||||
{
|
||||
return mceditDir.absoluteFilePath("mcedit.exe");
|
||||
}
|
||||
else if (mceditDir.exists("mcedit2.exe"))
|
||||
{
|
||||
return mceditDir.absoluteFilePath("mcedit2.exe");
|
||||
}
|
||||
return QString();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -7,11 +7,11 @@
|
||||
class MULTIMC_LOGIC_EXPORT MCEditTool
|
||||
{
|
||||
public:
|
||||
MCEditTool(SettingsObjectPtr settings);
|
||||
void setPath(QString & path);
|
||||
QString path() const;
|
||||
bool check(const QString &toolPath, QString &error);
|
||||
QString getProgramPath();
|
||||
MCEditTool(SettingsObjectPtr settings);
|
||||
void setPath(QString & path);
|
||||
QString path() const;
|
||||
bool check(const QString &toolPath, QString &error);
|
||||
QString getProgramPath();
|
||||
private:
|
||||
SettingsObjectPtr m_settings;
|
||||
SettingsObjectPtr m_settings;
|
||||
};
|
||||
|
Reference in New Issue
Block a user