summaryrefslogtreecommitdiffstats
path: root/application/pages
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-02 02:33:55 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-02 02:37:54 +0100
commit85b64ad76705cd152fb2b0525de75fe4e832c31c (patch)
treec95101d899b565da4ec99e43d6c5f4796a6c1385 /application/pages
parent3a4304d89dc59a5f4045c1f3f2b504ba188adb33 (diff)
downloadMultiMC-85b64ad76705cd152fb2b0525de75fe4e832c31c.tar
MultiMC-85b64ad76705cd152fb2b0525de75fe4e832c31c.tar.gz
MultiMC-85b64ad76705cd152fb2b0525de75fe4e832c31c.tar.lz
MultiMC-85b64ad76705cd152fb2b0525de75fe4e832c31c.tar.xz
MultiMC-85b64ad76705cd152fb2b0525de75fe4e832c31c.zip
NOISSUE MCEdit integration - remove old 'tool', replace with Worlds
Diffstat (limited to 'application/pages')
-rw-r--r--application/pages/WorldListPage.cpp54
-rw-r--r--application/pages/global/ExternalToolsPage.cpp23
2 files changed, 26 insertions, 51 deletions
diff --git a/application/pages/WorldListPage.cpp b/application/pages/WorldListPage.cpp
index fcef716b..a4f17744 100644
--- a/application/pages/WorldListPage.cpp
+++ b/application/pages/WorldListPage.cpp
@@ -24,10 +24,11 @@
#include <QMessageBox>
#include <QTreeView>
#include <QInputDialog>
-
+#include <tools/MCEditTool.h>
#include "MultiMC.h"
#include <GuiUtil.h>
+#include <QProcess>
WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id,
QString iconName, QString displayName, QString helpPage,
@@ -148,7 +149,8 @@ void WorldListPage::on_copySeedBtn_clicked()
void WorldListPage::on_mcEditBtn_clicked()
{
- const QString mceditPath = MMC->settings()->get("MCEditPath").toString();
+ auto mcedit = MMC->mcedit();
+ const QString mceditPath = mcedit->path();
QModelIndex index = getSelectedWorld();
@@ -162,49 +164,27 @@ void WorldListPage::on_mcEditBtn_clicked()
auto fullPath = m_worlds->data(index, WorldList::FolderRole).toString();
-#ifdef Q_OS_OSX
- QProcess *process = new QProcess();
- connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), process, SLOT(deleteLater()));
- process->setProgram(mceditPath);
- process->setArguments(QStringList() << fullPath);
- process->start();
-#else
- QDir mceditDir(mceditPath);
- QString program;
- #ifdef Q_OS_LINUX
- if (mceditDir.exists("mcedit.sh"))
- {
- program = mceditDir.absoluteFilePath("mcedit.sh");
- }
- else if (mceditDir.exists("mcedit.py"))
- {
- program = mceditDir.absoluteFilePath("mcedit.py");
- }
- #elif defined(Q_OS_WIN32)
- if (mceditDir.exists("mcedit.exe"))
- {
- program = mceditDir.absoluteFilePath("mcedit.exe");
- }
- else if (mceditDir.exists("mcedit2.exe"))
- {
- program = mceditDir.absoluteFilePath("mcedit2.exe");
- }
- #endif
+ auto program = mcedit->getProgramPath();
if(program.size())
{
- qint64 pid = 0;
-
- DesktopServices::openFile(program, fullPath, mceditPath, &pid);
- if(pid == 0)
+ qint64 pid;
+ if(!QProcess::startDetached(program, QStringList() << fullPath, mceditPath, &pid))
{
- QMessageBox::warning(this->parentWidget(), tr("MCEdit failed to start!"), tr("MCEdit failed to start.\nIt may be necessary to reinstall it."));
+ QMessageBox::warning(
+ this->parentWidget(),
+ tr("MCEdit failed to start!"),
+ tr("MCEdit failed to start.\nIt may be necessary to reinstall it.")
+ );
}
}
else
{
- QMessageBox::warning(this->parentWidget(), tr("No MCEdit found or set up!"), tr("You do not have MCEdit set up or it was moved.\nYou can set it up in the global settings."));
+ QMessageBox::warning(
+ this->parentWidget(),
+ tr("No MCEdit found or set up!"),
+ tr("You do not have MCEdit set up or it was moved.\nYou can set it up in the global settings.")
+ );
}
-#endif
}
void WorldListPage::worldChanged(const QModelIndex &current, const QModelIndex &previous)
diff --git a/application/pages/global/ExternalToolsPage.cpp b/application/pages/global/ExternalToolsPage.cpp
index e8091dee..4c3375c8 100644
--- a/application/pages/global/ExternalToolsPage.cpp
+++ b/application/pages/global/ExternalToolsPage.cpp
@@ -24,6 +24,7 @@
#include "tools/BaseProfiler.h"
#include <FileSystem.h>
#include "MultiMC.h"
+#include <tools/MCEditTool.h>
ExternalToolsPage::ExternalToolsPage(QWidget *parent) :
QWidget(parent),
@@ -93,8 +94,7 @@ void ExternalToolsPage::on_jprofilerPathBtn_clicked()
QString cooked_dir = FS::NormalizePath(raw_dir);
if (!MMC->profilers()["jprofiler"]->check(cooked_dir, &error))
{
- QMessageBox::critical(this, tr("Error"),
- tr("Error while checking JProfiler install:\n%1").arg(error));
+ QMessageBox::critical(this, tr("Error"), tr("Error while checking JProfiler install:\n%1").arg(error));
continue;
}
else
@@ -109,8 +109,7 @@ void ExternalToolsPage::on_jprofilerCheckBtn_clicked()
QString error;
if (!MMC->profilers()["jprofiler"]->check(ui->jprofilerPathEdit->text(), &error))
{
- QMessageBox::critical(this, tr("Error"),
- tr("Error while checking JProfiler install:\n%1").arg(error));
+ QMessageBox::critical(this, tr("Error"), tr("Error while checking JProfiler install:\n%1").arg(error));
}
else
{
@@ -132,8 +131,7 @@ void ExternalToolsPage::on_jvisualvmPathBtn_clicked()
QString cooked_dir = FS::NormalizePath(raw_dir);
if (!MMC->profilers()["jvisualvm"]->check(cooked_dir, &error))
{
- QMessageBox::critical(this, tr("Error"),
- tr("Error while checking JVisualVM install:\n%1").arg(error));
+ QMessageBox::critical(this, tr("Error"), tr("Error while checking JVisualVM install:\n%1").arg(error));
continue;
}
else
@@ -148,8 +146,7 @@ void ExternalToolsPage::on_jvisualvmCheckBtn_clicked()
QString error;
if (!MMC->profilers()["jvisualvm"]->check(ui->jvisualvmPathEdit->text(), &error))
{
- QMessageBox::critical(this, tr("Error"),
- tr("Error while checking JVisualVM install:\n%1").arg(error));
+ QMessageBox::critical(this, tr("Error"), tr("Error while checking JVisualVM install:\n%1").arg(error));
}
else
{
@@ -174,10 +171,9 @@ void ExternalToolsPage::on_mceditPathBtn_clicked()
break;
}
QString cooked_dir = FS::NormalizePath(raw_dir);
- if (!MMC->tools()["mcedit"]->check(cooked_dir, &error))
+ if (!MMC->mcedit()->check(cooked_dir, error))
{
- QMessageBox::critical(this, tr("Error"),
- tr("Error while checking MCEdit install:\n%1").arg(error));
+ QMessageBox::critical(this, tr("Error"), tr("Error while checking MCEdit install:\n%1").arg(error));
continue;
}
else
@@ -190,10 +186,9 @@ void ExternalToolsPage::on_mceditPathBtn_clicked()
void ExternalToolsPage::on_mceditCheckBtn_clicked()
{
QString error;
- if (!MMC->tools()["mcedit"]->check(ui->mceditPathEdit->text(), &error))
+ if (!!MMC->mcedit()->check(ui->mceditPathEdit->text(), error))
{
- QMessageBox::critical(this, tr("Error"),
- tr("Error while checking MCEdit install:\n%1").arg(error));
+ QMessageBox::critical(this, tr("Error"), tr("Error while checking MCEdit install:\n%1").arg(error));
}
else
{