12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #include "QFDIcon.h"
- #include <QFluentWidgets.h>
- 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<IconType>();
- 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());
- }
|