diff options
Diffstat (limited to 'logic/tools')
-rw-r--r-- | logic/tools/BaseExternalTool.cpp | 11 | ||||
-rw-r--r-- | logic/tools/BaseExternalTool.h | 13 | ||||
-rw-r--r-- | logic/tools/BaseProfiler.cpp | 4 | ||||
-rw-r--r-- | logic/tools/BaseProfiler.h | 2 | ||||
-rw-r--r-- | logic/tools/JProfiler.cpp | 22 | ||||
-rw-r--r-- | logic/tools/JProfiler.h | 4 | ||||
-rw-r--r-- | logic/tools/JVisualVM.cpp | 19 | ||||
-rw-r--r-- | logic/tools/JVisualVM.h | 4 | ||||
-rw-r--r-- | logic/tools/MCEditTool.cpp | 24 | ||||
-rw-r--r-- | logic/tools/MCEditTool.h | 4 |
10 files changed, 56 insertions, 51 deletions
diff --git a/logic/tools/BaseExternalTool.cpp b/logic/tools/BaseExternalTool.cpp index 04edece8..d2931db7 100644 --- a/logic/tools/BaseExternalTool.cpp +++ b/logic/tools/BaseExternalTool.cpp @@ -8,11 +8,10 @@ #include <windows.h> #endif -#include "logic/BaseInstance.h" -#include "MultiMC.h" +#include "BaseInstance.h" -BaseExternalTool::BaseExternalTool(InstancePtr instance, QObject *parent) - : QObject(parent), m_instance(instance) +BaseExternalTool::BaseExternalTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent) + : QObject(parent), m_instance(instance), globalSettings(settings) { } @@ -30,8 +29,8 @@ qint64 BaseExternalTool::pid(QProcess *process) #endif } -BaseDetachedTool::BaseDetachedTool(InstancePtr instance, QObject *parent) - : BaseExternalTool(instance, parent) +BaseDetachedTool::BaseDetachedTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent) + : BaseExternalTool(settings, instance, parent) { } diff --git a/logic/tools/BaseExternalTool.h b/logic/tools/BaseExternalTool.h index 8b8b2790..3c0b23ed 100644 --- a/logic/tools/BaseExternalTool.h +++ b/logic/tools/BaseExternalTool.h @@ -1,7 +1,7 @@ #pragma once #include <QObject> -#include <logic/BaseInstance.h> +#include <BaseInstance.h> class BaseInstance; class SettingsObject; @@ -11,12 +11,12 @@ class BaseExternalTool : public QObject { Q_OBJECT public: - explicit BaseExternalTool(InstancePtr instance, QObject *parent = 0); + explicit BaseExternalTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0); virtual ~BaseExternalTool(); protected: InstancePtr m_instance; - + SettingsObjectPtr globalSettings; qint64 pid(QProcess *process); }; @@ -24,7 +24,7 @@ class BaseDetachedTool : public BaseExternalTool { Q_OBJECT public: - explicit BaseDetachedTool(InstancePtr instance, QObject *parent = 0); + explicit BaseDetachedTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0); public slots: @@ -41,12 +41,15 @@ public: virtual QString name() const = 0; - virtual void registerSettings(std::shared_ptr<SettingsObject> settings) = 0; + virtual void registerSettings(SettingsObjectPtr settings) = 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; + +protected: + SettingsObjectPtr globalSettings; }; class BaseDetachedToolFactory : public BaseExternalToolFactory diff --git a/logic/tools/BaseProfiler.cpp b/logic/tools/BaseProfiler.cpp index d3c8d41e..2c9fed9b 100644 --- a/logic/tools/BaseProfiler.cpp +++ b/logic/tools/BaseProfiler.cpp @@ -2,8 +2,8 @@ #include <QProcess> -BaseProfiler::BaseProfiler(InstancePtr instance, QObject *parent) - : BaseExternalTool(instance, parent) +BaseProfiler::BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent) + : BaseExternalTool(settings, instance, parent) { } diff --git a/logic/tools/BaseProfiler.h b/logic/tools/BaseProfiler.h index decaa5b8..56397489 100644 --- a/logic/tools/BaseProfiler.h +++ b/logic/tools/BaseProfiler.h @@ -11,7 +11,7 @@ class BaseProfiler : public BaseExternalTool { Q_OBJECT public: - explicit BaseProfiler(InstancePtr instance, QObject *parent = 0); + explicit BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0); public slots: diff --git a/logic/tools/JProfiler.cpp b/logic/tools/JProfiler.cpp index 7cdf0268..d53ec615 100644 --- a/logic/tools/JProfiler.cpp +++ b/logic/tools/JProfiler.cpp @@ -3,22 +3,23 @@ #include <QDir> #include <QMessageBox> -#include "logic/settings/SettingsObject.h" -#include "logic/BaseProcess.h" -#include "logic/BaseInstance.h" -#include "MultiMC.h" +#include "settings/SettingsObject.h" +#include "BaseProcess.h" +#include "BaseInstance.h" -JProfiler::JProfiler(InstancePtr instance, QObject *parent) : BaseProfiler(instance, parent) +JProfiler::JProfiler(SettingsObjectPtr settings, InstancePtr instance, + QObject *parent) + : BaseProfiler(settings, instance, parent) { } void JProfiler::beginProfilingImpl(BaseProcess *process) { - int port = MMC->settings()->get("JProfilerPort").toInt(); + int port = globalSettings->get("JProfilerPort").toInt(); QProcess *profiler = new QProcess(this); profiler->setArguments(QStringList() << "-d" << QString::number(pid(process)) << "--gui" << "-p" << QString::number(port)); - profiler->setProgram(QDir(MMC->settings()->get("JProfilerPath").toString()) + profiler->setProgram(QDir(globalSettings->get("JProfilerPath").toString()) #ifdef Q_OS_WIN .absoluteFilePath("bin/jpenable.exe")); #else @@ -44,20 +45,21 @@ void JProfiler::beginProfilingImpl(BaseProcess *process) m_profilerProcess = profiler; } -void JProfilerFactory::registerSettings(std::shared_ptr<SettingsObject> settings) +void JProfilerFactory::registerSettings(SettingsObjectPtr settings) { settings->registerSetting("JProfilerPath"); settings->registerSetting("JProfilerPort", 42042); + globalSettings = settings; } BaseExternalTool *JProfilerFactory::createTool(InstancePtr instance, QObject *parent) { - return new JProfiler(instance, parent); + return new JProfiler(globalSettings, instance, parent); } bool JProfilerFactory::check(QString *error) { - return check(MMC->settings()->get("JProfilerPath").toString(), error); + return check(globalSettings->get("JProfilerPath").toString(), error); } bool JProfilerFactory::check(const QString &path, QString *error) diff --git a/logic/tools/JProfiler.h b/logic/tools/JProfiler.h index 0763a799..11df0779 100644 --- a/logic/tools/JProfiler.h +++ b/logic/tools/JProfiler.h @@ -6,7 +6,7 @@ class JProfiler : public BaseProfiler { Q_OBJECT public: - JProfiler(InstancePtr instance, QObject *parent = 0); + JProfiler(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0); protected: void beginProfilingImpl(BaseProcess *process); @@ -16,7 +16,7 @@ class JProfilerFactory : public BaseProfilerFactory { public: QString name() const override { return "JProfiler"; } - void registerSettings(std::shared_ptr<SettingsObject> settings) override; + 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; diff --git a/logic/tools/JVisualVM.cpp b/logic/tools/JVisualVM.cpp index 312be863..d258fde9 100644 --- a/logic/tools/JVisualVM.cpp +++ b/logic/tools/JVisualVM.cpp @@ -3,12 +3,12 @@ #include <QDir> #include <QStandardPaths> -#include "logic/settings/SettingsObject.h" -#include "logic/BaseProcess.h" -#include "logic/BaseInstance.h" -#include "MultiMC.h" +#include "settings/SettingsObject.h" +#include "BaseProcess.h" +#include "BaseInstance.h" -JVisualVM::JVisualVM(InstancePtr instance, QObject *parent) : BaseProfiler(instance, parent) +JVisualVM::JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent) + : BaseProfiler(settings, instance, parent) { } @@ -16,7 +16,7 @@ void JVisualVM::beginProfilingImpl(BaseProcess *process) { QProcess *profiler = new QProcess(this); profiler->setArguments(QStringList() << "--openpid" << QString::number(pid(process))); - profiler->setProgram(MMC->settings()->get("JVisualVMPath").toString()); + profiler->setProgram(globalSettings->get("JVisualVMPath").toString()); connect(profiler, &QProcess::started, [this]() { emit readyToLaunch(tr("JVisualVM started")); }); connect(profiler, @@ -37,7 +37,7 @@ void JVisualVM::beginProfilingImpl(BaseProcess *process) m_profilerProcess = profiler; } -void JVisualVMFactory::registerSettings(std::shared_ptr<SettingsObject> settings) +void JVisualVMFactory::registerSettings(SettingsObjectPtr settings) { QString defaultValue = QStandardPaths::findExecutable("jvisualvm"); if (defaultValue.isNull()) @@ -45,16 +45,17 @@ void JVisualVMFactory::registerSettings(std::shared_ptr<SettingsObject> settings defaultValue = QStandardPaths::findExecutable("visualvm"); } settings->registerSetting("JVisualVMPath", defaultValue); + globalSettings = settings; } BaseExternalTool *JVisualVMFactory::createTool(InstancePtr instance, QObject *parent) { - return new JVisualVM(instance, parent); + return new JVisualVM(globalSettings, instance, parent); } bool JVisualVMFactory::check(QString *error) { - return check(MMC->settings()->get("JVisualVMPath").toString(), error); + return check(globalSettings->get("JVisualVMPath").toString(), error); } bool JVisualVMFactory::check(const QString &path, QString *error) diff --git a/logic/tools/JVisualVM.h b/logic/tools/JVisualVM.h index 2a273568..f4ffe1bd 100644 --- a/logic/tools/JVisualVM.h +++ b/logic/tools/JVisualVM.h @@ -6,7 +6,7 @@ class JVisualVM : public BaseProfiler { Q_OBJECT public: - JVisualVM(InstancePtr instance, QObject *parent = 0); + JVisualVM(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0); protected: void beginProfilingImpl(BaseProcess *process); @@ -16,7 +16,7 @@ class JVisualVMFactory : public BaseProfilerFactory { public: QString name() const override { return "JVisualVM"; } - void registerSettings(std::shared_ptr<SettingsObject> settings) override; + 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; diff --git a/logic/tools/MCEditTool.cpp b/logic/tools/MCEditTool.cpp index c918d5d0..058eede8 100644 --- a/logic/tools/MCEditTool.cpp +++ b/logic/tools/MCEditTool.cpp @@ -6,14 +6,14 @@ #include <QUrl> // FIXME: mixing logic and UI!!!! #include <QInputDialog> +#include <QApplication> -#include "logic/settings/SettingsObject.h" -#include "logic/BaseInstance.h" -#include "logic/minecraft/MinecraftInstance.h" -#include "MultiMC.h" +#include "settings/SettingsObject.h" +#include "BaseInstance.h" +#include "minecraft/MinecraftInstance.h" -MCEditTool::MCEditTool(InstancePtr instance, QObject *parent) - : BaseDetachedTool(instance, parent) +MCEditTool::MCEditTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent) + : BaseDetachedTool(settings, instance, parent) { } @@ -37,8 +37,7 @@ QString MCEditTool::getSave() const } } bool ok = true; - const QString save = QInputDialog::getItem( - MMC->activeWindow(), tr("MCEdit"), tr("Choose which world to open:"), + const QString save = QInputDialog::getItem(QApplication::activeWindow(), tr("MCEdit"), tr("Choose which world to open:"), worlds, 0, false, &ok); if (ok) { @@ -49,7 +48,7 @@ QString MCEditTool::getSave() const void MCEditTool::runImpl() { - const QString mceditPath = MMC->settings()->get("MCEditPath").toString(); + const QString mceditPath = globalSettings->get("MCEditPath").toString(); const QString save = getSave(); if (save.isNull()) { @@ -80,17 +79,18 @@ void MCEditTool::runImpl() #endif } -void MCEditFactory::registerSettings(std::shared_ptr<SettingsObject> settings) +void MCEditFactory::registerSettings(SettingsObjectPtr settings) { settings->registerSetting("MCEditPath"); + globalSettings = settings; } BaseExternalTool *MCEditFactory::createTool(InstancePtr instance, QObject *parent) { - return new MCEditTool(instance, parent); + return new MCEditTool(globalSettings, instance, parent); } bool MCEditFactory::check(QString *error) { - return check(MMC->settings()->get("MCEditPath").toString(), error); + return check(globalSettings->get("MCEditPath").toString(), error); } bool MCEditFactory::check(const QString &path, QString *error) { diff --git a/logic/tools/MCEditTool.h b/logic/tools/MCEditTool.h index b5cfc64e..bd40f02d 100644 --- a/logic/tools/MCEditTool.h +++ b/logic/tools/MCEditTool.h @@ -6,7 +6,7 @@ class MCEditTool : public BaseDetachedTool { Q_OBJECT public: - explicit MCEditTool(InstancePtr instance, QObject *parent = 0); + explicit MCEditTool(SettingsObjectPtr settings, InstancePtr instance, QObject *parent = 0); protected: QString getSave() const; @@ -17,7 +17,7 @@ class MCEditFactory : public BaseDetachedToolFactory { public: QString name() const override { return "MCEdit"; } - void registerSettings(std::shared_ptr<SettingsObject> settings) override; + 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; |