summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/logic/CMakeLists.txt20
-rw-r--r--api/logic/Filter.cpp31
-rw-r--r--api/logic/Filter.h44
-rw-r--r--api/logic/FolderInstanceProvider.cpp43
-rw-r--r--api/logic/FolderInstanceProvider.h7
-rw-r--r--api/logic/InstanceCopyTask.cpp7
-rw-r--r--api/logic/InstanceCopyTask.h14
-rw-r--r--api/logic/InstanceCreationTask.cpp8
-rw-r--r--api/logic/InstanceCreationTask.h12
-rw-r--r--api/logic/InstanceImportTask.cpp8
-rw-r--r--api/logic/InstanceImportTask.h12
-rw-r--r--api/logic/InstanceTask.cpp9
-rw-r--r--api/logic/InstanceTask.h55
-rw-r--r--api/logic/minecraft/legacy/LegacyUpgradeTask.cpp7
-rw-r--r--api/logic/minecraft/legacy/LegacyUpgradeTask.h12
-rw-r--r--api/logic/modplatform/ftb/FtbPackDownloader.cpp84
-rw-r--r--api/logic/modplatform/ftb/FtbPackDownloader.h49
-rw-r--r--api/logic/modplatform/ftb/FtbPackFetchTask.cpp2
-rw-r--r--api/logic/modplatform/ftb/FtbPackFetchTask.h2
-rw-r--r--api/logic/modplatform/ftb/FtbPackInstallTask.cpp96
-rw-r--r--api/logic/modplatform/ftb/FtbPackInstallTask.h42
-rw-r--r--api/logic/modplatform/ftb/PackHelpers.h4
-rw-r--r--application/CMakeLists.txt85
-rw-r--r--application/FtbListModel.cpp2
-rw-r--r--application/InstancePageProvider.h22
-rw-r--r--application/InstanceWindow.cpp2
-rw-r--r--application/MainWindow.cpp44
-rw-r--r--application/MainWindow.h5
-rw-r--r--application/MultiMC.cpp2
-rw-r--r--application/SettingsUI.h2
-rw-r--r--application/VersionProxyModel.cpp71
-rw-r--r--application/VersionProxyModel.h19
-rw-r--r--application/dialogs/ChooseFtbPackDialog.cpp88
-rw-r--r--application/dialogs/ChooseFtbPackDialog.h34
-rw-r--r--application/dialogs/ChooseFtbPackDialog.ui119
-rw-r--r--application/dialogs/NewInstanceDialog.cpp263
-rw-r--r--application/dialogs/NewInstanceDialog.h43
-rw-r--r--application/dialogs/NewInstanceDialog.ui346
-rw-r--r--application/dialogs/VersionSelectDialog.cpp4
-rw-r--r--application/pagedialog/PageDialog.cpp11
-rw-r--r--application/pagedialog/PageDialog.h3
-rw-r--r--application/pages/BasePage.h15
-rw-r--r--application/pages/BasePageProvider.h4
-rw-r--r--application/pages/global/PackagesPage.cpp2
-rw-r--r--application/pages/global/PackagesPage.h2
-rw-r--r--application/pages/instance/InstanceSettingsPage.cpp (renamed from application/pages/InstanceSettingsPage.cpp)0
-rw-r--r--application/pages/instance/InstanceSettingsPage.h (renamed from application/pages/InstanceSettingsPage.h)2
-rw-r--r--application/pages/instance/InstanceSettingsPage.ui (renamed from application/pages/InstanceSettingsPage.ui)0
-rw-r--r--application/pages/instance/LegacyUpgradePage.cpp (renamed from application/pages/LegacyUpgradePage.cpp)7
-rw-r--r--application/pages/instance/LegacyUpgradePage.h (renamed from application/pages/LegacyUpgradePage.h)0
-rw-r--r--application/pages/instance/LegacyUpgradePage.ui (renamed from application/pages/LegacyUpgradePage.ui)0
-rw-r--r--application/pages/instance/LogPage.cpp (renamed from application/pages/LogPage.cpp)0
-rw-r--r--application/pages/instance/LogPage.h (renamed from application/pages/LogPage.h)2
-rw-r--r--application/pages/instance/LogPage.ui (renamed from application/pages/LogPage.ui)0
-rw-r--r--application/pages/instance/ModFolderPage.cpp (renamed from application/pages/ModFolderPage.cpp)4
-rw-r--r--application/pages/instance/ModFolderPage.h (renamed from application/pages/ModFolderPage.h)6
-rw-r--r--application/pages/instance/ModFolderPage.ui (renamed from application/pages/ModFolderPage.ui)0
-rw-r--r--application/pages/instance/NotesPage.cpp (renamed from application/pages/NotesPage.cpp)0
-rw-r--r--application/pages/instance/NotesPage.h (renamed from application/pages/NotesPage.h)2
-rw-r--r--application/pages/instance/NotesPage.ui (renamed from application/pages/NotesPage.ui)0
-rw-r--r--application/pages/instance/OtherLogsPage.cpp (renamed from application/pages/OtherLogsPage.cpp)4
-rw-r--r--application/pages/instance/OtherLogsPage.h (renamed from application/pages/OtherLogsPage.h)6
-rw-r--r--application/pages/instance/OtherLogsPage.ui (renamed from application/pages/OtherLogsPage.ui)0
-rw-r--r--application/pages/instance/ResourcePackPage.h (renamed from application/pages/ResourcePackPage.h)0
-rw-r--r--application/pages/instance/ScreenshotsPage.cpp (renamed from application/pages/ScreenshotsPage.cpp)2
-rw-r--r--application/pages/instance/ScreenshotsPage.h (renamed from application/pages/ScreenshotsPage.h)4
-rw-r--r--application/pages/instance/ScreenshotsPage.ui (renamed from application/pages/ScreenshotsPage.ui)0
-rw-r--r--application/pages/instance/TexturePackPage.h (renamed from application/pages/TexturePackPage.h)0
-rw-r--r--application/pages/instance/VersionPage.cpp (renamed from application/pages/VersionPage.cpp)0
-rw-r--r--application/pages/instance/VersionPage.h (renamed from application/pages/VersionPage.h)2
-rw-r--r--application/pages/instance/VersionPage.ui (renamed from application/pages/VersionPage.ui)0
-rw-r--r--application/pages/instance/WorldListPage.cpp (renamed from application/pages/WorldListPage.cpp)4
-rw-r--r--application/pages/instance/WorldListPage.h (renamed from application/pages/WorldListPage.h)6
-rw-r--r--application/pages/instance/WorldListPage.ui (renamed from application/pages/WorldListPage.ui)0
-rw-r--r--application/pages/modplatform/FTBPage.cpp152
-rw-r--r--application/pages/modplatform/FTBPage.h86
-rw-r--r--application/pages/modplatform/FTBPage.ui61
-rw-r--r--application/pages/modplatform/ImportPage.cpp125
-rw-r--r--application/pages/modplatform/ImportPage.h70
-rw-r--r--application/pages/modplatform/ImportPage.ui52
-rw-r--r--application/pages/modplatform/TechnicPage.cpp29
-rw-r--r--application/pages/modplatform/TechnicPage.h61
-rw-r--r--application/pages/modplatform/TechnicPage.ui48
-rw-r--r--application/pages/modplatform/TwitchPage.cpp29
-rw-r--r--application/pages/modplatform/TwitchPage.h61
-rw-r--r--application/pages/modplatform/TwitchPage.ui48
-rw-r--r--application/pages/modplatform/VanillaPage.cpp114
-rw-r--r--application/pages/modplatform/VanillaPage.h75
-rw-r--r--application/pages/modplatform/VanillaPage.ui149
-rw-r--r--application/resources/multimc/multimc.qrc6
-rw-r--r--application/resources/multimc/scalable/technic.svg1
-rw-r--r--application/resources/multimc/scalable/twitch.svg63
-rw-r--r--application/widgets/InstanceCardWidget.ui61
-rw-r--r--application/widgets/JavaSettingsWidget.cpp4
-rw-r--r--application/widgets/PageContainer.cpp3
-rw-r--r--application/widgets/PageContainer.h10
-rw-r--r--application/widgets/VersionSelectWidget.cpp23
-rw-r--r--application/widgets/VersionSelectWidget.h6
98 files changed, 1903 insertions, 1241 deletions
diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt
index e40f188e..c6daef6f 100644
--- a/api/logic/CMakeLists.txt
+++ b/api/logic/CMakeLists.txt
@@ -8,14 +8,10 @@ set(CORE_SOURCES
BaseInstaller.cpp
BaseVersionList.h
BaseVersionList.cpp
- InstanceCreationTask.h
- InstanceCreationTask.cpp
- InstanceCopyTask.h
- InstanceCopyTask.cpp
- InstanceImportTask.h
- InstanceImportTask.cpp
InstanceList.h
InstanceList.cpp
+ InstanceTask.h
+ InstanceTask.cpp
LoggedProcess.h
LoggedProcess.cpp
MessageLevel.cpp
@@ -32,6 +28,14 @@ set(CORE_SOURCES
MMCStrings.h
MMCStrings.cpp
+ # Basic instance manipulation tasks (derived from InstanceTask)
+ InstanceCreationTask.h
+ InstanceCreationTask.cpp
+ InstanceCopyTask.h
+ InstanceCopyTask.cpp
+ InstanceImportTask.h
+ InstanceImportTask.cpp
+
# Use tracking separate from memory management
Usable.h
@@ -42,6 +46,10 @@ set(CORE_SOURCES
Env.h
Env.cpp
+ # String filters
+ Filter.h
+ Filter.cpp
+
# JSON parsing helpers
Json.h
Json.cpp
diff --git a/api/logic/Filter.cpp b/api/logic/Filter.cpp
new file mode 100644
index 00000000..7f6667ae
--- /dev/null
+++ b/api/logic/Filter.cpp
@@ -0,0 +1,31 @@
+#include "Filter.h"
+
+Filter::~Filter(){}
+
+ContainsFilter::ContainsFilter(const QString& pattern) : pattern(pattern){}
+ContainsFilter::~ContainsFilter(){}
+bool ContainsFilter::accepts(const QString& value)
+{
+ return value.contains(pattern);
+}
+
+ExactFilter::ExactFilter(const QString& pattern) : pattern(pattern){}
+ExactFilter::~ExactFilter(){}
+bool ExactFilter::accepts(const QString& value)
+{
+ return value.contains(pattern);
+}
+
+RegexpFilter::RegexpFilter(const QString& regexp, bool invert)
+ :invert(invert)
+{
+ pattern.setPattern(regexp);
+ pattern.optimize();
+}
+RegexpFilter::~RegexpFilter(){}
+bool RegexpFilter::accepts(const QString& value)
+{
+ auto match = pattern.match(value);
+ bool matched = match.hasMatch();
+ return invert ? (!matched) : (matched);
+}
diff --git a/api/logic/Filter.h b/api/logic/Filter.h
new file mode 100644
index 00000000..8de7d8f9
--- /dev/null
+++ b/api/logic/Filter.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <QString>
+#include <QRegularExpression>
+
+#include "multimc_logic_export.h"
+
+class MULTIMC_LOGIC_EXPORT Filter
+{
+public:
+ virtual ~Filter();
+ virtual bool accepts(const QString & value) = 0;
+};
+
+class MULTIMC_LOGIC_EXPORT ContainsFilter: public Filter
+{
+public:
+ ContainsFilter(const QString &pattern);
+ virtual ~ContainsFilter();
+ bool accepts(const QString & value) override;
+private:
+ QString pattern;
+};
+
+class MULTIMC_LOGIC_EXPORT ExactFilter: public Filter
+{
+public:
+ ExactFilter(const QString &pattern);
+ virtual ~ExactFilter();
+ bool accepts(const QString & value) override;
+private:
+ QString pattern;
+};
+
+class MULTIMC_LOGIC_EXPORT RegexpFilter: public Filter
+{
+public:
+ RegexpFilter(const QString &regexp, bool invert);
+ virtual ~RegexpFilter();
+ bool accepts(const QString & value) override;
+private:
+ QRegularExpression pattern;
+ bool invert = false;
+};
diff --git a/api/logic/FolderInstanceProvider.cpp b/api/logic/FolderInstanceProvider.cpp
index 52e23254..69ba6c82 100644
--- a/api/logic/FolderInstanceProvider.cpp
+++ b/api/logic/FolderInstanceProvider.cpp
@@ -412,46 +412,13 @@ private:
QTimer m_backoffTimer;
};
-#include "InstanceImportTask.h"
-Task * FolderInstanceProvider::zipImportTask(const QUrl sourceUrl, const QString& instName, const QString& instGroup, const QString& instIcon)
+#include "InstanceTask.h"
+Task * FolderInstanceProvider::wrapInstanceTask(InstanceTask * task)
{
auto stagingPath = getStagedInstancePath();
- auto task = new InstanceImportTask(m_globalSettings, sourceUrl, stagingPath, instName, instIcon, instGroup);
- return new FolderInstanceStaging(this, task, stagingPath, instName, instGroup);
-}
-
-#include "InstanceCreationTask.h"
-Task * FolderInstanceProvider::creationTask(BaseVersionPtr version, const QString& instName, const QString& instGroup, const QString& instIcon)
-{
- auto stagingPath = getStagedInstancePath();
- auto task = new InstanceCreationTask(m_globalSettings, stagingPath, version, instName, instIcon, instGroup);
- return new FolderInstanceStaging(this, task, stagingPath, instName, instGroup);
-}
-
-#include <modplatform/ftb/FtbPackInstallTask.h>
-Task * FolderInstanceProvider::ftbCreationTask(FtbPackDownloader *downloader, const QString& instName, const QString& instGroup, const QString& instIcon)
-{
- auto stagingPath = getStagedInstancePath();
- auto task = new FtbPackInstallTask(downloader, m_globalSettings, stagingPath, instName, instIcon, instGroup);
- return new FolderInstanceStaging(this, task, stagingPath, instName, instGroup);
-}
-
-#include "InstanceCopyTask.h"
-Task * FolderInstanceProvider::copyTask(const InstancePtr& oldInstance, const QString& instName, const QString& instGroup, const QString& instIcon, bool copySaves)
-{
- auto stagingPath = getStagedInstancePath();
- auto task = new InstanceCopyTask(m_globalSettings, stagingPath, oldInstance, instName, instIcon, instGroup, copySaves);
- return new FolderInstanceStaging(this, task, stagingPath, instName, instGroup);
-}
-
-// FIXME: find a better place for this
-#include "minecraft/legacy/LegacyUpgradeTask.h"
-Task * FolderInstanceProvider::legacyUpgradeTask(const InstancePtr& oldInstance)
-{
- auto stagingPath = getStagedInstancePath();
- QString newName = tr("%1 (Migrated)").arg(oldInstance->name());
- auto task = new LegacyUpgradeTask(m_globalSettings, stagingPath, oldInstance, newName);
- return new FolderInstanceStaging(this, task, stagingPath, newName, oldInstance->group());
+ task->setStagingPath(stagingPath);
+ task->setParentSettings(m_globalSettings);
+ return new FolderInstanceStaging(this, task, stagingPath, task->name(), task->group());
}
QString FolderInstanceProvider::getStagedInstancePath()
diff --git a/api/logic/FolderInstanceProvider.h b/api/logic/FolderInstanceProvider.h
index 2641a46b..e13dcfe9 100644
--- a/api/logic/FolderInstanceProvider.h
+++ b/api/logic/FolderInstanceProvider.h
@@ -2,9 +2,9 @@
#include "BaseInstanceProvider.h"
#include <QMap>
-#include <modplatform/ftb/FtbPackDownloader.h>
class QFileSystemWatcher;
+class InstanceTask;
class MULTIMC_LOGIC_EXPORT FolderInstanceProvider : public BaseInstanceProvider
{
@@ -20,6 +20,7 @@ public:
InstancePtr loadInstance(const InstanceId& id) override;
+ /*
// create instance in this provider
Task * creationTask(BaseVersionPtr version, const QString &instName, const QString &instGroup, const QString &instIcon);
@@ -34,6 +35,10 @@ public:
// migrate an instance to the current format
Task * legacyUpgradeTask(const InstancePtr& oldInstance);
+*/
+
+ // Wrap an instance creation task in some more task machinery and make it ready to be used
+ Task * wrapInstanceTask(InstanceTask * task);
/**
* Create a new empty staging area for instance creation and @return a path/key top commit it later.
diff --git a/api/logic/InstanceCopyTask.cpp b/api/logic/InstanceCopyTask.cpp
index 9ede65f5..62c22362 100644
--- a/api/logic/InstanceCopyTask.cpp
+++ b/api/logic/InstanceCopyTask.cpp
@@ -6,14 +6,9 @@
#include "pathmatcher/RegexpMatcher.h"
#include <QtConcurrentRun>
-InstanceCopyTask::InstanceCopyTask(SettingsObjectPtr settings, const QString & stagingPath, InstancePtr origInstance, const QString& instName, const QString& instIcon, const QString& instGroup, bool copySaves)
+InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, bool copySaves)
{
- m_globalSettings = settings;
- m_stagingPath = stagingPath;
m_origInstance = origInstance;
- m_instName = instName;
- m_instIcon = instIcon;
- m_instGroup = instGroup;
if(!copySaves)
{
diff --git a/api/logic/InstanceCopyTask.h b/api/logic/InstanceCopyTask.h
index dc46bfec..a8dc9783 100644
--- a/api/logic/InstanceCopyTask.h
+++ b/api/logic/InstanceCopyTask.h
@@ -9,16 +9,15 @@
#include "settings/SettingsObject.h"
#include "BaseVersion.h"
#include "BaseInstance.h"
-
+#include "InstanceTask.h"
class BaseInstanceProvider;
-class MULTIMC_LOGIC_EXPORT InstanceCopyTask : public Task
+class MULTIMC_LOGIC_EXPORT InstanceCopyTask : public InstanceTask
{
Q_OBJECT
public:
- explicit InstanceCopyTask(SettingsObjectPtr settings, const QString & stagingPath, InstancePtr origInstance, const QString &instName,
- const QString &instIcon, const QString &instGroup, bool copySaves);
+ explicit InstanceCopyTask(InstancePtr origInstance, bool copySaves);
protected:
//! Entry point for tasks.
@@ -27,15 +26,8 @@ protected:
void copyAborted();
private: /* data */
- SettingsObjectPtr m_globalSettings;
InstancePtr m_origInstance;
- QString m_instName;
- QString m_instIcon;
- QString m_instGroup;
- QString m_stagingPath;
QFuture<bool> m_copyFuture;
QFutureWatcher<bool> m_copyFutureWatcher;
std::unique_ptr<IPathMatcher> m_matcher;
};
-
-
diff --git a/api/logic/InstanceCreationTask.cpp b/api/logic/InstanceCreationTask.cpp
index 8a68815a..6dc2496c 100644
--- a/api/logic/InstanceCreationTask.cpp
+++ b/api/logic/InstanceCreationTask.cpp
@@ -7,14 +7,8 @@
#include "minecraft/MinecraftInstance.h"
#include "minecraft/ComponentList.h"
-InstanceCreationTask::InstanceCreationTask(SettingsObjectPtr settings, const QString & stagingPath, BaseVersionPtr version,
- const QString& instName, const QString& instIcon, const QString& instGroup)
+InstanceCreationTask::InstanceCreationTask(BaseVersionPtr version)
{
- m_globalSettings = settings;
- m_stagingPath = stagingPath;
- m_instName = instName;
- m_instIcon = instIcon;
- m_instGroup = instGroup;
m_version = version;
}
diff --git a/api/logic/InstanceCreationTask.h b/api/logic/InstanceCreationTask.h
index 49fd4615..e06eacbb 100644
--- a/api/logic/InstanceCreationTask.h
+++ b/api/logic/InstanceCreationTask.h
@@ -6,24 +6,18 @@
#include <QUrl>
#include "settings/SettingsObject.h"
#include "BaseVersion.h"
+#include "InstanceTask.h"
-class MULTIMC_LOGIC_EXPORT InstanceCreationTask : public Task
+class MULTIMC_LOGIC_EXPORT InstanceCreationTask : public InstanceTask
{
Q_OBJECT
public:
- explicit InstanceCreationTask(SettingsObjectPtr settings, const QString & stagingPath, BaseVersionPtr version, const QString &instName,
- const QString &instIcon, const QString &instGroup);
+ explicit InstanceCreationTask(BaseVersionPtr version);
protected:
//! Entry point for tasks.
virtual void executeTask() override;
private: /* data */
- SettingsObjectPtr m_globalSettings;
- QString m_stagingPath;
BaseVersionPtr m_version;
- QString m_instName;
- QString m_instIcon;
- QString m_instGroup;
};
-
diff --git a/api/logic/InstanceImportTask.cpp b/api/logic/InstanceImportTask.cpp
index 7fae97b8..b5375cbc 100644
--- a/api/logic/InstanceImportTask.cpp
+++ b/api/logic/InstanceImportTask.cpp
@@ -16,15 +16,9 @@
#include "modplatform/flame/PackManifest.h"
#include "Json.h"
-InstanceImportTask::InstanceImportTask(SettingsObjectPtr settings, const QUrl sourceUrl, const QString & stagingPath,
- const QString &instName, const QString &instIcon, const QString &instGroup)
+InstanceImportTask::InstanceImportTask(const QUrl sourceUrl)
{
- m_globalSettings = settings;
m_sourceUrl = sourceUrl;
- m_stagingPath = stagingPath;
- m_instName = instName;
- m_instIcon = instIcon;
- m_instGroup = instGroup;
}
void InstanceImportTask::executeTask()
diff --git a/api/logic/InstanceImportTask.h b/api/logic/InstanceImportTask.h
index 99397009..06778dfe 100644
--- a/api/logic/InstanceImportTask.h
+++ b/api/logic/InstanceImportTask.h
@@ -1,6 +1,6 @@
#pragma once
-#include "tasks/Task.h"
+#include "InstanceTask.h"
#include "multimc_logic_export.h"
#include "net/NetJob.h"
#include <QUrl>
@@ -16,12 +16,11 @@ namespace Flame
class FileResolvingTask;
}
-class MULTIMC_LOGIC_EXPORT InstanceImportTask : public Task
+class MULTIMC_LOGIC_EXPORT InstanceImportTask : public InstanceTask
{
Q_OBJECT
public:
- explicit InstanceImportTask(SettingsObjectPtr settings, const QUrl sourceUrl, const QString & stagingPath, const QString &instName,
- const QString &instIcon, const QString &instGroup);
+ explicit InstanceImportTask(const QUrl sourceUrl);
protected:
//! Entry point for tasks.
@@ -40,16 +39,11 @@ private slots:
void extractAborted();
private: /* data */
- SettingsObjectPtr m_globalSettings;
NetJobPtr m_filesNetJob;
shared_qobject_ptr<Flame::FileResolvingTask> m_modIdResolver;
QUrl m_sourceUrl;
QString m_archivePath;
bool m_downloadRequired = false;
- QString m_instName;
- QString m_instIcon;
- QString m_instGroup;
- QString m_stagingPath;
std::unique_ptr<QuaZip> m_packZip;
QFuture<QStringList> m_extractFuture;
QFutureWatcher<QStringList> m_extractFutureWatcher;
diff --git a/api/logic/InstanceTask.cpp b/api/logic/InstanceTask.cpp
new file mode 100644
index 00000000..dd132877
--- /dev/null
+++ b/api/logic/InstanceTask.cpp
@@ -0,0 +1,9 @@
+#include "InstanceTask.h"
+
+InstanceTask::InstanceTask()
+{
+}
+
+InstanceTask::~InstanceTask()
+{
+}
diff --git a/api/logic/InstanceTask.h b/api/logic/InstanceTask.h
new file mode 100644
index 00000000..8fc98eb7
--- /dev/null
+++ b/api/logic/InstanceTask.h
@@ -0,0 +1,55 @@
+#pragma once
+
+#include "tasks/Task.h"
+#include "multimc_logic_export.h"
+#include "settings/SettingsObject.h"
+
+class BaseInstanceProvider;
+
+class MULTIMC_LOGIC_EXPORT InstanceTask : public Task
+{
+ Q_OBJECT
+public:
+ explicit InstanceTask();
+ virtual ~InstanceTask();
+
+ void setParentSettings(SettingsObjectPtr settings)
+ {
+ m_globalSettings = settings;
+ }
+
+ void setStagingPath(const QString &stagingPath)
+ {
+ m_stagingPath = stagingPath;
+ }
+
+ void setName(const QString &name)
+ {
+ m_instName = name;
+ }
+ QString name() const
+ {
+ return m_instName;
+ }
+
+ void setIcon(const QString &icon)
+ {
+ m_instIcon = icon;
+ }
+
+ void setGroup(const QString &group)
+ {
+ m_instGroup = group;
+ }
+ QString group() const
+ {
+ return m_instGroup;
+ }
+
+protected: /* data */
+ SettingsObjectPtr m_globalSettings;
+ QString m_instName;
+ QString m_instIcon;
+ QString m_instGroup;
+ QString m_stagingPath;
+};
diff --git a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
index 9fc6d92b..5cc3b5d9 100644
--- a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
+++ b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
@@ -10,12 +10,9 @@
#include "minecraft/ComponentList.h"
#include "classparser.h"
-LegacyUpgradeTask::LegacyUpgradeTask(SettingsObjectPtr settings, const QString & stagingPath, InstancePtr origInstance, const QString & newName)
+LegacyUpgradeTask::LegacyUpgradeTask(InstancePtr origInstance)
{
- m_globalSettings = settings;
- m_stagingPath = stagingPath;
m_origInstance = origInstance;
- m_newName = newName;
}
void LegacyUpgradeTask::executeTask()
@@ -70,7 +67,7 @@ void LegacyUpgradeTask::copyFinished()
// NOTE: this scope ensures the instance is fully saved before we emitSucceeded
{
MinecraftInstance inst(m_globalSettings, instanceSettings, m_stagingPath);
- inst.setName(m_newName);
+ inst.setName(m_instName);
inst.init();
QString preferredVersionNumber = decideVersion(legacyInst->currentVersionId(), legacyInst->intendedVersionId());
diff --git a/api/logic/minecraft/legacy/LegacyUpgradeTask.h b/api/logic/minecraft/legacy/LegacyUpgradeTask.h
index 56896385..a93dd0d9 100644
--- a/api/logic/minecraft/legacy/LegacyUpgradeTask.h
+++ b/api/logic/minecraft/legacy/LegacyUpgradeTask.h
@@ -1,6 +1,6 @@
#pragma once
-#include "tasks/Task.h"
+#include "InstanceTask.h"
#include "multimc_logic_export.h"
#include "net/NetJob.h"
#include <QUrl>
@@ -13,11 +13,11 @@
class BaseInstanceProvider;
-class MULTIMC_LOGIC_EXPORT LegacyUpgradeTask : public Task
+class MULTIMC_LOGIC_EXPORT LegacyUpgradeTask : public InstanceTask
{
Q_OBJECT
public:
- explicit LegacyUpgradeTask(SettingsObjectPtr settings, const QString & stagingPath, InstancePtr origInstance, const QString & newName);
+ explicit LegacyUpgradeTask(InstancePtr origInstance);
protected:
//! Entry point for tasks.
@@ -26,13 +26,7 @@ protected:
void copyAborted();
private: /* data */
- SettingsObjectPtr m_globalSettings;
InstancePtr m_origInstance;
- QString m_stagingPath;
- QString m_newName;
QFuture<bool> m_copyFuture;
QFutureWatcher<bool> m_copyFutureWatcher;
};
-
-
-
diff --git a/api/logic/modplatform/ftb/FtbPackDownloader.cpp b/api/logic/modplatform/ftb/FtbPackDownloader.cpp
index caadd4ae..3e274c9e 100644
--- a/api/logic/modplatform/ftb/FtbPackDownloader.cpp
+++ b/api/logic/modplatform/ftb/FtbPackDownloader.cpp
@@ -3,36 +3,25 @@
#include "FtbPackFetchTask.h"
#include "Env.h"
-FtbPackDownloader::FtbPackDownloader() {
+FtbPackDownloader::FtbPackDownloader()
+{
done = false;
fetching = false;
}
-FtbPackDownloader::~FtbPackDownloader(){
-}
-
-bool FtbPackDownloader::isValidPackSelected(){
- FtbModpack dummy;
- dummy.name = "__INVALID__";
-
- FtbModpack other = fetchedPacks.value(selected.name, dummy);
- if(other.name == "__INVALID__") {
- return false;
- }
-
- return other.oldVersions.contains(selectedVersion) && !other.broken;
-}
-
-QString FtbPackDownloader::getSuggestedInstanceName() {
- return selected.name;
+FtbPackDownloader::~FtbPackDownloader()
+{
}
-FtbModpackList FtbPackDownloader::getModpacks() {
+FtbModpackList FtbPackDownloader::getModpacks()
+{
return static_cast<FtbModpackList>(fetchedPacks.values());
}
-void FtbPackDownloader::fetchModpacks(bool force = false){
- if(fetching || (!force && done)) {
+void FtbPackDownloader::fetchModpacks(bool force = false)
+{
+ if(fetching || (!force && done))
+ {
qDebug() << "Skipping modpack refetch because done or already fetching [done =>" << done << "| fetching =>" << fetching << "]";
return;
}
@@ -46,8 +35,10 @@ void FtbPackDownloader::fetchModpacks(bool force = false){
}
-void FtbPackDownloader::fetchSuccess(FtbModpackList modpacks) {
- for(int i = 0; i < modpacks.size(); i++) {
+void FtbPackDownloader::fetchSuccess(FtbModpackList modpacks)
+{
+ for(int i = 0; i < modpacks.size(); i++)
+ {
fetchedPacks.insert(modpacks.at(i).name, modpacks.at(i));
}
@@ -57,53 +48,10 @@ void FtbPackDownloader::fetchSuccess(FtbModpackList modpacks) {
fetchTask->deleteLater();
}
-void FtbPackDownloader::fetchFailed(QString reason) {
+void FtbPackDownloader::fetchFailed(QString reason)
+{
qWarning() << "Failed to fetch FtbData" << reason;
fetching = false;
emit packFetchFailed();
fetchTask->deleteLater();
}
-
-void FtbPackDownloader::selectPack(FtbModpack modpack, QString version) {
- selected = modpack;
- selectedVersion = version;
-}
-
-FtbModpack FtbPackDownloader::getSelectedPack() {
- return selected;
-}
-
-void FtbPackDownloader::downloadSelected(MetaEntryPtr cache) {
- NetJob *job = new NetJob("Downlad FTB Pack");
-
- cache->setStale(true);
- QString url = QString("http://ftb.cursecdn.com/FTB2/modpacks/%1/%2/%3").arg(selected.dir, selectedVersion.replace(".", "_"), selected.file);
- job->addNetAction(Net::Download::makeCached(url, cache));
- downloadPath = cache->getFullPath();
-
- netJobContainer.reset(job);
-
- connect(job, &NetJob::succeeded, this, &FtbPackDownloader::_downloadSucceeded);
- connect(job, &NetJob::failed, this, &FtbPackDownloader::_downloadFailed);
- connect(job, &NetJob::progress, this, &FtbPackDownloader::_downloadProgress);
- job->start();
-}
-
-void FtbPackDownloader::_downloadSucceeded() {
- netJobContainer.reset();
- emit downloadSucceded(downloadPath);
-}
-
-void FtbPackDownloader::_downloadProgress(qint64 current, qint64 total) {
- emit downloadProgress(current, total);
-}
-
-void FtbPackDownloader::_downloadFailed(QString reason) {
- netJobContainer.reset();
- emit downloadFailed(reason);
-}
-
-NetJobPtr FtbPackDownloader::getNetJob()
-{
- return netJobContainer;
-}
diff --git a/api/logic/modplatform/ftb/FtbPackDownloader.h b/api/logic/modplatform/ftb/FtbPackDownloader.h
index c5cc9bd2..cf7eb567 100644
--- a/api/logic/modplatform/ftb/FtbPackDownloader.h
+++ b/api/logic/modplatform/ftb/FtbPackDownloader.h
@@ -11,54 +11,29 @@
#pragma once
-class FtbPackDownloader;
-class MULTIMC_LOGIC_EXPORT FtbPackDownloader : public QObject {
-
+class MULTIMC_LOGIC_EXPORT FtbPackDownloader : public QObject
+{
Q_OBJECT
-private:
- QMap<QString, FtbModpack> fetchedPacks;
- bool fetching = false;
- bool done = false;
-
- FtbModpack selected;
- QString selectedVersion;
- QString downloadPath;
-
- FtbPackFetchTask *fetchTask = 0;
- NetJobPtr netJobContainer;
-
- void _downloadSucceeded();
- void _downloadFailed(QString reason);
- void _downloadProgress(qint64 current, qint64 total);
-
-private slots:
- void fetchSuccess(FtbModpackList modlist);
- void fetchFailed(QString reason);
-
public:
FtbPackDownloader();
- ~FtbPackDownloader();
-
- bool isValidPackSelected();
- void selectPack(FtbModpack modpack, QString version);
-
- FtbModpack getSelectedPack();
+ virtual ~FtbPackDownloader();
void fetchModpacks(bool force);
- void downloadSelected(MetaEntryPtr cache);
-
- QString getSuggestedInstanceName();
-
FtbModpackList getModpacks();
- NetJobPtr getNetJob();
signals:
void ready();
void packFetchFailed();
- void downloadSucceded(QString archivePath);
- void downloadFailed(QString reason);
- void downloadProgress(qint64 current, qint64 total);
+private slots:
+ void fetchSuccess(FtbModpackList modlist);
+ void fetchFailed(QString reason);
+private:
+ QMap<QString, FtbModpack> fetchedPacks;
+ bool fetching = false;
+ bool done = false;
+
+ FtbPackFetchTask *fetchTask = 0;
};
diff --git a/api/logic/modplatform/ftb/FtbPackFetchTask.cpp b/api/logic/modplatform/ftb/FtbPackFetchTask.cpp
index 9e151186..30253bb9 100644
--- a/api/logic/modplatform/ftb/FtbPackFetchTask.cpp
+++ b/api/logic/modplatform/ftb/FtbPackFetchTask.cpp
@@ -58,6 +58,8 @@ void FtbPackFetchTask::fileDownloadFinished(){
modpack.mods = element.attribute("mods");
modpack.image = element.attribute("image");
modpack.oldVersions = element.attribute("oldVersions").split(";");
+ modpack.broken = false;
+ modpack.bugged = false;
//remove empty if the xml is bugged
for(QString curr : modpack.oldVersions) {
diff --git a/api/logic/modplatform/ftb/FtbPackFetchTask.h b/api/logic/modplatform/ftb/FtbPackFetchTask.h
index 3cfac4ed..a2e4b5ab 100644
--- a/api/logic/modplatform/ftb/FtbPackFetchTask.h
+++ b/api/logic/modplatform/ftb/FtbPackFetchTask.h
@@ -12,7 +12,7 @@ class MULTIMC_LOGIC_EXPORT FtbPackFetchTask : public QObject {
public:
FtbPackFetchTask();
- ~FtbPackFetchTask();
+ virtual ~FtbPackFetchTask();
void fetch();
diff --git a/api/logic/modplatform/ftb/FtbPackInstallTask.cpp b/api/logic/modplatform/ftb/FtbPackInstallTask.cpp
index 530f72ca..e3bb2340 100644
--- a/api/logic/modplatform/ftb/FtbPackInstallTask.cpp
+++ b/api/logic/modplatform/ftb/FtbPackInstallTask.cpp
@@ -9,52 +9,65 @@
#include "minecraft/ComponentList.h"
#include "minecraft/GradleSpecifier.h"
-FtbPackInstallTask::FtbPackInstallTask(FtbPackDownloader *downloader, SettingsObjectPtr settings,
- const QString &stagingPath, const QString &instName, const QString &instIcon, const QString &instGroup) :
- m_globalSettings(settings), m_stagingPath(stagingPath), m_instName(instName), m_instIcon(instIcon), m_instGroup(instGroup)
+FtbPackInstallTask::FtbPackInstallTask(FtbModpack pack, QString version)
{
- m_downloader = downloader;
+ m_pack = pack;
+ m_version = version;
}
-void FtbPackInstallTask::executeTask() {
+void FtbPackInstallTask::executeTask()
+{
downloadPack();
}
-void FtbPackInstallTask::downloadPack(){
- FtbModpack toInstall = m_downloader->getSelectedPack();
- setStatus(tr("Downloading zip for %1").arg(toInstall.name));
+void FtbPackInstallTask::downloadPack()
+{
+ setStatus(tr("Downloading zip for %1").arg(m_pack.name));
+
+ auto entry = ENV.metacache()->resolveEntry("general", "FTBPacks/" + m_pack.name);
+ NetJob *job = new NetJob("Downlad FTB Pack");
+
+ entry->setStale(true);
+ QString url = QString("http://ftb.cursecdn.com/FTB2/modpacks/%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
+ job->addNetAction(Net::Download::makeCached(url, entry));
+ archivePath = entry->getFullPath();
- auto entry = ENV.metacache()->resolveEntry("general", "FTBPacks/" + toInstall.name);
- m_downloader->downloadSelected(entry);
+ netJobContainer.reset(job);
+ connect(job, &NetJob::succeeded, this, &FtbPackInstallTask::onDownloadSucceeded);
+ connect(job, &NetJob::failed, this, &FtbPackInstallTask::onDownloadFailed);
+ connect(job, &NetJob::progress, this, &FtbPackInstallTask::onDownloadProgress);
+ job->start();
- connect(m_downloader, &FtbPackDownloader::downloadSucceded, this, &FtbPackInstallTask::onDownloadSucceeded);
- connect(m_downloader, &FtbPackDownloader::downloadProgress, this, &FtbPackInstallTask::onDownloadProgress);
- connect(m_downloader, &FtbPackDownloader::downloadFailed, this,&FtbPackInstallTask::onDownloadFailed);
progress(1, 4);
}
-void FtbPackInstallTask::onDownloadSucceeded(QString archivePath){
+void FtbPackInstallTask::onDownloadSucceeded()
+{
abortable = false;
- unzip(archivePath);
+ unzip();
}
-void FtbPackInstallTask::onDownloadFailed(QString reason) {
+void FtbPackInstallTask::onDownloadFailed(QString reason)
+{
emitFailed(reason);
}
-void FtbPackInstallTask::onDownloadProgress(qint64 current, qint64 total){
+void FtbPackInstallTask::onDownloadProgress(qint64 current, qint64 total)
+{
abortable = true;
progress(current, total * 4);
- setStatus(tr("Downloading zip for %1 (%2\%)").arg(m_downloader->getSelectedPack().name).arg(current / 10));
+ setStatus(tr("Downloading zip for %1 (%2\%)").arg(m_pack.name).arg(current / 10));
}
-void FtbPackInstallTask::unzip(QString archivePath) {
+void FtbPackInstallTask::unzip()
+{
progress(2, 4);
setStatus(tr("Extracting modpack"));
QDir extractDir(m_stagingPath);
m_packZip.reset(new QuaZip(archivePath));
- if(!m_packZip->open(QuaZip::mdUnzip)) {
+ if(!m_packZip->open(QuaZip::mdUnzip))
+ {
emitFailed(tr("Failed to open modpack file %1!").arg(archivePath));
return;
}
@@ -65,22 +78,26 @@ void FtbPackInstallTask::unzip(QString archivePath) {
m_extractFutureWatcher.setFuture(m_extractFuture);
}
-void FtbPackInstallTask::onUnzipFinished() {
+void FtbPackInstallTask::onUnzipFinished()
+{
install();
}
-void FtbPackInstallTask::onUnzipCanceled() {
+void FtbPackInstallTask::onUnzipCanceled()
+{
emitAborted();
}
-void FtbPackInstallTask::install() {
+void FtbPackInstallTask::install()
+{
progress(3, 4);
- FtbModpack toInstall = m_downloader->getSelectedPack();
setStatus(tr("Installing modpack"));
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
- if(unzipMcDir.exists()) {
+ if(unzipMcDir.exists())
+ {
//ok, found minecraft dir, move contents to instance dir
- if(!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft")) {
+ if(!QDir().rename(m_stagingPath + "/unzip/minecraft", m_stagingPath + "/.minecraft"))
+ {
emitFailed(tr("Failed to move unzipped minecraft!"));
return;
}
@@ -94,14 +111,15 @@ void FtbPackInstallTask::install() {
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
auto components = instance.getComponentList();
components->buildingFromScratch();
- components->setComponentVersion("net.minecraft", toInstall.mcVersion, true);
+ components->setComponentVersion("net.minecraft", m_pack.mcVersion, true);
bool fallback = true;
//handle different versions
QFile packJson(m_stagingPath + "/.minecraft/pack.json");
QDir jarmodDir = QDir(m_stagingPath + "/unzip/instMods");
- if(packJson.exists()) {
+ if(packJson.exists())
+ {
packJson.open(QIODevice::ReadOnly | QIODevice::Text);
QJsonDocument doc = QJsonDocument::fromJson(packJson.readAll());
packJson.close();
@@ -109,15 +127,17 @@ void FtbPackInstallTask::install() {
//we only care about the libs
QJsonArray libs = doc.object().value("libraries").toArray();
- foreach (const QJsonValue &value, libs) {
+ foreach (const QJsonValue &value, libs)
+ {
QString nameValue = value.toObject().value("name").toString();
- if(!nameValue.startsWith("net.minecraftforge")) {
+ if(!nameValue.startsWith("net.minecraftforge"))
+ {
continue;
}
GradleSpecifier forgeVersion(nameValue);
- components->setComponentVersion("net.minecraftforge", forgeVersion.version().replace(toInstall.mcVersion, "").replace("-", ""));
+ components->setComponentVersion("net.minecraftforge", forgeVersion.version().replace(m_pack.mcVersion, "").replace("-", ""));
packJson.remove();
fallback = false;
break;
@@ -125,7 +145,8 @@ void FtbPackInstallTask::install() {
}
- if(jarmodDir.exists()) {
+ if(jarmodDir.exists())
+ {
qDebug() << "Found jarmods, installing...";
QStringList jarmods;
@@ -142,7 +163,8 @@ void FtbPackInstallTask::install() {
//just nuke unzip directory, it s not needed anymore
FS::deletePath(m_stagingPath + "/unzip");
- if(fallback) {
+ if(fallback)
+ {
//TODO: Some fallback mechanism... or just keep failing!
emitFailed(tr("No installation method found!"));
return;
@@ -154,7 +176,8 @@ void FtbPackInstallTask::install() {
instance.init();
instance.setName(m_instName);
- if(m_instIcon == "default") {
+ if(m_instIcon == "default")
+ {
m_instIcon = "ftb_logo";
}
instance.setIconKey(m_instIcon);
@@ -166,8 +189,9 @@ void FtbPackInstallTask::install() {
bool FtbPackInstallTask::abort()
{
- if(abortable) {
- return m_downloader->getNetJob()->abort();
+ if(abortable)
+ {
+ return netJobContainer->abort();
}
return false;
}
diff --git a/api/logic/modplatform/ftb/FtbPackInstallTask.h b/api/logic/modplatform/ftb/FtbPackInstallTask.h
index 7d6e5276..64f4809d 100644
--- a/api/logic/modplatform/ftb/FtbPackInstallTask.h
+++ b/api/logic/modplatform/ftb/FtbPackInstallTask.h
@@ -1,5 +1,5 @@
#pragma once
-#include "tasks/Task.h"
+#include "InstanceTask.h"
#include "modplatform/ftb/FtbPackDownloader.h"
#include "BaseInstanceProvider.h"
#include "net/NetJob.h"
@@ -9,47 +9,41 @@
#include "meta/Version.h"
#include "meta/VersionList.h"
-class MULTIMC_LOGIC_EXPORT FtbPackInstallTask : public Task {
+class MULTIMC_LOGIC_EXPORT FtbPackInstallTask : public InstanceTask {
Q_OBJECT
public:
- explicit FtbPackInstallTask(FtbPackDownloader *downloader, SettingsObjectPtr settings, const QString &stagingPath, const QString &instName,
- const QString &instIcon, const QString &instGroup);
+ explicit FtbPackInstallTask(FtbModpack pack, QString version);
+ virtual ~FtbPackInstallTask(){}
+
bool abort() override;
protected:
//! Entry point for tasks.
virtual void executeTask() override;
-private: /* data */
- SettingsObjectPtr m_globalSettings;
- QString m_stagingPath;
- QString m_instName;
- QString m_instIcon;
- QString m_instGroup;
- NetJobPtr m_netJobPtr;
-
- FtbPackDownloader *m_downloader;
-
- std::unique_ptr<QuaZip> m_packZip;
- QFuture<QStringList> m_extractFuture;
- QFutureWatcher<QStringList> m_extractFutureWatcher;
-
+private:
void downloadPack();
- void unzip(QString archivePath);
+ void unzip();
void install();
- bool moveRecursively(QString source, QString dest);
-
- bool abortable = false;
-
private slots:
- void onDownloadSucceeded(QString archivePath);
+ void onDownloadSucceeded();
void onDownloadFailed(QString reason);
void onDownloadProgress(qint64 current, qint64 total);
void onUnzipFinished();
void onUnzipCanceled();
+private: /* data */
+ bool abortable = false;
+ std::unique_ptr<QuaZip> m_packZip;
+ QFuture<QStringList> m_extractFuture;
+ QFutureWatcher<QStringList> m_extractFutureWatcher;
+ NetJobPtr netJobContainer;
+ QString archivePath;
+
+ FtbModpack m_pack;
+ QString m_version;
};
diff --git a/api/logic/modplatform/ftb/PackHelpers.h b/api/logic/modplatform/ftb/PackHelpers.h
index f761ed6b..b184ed33 100644
--- a/api/logic/modplatform/ftb/PackHelpers.h
+++ b/api/logic/modplatform/ftb/PackHelpers.h
@@ -17,8 +17,8 @@ struct FtbModpack {
QString dir;
QString file; //<- Url in the xml, but doesn't make much sense
- bool bugged = false;
- bool broken = false;
+ bool bugged = true;
+ bool broken = true;
};
//We need it for the proxy model
Q_DECLARE_METATYPE(FtbModpack)
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt
index 48c1a359..5eeca240 100644
--- a/application/CMakeLists.txt
+++ b/application/CMakeLists.txt
@@ -80,29 +80,32 @@ SET(MULTIMC_SOURCES
JavaCommon.h
JavaCommon.cpp
- # GUI - page dialog pages
+ # GUI - paged dialog base
pages/BasePage.h
pages/BasePageContainer.h
- pages/VersionPage.cpp
- pages/VersionPage.h
- pages/TexturePackPage.h
- pages/ResourcePackPage.h
- pages/ModFolderPage.cpp
- pages/ModFolderPage.h
- pages/NotesPage.cpp
- pages/NotesPage.h
- pages/LogPage.cpp
- pages/LogPage.h
- pages/InstanceSettingsPage.cpp
- pages/InstanceSettingsPage.h
- pages/ScreenshotsPage.cpp
- pages/ScreenshotsPage.h
- pages/OtherLogsPage.cpp
- pages/OtherLogsPage.h
- pages/LegacyUpgradePage.cpp
- pages/LegacyUpgradePage.h
- pages/WorldListPage.cpp
- pages/WorldListPage.h
+ pages/BasePageProvider.h
+
+ # GUI - instance pages
+ pages/instance/VersionPage.cpp
+ pages/instance/VersionPage.h
+ pages/instance/TexturePackPage.h
+ pages/instance/ResourcePackPage.h
+ pages/instance/ModFolderPage.cpp
+ pages/instance/ModFolderPage.h
+ pages/instance/NotesPage.cpp
+ pages/instance/NotesPage.h
+ pages/instance/LogPage.cpp
+ pages/instance/LogPage.h
+ pages/instance/InstanceSettingsPage.cpp
+ pages/instance/InstanceSettingsPage.h
+ pages/instance/ScreenshotsPage.cpp
+ pages/instance/ScreenshotsPage.h
+ pages/instance/OtherLogsPage.cpp
+ pages/instance/OtherLogsPage.h
+ pages/instance/LegacyUpgradePage.cpp
+ pages/instance/LegacyUpgradePage.h
+ pages/instance/WorldListPage.cpp
+ pages/instance/WorldListPage.h
# GUI - global settings pages
pages/global/AccountListPage.cpp
@@ -124,6 +127,18 @@ SET(MULTIMC_SOURCES
pages/global/PackagesPage.cpp
pages/global/PackagesPage.h
+ # GUI - platform pages
+ pages/modplatform/VanillaPage.cpp
+ pages/modplatform/VanillaPage.h
+ pages/modplatform/FTBPage.cpp
+ pages/modplatform/FTBPage.h
+ pages/modplatform/TwitchPage.cpp
+ pages/modplatform/TwitchPage.h
+ pages/modplatform/TechnicPage.cpp
+ pages/modplatform/TechnicPage.h
+ pages/modplatform/ImportPage.cpp
+ pages/modplatform/ImportPage.h
+
# GUI - dialogs
dialogs/AboutDialog.cpp
dialogs/AboutDialog.h
@@ -159,8 +174,6 @@ SET(MULTIMC_SOURCES
dialogs/VersionSelectDialog.h
dialogs/SkinUploadDialog.cpp
dialogs/SkinUploadDialog.h
- dialogs/ChooseFtbPackDialog.cpp
- dialogs/ChooseFtbPackDialog.h
# GUI - widgets
@@ -210,15 +223,15 @@ SET(MULTIMC_SOURCES
######## UIs ########
SET(MULTIMC_UIS
# Instance pages
- pages/VersionPage.ui
- pages/ModFolderPage.ui
- pages/LogPage.ui
- pages/InstanceSettingsPage.ui
- pages/NotesPage.ui
- pages/ScreenshotsPage.ui
- pages/OtherLogsPage.ui
- pages/LegacyUpgradePage.ui
- pages/WorldListPage.ui
+ pages/instance/VersionPage.ui
+ pages/instance/ModFolderPage.ui
+ pages/instance/LogPage.ui
+ pages/instance/InstanceSettingsPage.ui
+ pages/instance/NotesPage.ui
+ pages/instance/ScreenshotsPage.ui
+ pages/instance/OtherLogsPage.ui
+ pages/instance/LegacyUpgradePage.ui
+ pages/instance/WorldListPage.ui
# Global settings pages
pages/global/AccountListPage.ui
@@ -230,6 +243,13 @@ SET(MULTIMC_UIS
pages/global/PasteEEPage.ui
pages/global/PackagesPage.ui
+ # Platform pages
+ pages/modplatform/VanillaPage.ui
+ pages/modplatform/FTBPage.ui
+ pages/modplatform/TwitchPage.ui
+ pages/modplatform/TechnicPage.ui
+ pages/modplatform/ImportPage.ui
+
# Dialogs
dialogs/CopyInstanceDialog.ui
dialogs/NewComponentDialog.ui
@@ -244,7 +264,6 @@ SET(MULTIMC_UIS
dialogs/UpdateDialog.ui
dialogs/NotificationDialog.ui
dialogs/SkinUploadDialog.ui
- dialogs/ChooseFtbPackDialog.ui
# Widgets/other
widgets/CustomCommands.ui
diff --git a/application/FtbListModel.cpp b/application/FtbListModel.cpp
index 68a68794..d79bcac0 100644
--- a/application/FtbListModel.cpp
+++ b/application/FtbListModel.cpp
@@ -108,7 +108,9 @@ QVariant FtbListModel::data(const QModelIndex &index, int role) const
void FtbListModel::fill(FtbModpackList modpacks)
{
+ beginResetModel();
this->modpacks = modpacks;
+ endResetModel();
}
FtbModpack FtbListModel::at(int row)
diff --git a/application/InstancePageProvider.h b/application/InstancePageProvider.h
index b13ce93d..9dda7859 100644
--- a/application/InstancePageProvider.h
+++ b/application/InstancePageProvider.h
@@ -3,18 +3,18 @@
#include "minecraft/legacy/LegacyInstance.h"
#include <FileSystem.h>
#include "pages/BasePage.h"
-#include "pages/LogPage.h"
-#include "pages/VersionPage.h"
-#include "pages/ModFolderPage.h"
-#include "pages/ResourcePackPage.h"
-#include "pages/TexturePackPage.h"
-#include "pages/NotesPage.h"
-#include "pages/ScreenshotsPage.h"
-#include "pages/InstanceSettingsPage.h"
-#include "pages/OtherLogsPage.h"
#include "pages/BasePageProvider.h"
-#include "pages/LegacyUpgradePage.h"
-#include "pages/WorldListPage.h"
+#include "pages/instance/LogPage.h"
+#include "pages/instance/VersionPage.h"
+#include "pages/instance/ModFolderPage.h"
+#include "pages/instance/ResourcePackPage.h"
+#include "pages/instance/TexturePackPage.h"
+#include "pages/instance/NotesPage.h"
+#include "pages/instance/ScreenshotsPage.h"
+#include "pages/instance/InstanceSettingsPage.h"
+#include "pages/instance/OtherLogsPage.h"
+#include "pages/instance/LegacyUpgradePage.h"
+#include "pages/instance/WorldListPage.h"
class InstancePageProvider : public QObject, public BasePageProvider
diff --git a/application/InstanceWindow.cpp b/application/InstanceWindow.cpp
index 2e876fea..5895ca3a 100644
--- a/application/InstanceWindow.cpp
+++ b/application/InstanceWindow.cpp
@@ -47,7 +47,7 @@ InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent)
// Add page container
{
auto provider = std::make_shared<InstancePageProvider>(m_instance);
- m_container = new PageContainer(provider, "console", this);
+ m_container = new PageContainer(provider.get(), "console", this);
m_container->setParentContainer(this);
setCentralWidget(m_container);
}
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index 542d1da6..60742412 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -90,6 +90,7 @@
#include <InstanceImportTask.h>
#include "UpdateController.h"
#include "KonamiCode.h"
+#include <InstanceCopyTask.h>
// WHY: to hold the pre-translation strings together with the T pointer, so it can be retranslated without a lot of ugly code
template <typename T>
@@ -1267,26 +1268,9 @@ void MainWindow::runModalTask(Task *task)
loadDialog.execWithTask(task);
}
-void MainWindow::instanceFromZipPack(QString instName, QString instGroup, QString instIcon, QUrl url)
+void MainWindow::instanceFromInstanceTask(InstanceTask *rawTask)
{
- std::unique_ptr<Task> task(MMC->folderProvider()->zipImportTask(url, instName, instGroup, instIcon));
- runModalTask(task.get());
-
- // FIXME: handle instance selection after creation
- // finalizeInstance(newInstance);
-}
-
-void MainWindow::instanceFromVersion(QString instName, QString instGroup, QString instIcon, BaseVersionPtr version)
-{
- std::unique_ptr<Task> task(MMC->folderProvider()->creationTask(version, instName, instGroup, instIcon));
- runModalTask(task.get());
-
- // FIXME: handle instance selection after creation
- // finalizeInstance(newInstance);
-}
-
-void MainWindow::instanceFromFtbPack(FtbPackDownloader *downloader, QString instName, QString instGroup, QString instIcon) {
- std::unique_ptr<Task> task(MMC->folderProvider()->ftbCreationTask(downloader, instName, instGroup, instIcon));
+ std::unique_ptr<Task> task(MMC->folderProvider()->wrapInstanceTask(rawTask));
runModalTask(task.get());
// FIXME: handle instance selection after creation
@@ -1302,8 +1286,11 @@ void MainWindow::on_actionCopyInstance_triggered()
if (!copyInstDlg.exec())
return;
- std::unique_ptr<Task> task(MMC->folderProvider()->copyTask(m_selectedInstance, copyInstDlg.instName(), copyInstDlg.instGroup(),
- copyInstDlg.iconKey(), copyInstDlg.shouldCopySaves()));
+ auto copyTask = new InstanceCopyTask(m_selectedInstance, copyInstDlg.shouldCopySaves());
+ copyTask->setName(copyInstDlg.instName());
+ copyTask->setGroup(copyInstDlg.instGroup());
+ copyTask->setIcon(copyInstDlg.iconKey());
+ std::unique_ptr<Task> task(MMC->folderProvider()->wrapInstanceTask(copyTask));
runModalTask(task.get());
// FIXME: handle instance selection after creation
@@ -1366,19 +1353,10 @@ void MainWindow::addInstance(QString url)
MMC->settings()->set("LastUsedGroupForNewInstance", newInstDlg.instGroup());
- const QUrl modpackUrl = newInstDlg.modpackUrl();
-
- if(newInstDlg.isFtbModpackRequested())
- {
- instanceFromFtbPack(newInstDlg.getFtbPackDownloader(), newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey());
- }
- else if (modpackUrl.isValid())
- {
- instanceFromZipPack(newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey(), modpackUrl);
- }
- else
+ InstanceTask * creationTask = newInstDlg.extractTask();
+ if(creationTask)
{
- instanceFromVersion(newInstDlg.instName(), newInstDlg.instGroup(), newInstDlg.iconKey(), newInstDlg.selectedVersion());
+ instanceFromInstanceTask(creationTask);
}
}
diff --git a/application/MainWindow.h b/application/MainWindow.h
index e9897606..609df4ca 100644
--- a/application/MainWindow.h
+++ b/application/MainWindow.h
@@ -39,6 +39,7 @@ class BaseProfilerFactory;
class GroupView;
class ServerStatus;
class KonamiCode;
+class InstanceTask;
class MainWindow : public QMainWindow
{
@@ -187,9 +188,7 @@ private:
void setSelectedInstanceById(const QString &id);
void runModalTask(Task *task);
- void instanceFromVersion(QString instName, QString instGroup, QString instIcon, BaseVersionPtr version);
- void instanceFromZipPack(QString instName, QString instGroup, QString instIcon, QUrl url);
- void instanceFromFtbPack(FtbPackDownloader *downloader, QString instName, QString instGroup, QString instIcon);
+ void instanceFromInstanceTask(InstanceTask *task);
void finalizeInstance(InstancePtr inst);
private:
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index 230d757f..4236fbcf 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -497,6 +497,8 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
m_settings->registerSetting("PagedGeometry", "");
+ m_settings->registerSetting("NewInstanceGeometry", "");
+
m_settings->registerSetting("UpdateDialogGeometry", "");
// paste.ee API key
diff --git a/application/SettingsUI.h b/application/SettingsUI.h
index 5b8badf2..0d14fbee 100644
--- a/application/SettingsUI.h
+++ b/application/SettingsUI.h
@@ -19,7 +19,7 @@ void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QStrin
return;
{
SettingsObject::Lock lock(MMC->settings());
- PageDialog dlg(provider, open_page, parent);
+ PageDialog dlg(provider.get(), open_page, parent);
dlg.exec();
}
}
diff --git a/application/VersionProxyModel.cpp b/application/VersionProxyModel.cpp
index 0dbc4ef6..c180adf2 100644
--- a/application/VersionProxyModel.cpp
+++ b/application/VersionProxyModel.cpp
@@ -20,34 +20,21 @@ public:
const auto &filters = m_parent->filters();
for (auto it = filters.begin(); it != filters.end(); ++it)
{
- auto role = it.key();
auto idx = sourceModel()->index(source_row, 0, source_parent);
- auto data = sourceModel()->data(idx, role);
-
- switch(role)
+ auto data = sourceModel()->data(idx, it.key());
+ auto match = data.toString();
+ if(!it.value()->accepts(match))
{
- case BaseVersionList::ParentVersionRole:
- case BaseVersionList::VersionIdRole:
- // TODO: work with metadata here. Previous implementation based on the Version class is not sufficient
- default:
- {
- auto match = data.toString();
- if(it.value().exact)
- {
- if (match != it.value().string)
- {
- return false;
- }
- }
- else if (match.contains(it.value().string))
- {
- return false;
- }
- }
+ return false;
}
}
return true;
}
+
+ void filterChanged()
+ {
+ invalidateFilter();
+ }
private:
VersionProxyModel *m_parent;
};
@@ -56,12 +43,12 @@ VersionProxyModel::VersionProxyModel(QObject *parent) : QAbstractProxyModel(pare
{
filterModel = new VersionFilterModel(this);
connect(filterModel, &QAbstractItemModel::dataChanged, this, &VersionProxyModel::sourceDataChanged);
+ connect(filterModel, &QAbstractItemModel::rowsAboutToBeInserted, this, &VersionProxyModel::sourceRowsAboutToBeInserted);
+ connect(filterModel, &QAbstractItemModel::rowsInserted, this, &VersionProxyModel::sourceRowsInserted);
+ connect(filterModel, &QAbstractItemModel::rowsAboutToBeRemoved, this, &VersionProxyModel::sourceRowsAboutToBeRemoved);
+ connect(filterModel, &QAbstractItemModel::rowsRemoved, this, &VersionProxyModel::sourceRowsRemoved);
// FIXME: implement when needed
/*
- connect(replacing, &QAbstractItemModel::rowsAboutToBeInserted, this, &VersionProxyModel::sourceRowsAboutToBeInserted);
- connect(replacing, &QAbstractItemModel::rowsInserted, this, &VersionProxyModel::sourceRowsInserted);
- connect(replacing, &QAbstractItemModel::rowsAboutToBeRemoved, this, &VersionProxyModel::sourceRowsAboutToBeRemoved);
- connect(replacing, &QAbstractItemModel::rowsRemoved, this, &VersionProxyModel::sourceRowsRemoved);
connect(replacing, &QAbstractItemModel::rowsAboutToBeMoved, this, &VersionProxyModel::sourceRowsAboutToBeMoved);
connect(replacing, &QAbstractItemModel::rowsMoved, this, &VersionProxyModel::sourceRowsMoved);
connect(replacing, &QAbstractItemModel::layoutAboutToBeChanged, this, &VersionProxyModel::sourceLayoutAboutToBeChanged);
@@ -390,16 +377,13 @@ QModelIndex VersionProxyModel::getVersion(const QString& version) const
void VersionProxyModel::clearFilters()
{
m_filters.clear();
- filterModel->invalidate();
+ filterModel->filterChanged();
}
-void VersionProxyModel::setFilter(const BaseVersionList::ModelRoles column, const QString &filter, const bool exact)
+void VersionProxyModel::setFilter(const BaseVersionList::ModelRoles column, Filter * f)
{
- Filter f;
- f.string = filter;
- f.exact = exact;
- m_filters[column] = f;
- filterModel->invalidate();
+ m_filters[column].reset(f);
+ filterModel->filterChanged();
}
const VersionProxyModel::FilterMap &VersionProxyModel::filters() const
@@ -417,4 +401,25 @@ void VersionProxyModel::sourceReset()
endResetModel();
}
+void VersionProxyModel::sourceRowsAboutToBeInserted(const QModelIndex& parent, int first, int last)
+{
+ beginInsertRows(parent, first, last);
+}
+
+void VersionProxyModel::sourceRowsInserted(const QModelIndex& parent, int first, int last)
+{
+ endInsertRows();
+}
+
+void VersionProxyModel::sourceRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last)
+{
+ beginRemoveRows(parent, first, last);
+}
+
+void VersionProxyModel::sourceRowsRemoved(const QModelIndex& parent, int first, int last)
+{
+ endRemoveRows();
+}
+
+
#include "VersionProxyModel.moc"
diff --git a/application/VersionProxyModel.h b/application/VersionProxyModel.h
index 4441ea6b..33a0d1ea 100644
--- a/application/VersionProxyModel.h
+++ b/application/VersionProxyModel.h
@@ -2,17 +2,15 @@
#include <QAbstractProxyModel>
#include "BaseVersionList.h"
+#include <Filter.h>
+
class VersionFilterModel;
class VersionProxyModel: public QAbstractProxyModel
{
Q_OBJECT
public:
- struct Filter
- {
- QString string;
- bool exact = false;
- };
+
enum Column
{
Name,
@@ -22,7 +20,7 @@ public:
Architecture,
Path
};
- typedef QHash<BaseVersionList::ModelRoles, Filter> FilterMap;
+ typedef QHash<BaseVersionList::ModelRoles, std::shared_ptr<Filter>> FilterMap;
public:
VersionProxyModel ( QObject* parent = 0 );
@@ -39,16 +37,23 @@ public:
virtual void setSourceModel(QAbstractItemModel *sourceModel) override;
const FilterMap &filters() const;
- void setFilter(const BaseVersionList::ModelRoles column, const QString &filter, const bool exact);
+ void setFilter(const BaseVersionList::ModelRoles column, Filter * filter);
void clearFilters();
QModelIndex getRecommended() const;
QModelIndex getVersion(const QString & version) const;
private slots:
void sourceDataChanged(const QModelIndex &source_top_left,const QModelIndex &source_bottom_right);
+
void sourceAboutToBeReset();
void sourceReset();
+ void sourceRowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
+ void sourceRowsInserted(const QModelIndex &parent, int first, int last);
+
+ void sourceRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
+ void sourceRowsRemoved(const QModelIndex &parent, int first, int last);
+
private:
QList<Column> m_columns;
FilterMap m_filters;
diff --git a/application/dialogs/ChooseFtbPackDialog.cpp b/application/dialogs/ChooseFtbPackDialog.cpp
deleted file mode 100644
index b1deae6e..00000000
--- a/application/dialogs/ChooseFtbPackDialog.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "ChooseFtbPackDialog.h"
-#include <QPushButton>
-
-ChooseFtbPackDialog::ChooseFtbPackDialog(FtbModpackList modpacks) : ui(new Ui::ChooseFtbPackDialog)
-{
- ui->setupUi(this);
-
- filterModel = new FtbFilterModel(this);
- listModel = new FtbListModel(this);
- filterModel->setSourceModel(listModel);
- listModel->fill(modpacks);
-
- ui->packList->setModel(filterModel);
- ui->packList->setSortingEnabled(true);
- ui->packList->header()->hide();
- ui->packList->setIndentation(0);
-
- filterModel->setSorting(FtbFilterModel::Sorting::ByName);
-
- for(int i = 0; i < filterModel->getAvailableSortings().size(); i++){
- ui->sortByBox->addItem(filterModel->getAvailableSortings().keys().at(i));
- }
-
- ui->sortByBox->setCurrentText(filterModel->getAvailableSortings().key(filterModel->getCurrentSorting()));
-
- connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &ChooseFtbPackDialog::onSortingSelectionChanged);
- connect(ui->packVersionSelection, &QComboBox::currentTextChanged, this, &ChooseFtbPackDialog::onVersionSelectionItemChanged);
- connect(ui->packList->selectionModel(), &QItemSelectionModel::currentChanged, this, &ChooseFtbPackDialog::onPackSelectionChanged);
-
- ui->modpackInfo->setOpenExternalLinks(true);
-
- ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
-}
-
-ChooseFtbPackDialog::~ChooseFtbPackDialog()
-{
- delete ui;
-}
-
-void ChooseFtbPackDialog::onPackSelectionChanged(QModelIndex now, QModelIndex prev)
-{
- ui->packVersionSelection->clear();
- FtbModpack selectedPack = filterModel->data(now, Qt::UserRole).value<FtbModpack>();
-
- ui->modpackInfo->setHtml("Pack by <b>" + selectedPack.author + "</b>" + "<br>Minecraft " + selectedPack.mcVersion + "<br>"
- "<br>" + selectedPack.description + "<ul><li>" + selectedPack.mods.replace(";", "</li><li>") + "</li></ul>");
-
- bool currentAdded = false;
-
- for(int i = 0; i < selectedPack.oldVersions.size(); i++) {
- if(selectedPack.currentVersion == selectedPack.oldVersions.at(i)) {
- currentAdded = true;
- }
- ui->packVersionSelection->addItem(selectedPack.oldVersions.at(i));
- }
-
- if(!currentAdded) {
- ui->packVersionSelection->addItem(selectedPack.currentVersion);
- }
-
- selected = selectedPack;
- ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!selected.broken);
-}
-
-void ChooseFtbPackDialog::onVersionSelectionItemChanged(QString data)
-{
- if(data.isNull() || data.isEmpty()) {
- selectedVersion = "";
- return;
- }
-
- selectedVersion = data;
-}
-
-FtbModpack ChooseFtbPackDialog::getSelectedModpack()
-{
- return selected;
-}
-
-QString ChooseFtbPackDialog::getSelectedVersion()
-{
- return selectedVersion;
-}
-
-void ChooseFtbPackDialog::onSortingSelectionChanged(QString data)
-{
- filterModel->setSorting(filterModel->getAvailableSortings().value(data));
-}
diff --git a/application/dialogs/ChooseFtbPackDialog.h b/application/dialogs/ChooseFtbPackDialog.h
deleted file mode 100644
index f9f3dd08..00000000
--- a/application/dialogs/ChooseFtbPackDialog.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-
-#include <QDialog>
-#include <net/NetJob.h>
-#include <modplatform/ftb/PackHelpers.h>
-#include "ui_ChooseFtbPackDialog.h"
-#include "FtbListModel.h"
-
-namespace Ui {
- class ChooseFtbPackDialog;
-}
-
-class ChooseFtbPackDialog : public QDialog {
-
- Q_OBJECT
-
-private:
- Ui::ChooseFtbPackDialog *ui;
- FtbModpack selected;
- QString selectedVersion;
- FtbListModel* listModel;
- FtbFilterModel* filterModel;
-
-private slots:
- void onSortingSelectionChanged(QString data);
- void onVersionSelectionItemChanged(QString data);
- void onPackSelectionChanged(QModelIndex first, QModelIndex second);
-public:
- ChooseFtbPackDialog(FtbModpackList packs);
- ~ChooseFtbPackDialog();
-
- FtbModpack getSelectedModpack();
- QString getSelectedVersion();
-};
diff --git a/application/dialogs/ChooseFtbPackDialog.ui b/application/dialogs/ChooseFtbPackDialog.ui
deleted file mode 100644
index f590a4cd..00000000
--- a/application/dialogs/ChooseFtbPackDialog.ui
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ChooseFtbPackDialog</class>
- <widget class="QDialog" name="ChooseFtbPackDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>700</width>
- <height>437</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="sizeGripEnabled">
- <bool>false</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="1" column="1">
- <widget class="QLabel" name="selectedVersionLabel">
- <property name="text">
- <string>Version selected:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QTreeView" name="packList">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QComboBox" name="sortByBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="1" column="3">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="autoFillBackground">
- <bool>false</bool>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- <property name="centerButtons">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QComboBox" name="packVersionSelection">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="3">
- <widget class="QTextBrowser" name="modpackInfo"/>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>ChooseFtbPackDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>211</x>
- <y>173</y>
- </hint>
- <hint type="destinationlabel">
- <x>889</x>
- <y>501</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>ChooseFtbPackDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>225</x>
- <y>162</y>
- </hint>
- <hint type="destinationlabel">
- <x>524</x>
- <y>458</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp
index eee3991c..f0783603 100644
--- a/application/dialogs/NewInstanceDialog.cpp
+++ b/application/dialogs/NewInstanceDialog.cpp
@@ -25,80 +25,30 @@
#include "VersionSelectDialog.h"
#include "ProgressDialog.h"
#include "IconPickerDialog.h"
-#include "ChooseFtbPackDialog.h"
#include <QLayout>
#include <QPushButton>
#include <QFileDialog>
#include <QValidator>
+#include <QDialogButtonBox>
-#include <meta/Index.h>
-#include <meta/VersionList.h>
-
-class UrlValidator : public QValidator
-{
-public:
- using QValidator::QValidator;
-
- State validate(QString &in, int &pos) const
- {
- const QUrl url(in);
- if (url.isValid() && !url.isRelative() && !url.isEmpty())
- {
- return Acceptable;
- }
- else if (QFile::exists(in))
- {
- return Acceptable;
- }
- else
- {
- return Intermediate;
- }
- }
-};
+#include "widgets/PageContainer.h"
+#include <pages/modplatform/VanillaPage.h>
+#include <pages/modplatform/FTBPage.h>
+#include <pages/modplatform/TwitchPage.h>
+#include <pages/modplatform/ImportPage.h>
+#include <pages/modplatform/TechnicPage.h>
NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString & url, QWidget *parent)
: QDialog(parent), ui(new Ui::NewInstanceDialog)
{
ui->setupUi(this);
- resize(minimumSizeHint());
- layout()->setSizeConstraint(QLayout::SetFixedSize);
- auto vlist = ENV.metadataIndex()->get("net.minecraft");
- if(vlist->isLoaded())
- {
- setSelectedVersion(vlist->getRecommended());
- }
- else
- {
- vlist->load(Net::Mode::Online);
- auto task = vlist->getLoadTask();
- if(vlist->isLoaded())
- {
- setSelectedVersion(vlist->getRecommended());
- }
- if(task)
- {
- connect(task.get(), &Task::succeeded, this, &NewInstanceDialog::versionListUpdated);
- }
- }
+ setWindowIcon(MMC->getThemedIcon("new"));
InstIconKey = "default";
ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey));
- ui->modpackEdit->setValidator(new UrlValidator(ui->modpackEdit));
-
- ui->instNameTextBox->setAlignment(Qt::AlignHCenter);
-
- connect(ui->modpackEdit, &QLineEdit::textChanged, this, &NewInstanceDialog::updateDialogState);
- connect(ui->modpackBox, &QRadioButton::clicked, this, &NewInstanceDialog::updateDialogState);
-
- connect(ui->versionBox, &QRadioButton::clicked, this, &NewInstanceDialog::updateDialogState);
- connect(ui->versionTextBox, &QLineEdit::textChanged, this, &NewInstanceDialog::updateDialogState);
-
- connect(ui->ftbBox, &QRadioButton::clicked, this, &NewInstanceDialog::updateDialogState);
-
auto groups = MMC->instances()->getGroups().toSet();
auto groupList = QStringList(groups.toList());
groupList.sort(Qt::CaseInsensitive);
@@ -113,32 +63,47 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
}
ui->groupBox->setCurrentIndex(index);
ui->groupBox->lineEdit()->setPlaceholderText(tr("No group"));
- ui->buttonBox->setFocus();
- originalPlaceholderText = ui->instNameTextBox->placeholderText();
- if(!url.isEmpty())
- {
- ui->modpackBox->setChecked(true);
- ui->modpackEdit->setText(url);
- }
+ m_buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok);
+ m_buttons->button(QDialogButtonBox::Ok)->setDefault(true);
- ftbPackDownloader = new FtbPackDownloader();
+ connect(m_buttons->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &QDialog::accept);
+ connect(m_buttons->button(QDialogButtonBox::Help), &QPushButton::clicked, m_container, &PageContainer::help);
- connect(ftbPackDownloader, &FtbPackDownloader::ready, this, &NewInstanceDialog::ftbPackDataDownloadSuccessfully);
- connect(ftbPackDownloader, &FtbPackDownloader::packFetchFailed, this, &NewInstanceDialog::ftbPackDataDownloadFailed);
+ m_container = new PageContainer(this);
+ m_container->setSizePolicy(QSizePolicy::Policy::Preferred, QSizePolicy::Policy::Expanding);
+ ui->verticalLayout->insertWidget(2, m_container);
- ftbPackDownloader->fetchModpacks(false);
+ m_container->addButtons(m_buttons);
+ m_buttons->setFocus();
+
+ if(!url.isEmpty())
+ {
+ m_container->selectPage("import");
+ importPage->setUrl(url);
+ }
updateDialogState();
+
+ restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("NewInstanceGeometry").toByteArray()));
}
-void NewInstanceDialog::versionListUpdated()
+QList<BasePage *> NewInstanceDialog::getPages()
{
- if(!m_versionSetByUser)
+ importPage = new ImportPage(this);
+ return
{
- auto vlist = ENV.metadataIndex()->get("net.minecraft");
- setSelectedVersion(vlist->getRecommended());
- }
+ new VanillaPage(this),
+ new FTBPage(this),
+ importPage,
+ new TwitchPage(this),
+ new TechnicPage(this)
+ };
+}
+
+QString NewInstanceDialog::dialogTitle()
+{
+ return tr("New Instance");
}
NewInstanceDialog::~NewInstanceDialog()
@@ -146,58 +111,29 @@ NewInstanceDialog::~NewInstanceDialog()
delete ui;
}
-void NewInstanceDialog::updateDialogState()
+void NewInstanceDialog::setSuggestedPack(const QString& name, InstanceTask* task)
{
- QString suggestedName;
- if(ui->versionBox->isChecked())
- {
- suggestedName = ui->versionTextBox->text();
- }
- else if (ui->modpackBox->isChecked())
- {
- auto url = QUrl::fromUserInput(ui->modpackEdit->text());
- QFileInfo fi(url.fileName());
- suggestedName = fi.completeBaseName();
- }
- else if (ui->ftbBox->isChecked())
- {
- if(ftbPackDownloader->isValidPackSelected()) {
- suggestedName = ftbPackDownloader->getSuggestedInstanceName();
- ui->labelFtbPack->setText(selectedPack.name);
- }
+ creationTask.reset(task);
+ ui->instNameTextBox->setPlaceholderText(name);
- }
-
- ftbModpackRequested = ui->ftbBox->isChecked();
-
- if(suggestedName.isEmpty())
- {
- ui->instNameTextBox->setPlaceholderText(originalPlaceholderText);
- }
- else
- {
- ui->instNameTextBox->setPlaceholderText(suggestedName);
- }
- bool allowOK = !instName().isEmpty() && (
- (ui->versionBox->isChecked() && m_selectedVersion) ||
- (ui->modpackBox->isChecked() && ui->modpackEdit->hasAcceptableInput()) ||
- (ui->ftbBox->isChecked() && ftbPackDownloader && ftbPackDownloader->isValidPackSelected() )
- );
- ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
+ auto allowOK = task && !instName().isEmpty();
+ m_buttons->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
}
-void NewInstanceDialog::setSelectedVersion(BaseVersionPtr version)
+InstanceTask * NewInstanceDialog::extractTask()
{
- m_selectedVersion = version;
+ InstanceTask * extracted = creationTask.get();
+ creationTask.release();
+ extracted->setName(instName());
+ extracted->setGroup(instGroup());
+ extracted->setIcon(iconKey());
+ return extracted;
+}
- if (m_selectedVersion)
- {
- ui->versionTextBox->setText(version->descriptor());
- }
- else
- {
- ui->versionTextBox->setText("");
- }
+void NewInstanceDialog::updateDialogState()
+{
+ auto allowOK = creationTask && !instName().isEmpty();
+ m_buttons->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
}
QString NewInstanceDialog::instName() const
@@ -208,7 +144,7 @@ QString NewInstanceDialog::instName() const
return result.trimmed();
}
result = ui->instNameTextBox->placeholderText();
- if(result.size() && result != originalPlaceholderText)
+ if(result.size())
{
return result.trimmed();
}
@@ -223,45 +159,6 @@ QString NewInstanceDialog::iconKey() const
{
return InstIconKey;
}
-QUrl NewInstanceDialog::modpackUrl() const
-{
- if (ui->modpackBox->isChecked())
- {
- const QUrl url(ui->modpackEdit->text());
- if (url.isValid() && !url.isRelative() && !url.host().isEmpty())
- {
- return url;
- }
- else
- {
- return QUrl::fromLocalFile(ui->modpackEdit->text());
- }
- }
- else
- {
- return QUrl();
- }
-}
-
-BaseVersionPtr NewInstanceDialog::selectedVersion() const
-{
- return m_selectedVersion;
-}
-
-void NewInstanceDialog::on_btnChangeVersion_clicked()
-{
- VersionSelectDialog vselect(ENV.metadataIndex()->get("net.minecraft").get(), tr("Change Minecraft version"), this);
- vselect.exec();
- if (vselect.result() == QDialog::Accepted)
- {
- BaseVersionPtr version = vselect.selectedVersion();
- if (version)
- {
- m_versionSetByUser = true;
- setSelectedVersion(version);
- }
- }
-}
void NewInstanceDialog::on_iconButton_clicked()
{
@@ -280,46 +177,14 @@ void NewInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
updateDialogState();
}
-void NewInstanceDialog::on_modpackBtn_clicked()
+void NewInstanceDialog::closeEvent(QCloseEvent* event)
{
- const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), tr("Zip (*.zip)"));
- if (url.isValid())
+ qDebug() << "New instance dialog close requested";
+ if (m_container->prepareToClose())
{
- if (url.isLocalFile())
- {
- ui->modpackEdit->setText(url.toLocalFile());
- }
- else
- {
- ui->modpackEdit->setText(url.toString());
- }
- }
-}
-
-bool NewInstanceDialog::isFtbModpackRequested() {
- return ftbModpackRequested;
-}
-
-FtbPackDownloader *NewInstanceDialog::getFtbPackDownloader() {
- return ftbPackDownloader;
-}
-
-void NewInstanceDialog::on_btnChooseFtbPack_clicked() {
- ChooseFtbPackDialog dl(ftbPackDownloader->getModpacks());
- dl.exec();
- if(dl.result() == QDialog::Accepted) {
- selectedPack = dl.getSelectedModpack();
- ftbPackDownloader->selectPack(selectedPack, dl.getSelectedVersion());
+ qDebug() << "New instance dialog close approved";
+ MMC->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
+ qDebug() << "New instance dialog geometry saved";
+ QDialog::closeEvent(event);
}
- updateDialogState();
}
-
-void NewInstanceDialog::ftbPackDataDownloadSuccessfully() {
- ui->packDataDownloadStatus->setText(tr("(Data download complete)"));
- ui->ftbBox->setEnabled(true);
-}
-
-void NewInstanceDialog::ftbPackDataDownloadFailed() {
- ui->packDataDownloadStatus->setText(tr("(Data download failed)"));
-}
-
diff --git a/application/dialogs/NewInstanceDialog.h b/application/dialogs/NewInstanceDialog.h
index f1fe26f4..ca134d32 100644
--- a/application/dialogs/NewInstanceDialog.h
+++ b/application/dialogs/NewInstanceDialog.h
@@ -18,15 +18,19 @@
#include <QDialog>
#include "BaseVersion.h"
-#include "modplatform/ftb/FtbPackDownloader.h"
-#include "modplatform/ftb/PackHelpers.h"
+#include "pages/BasePageProvider.h"
+#include "InstanceTask.h"
namespace Ui
{
class NewInstanceDialog;
}
-class NewInstanceDialog : public QDialog
+class PageContainer;
+class QDialogButtonBox;
+class ImportPage;
+
+class NewInstanceDialog : public QDialog, public BasePageProvider
{
Q_OBJECT
@@ -36,39 +40,28 @@ public:
void updateDialogState();
- void setSelectedVersion(BaseVersionPtr version);
+ void setSuggestedPack(const QString & name = QString(), InstanceTask * task = nullptr);
+ InstanceTask * extractTask();
+
+ QString dialogTitle() override;
+ QList<BasePage *> getPages() override;
QString instName() const;
QString instGroup() const;
QString iconKey() const;
- QUrl modpackUrl() const;
- BaseVersionPtr selectedVersion() const;
-
- bool isFtbModpackRequested();
- FtbPackDownloader* getFtbPackDownloader();
private
slots:
- void on_btnChangeVersion_clicked();
void on_iconButton_clicked();
- void on_modpackBtn_clicked();
- void on_btnChooseFtbPack_clicked();
void on_instNameTextBox_textChanged(const QString &arg1);
- void versionListUpdated();
-
- void ftbPackDataDownloadSuccessfully();
- void ftbPackDataDownloadFailed();
+ virtual void closeEvent(QCloseEvent *event);
private:
- Ui::NewInstanceDialog *ui;
-
- bool m_versionSetByUser = false;
- bool ftbModpackRequested = false;
+ Ui::NewInstanceDialog *ui = nullptr;
+ PageContainer * m_container = nullptr;
+ QDialogButtonBox * m_buttons = nullptr;
- BaseVersionPtr m_selectedVersion;
QString InstIconKey;
- QString originalPlaceholderText;
-
- FtbPackDownloader* ftbPackDownloader;
- FtbModpack selectedPack;
+ ImportPage *importPage = nullptr;
+ std::unique_ptr<InstanceTask> creationTask;
};
diff --git a/application/dialogs/NewInstanceDialog.ui b/application/dialogs/NewInstanceDialog.ui
index 428b9c57..7fb19ff5 100644
--- a/application/dialogs/NewInstanceDialog.ui
+++ b/application/dialogs/NewInstanceDialog.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>281</width>
- <height>407</height>
+ <width>730</width>
+ <height>127</height>
</rect>
</property>
<property name="windowTitle">
@@ -25,357 +25,63 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <layout class="QHBoxLayout" name="iconBtnLayout">
- <item>
- <spacer name="iconBtnLeftSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QToolButton" name="iconButton">
- <property name="iconSize">
- <size>
- <width>80</width>
- <height>80</height>
- </size>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="iconBtnRightSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QLineEdit" name="instNameTextBox">
- <property name="placeholderText">
- <string>Name</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="line">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="labelVersion_3">
- <property name="text">
- <string>&amp;Group:</string>
- </property>
- <property name="buddy">
- <cstring>groupBox</cstring>
- </property>
- </widget>
- </item>
- <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="1" column="2">
<widget class="QComboBox" name="groupBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
- </layout>
- </item>
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="5" column="0">
- <widget class="QRadioButton" name="ftbBox">
- <property name="enabled">
- <bool>false</bool>
- </property>
+ <item row="1" column="1">
+ <widget class="QLabel" name="groupLabel">
<property name="text">
- <string>Install FTB Pack</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QToolButton" name="btnChangeVersion">
- <property name="text">
- <string notr="true">...</string>
- </property>
- </widget>
- </item>
- <item row="7" column="2">
- <widget class="QToolButton" name="btnChooseFtbPack">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QToolButton" name="modpackBtn">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string notr="true">...</string>
- </property>
- </widget>
- </item>
- <item row="7" column="0" colspan="2">
- <widget class="QLabel" name="labelFtbPack">
- <property name="enabled">
- <bool>false</bool>
+ <string>&amp;Group:</string>
</property>
- <property name="text">
- <string> No Pack choosen</string>
+ <property name="buddy">
+ <cstring>groupBox</cstring>
</property>
</widget>
</item>
- <item row="3" column="0" colspan="3">
- <widget class="QRadioButton" name="modpackBox">
- <property name="text">
- <string>Impor&amp;t Modpack (local file or link):</string>
- </property>
- </widget>
+ <item row="0" column="2">
+ <widget class="QLineEdit" name="instNameTextBox"/>
</item>
- <item row="1" column="0" colspan="3">
- <widget class="QRadioButton" name="versionBox">
+ <item row="0" column="1">
+ <widget class="QLabel" name="nameLabel">
<property name="text">
- <string>Vani&amp;lla Minecraft (select version):</string>
- </property>
- <property name="checked">
- <bool>true</bool>
+ <string>&amp;Name:</string>
</property>
- </widget>
- </item>
- <item row="2" column="0" colspan="2">
- <widget class="QLineEdit" name="versionTextBox">
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="2">
- <widget class="FocusLineEdit" name="modpackEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string notr="true">http://</string>
+ <property name="buddy">
+ <cstring>instNameTextBox</cstring>
</property>
</widget>
</item>
- <item row="5" column="1" colspan="2">
- <widget class="QLabel" name="packDataDownloadStatus">
- <property name="text">
- <string>(Loading Pack data...)</string>
+ <item row="0" column="0" rowspan="2">
+ <widget class="QToolButton" name="iconButton">
+ <property name="iconSize">
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
</property>
</widget>
</item>
</layout>
</item>
<item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="Line" name="line_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
+ <widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
</widget>
</item>
</layout>
</widget>
- <customwidgets>
- <customwidget>
- <class>FocusLineEdit</class>
- <extends>QLineEdit</extends>
- <header>widgets/FocusLineEdit.h</header>
- </customwidget>
- </customwidgets>
<tabstops>
+ <tabstop>iconButton</tabstop>
<tabstop>instNameTextBox</tabstop>
<tabstop>groupBox</tabstop>
- <tabstop>versionBox</tabstop>
- <tabstop>versionTextBox</tabstop>
- <tabstop>btnChangeVersion</tabstop>
- <tabstop>modpackBox</tabstop>
- <tabstop>modpackEdit</tabstop>
- <tabstop>modpackBtn</tabstop>
- <tabstop>iconButton</tabstop>
</tabstops>
<resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>NewInstanceDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>266</x>
- <y>378</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>buttonBox</sender>
- <signal>rejected()</signal>
- <receiver>NewInstanceDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>271</x>
- <y>378</y>
- </hint>
- <hint type="destinationlabel">
- <x>280</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>modpackBox</sender>
- <signal>toggled(bool)</signal>
- <receiver>modpackEdit</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>91</x>
- <y>251</y>
- </hint>
- <hint type="destinationlabel">
- <x>240</x>
- <y>278</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>modpackBox</sender>
- <signal>toggled(bool)</signal>
- <receiver>modpackBtn</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>139</x>
- <y>251</y>
- </hint>
- <hint type="destinationlabel">
- <x>270</x>
- <y>278</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>versionBox</sender>
- <signal>toggled(bool)</signal>
- <receiver>versionTextBox</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>93</x>
- <y>195</y>
- </hint>
- <hint type="destinationlabel">
- <x>223</x>
- <y>224</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>versionBox</sender>
- <signal>toggled(bool)</signal>
- <receiver>btnChangeVersion</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>104</x>
- <y>198</y>
- </hint>
- <hint type="destinationlabel">
- <x>270</x>
- <y>224</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>ftbBox</sender>
- <signal>toggled(bool)</signal>
- <receiver>btnChooseFtbPack</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>67</x>
- <y>301</y>
- </hint>
- <hint type="destinationlabel">
- <x>254</x>
- <y>327</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>ftbBox</sender>
- <signal>toggled(bool)</signal>
- <receiver>labelFtbPack</receiver>
- <slot>setEnabled(bool)</slot>
- <hints>
- <hint type="sourcelabel">
- <x>81</x>
- <y>310</y>
- </hint>
- <hint type="destinationlabel">
- <x>73</x>
- <y>334</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
diff --git a/application/dialogs/VersionSelectDialog.cpp b/application/dialogs/VersionSelectDialog.cpp
index a44572cc..1ed81e79 100644
--- a/application/dialogs/VersionSelectDialog.cpp
+++ b/application/dialogs/VersionSelectDialog.cpp
@@ -40,7 +40,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title,
m_verticalLayout = new QVBoxLayout(this);
m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
- m_versionWidget = new VersionSelectWidget(vlist, parent);
+ m_versionWidget = new VersionSelectWidget(parent);
m_verticalLayout->addWidget(m_versionWidget);
m_horizontalLayout = new QHBoxLayout();
@@ -107,7 +107,7 @@ void VersionSelectDialog::setResizeOn(int column)
int VersionSelectDialog::exec()
{
QDialog::open();
- m_versionWidget->initialize();
+ m_versionWidget->initialize(m_vlist);
return QDialog::exec();
}
diff --git a/application/pagedialog/PageDialog.cpp b/application/pagedialog/PageDialog.cpp
index b201de85..1b5284d2 100644
--- a/application/pagedialog/PageDialog.cpp
+++ b/application/pagedialog/PageDialog.cpp
@@ -25,7 +25,7 @@
#include "widgets/IconLabel.h"
#include "widgets/PageContainer.h"
-PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWidget *parent)
+PageDialog::PageDialog(BasePageProvider *pageProvider, QString defaultId, QWidget *parent)
: QDialog(parent)
{
setWindowTitle(pageProvider->dialogTitle());
@@ -37,17 +37,14 @@ PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWid
mainLayout->setContentsMargins(0, 0, 0, 0);
setLayout(mainLayout);
- QDialogButtonBox *buttons =
- new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close);
+ QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close);
buttons->button(QDialogButtonBox::Close)->setDefault(true);
m_container->addButtons(buttons);
connect(buttons->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));
- connect(buttons->button(QDialogButtonBox::Help), SIGNAL(clicked()), m_container,
- SLOT(help()));
+ connect(buttons->button(QDialogButtonBox::Help), SIGNAL(clicked()), m_container, SLOT(help()));
- restoreGeometry(
- QByteArray::fromBase64(MMC->settings()->get("PagedGeometry").toByteArray()));
+ restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("PagedGeometry").toByteArray()));
}
void PageDialog::closeEvent(QCloseEvent *event)
diff --git a/application/pagedialog/PageDialog.h b/application/pagedialog/PageDialog.h
index 67cd290e..a287f9c9 100644
--- a/application/pagedialog/PageDialog.h
+++ b/application/pagedialog/PageDialog.h
@@ -23,8 +23,7 @@ class PageDialog : public QDialog
{
Q_OBJECT
public:
- explicit PageDialog(BasePageProviderPtr pageProvider, QString defaultId = QString(),
- QWidget *parent = 0);
+ explicit PageDialog(BasePageProvider *pageProvider, QString defaultId = QString(), QWidget *parent = 0);
virtual ~PageDialog() {}
private
diff --git a/application/pages/BasePage.h b/application/pages/BasePage.h
index 63a26239..d4547770 100644
--- a/application/pages/BasePage.h
+++ b/application/pages/BasePage.h
@@ -31,8 +31,18 @@ public:
virtual bool apply() { return true; }
virtual bool shouldDisplay() const { return true; }
virtual QString helpPage() const { return QString(); }
- virtual void opened() {}
- virtual void closed() {}
+ void opened()
+ {
+ isOpened = true;
+ openedImpl();
+ }
+ void closed()
+ {
+ isOpened = false;
+ closedImpl();
+ }
+ virtual void openedImpl() {}
+ virtual void closedImpl() {}
virtual void setParentContainer(BasePageContainer * container)
{
m_container = container;
@@ -42,6 +52,7 @@ public:
int listIndex = -1;
protected:
BasePageContainer * m_container = nullptr;
+ bool isOpened = false;
};
typedef std::shared_ptr<BasePage> BasePagePtr;
diff --git a/application/pages/BasePageProvider.h b/application/pages/BasePageProvider.h
index 0ebcff7a..1cc7458a 100644
--- a/application/pages/BasePageProvider.h
+++ b/application/pages/BasePageProvider.h
@@ -15,7 +15,7 @@
#pragma once
-#include "BasePage.h"
+#include "pages/BasePage.h"
#include <memory>
#include <functional>
@@ -65,5 +65,3 @@ private:
QList<PageCreator> m_creators;
QString m_dialogTitle;
};
-
-typedef std::shared_ptr<BasePageProvider> BasePageProviderPtr;
diff --git a/application/pages/global/PackagesPage.cpp b/application/pages/global/PackagesPage.cpp
index 5fd4934c..7cf1e3f5 100644
--- a/application/pages/global/PackagesPage.cpp
+++ b/application/pages/global/PackagesPage.cpp
@@ -218,7 +218,7 @@ void PackagesPage::updateVersion()
}
}
-void PackagesPage::opened()
+void PackagesPage::openedImpl()
{
ENV.metadataIndex()->load(Net::Mode::Offline);
}
diff --git a/application/pages/global/PackagesPage.h b/application/pages/global/PackagesPage.h
index 2afbcf8e..ad155d9e 100644
--- a/application/pages/global/PackagesPage.h
+++ b/application/pages/global/PackagesPage.h
@@ -36,7 +36,7 @@ public:
QString id() const override { return "packages-global"; }
QString displayName() const override { return tr("Packages"); }
QIcon icon() const override;
- void opened() override;
+ void openedImpl() override;
private slots:
void on_refreshIndexBtn_clicked();
diff --git a/application/pages/InstanceSettingsPage.cpp b/application/pages/instance/InstanceSettingsPage.cpp
index 71e90a32..71e90a32 100644
--- a/application/pages/InstanceSettingsPage.cpp
+++ b/application/pages/instance/InstanceSettingsPage.cpp
diff --git a/application/pages/InstanceSettingsPage.h b/application/pages/instance/InstanceSettingsPage.h
index 4959bdbe..c5d7d3b6 100644
--- a/application/pages/InstanceSettingsPage.h
+++ b/application/pages/instance/InstanceSettingsPage.h
@@ -20,7 +20,7 @@
#include "java/JavaChecker.h"
#include "BaseInstance.h"
#include <QObjectPtr.h>
-#include "BasePage.h"
+#include "pages/BasePage.h"
#include "JavaCommon.h"
#include "MultiMC.h"
diff --git a/application/pages/InstanceSettingsPage.ui b/application/pages/instance/InstanceSettingsPage.ui
index 0c180df3..0c180df3 100644
--- a/application/pages/InstanceSettingsPage.ui
+++ b/application/pages/instance/InstanceSettingsPage.ui
diff --git a/application/pages/LegacyUpgradePage.cpp b/application/pages/instance/LegacyUpgradePage.cpp
index a8f4a08c..f808ab88 100644
--- a/application/pages/LegacyUpgradePage.cpp
+++ b/application/pages/instance/LegacyUpgradePage.cpp
@@ -35,7 +35,12 @@ void LegacyUpgradePage::runModalTask(Task *task)
void LegacyUpgradePage::on_upgradeButton_clicked()
{
- std::unique_ptr<Task> task(MMC->folderProvider()->legacyUpgradeTask(m_inst));
+ QString newName = tr("%1 (Migrated)").arg(m_inst->name());
+ auto upgradeTask = new LegacyUpgradeTask(m_inst);
+ upgradeTask->setName(newName);
+ upgradeTask->setGroup(m_inst->group());
+ upgradeTask->setIcon(m_inst->iconKey());
+ std::unique_ptr<Task> task(MMC->folderProvider()->wrapInstanceTask(upgradeTask));
runModalTask(task.get());
}
diff --git a/application/pages/LegacyUpgradePage.h b/application/pages/instance/LegacyUpgradePage.h
index 3e1abe93..3e1abe93 100644
--- a/application/pages/LegacyUpgradePage.h
+++ b/application/pages/instance/LegacyUpgradePage.h
diff --git a/application/pages/LegacyUpgradePage.ui b/application/pages/instance/LegacyUpgradePage.ui
index a94ee039..a94ee039 100644
--- a/application/pages/LegacyUpgradePage.ui
+++ b/application/pages/instance/LegacyUpgradePage.ui
diff --git a/application/pages/LogPage.cpp b/application/pages/instance/LogPage.cpp
index 0fa1ee67..0fa1ee67 100644
--- a/application/pages/LogPage.cpp
+++ b/application/pages/instance/LogPage.cpp
diff --git a/application/pages/LogPage.h b/application/pages/instance/LogPage.h
index b830118e..2229418d 100644
--- a/application/pages/LogPage.h
+++ b/application/pages/instance/LogPage.h
@@ -19,7 +19,7 @@
#include "BaseInstance.h"
#include "launch/LaunchTask.h"
-#include "BasePage.h"
+#include "pages/BasePage.h"
#include <MultiMC.h>
namespace Ui
diff --git a/application/pages/LogPage.ui b/application/pages/instance/LogPage.ui
index 4843d7c3..4843d7c3 100644
--- a/application/pages/LogPage.ui
+++ b/application/pages/instance/LogPage.ui
diff --git a/application/pages/ModFolderPage.cpp b/application/pages/instance/ModFolderPage.cpp
index 2b3f4416..90155df3 100644
--- a/application/pages/ModFolderPage.cpp
+++ b/application/pages/instance/ModFolderPage.cpp
@@ -59,12 +59,12 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods,
connect(ui->filterEdit, &QLineEdit::textChanged, this, &ModFolderPage::on_filterTextChanged );
}
-void ModFolderPage::opened()
+void ModFolderPage::openedImpl()
{
m_mods->startWatching();
}
-void ModFolderPage::closed()
+void ModFolderPage::closedImpl()
{
m_mods->stopWatching();
}
diff --git a/application/pages/ModFolderPage.h b/application/pages/instance/ModFolderPage.h
index 02282c41..15e728cb 100644
--- a/application/pages/ModFolderPage.h
+++ b/application/pages/instance/ModFolderPage.h
@@ -18,7 +18,7 @@
#include <QWidget>
#include "minecraft/MinecraftInstance.h"
-#include "BasePage.h"
+#include "pages/BasePage.h"
#include <MultiMC.h>
class ModList;
@@ -60,8 +60,8 @@ public:
}
virtual bool shouldDisplay() const override;
- virtual void opened() override;
- virtual void closed() override;
+ virtual void openedImpl() override;
+ virtual void closedImpl() override;
protected:
bool eventFilter(QObject *obj, QEvent *ev) override;
bool modListFilter(QKeyEvent *ev);
diff --git a/application/pages/ModFolderPage.ui b/application/pages/instance/ModFolderPage.ui
index b5597bdc..b5597bdc 100644
--- a/application/pages/ModFolderPage.ui
+++ b/application/pages/instance/ModFolderPage.ui
diff --git a/application/pages/NotesPage.cpp b/application/pages/instance/NotesPage.cpp
index 48bb468c..48bb468c 100644
--- a/application/pages/NotesPage.cpp
+++ b/application/pages/instance/NotesPage.cpp
diff --git a/application/pages/NotesPage.h b/application/pages/instance/NotesPage.h
index eab446ad..4a25f9b1 100644
--- a/application/pages/NotesPage.h
+++ b/application/pages/instance/NotesPage.h
@@ -18,7 +18,7 @@
#include <QWidget>
#include "BaseInstance.h"
-#include "BasePage.h"
+#include "pages/BasePage.h"
#include <MultiMC.h>
namespace Ui
diff --git a/application/pages/NotesPage.ui b/application/pages/instance/NotesPage.ui
index 88cca92f..88cca92f 100644
--- a/application/pages/NotesPage.ui
+++ b/application/pages/instance/NotesPage.ui
diff --git a/application/pages/OtherLogsPage.cpp b/application/pages/instance/OtherLogsPage.cpp
index 2141e0cc..10cb1145 100644
--- a/application/pages/OtherLogsPage.cpp
+++ b/application/pages/instance/OtherLogsPage.cpp
@@ -54,11 +54,11 @@ OtherLogsPage::~OtherLogsPage()
delete ui;
}
-void OtherLogsPage::opened()
+void OtherLogsPage::openedImpl()
{
m_watcher->enable();
}
-void OtherLogsPage::closed()
+void OtherLogsPage::closedImpl()
{
m_watcher->disable();
}
diff --git a/application/pages/OtherLogsPage.h b/application/pages/instance/OtherLogsPage.h
index 157f5e9d..ac01ef0a 100644
--- a/application/pages/OtherLogsPage.h
+++ b/application/pages/instance/OtherLogsPage.h
@@ -17,7 +17,7 @@
#include <QWidget>
-#include "BasePage.h"
+#include "pages/BasePage.h"
#include <MultiMC.h>
#include <pathmatcher/IPathMatcher.h>
@@ -52,8 +52,8 @@ public:
{
return "Minecraft-Logs";
}
- void opened() override;
- void closed() override;
+ void openedImpl() override;
+ void closedImpl() override;
private slots:
void populateSelectLogBox();
diff --git a/application/pages/OtherLogsPage.ui b/application/pages/instance/OtherLogsPage.ui
index 56ff3b62..56ff3b62 100644
--- a/application/pages/OtherLogsPage.ui
+++ b/application/pages/instance/OtherLogsPage.ui
diff --git a/application/pages/ResourcePackPage.h b/application/pages/instance/ResourcePackPage.h
index 19dc78da..19dc78da 100644
--- a/application/pages/ResourcePackPage.h
+++ b/application/pages/instance/ResourcePackPage.h
diff --git a/application/pages/ScreenshotsPage.cpp b/application/pages/instance/ScreenshotsPage.cpp
index 7d32576a..71458386 100644
--- a/application/pages/ScreenshotsPage.cpp
+++ b/application/pages/instance/ScreenshotsPage.cpp
@@ -347,7 +347,7 @@ void ScreenshotsPage::on_renameBtn_clicked()
// TODO: mass renaming
}
-void ScreenshotsPage::opened()
+void ScreenshotsPage::openedImpl()
{
if(!m_valid)
{
diff --git a/application/pages/ScreenshotsPage.h b/application/pages/instance/ScreenshotsPage.h
index c3ccbdee..e31fb8b4 100644
--- a/application/pages/ScreenshotsPage.h
+++ b/application/pages/instance/ScreenshotsPage.h
@@ -17,7 +17,7 @@
#include <QWidget>
-#include "BasePage.h"
+#include "pages/BasePage.h"
#include <MultiMC.h>
class QFileSystemModel;
@@ -39,7 +39,7 @@ public:
explicit ScreenshotsPage(QString path, QWidget *parent = 0);
virtual ~ScreenshotsPage();
- virtual void opened() override;
+ virtual void openedImpl() override;
enum
{
diff --git a/application/pages/ScreenshotsPage.ui b/application/pages/instance/ScreenshotsPage.ui
index d05c4384..d05c4384 100644
--- a/application/pages/ScreenshotsPage.ui
+++ b/application/pages/instance/ScreenshotsPage.ui
diff --git a/application/pages/TexturePackPage.h b/application/pages/instance/TexturePackPage.h
index b03614f0..b03614f0 100644
--- a/application/pages/TexturePackPage.h
+++ b/application/pages/instance/TexturePackPage.h
diff --git a/application/pages/VersionPage.cpp b/application/pages/instance/VersionPage.cpp
index 00ae0a7e..00ae0a7e 100644
--- a/application/pages/VersionPage.cpp
+++ b/application/pages/instance/VersionPage.cpp
diff --git a/application/pages/VersionPage.h b/application/pages/instance/VersionPage.h
index 49620c56..85304ea5 100644
--- a/application/pages/VersionPage.h
+++ b/application/pages/instance/VersionPage.h
@@ -19,7 +19,7 @@
#include "minecraft/MinecraftInstance.h"
#include "minecraft/ComponentList.h"
-#include "BasePage.h"
+#include "pages/BasePage.h"
namespace Ui
{
diff --git a/application/pages/VersionPage.ui b/application/pages/instance/VersionPage.ui
index d54dd840..d54dd840 100644
--- a/application/pages/VersionPage.ui
+++ b/application/pages/instance/VersionPage.ui
diff --git a/application/pages/WorldListPage.cpp b/application/pages/instance/WorldListPage.cpp
index 56a7e791..539d26a0 100644
--- a/application/pages/WorldListPage.cpp
+++ b/application/pages/instance/WorldListPage.cpp
@@ -55,12 +55,12 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
worldChanged(QModelIndex(), QModelIndex());
}
-void WorldListPage::opened()
+void WorldListPage::openedImpl()
{
m_worlds->startWatching();
}
-void WorldListPage::closed()
+void WorldListPage::closedImpl()
{
m_worlds->stopWatching();
}
diff --git a/application/pages/WorldListPage.h b/application/pages/instance/WorldListPage.h
index d0aa6150..71b87bda 100644
--- a/application/pages/WorldListPage.h
+++ b/application/pages/instance/WorldListPage.h
@@ -18,7 +18,7 @@
#include <QWidget>
#include "minecraft/MinecraftInstance.h"
-#include "BasePage.h"
+#include "pages/BasePage.h"
#include <MultiMC.h>
#include <LoggedProcess.h>
@@ -56,8 +56,8 @@ public:
}
virtual bool shouldDisplay() const override;
- virtual void opened() override;
- virtual void closed() override;
+ virtual void openedImpl() override;
+ virtual void closedImpl() override;
protected:
bool eventFilter(QObject *obj, QEvent *ev) override;
diff --git a/application/pages/WorldListPage.ui b/application/pages/instance/WorldListPage.ui
index 0018ddf3..0018ddf3 100644
--- a/application/pages/WorldListPage.ui
+++ b/application/pages/instance/WorldListPage.ui
diff --git a/application/pages/modplatform/FTBPage.cpp b/application/pages/modplatform/FTBPage.cpp
new file mode 100644
index 00000000..a8ec6577
--- /dev/null
+++ b/application/pages/modplatform/FTBPage.cpp
@@ -0,0 +1,152 @@
+#include "FTBPage.h"
+#include "ui_FTBPage.h"
+
+#include "MultiMC.h"
+#include "FolderInstanceProvider.h"
+#include "dialogs/CustomMessageBox.h"
+#include "dialogs/NewInstanceDialog.h"
+#include "modplatform/ftb/FtbPackDownloader.h"
+#include "modplatform/ftb/FtbPackInstallTask.h"
+#include <FtbListModel.h>
+
+FTBPage::FTBPage(NewInstanceDialog* dialog, QWidget *parent)
+ : QWidget(parent), dialog(dialog), ui(new Ui::FTBPage)
+{
+ ui->setupUi(this);
+ ftbPackDownloader = new FtbPackDownloader();
+
+ connect(ftbPackDownloader, &FtbPackDownloader::ready, this, &FTBPage::ftbPackDataDownloadSuccessfully);
+ connect(ftbPackDownloader, &FtbPackDownloader::packFetchFailed, this, &FTBPage::ftbPackDataDownloadFailed);
+
+ filterModel = new FtbFilterModel(this);
+ listModel = new FtbListModel(this);
+ filterModel->setSourceModel(listModel);
+
+ ui->packList->setModel(filterModel);
+ ui->packList->setSortingEnabled(true);
+ ui->packList->header()->hide();
+ ui->packList->setIndentation(0);
+
+ filterModel->setSorting(FtbFilterModel::Sorting::ByName);
+
+ for(int i = 0; i < filterModel->getAvailableSortings().size(); i++)
+ {
+ ui->sortByBox->addItem(filterModel->getAvailableSortings().keys().at(i));
+ }
+
+ ui->sortByBox->setCurrentText(filterModel->getAvailableSortings().key(filterModel->getCurrentSorting()));
+
+ connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FTBPage::onSortingSelectionChanged);
+ connect(ui->packVersionSelection, &QComboBox::currentTextChanged, this, &FTBPage::onVersionSelectionItemChanged);
+ connect(ui->packList->selectionModel(), &QItemSelectionModel::currentChanged, this, &FTBPage::onPackSelectionChanged);
+
+ ui->modpackInfo->setOpenExternalLinks(true);
+}
+
+FTBPage::~FTBPage()
+{
+ delete ui;
+ if(ftbPackDownloader)
+ {
+ ftbPackDownloader->deleteLater();
+ }
+}
+
+bool FTBPage::shouldDisplay() const
+{
+ return true;
+}
+
+void FTBPage::openedImpl()
+{
+ if(!initialized)
+ {
+ ftbPackDownloader->fetchModpacks(false);
+ initialized = true;
+ }
+ suggestCurrent();
+}
+
+void FTBPage::suggestCurrent()
+{
+ if(isOpened)
+ {
+ if(!selected.broken)
+ {
+ dialog->setSuggestedPack(selected.name, new FtbPackInstallTask(selected, selectedVersion));
+ }
+ else
+ {
+ dialog->setSuggestedPack();
+ }
+ }
+}
+
+FtbPackDownloader *FTBPage::getFtbPackDownloader()
+{
+ return ftbPackDownloader;
+}
+
+void FTBPage::ftbPackDataDownloadSuccessfully()
+{
+ listModel->fill(ftbPackDownloader->getModpacks());
+}
+
+void FTBPage::ftbPackDataDownloadFailed()
+{
+ qDebug() << "Stuff went missing while grabbing FTB pack list or something...";
+}
+
+void FTBPage::onPackSelectionChanged(QModelIndex now, QModelIndex prev)
+{
+ ui->packVersionSelection->clear();
+ FtbModpack selectedPack = filterModel->data(now, Qt::UserRole).value<FtbModpack>();
+
+ ui->modpackInfo->setHtml("Pack by <b>" + selectedPack.author + "</b>" + "<br>Minecraft " + selectedPack.mcVersion + "<br>"
+ "<br>" + selectedPack.description + "<ul><li>" + selectedPack.mods.replace(";", "</li><li>") + "</li></ul>");
+
+ bool currentAdded = false;
+
+ for(int i = 0; i < selectedPack.oldVersions.size(); i++)
+ {
+ if(selectedPack.currentVersion == selectedPack.oldVersions.at(i))
+ {
+ currentAdded = true;
+ }
+ ui->packVersionSelection->addItem(selectedPack.oldVersions.at(i));
+ }
+
+ if(!currentAdded)
+ {
+ ui->packVersionSelection->addItem(selectedPack.currentVersion);
+ }
+
+ selected = selectedPack;
+ suggestCurrent();
+}
+
+void FTBPage::onVersionSelectionItemChanged(QString data)
+{
+ if(data.isNull() || data.isEmpty())
+ {
+ selectedVersion = "";
+ return;
+ }
+
+ selectedVersion = data;
+}
+
+FtbModpack FTBPage::getSelectedModpack()
+{
+ return selected;
+}
+
+QString FTBPage::getSelectedVersion()
+{
+ return selectedVersion;
+}
+
+void FTBPage::onSortingSelectionChanged(QString data)
+{
+ filterModel->setSorting(filterModel->getAvailableSortings().value(data));
+}
diff --git a/application/pages/modplatform/FTBPage.h b/application/pages/modplatform/FTBPage.h
new file mode 100644
index 00000000..f7d6ca8b
--- /dev/null
+++ b/application/pages/modplatform/FTBPage.h
@@ -0,0 +1,86 @@
+/* Copyright 2013-2018 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <QWidget>
+
+#include "pages/BasePage.h"
+#include <MultiMC.h>
+#include "tasks/Task.h"
+#include "modplatform/ftb/PackHelpers.h"
+
+namespace Ui
+{
+class FTBPage;
+}
+
+class FtbListModel;
+class FtbFilterModel;
+class FtbPackDownloader;
+class NewInstanceDialog;
+
+class FTBPage : public QWidget, public BasePage
+{
+ Q_OBJECT
+
+public:
+ explicit FTBPage(NewInstanceDialog * dialog, QWidget *parent = 0);
+ virtual ~FTBPage();
+ QString displayName() const override
+ {
+ return tr("FTB Legacy");
+ }
+ QIcon icon() const override
+ {
+ return MMC->getThemedIcon("ftb_logo");
+ }
+ QString id() const override
+ {
+ return "ftb";
+ }
+ QString helpPage() const override
+ {
+ return "FTB-platform";
+ }
+ bool shouldDisplay() const override;
+ void openedImpl() override;
+
+ FtbPackDownloader* getFtbPackDownloader();
+ FtbModpack getSelectedModpack();
+ QString getSelectedVersion();
+
+private:
+ void suggestCurrent();
+
+private slots:
+ void ftbPackDataDownloadSuccessfully();
+ void ftbPackDataDownloadFailed();
+ void onSortingSelectionChanged(QString data);
+ void onVersionSelectionItemChanged(QString data);
+ void onPackSelectionChanged(QModelIndex first, QModelIndex second);
+
+private:
+ bool initialized = false;
+ FtbPackDownloader* ftbPackDownloader = nullptr;
+ FtbModpack selectedPack;
+ FtbModpack selected;
+ QString selectedVersion;
+ FtbListModel* listModel = nullptr;
+ FtbFilterModel* filterModel = nullptr;
+ NewInstanceDialog* dialog = nullptr;
+
+ Ui::FTBPage *ui = nullptr;
+};
diff --git a/application/pages/modplatform/FTBPage.ui b/application/pages/modplatform/FTBPage.ui
new file mode 100644
index 00000000..c54fc392
--- /dev/null
+++ b/application/pages/modplatform/FTBPage.ui
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FTBPage</class>
+ <widget class="QWidget" name="FTBPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>801</width>
+ <height>674</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QTreeView" name="packList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="3">
+ <widget class="QTextBrowser" name="modpackInfo"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QComboBox" name="sortByBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="selectedVersionLabel">
+ <property name="text">
+ <string>Version selected:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" colspan="2">
+ <widget class="QComboBox" name="packVersionSelection">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/application/pages/modplatform/ImportPage.cpp b/application/pages/modplatform/ImportPage.cpp
new file mode 100644
index 00000000..545ca38d
--- /dev/null
+++ b/application/pages/modplatform/ImportPage.cpp
@@ -0,0 +1,125 @@
+#include "ImportPage.h"
+#include "ui_ImportPage.h"
+
+#include "MultiMC.h"
+#include "FolderInstanceProvider.h"
+#include "dialogs/CustomMessageBox.h"
+#include "dialogs/ProgressDialog.h"
+#include "dialogs/NewInstanceDialog.h"
+#include <QFileDialog>
+#include <InstanceImportTask.h>
+
+class UrlValidator : public QValidator
+{
+public:
+ using QValidator::QValidator;
+
+ State validate(QString &in, int &pos) const
+ {
+ const QUrl url(in);
+ if (url.isValid() && !url.isRelative() && !url.isEmpty())
+ {
+ return Acceptable;
+ }
+ else if (QFile::exists(in))
+ {
+ return Acceptable;
+ }
+ else
+ {
+ return Intermediate;
+ }
+ }
+};
+
+ImportPage::ImportPage(NewInstanceDialog* dialog, QWidget *parent)
+ : QWidget(parent), ui(new Ui::ImportPage), dialog(dialog)
+{
+ ui->setupUi(this);
+ ui->modpackEdit->setValidator(new UrlValidator(ui->modpackEdit));
+ connect(ui->modpackEdit, &QLineEdit::textChanged, this, &ImportPage::updateState);
+}
+
+ImportPage::~ImportPage()
+{
+ delete ui;
+}
+
+bool ImportPage::shouldDisplay() const
+{
+ return true;
+}
+
+void ImportPage::openedImpl()
+{
+ updateState();
+}
+
+void ImportPage::updateState()
+{
+ if(!isOpened)
+ {
+ return;
+ }
+ if(ui->modpackEdit->hasAcceptableInput())
+ {
+ QString input = ui->modpackEdit->text();
+ auto url = QUrl::fromUserInput(input);
+ if(url.isLocalFile())
+ {
+ // FIXME: actually do some validation of what's inside here... this is fake AF
+ QFileInfo fi(input);
+ if(fi.exists() && fi.suffix() == "zip")
+ {
+ QFileInfo fi(url.fileName());
+ dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url));
+ }
+ }
+ else
+ {
+ // hook, line and sinker.
+ QFileInfo fi(url.fileName());
+ dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url));
+ }
+ }
+ else
+ {
+ dialog->setSuggestedPack();
+ }
+}
+
+void ImportPage::setUrl(const QString& url)
+{
+ ui->modpackEdit->setText(url);
+ updateState();
+}
+
+void ImportPage::on_modpackBtn_clicked()
+{
+ const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), tr("Zip (*.zip)"));
+ if (url.isValid())
+ {
+ if (url.isLocalFile())
+ {
+ ui->modpackEdit->setText(url.toLocalFile());
+ }
+ else
+ {
+ ui->modpackEdit->setText(url.toString());
+ }
+ }
+}
+
+
+QUrl ImportPage::modpackUrl() const
+{
+ const QUrl url(ui->modpackEdit->text());
+ if (url.isValid() && !url.isRelative() && !url.host().isEmpty())
+ {
+ return url;
+ }
+ else
+ {
+ return QUrl::fromLocalFile(ui->modpackEdit->text());
+ }
+}
diff --git a/application/pages/modplatform/ImportPage.h b/application/pages/modplatform/ImportPage.h
new file mode 100644
index 00000000..8f62e6b1
--- /dev/null
+++ b/application/pages/modplatform/ImportPage.h
@@ -0,0 +1,70 @@
+/* Copyright 2013-2018 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <QWidget>
+
+#include "pages/BasePage.h"
+#include <MultiMC.h>
+#include "tasks/Task.h"
+
+namespace Ui
+{
+class ImportPage;
+}
+
+class NewInstanceDialog;
+
+class ImportPage : public QWidget, public BasePage
+{
+ Q_OBJECT
+
+public:
+ explicit ImportPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ virtual ~ImportPage();
+ virtual QString displayName() const override
+ {
+ return tr("Import from zip");
+ }
+ virtual QIcon icon() const override
+ {
+ return MMC->getThemedIcon("viewfolder");
+ }
+ virtual QString id() const override
+ {
+ return "import";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Zip-import";
+ }
+ virtual bool shouldDisplay() const override;
+
+ void setUrl(const QString & url);
+ void openedImpl() override;
+
+private slots:
+ void on_modpackBtn_clicked();
+ void updateState();
+
+private:
+ QUrl modpackUrl() const;
+
+private:
+ Ui::ImportPage *ui = nullptr;
+ NewInstanceDialog* dialog = nullptr;
+};
+
diff --git a/application/pages/modplatform/ImportPage.ui b/application/pages/modplatform/ImportPage.ui
new file mode 100644
index 00000000..eb63cbe9
--- /dev/null
+++ b/application/pages/modplatform/ImportPage.ui
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ImportPage</class>
+ <widget class="QWidget" name="ImportPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>546</width>
+ <height>405</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="1">
+ <widget class="QPushButton" name="modpackBtn">
+ <property name="text">
+ <string>Browse</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLineEdit" name="modpackEdit">
+ <property name="placeholderText">
+ <string notr="true">http://</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="modpackLabel">
+ <property name="text">
+ <string>Local file or link to a direct download:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/application/pages/modplatform/TechnicPage.cpp b/application/pages/modplatform/TechnicPage.cpp
new file mode 100644
index 00000000..c0f4faa5
--- /dev/null
+++ b/application/pages/modplatform/TechnicPage.cpp
@@ -0,0 +1,29 @@
+#include "TechnicPage.h"
+#include "ui_TechnicPage.h"
+
+#include "MultiMC.h"
+#include "FolderInstanceProvider.h"
+#include "dialogs/CustomMessageBox.h"
+#include "dialogs/ProgressDialog.h"
+#include "dialogs/NewInstanceDialog.h"
+
+TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget *parent)
+ : QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog)
+{
+ ui->setupUi(this);
+}
+
+TechnicPage::~TechnicPage()
+{
+ delete ui;
+}
+
+bool TechnicPage::shouldDisplay() const
+{
+ return true;
+}
+
+void TechnicPage::openedImpl()
+{
+ dialog->setSuggestedPack();
+}
diff --git a/application/pages/modplatform/TechnicPage.h b/application/pages/modplatform/TechnicPage.h
new file mode 100644
index 00000000..5b0f16a6
--- /dev/null
+++ b/application/pages/modplatform/TechnicPage.h
@@ -0,0 +1,61 @@
+/* Copyright 2013-2018 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <QWidget>
+
+#include "pages/BasePage.h"
+#include <MultiMC.h>
+#include "tasks/Task.h"
+
+namespace Ui
+{
+class TechnicPage;
+}
+
+class NewInstanceDialog;
+
+class TechnicPage : public QWidget, public BasePage
+{
+ Q_OBJECT
+
+public:
+ explicit TechnicPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ virtual ~TechnicPage();
+ virtual QString displayName() const override
+ {
+ return tr("Technic");
+ }
+ virtual QIcon icon() const override
+ {
+ return MMC->getThemedIcon("technic");
+ }
+ virtual QString id() const override
+ {
+ return "technic";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Technic-platform";
+ }
+ virtual bool shouldDisplay() const override;
+
+ void openedImpl() override;
+
+private:
+ Ui::TechnicPage *ui = nullptr;
+ NewInstanceDialog* dialog = nullptr;
+};
diff --git a/application/pages/modplatform/TechnicPage.ui b/application/pages/modplatform/TechnicPage.ui
new file mode 100644
index 00000000..6bb6e9e0
--- /dev/null
+++ b/application/pages/modplatform/TechnicPage.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TechnicPage</class>
+ <widget class="QWidget" name="TechnicPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>546</width>
+ <height>405</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="font">
+ <font>
+ <pointsize>40</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string notr="true">¯\_(ツ)_/¯ </string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/application/pages/modplatform/TwitchPage.cpp b/application/pages/modplatform/TwitchPage.cpp
new file mode 100644
index 00000000..a264c2f7
--- /dev/null
+++ b/application/pages/modplatform/TwitchPage.cpp
@@ -0,0 +1,29 @@
+#include "TwitchPage.h"
+#include "ui_TwitchPage.h"
+
+#include "MultiMC.h"
+#include "FolderInstanceProvider.h"
+#include "dialogs/CustomMessageBox.h"
+#include "dialogs/ProgressDialog.h"
+#include "dialogs/NewInstanceDialog.h"
+
+TwitchPage::TwitchPage(NewInstanceDialog* dialog, QWidget *parent)
+ : QWidget(parent), ui(new Ui::TwitchPage), dialog(dialog)
+{
+ ui->setupUi(this);
+}
+
+TwitchPage::~TwitchPage()
+{
+ delete ui;
+}
+
+bool TwitchPage::shouldDisplay() const
+{
+ return true;
+}
+
+void TwitchPage::openedImpl()
+{
+ dialog->setSuggestedPack();
+}
diff --git a/application/pages/modplatform/TwitchPage.h b/application/pages/modplatform/TwitchPage.h
new file mode 100644
index 00000000..8e072917
--- /dev/null
+++ b/application/pages/modplatform/TwitchPage.h
@@ -0,0 +1,61 @@
+/* Copyright 2013-2018 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <QWidget>
+
+#include "pages/BasePage.h"
+#include <MultiMC.h>
+#include "tasks/Task.h"
+
+namespace Ui
+{
+class TwitchPage;
+}
+
+class NewInstanceDialog;
+
+class TwitchPage : public QWidget, public BasePage
+{
+ Q_OBJECT
+
+public:
+ explicit TwitchPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ virtual ~TwitchPage();
+ virtual QString displayName() const override
+ {
+ return tr("Twitch");
+ }
+ virtual QIcon icon() const override
+ {
+ return MMC->getThemedIcon("twitch");
+ }
+ virtual QString id() const override
+ {
+ return "twitch";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Twitch-platform";
+ }
+ virtual bool shouldDisplay() const override;
+
+ void openedImpl() override;
+
+private:
+ Ui::TwitchPage *ui = nullptr;
+ NewInstanceDialog* dialog = nullptr;
+};
diff --git a/application/pages/modplatform/TwitchPage.ui b/application/pages/modplatform/TwitchPage.ui
new file mode 100644
index 00000000..19178505
--- /dev/null
+++ b/application/pages/modplatform/TwitchPage.ui
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TwitchPage</class>
+ <widget class="QWidget" name="TwitchPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>546</width>
+ <height>405</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="font">
+ <font>
+ <pointsize>40</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string notr="true">¯\_(ツ)_/¯ </string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/application/pages/modplatform/VanillaPage.cpp b/application/pages/modplatform/VanillaPage.cpp
new file mode 100644
index 00000000..013ca426
--- /dev/null
+++ b/application/pages/modplatform/VanillaPage.cpp
@@ -0,0 +1,114 @@
+#include "VanillaPage.h"
+#include "ui_VanillaPage.h"
+
+#include "MultiMC.h"
+#include "FolderInstanceProvider.h"
+#include "dialogs/CustomMessageBox.h"
+#include "dialogs/ProgressDialog.h"
+
+#include <meta/Index.h>
+#include <meta/VersionList.h>
+#include <dialogs/NewInstanceDialog.h>
+#include <Filter.h>
+#include <Env.h>
+#include <InstanceCreationTask.h>
+
+VanillaPage::VanillaPage(NewInstanceDialog *dialog, QWidget *parent)
+ : QWidget(parent), dialog(dialog), ui(new Ui::VanillaPage)
+{
+ ui->setupUi(this);
+ ui->tabWidget->tabBar()->hide();
+ connect(ui->versionList, &VersionSelectWidget::selectedVersionChanged, this, &VanillaPage::setSelectedVersion);
+ filterChanged();
+ connect(ui->alphaFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged);
+ connect(ui->betaFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged);
+ connect(ui->snapshotFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged);
+ connect(ui->oldSnapshotFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged);
+ connect(ui->releaseFilter, &QCheckBox::stateChanged, this, &VanillaPage::filterChanged);
+}
+
+void VanillaPage::openedImpl()
+{
+ if(!initialized)
+ {
+ auto vlist = ENV.metadataIndex()->get("net.minecraft");
+ ui->versionList->initialize(vlist.get());
+ if(vlist->isLoaded())
+ {
+ setSelectedVersion(vlist->getRecommended());
+ }
+ else
+ {
+ vlist->load(Net::Mode::Online);
+ auto task = vlist->getLoadTask();
+ if(vlist->isLoaded())
+ {
+ setSelectedVersion(vlist->getRecommended());
+ }
+ if(task)
+ {
+ connect(task.get(), &Task::succeeded, this, &VanillaPage::versionListUpdated);
+ }
+ }
+ initialized = true;
+ }
+ else
+ {
+ suggestCurrent();
+ }
+}
+
+void VanillaPage::filterChanged()
+{
+ QStringList out;
+ if(ui->alphaFilter->isChecked())
+ out << "(old_alpha)";
+ if(ui->betaFilter->isChecked())
+ out << "(old_beta)";
+ if(ui->snapshotFilter->isChecked())
+ out << "(snapshot)";
+ if(ui->oldSnapshotFilter->isChecked())
+ out << "(old_snapshot)";
+ if(ui->releaseFilter->isChecked())
+ out << "(release)";
+ auto regexp = out.join('|');
+ ui->versionList->setFilter(BaseVersionList::TypeRole, new RegexpFilter(regexp, false));
+}
+
+VanillaPage::~VanillaPage()
+{
+ delete ui;
+}
+
+bool VanillaPage::shouldDisplay() const
+{
+ return true;
+}
+
+BaseVersionPtr VanillaPage::selectedVersion() const
+{
+ return m_selectedVersion;
+}
+
+void VanillaPage::versionListUpdated()
+{
+ if(!m_versionSetByUser)
+ {
+ auto vlist = ENV.metadataIndex()->get("net.minecraft");
+ setSelectedVersion(vlist->getRecommended());
+ }
+}
+
+void VanillaPage::suggestCurrent()
+{
+ if(m_selectedVersion && isOpened)
+ {
+ dialog->setSuggestedPack(m_selectedVersion->descriptor(), new InstanceCreationTask(m_selectedVersion));
+ }
+}
+
+void VanillaPage::setSelectedVersion(BaseVersionPtr version)
+{
+ m_selectedVersion = version;
+ suggestCurrent();
+}
diff --git a/application/pages/modplatform/VanillaPage.h b/application/pages/modplatform/VanillaPage.h
new file mode 100644
index 00000000..3f9d20ec
--- /dev/null
+++ b/application/pages/modplatform/VanillaPage.h
@@ -0,0 +1,75 @@
+/* Copyright 2013-2018 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <QWidget>
+
+#include "pages/BasePage.h"
+#include <MultiMC.h>
+#include "tasks/Task.h"
+
+namespace Ui
+{
+class VanillaPage;
+}
+
+class NewInstanceDialog;
+
+class VanillaPage : public QWidget, public BasePage
+{
+ Q_OBJECT
+
+public:
+ explicit VanillaPage(NewInstanceDialog *dialog, QWidget *parent = 0);
+ virtual ~VanillaPage();
+ virtual QString displayName() const override
+ {
+ return tr("Vanilla");
+ }
+ virtual QIcon icon() const override
+ {
+ return MMC->getThemedIcon("minecraft");
+ }
+ virtual QString id() const override
+ {
+ return "vanilla";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Vanilla-platform";
+ }
+ virtual bool shouldDisplay() const override;
+ void openedImpl() override;
+
+ BaseVersionPtr selectedVersion() const;
+
+public slots:
+ void setSelectedVersion(BaseVersionPtr version);
+
+private slots:
+ void versionListUpdated();
+ void filterChanged();
+
+private:
+ void suggestCurrent();
+
+private:
+ bool initialized = false;
+ NewInstanceDialog *dialog = nullptr;
+ Ui::VanillaPage *ui = nullptr;
+ bool m_versionSetByUser = false;
+ BaseVersionPtr m_selectedVersion;
+};
diff --git a/application/pages/modplatform/VanillaPage.ui b/application/pages/modplatform/VanillaPage.ui
new file mode 100644
index 00000000..713d04a0
--- /dev/null
+++ b/application/pages/modplatform/VanillaPage.ui
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>VanillaPage</class>
+ <widget class="QWidget" name="VanillaPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>815</width>
+ <height>607</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string notr="true">Tab 1</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Filter</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="releaseFilter">
+ <property name="text">
+ <string>Releases</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="snapshotFilter">
+ <property name="text">
+ <string>Snapshots</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="oldSnapshotFilter">
+ <property name="text">
+ <string>Old Snapshots</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="betaFilter">
+ <property name="text">
+ <string>Betas</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="alphaFilter">
+ <property name="text">
+ <string>Alphas</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="refreshBtn">
+ <property name="text">
+ <string>Refresh</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0">
+ <widget class="VersionSelectWidget" name="versionList" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>VersionSelectWidget</class>
+ <extends>QWidget</extends>
+ <header>widgets/VersionSelectWidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/application/resources/multimc/multimc.qrc b/application/resources/multimc/multimc.qrc
index 780e458d..bea3a325 100644
--- a/application/resources/multimc/multimc.qrc
+++ b/application/resources/multimc/multimc.qrc
@@ -11,6 +11,12 @@
<!-- REDDIT logo icon, needs reddit license! -->
<file>scalable/reddit-alien.svg</file>
+ <!-- twitch logo icon -->
+ <file>scalable/twitch.svg</file>
+
+ <!-- technic logo icon -->
+ <file>scalable/technic.svg</file>
+
<!-- A proxy icon. Our own. SSSsss -->
<file>scalable/proxy.svg</file>
diff --git a/application/resources/multimc/scalable/technic.svg b/application/resources/multimc/scalable/technic.svg
new file mode 100644
index 00000000..827b590a
--- /dev/null
+++ b/application/resources/multimc/scalable/technic.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="2500" height="2479" viewBox="0 0 1464.248 1452.156"><path fill="#1389D2" d="M644.592 5.192c159.049-19.094 324.188 14.764 461.941 96.756 143.299 84.188 256.41 218.769 313.509 374.945 62.353 168.133 58.63 359.689-10.432 525.205-63.691 154.529-182.775 285.021-330.227 363.417-149.71 80.709-327.849 105.845-494.333 71.979-172.465-34.279-331.022-133.533-437.232-273.729C51.059 1037.725-2.015 878.924.058 719.941c.548-167.949 63.08-334.559 172.343-461.998C290.451 118.177 462.794 25.934 644.592 5.192m-120.67 181.494c-131.408 49.538-243.479 148.488-308.511 273.003-60.641 114.509-80.038 249.94-54.906 377.018 25.076 130.193 97.609 250.192 200.162 334.012 101.76 84.247 232.924 131.896 365.063 132.754-.795-37.831-.366-75.591-1.04-113.416-.792-31.415-30.866-53.744-59.722-58.563-.917 28.305.119 62.895-24.771 82.113-23.731 16.288-55.638 15.919-82.479 8.782-27.149-7.626-42.216-35.808-43.011-62.532-1.647-40.565-.244-81.196-.729-121.828-10.86-.059-21.781-.059-32.702-.059-.06-35.442-.06-70.892 0-106.273 10.92-.065 21.84-.125 32.762-.125 0-12.076 0-24.093-.06-36.115-14.033-4.635-30.263-10.188-35.934-25.379-14.033-33.186 3.417-70.462-10.188-103.891-13.911-35.203-27.759-74.125-14.825-111.888 7.992-26.598 34.042-43.56 61.007-45.694-.06-76.808 0-153.553-.06-230.358-.429-40.754 16.288-82.725 48.924-108.164 37.215-29.525 86.57-37.092 132.812-36.786 102.921.061 203.701 48.864 270.2 126.893-.124 18.362 0 36.727-.124 55.149-92.185.061-184.359-.063-276.54 0-10.006-1.828-19.523 7.505-17.754 17.569.304 58.812-.549 117.682-.308 176.492 17.021.061 34.104.304 51.125-.488 2.866-11.774 6.038-23.425 9.454-35.019 74.982 18.424 149.893 36.789 224.809 55.335-2.502 8.6-4.938 17.266-7.382 25.927-6.588 2.5-13.177 5.001-19.767 7.504-2.621 203.154-4.331 406.363-6.648 609.514 176.251-60.091 319.795-208.828 369.755-388.73 39.415-137.021 25.262-288.622-39.527-415.699-63.628-126.646-175.579-227.98-307.72-279.104-133.783-52.65-287.092-53.321-421.365-1.954m140.741 710.665c0 11.401 0 22.817.063 34.221 10.125.06 20.253.06 30.381.06.061 35.448.061 70.896 0 106.34-10.128 0-20.315 0-30.442.059v32.333c19.949.06 39.961.06 59.909-.061-.917-57.646-.365-115.305-1.283-172.95a9391.232 9391.232 0 0 0-58.628-.002z"/></svg> \ No newline at end of file
diff --git a/application/resources/multimc/scalable/twitch.svg b/application/resources/multimc/scalable/twitch.svg
new file mode 100644
index 00000000..80999380
--- /dev/null
+++ b/application/resources/multimc/scalable/twitch.svg
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="Layer_1"
+ data-name="Layer 1"
+ viewBox="0 0 134 134"
+ version="1.1"
+ sodipodi:docname="twitch.svg"
+ inkscape:version="0.92.2 2405546, 2018-03-11"
+ width="134"
+ height="134">
+ <metadata
+ id="metadata13">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title>Glitch</dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1414"
+ inkscape:window-height="944"
+ id="namedview11"
+ showgrid="false"
+ inkscape:zoom="1.761194"
+ inkscape:cx="-109.17797"
+ inkscape:cy="66.999998"
+ inkscape:window-x="2640"
+ inkscape:window-y="554"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="Layer_1" />
+ <defs
+ id="defs4">
+ <style
+ id="style2">.cls-1{fill:#6441a4;fill-rule:evenodd;}</style>
+ </defs>
+ <title
+ id="title6">Glitch</title>
+ <path
+ class="cls-1"
+ d="M 9,0 0,23 v 94 h 32 v 17 H 50 L 67,117 H 93 L 128,82 V 0 Z M 116,76 96,96 H 64 L 47,113 V 96 H 20 V 12 h 96 z M 96,35 V 70 H 84 V 35 Z M 64,35 V 70 H 52 V 35 Z"
+ id="path8"
+ style="fill:#6441a4;fill-opacity:1;fill-rule:evenodd"
+ inkscape:connector-curvature="0" />
+</svg>
diff --git a/application/widgets/InstanceCardWidget.ui b/application/widgets/InstanceCardWidget.ui
new file mode 100644
index 00000000..3ea3e85f
--- /dev/null
+++ b/application/widgets/InstanceCardWidget.ui
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>InstanceCardWidget</class>
+ <widget class="QWidget" name="InstanceCardWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>473</width>
+ <height>118</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" rowspan="2">
+ <widget class="QToolButton" name="iconButton">
+ <property name="iconSize">
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="nameLabel">
+ <property name="text">
+ <string>&amp;Name:</string>
+ </property>
+ <property name="buddy">
+ <cstring>instNameTextBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLineEdit" name="instNameTextBox"/>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="groupLabel">
+ <property name="text">
+ <string>&amp;Group:</string>
+ </property>
+ <property name="buddy">
+ <cstring>groupBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QComboBox" name="groupBox">
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/application/widgets/JavaSettingsWidget.cpp b/application/widgets/JavaSettingsWidget.cpp
index 13cd27e7..13fad72a 100644
--- a/application/widgets/JavaSettingsWidget.cpp
+++ b/application/widgets/JavaSettingsWidget.cpp
@@ -41,7 +41,7 @@ void JavaSettingsWidget::setupUi()
m_verticalLayout = new QVBoxLayout(this);
m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
- m_versionWidget = new VersionSelectWidget(MMC->javalist().get(), this);
+ m_versionWidget = new VersionSelectWidget(this);
m_versionWidget->setResizeOn(2);
m_verticalLayout->addWidget(m_versionWidget);
@@ -116,7 +116,7 @@ void JavaSettingsWidget::setupUi()
void JavaSettingsWidget::initialize()
{
- m_versionWidget->initialize();
+ m_versionWidget->initialize(MMC->javalist().get());
auto s = MMC->settings();
// Memory
observedMinMemory = s->get("MinMemAlloc").toInt();
diff --git a/application/widgets/PageContainer.cpp b/application/widgets/PageContainer.cpp
index 0f78329a..4dbd7fb2 100644
--- a/application/widgets/PageContainer.cpp
+++ b/application/widgets/PageContainer.cpp
@@ -53,7 +53,7 @@ protected:
}
};
-PageContainer::PageContainer(BasePageProviderPtr pageProvider, QString defaultId,
+PageContainer::PageContainer(BasePageProvider *pageProvider, QString defaultId,
QWidget *parent)
: QWidget(parent)
{
@@ -158,6 +158,7 @@ void PageContainer::createUI()
m_layout->addWidget(m_pageList, 0, 0, 2, 1);
m_layout->addLayout(m_pageStack, 1, 1, 1, 1);
m_layout->setColumnStretch(1, 4);
+ m_layout->setContentsMargins(0, 0, 0, 0);
setLayout(m_layout);
}
diff --git a/application/widgets/PageContainer.h b/application/widgets/PageContainer.h
index 96eac80a..ea9f8ce1 100644
--- a/application/widgets/PageContainer.h
+++ b/application/widgets/PageContainer.h
@@ -35,7 +35,7 @@ class PageContainer : public QWidget, public BasePageContainer
{
Q_OBJECT
public:
- explicit PageContainer(BasePageProviderPtr pageProvider, QString defaultId = QString(),
+ explicit PageContainer(BasePageProvider *pageProvider, QString defaultId = QString(),
QWidget *parent = 0);
virtual ~PageContainer() {}
@@ -67,11 +67,13 @@ public:
private:
void createUI();
-private
-slots:
+
+public slots:
+ void help();
+
+private slots:
void currentChanged(const QModelIndex &current);
void showPage(int row);
- void help();
private:
BasePageContainer * m_container = nullptr;
diff --git a/application/widgets/VersionSelectWidget.cpp b/application/widgets/VersionSelectWidget.cpp
index 2a7cbfb7..ce1141b6 100644
--- a/application/widgets/VersionSelectWidget.cpp
+++ b/application/widgets/VersionSelectWidget.cpp
@@ -6,8 +6,8 @@
#include <VersionProxyModel.h>
#include <dialogs/CustomMessageBox.h>
-VersionSelectWidget::VersionSelectWidget(BaseVersionList* vlist, QWidget* parent)
- : QWidget(parent), m_vlist(vlist)
+VersionSelectWidget::VersionSelectWidget(QWidget* parent)
+ : QWidget(parent)
{
setObjectName(QStringLiteral("VersionSelectWidget"));
verticalLayout = new QVBoxLayout(this);
@@ -15,7 +15,6 @@ VersionSelectWidget::VersionSelectWidget(BaseVersionList* vlist, QWidget* parent
verticalLayout->setContentsMargins(0, 0, 0, 0);
m_proxyModel = new VersionProxyModel(this);
- m_proxyModel->setSourceModel(vlist);
listView = new VersionListView(this);
listView->setObjectName(QStringLiteral("listView"));
@@ -27,8 +26,6 @@ VersionSelectWidget::VersionSelectWidget(BaseVersionList* vlist, QWidget* parent
listView->header()->setCascadingSectionResizes(true);
listView->header()->setStretchLastSection(false);
listView->setModel(m_proxyModel);
- listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
- listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch);
verticalLayout->addWidget(listView);
sneakyProgressBar = new QProgressBar(this);
@@ -67,8 +64,13 @@ void VersionSelectWidget::setResizeOn(int column)
listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch);
}
-void VersionSelectWidget::initialize()
+void VersionSelectWidget::initialize(BaseVersionList *vlist)
{
+ m_vlist = vlist;
+ m_proxyModel->setSourceModel(vlist);
+ listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
+ listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch);
+
if (!m_vlist->isLoaded())
{
loadList();
@@ -185,10 +187,15 @@ BaseVersionPtr VersionSelectWidget::selectedVersion() const
void VersionSelectWidget::setExactFilter(BaseVersionList::ModelRoles role, QString filter)
{
- m_proxyModel->setFilter(role, filter, true);
+ m_proxyModel->setFilter(role, new ExactFilter(filter));
}
void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter)
{
- m_proxyModel->setFilter(role, filter, false);
+ m_proxyModel->setFilter(role, new ContainsFilter(filter));
+}
+
+void VersionSelectWidget::setFilter(BaseVersionList::ModelRoles role, Filter *filter)
+{
+ m_proxyModel->setFilter(role, filter);
}
diff --git a/application/widgets/VersionSelectWidget.h b/application/widgets/VersionSelectWidget.h
index 3ea0b4f5..c134887f 100644
--- a/application/widgets/VersionSelectWidget.h
+++ b/application/widgets/VersionSelectWidget.h
@@ -23,16 +23,17 @@ class VersionProxyModel;
class VersionListView;
class QVBoxLayout;
class QProgressBar;
+class Filter;
class VersionSelectWidget: public QWidget
{
Q_OBJECT
public:
- explicit VersionSelectWidget(BaseVersionList *vlist, QWidget *parent = 0);
+ explicit VersionSelectWidget(QWidget *parent = 0);
~VersionSelectWidget();
//! loads the list if needed.
- void initialize();
+ void initialize(BaseVersionList *vlist);
//! Starts a task that loads the list.
void loadList();
@@ -45,6 +46,7 @@ public:
void setCurrentVersion(const QString & version);
void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter);
void setExactFilter(BaseVersionList::ModelRoles role, QString filter);
+ void setFilter(BaseVersionList::ModelRoles role, Filter *filter);
void setEmptyString(QString emptyString);
void setEmptyErrorString(QString emptyErrorString);
void setResizeOn(int column);