From e1a530f84dce9b4c1b262669157359fbbd436428 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Tue, 3 May 2016 00:27:28 +0200 Subject: GH-1559 Fix FTB icons This was caused by separation of GUI and logic. Now logic has an interface that GUI implements. It should be expanded upon later. --- api/logic/Env.cpp | 10 ++++++++++ api/logic/Env.h | 6 ++++++ api/logic/icons/IIconList.h | 20 ++++++++++++++++++++ api/logic/minecraft/ftb/FTBPlugin.cpp | 6 +++++- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 api/logic/icons/IIconList.h (limited to 'api/logic') diff --git a/api/logic/Env.cpp b/api/logic/Env.cpp index cc0c5981..b8e07343 100644 --- a/api/logic/Env.cpp +++ b/api/logic/Env.cpp @@ -43,6 +43,16 @@ std::shared_ptr< QNetworkAccessManager > Env::qnam() return m_qnam; } +std::shared_ptr Env::icons() +{ + return m_iconlist; +} + +void Env::registerIconList(std::shared_ptr iconlist) +{ + m_iconlist = iconlist; +} + /* class NullVersion : public BaseVersion { diff --git a/api/logic/Env.h b/api/logic/Env.h index 4d8945d7..dcf1947f 100644 --- a/api/logic/Env.h +++ b/api/logic/Env.h @@ -1,6 +1,7 @@ #pragma once #include +#include "icons/IIconList.h" #include #include @@ -32,6 +33,8 @@ public: std::shared_ptr metacache(); + std::shared_ptr icons(); + /// init the cache. FIXME: possible future hook point void initHttpMetaCache(); @@ -46,6 +49,8 @@ public: void registerVersionList(QString name, std::shared_ptr vlist); + void registerIconList(std::shared_ptr iconlist); + std::shared_ptr wonkoIndex(); QString wonkoRootUrl() const { return m_wonkoRootUrl; } @@ -54,6 +59,7 @@ public: protected: std::shared_ptr m_qnam; std::shared_ptr m_metacache; + std::shared_ptr m_iconlist; QMap> m_versionLists; std::shared_ptr m_wonkoIndex; QString m_wonkoRootUrl; diff --git a/api/logic/icons/IIconList.h b/api/logic/icons/IIconList.h new file mode 100644 index 00000000..a7e0fa07 --- /dev/null +++ b/api/logic/icons/IIconList.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +enum IconType : unsigned +{ + Builtin, + Transient, + FileBased, + ICONS_TOTAL, + ToBeDeleted +}; + +class IIconList +{ +public: + virtual ~IIconList(){} + virtual bool addIcon(QString key, QString name, QString path, IconType type) = 0; +}; + diff --git a/api/logic/minecraft/ftb/FTBPlugin.cpp b/api/logic/minecraft/ftb/FTBPlugin.cpp index a142c106..134257bf 100644 --- a/api/logic/minecraft/ftb/FTBPlugin.cpp +++ b/api/logic/minecraft/ftb/FTBPlugin.cpp @@ -257,7 +257,11 @@ void FTBPlugin::loadInstances(SettingsObjectPtr globalSettings, QMapicons()->addIcon(iconKey, iconKey, FS::PathCombine(record.templateDir, record.logo), MMCIcon::Transient); + auto icons = ENV.icons(); + if(icons) + { + icons->addIcon(iconKey, iconKey, FS::PathCombine(record.templateDir, record.logo), IconType::Transient); + } auto settingsFilePath = FS::PathCombine(record.instanceDir, "instance.cfg"); qDebug() << "ICON get!"; -- cgit