#include "QFDIcon.h" #include QString QFDIcon::iconName(QFDIcon::IconType type) { switch (type) { case Data: return "Data"; case Detail: return "Detail"; case Expert: return "Expert"; case Filter: return "Filter"; case Logout: return "Logout"; case Minus: return "Minus"; case Open: return "Open"; case Project: return "Project"; case Project1: return "Project1"; case Schecme: return "Scheme"; case User: return "User"; } return "Unknown"; } QFDIcon::QFDIcon(IconType type, Qfw::Theme t) : FluentIconBase(""), m_theme(t), m_type(type) { iconEngine->setIconPath(iconPath()); } QString QFDIcon::iconPath() { QString colorName; if (m_theme == Qfw::Theme::AUTO) { colorName = QFWIns.isDarkTheme() ? "white" : "black"; } else { colorName = Qfw::ThemeString(m_theme).toLower(); } return QString(":/resource/svg/%1_%2.svg").arg(iconName(m_type)).arg(colorName); } QIcon QFDIcon::icon() { return QIcon(iconEngine->clone()); } QString QFDIcon::typeName() const { return iconName(m_type); } QString QFDIcon::enumName() const { QMetaEnum metaEnum = QMetaEnum::fromType(); return metaEnum.valueToKey(m_type); } FluentIconBase *QFDIcon::clone() { return new QFDIcon(m_type, m_theme); } Qfw::Theme QFDIcon::theme() const { return m_theme; } void QFDIcon::setTheme(const Qfw::Theme &theme) { m_theme = theme; iconEngine->setIconPath(iconPath()); }