21 #ifndef TULIPFONTICONENGINE_H
22 #define TULIPFONTICONENGINE_H
24 #include <QIconEngine>
27 #include <tulip/tulipconf.h>
28 #include <tulip/TulipSettings.h>
30 class TLP_QT_SCOPE TulipFontIconEngine :
public QIconEngine {
35 void init(
const std::string &iconName);
38 TulipFontIconEngine(
const std::string &iconName,
bool darkMode =
false);
39 TulipFontIconEngine(
const QString &iconName,
bool darkMode =
false);
40 TulipFontIconEngine(
const TulipFontIconEngine &engine)
41 : QIconEngine(), iconQString(engine.iconQString), font(engine.font) {}
43 TulipFontIconEngine *clone()
const override {
44 return new TulipFontIconEngine(*
this);
47 void paint(QPainter *painter,
const QRect &rect, QIcon::Mode mode, QIcon::State state)
override;
49 QPixmap pixmap(
const QSize &size, QIcon::Mode mode, QIcon::State state)
override;
51 static inline QIcon icon(
const char *iconName,
bool darkMode =
false) {
52 return QIcon(
new TulipFontIconEngine(std::string(iconName), darkMode));
55 static inline QIcon icon(
const std::string &iconName,
bool darkMode =
false) {
56 return QIcon(
new TulipFontIconEngine(iconName, darkMode));
59 static inline QIcon icon(
const QString &iconName,
bool darkMode =
false) {
60 return QIcon(
new TulipFontIconEngine(iconName, darkMode));
63 static inline QPixmap pixmap(
const std::string &iconName,
unsigned int height,
64 bool dm = tlp::TulipSettings::isDisplayInDarkMode(),
65 QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::On) {
66 return TulipFontIconEngine(iconName, dm).pixmap(QSize(height, height), mode, state);
69 static inline QPixmap pixmap(
const QString &iconName,
unsigned int height,
70 bool dm = tlp::TulipSettings::isDisplayInDarkMode(),
71 QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::On) {
72 return TulipFontIconEngine(iconName, dm).pixmap(QSize(height, height), mode, state);