diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/CMakeLists.txt | 6 | ||||
-rw-r--r-- | application/MultiMC.cpp | 37 |
2 files changed, 16 insertions, 27 deletions
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index f72b6a16..47563693 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -120,6 +120,12 @@ SET(MULTIMC_SOURCES BuildConfig.h ${PROJECT_BINARY_DIR}/BuildConfig.cpp + # Resource handlers and transformers + handlers/IconResourceHandler.cpp + handlers/IconResourceHandler.h + handlers/WebResourceHandler.cpp + handlers/WebResourceHandler.h + # GUI - general utilities GuiUtil.h GuiUtil.cpp diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 98919d30..a893c875 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -48,7 +48,8 @@ #include "trans/TranslationDownloader.h" #include "resources/Resource.h" -#include "resources/IconResourceHandler.h" +#include "handlers/IconResourceHandler.h" +#include "handlers/WebResourceHandler.h" #include "ftb/FTBPlugin.h" @@ -341,36 +342,18 @@ void MultiMC::initIcons() ENV.m_icons->directoryChanged(value.toString()); }); - Resource::registerTransformer([](const QVariantMap &map) -> QIcon + //FIXME: none of this should be here. + Resource::registerHandler<WebResourceHandler>("web"); + Resource::registerHandler<IconResourceHandler>("icon"); + + Resource::registerTransformer([](const QByteArray &data) -> QPixmap { - QIcon icon; - for (auto it = map.constBegin(); it != map.constEnd(); ++it) - { - icon.addFile(it.key(), QSize(it.value().toInt(), it.value().toInt())); - } - return icon; + return QPixmap::fromImage(QImage::fromData(data)); }); - Resource::registerTransformer([](const QVariantMap &map) -> QPixmap + Resource::registerTransformer([](const QByteArray &data) -> QIcon { - QVariantList sizes = map.values(); - if (sizes.isEmpty()) - { - return QPixmap(); - } - std::sort(sizes.begin(), sizes.end()); - if (sizes.last().toInt() != -1) // only scalable available - { - return QPixmap(map.key(sizes.last())); - } - else - { - return QPixmap(); - } + return QIcon(QPixmap::fromImage(QImage::fromData(data))); }); - Resource::registerTransformer([](const QByteArray &data) -> QPixmap - { return QPixmap::fromImage(QImage::fromData(data)); }); - Resource::registerTransformer([](const QByteArray &data) -> QIcon - { return QIcon(QPixmap::fromImage(QImage::fromData(data))); }); } |