From f9d94a45eebd5fb7b14d4bcc6ad77cb96ecdd771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 10 Nov 2016 02:54:53 +0100 Subject: NOISSUE allow using icon themes for instances and instance badges --- api/gui/icons/MMCIcon.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'api/gui/icons/MMCIcon.cpp') diff --git a/api/gui/icons/MMCIcon.cpp b/api/gui/icons/MMCIcon.cpp index f71281d0..11ad93e2 100644 --- a/api/gui/icons/MMCIcon.cpp +++ b/api/gui/icons/MMCIcon.cpp @@ -15,6 +15,7 @@ #include "MMCIcon.h" #include +#include IconType operator--(IconType &t, int) { @@ -58,7 +59,11 @@ QIcon MMCIcon::icon() const { if (m_current_type == IconType::ToBeDeleted) return QIcon(); - return m_images[m_current_type].icon; + auto & icon = m_images[m_current_type].icon; + if(!icon.isNull()) + return icon; + // FIXME: inject this. + return XdgIcon::fromTheme(m_images[m_current_type].key); } void MMCIcon::remove(IconType rm_type) @@ -78,12 +83,22 @@ void MMCIcon::remove(IconType rm_type) void MMCIcon::replace(IconType new_type, QIcon icon, QString path) { - QFileInfo foo(path); if (new_type > m_current_type || m_current_type == IconType::ToBeDeleted) { m_current_type = new_type; } m_images[new_type].icon = icon; - m_images[new_type].changed = foo.lastModified(); m_images[new_type].filename = path; + m_images[new_type].key = QString(); +} + +void MMCIcon::replace(IconType new_type, const QString& key) +{ + if (new_type > m_current_type || m_current_type == IconType::ToBeDeleted) + { + m_current_type = new_type; + } + m_images[new_type].icon = QIcon(); + m_images[new_type].filename = QString(); + m_images[new_type].key = key; } -- cgit v1.2.3