diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-09-26 13:45:29 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-09-26 13:45:29 +0200 |
commit | 271ad9e4fdb4f003abd33b59ca9cadfb5bab9823 (patch) | |
tree | f006b597a61531345b810fb5ea28f45c850fd8a4 /application | |
parent | cca670013463f0062cec950d9b9bb76f9150ed93 (diff) | |
download | MultiMC-271ad9e4fdb4f003abd33b59ca9cadfb5bab9823.tar MultiMC-271ad9e4fdb4f003abd33b59ca9cadfb5bab9823.tar.gz MultiMC-271ad9e4fdb4f003abd33b59ca9cadfb5bab9823.tar.lz MultiMC-271ad9e4fdb4f003abd33b59ca9cadfb5bab9823.tar.xz MultiMC-271ad9e4fdb4f003abd33b59ca9cadfb5bab9823.zip |
GH-1072 split resource system to UI and logic parts
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))); }); } |