Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
themed_icon.h
Go to the documentation of this file.
1
9
10#pragma once
11
14
15#include <QIcon>
16#include <QPalette>
17#include <QSize>
18#include <QString>
19
41class ThemedIcon : public QIcon
42{
43public:
50 explicit ThemedIcon(const QString &svg_resource_path,
51 ThemeManager::ThemeToken token,
52 QSize size = QSize(14, 14));
53
59 explicit ThemedIcon(const char *name) :
60 ThemedIcon(QString::fromUtf8(name))
61 {
62 }
63
69 explicit ThemedIcon(const QString &name)
70 {
71 *this = ThemedIcon(QStringLiteral(":/svg_icons/") + name + QStringLiteral(".svg"),
72 ThemeManager::PaletteText);
73 }
74
86 explicit ThemedIcon(const QString &svg_resource_path,
87 ThemeManager::ThemeToken token,
88 ThemeManager::ThemeToken active_token,
89 ThemeManager::ThemeToken selected_token = ThemeManager::NoRole,
90 QSize size = QSize(14, 14));
91
98 void setPalette(const QPalette &palette);
99
100private:
101 // Private delegate: the engine shares @p palette so setPalette() can reach it.
102 ThemedIcon(const QString &svg_resource_path,
103 ThemeManager::ThemeToken token,
104 ThemeManager::ThemeToken active_token,
105 ThemeManager::ThemeToken selected_token,
106 QSize size, IconPaletteRef palette);
107
108 IconPaletteRef palette_;
109};
ThemedIcon(const QString &svg_resource_path, ThemeManager::ThemeToken token, QSize size=QSize(14, 14))
Definition themed_icon.cpp:156
void setPalette(const QPalette &palette)
Set a custom palette for drawing this icon instead of the application palette.
Definition themed_icon.cpp:183
ThemedIcon(const char *name)
Convenience constructor for creating a themed icon from a stock name.
Definition themed_icon.h:59
ThemedIcon(const QString &name)
Convenience constructor for creating a themed icon from a stock name.
Definition themed_icon.h:69
std::shared_ptr< std::optional< QPalette > > IconPaletteRef
Palette override shared between an icon object and its engine, so that ThemedIcon::setPalette() / Con...
Definition token_palette.h:27