Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
contrast_adapt_icon.h
Go to the documentation of this file.
1
9
10#pragma once
11
13
14#include <QColor>
15#include <QHash>
16#include <QIcon>
17#include <QPalette>
18#include <QSize>
19#include <QString>
20
21#include <memory>
22
76class ContrastAdaptIcon : public QIcon
77{
78public:
91 explicit ContrastAdaptIcon(const QString &svg_resource_path,
92 QPalette::ColorRole surface_role = QPalette::Window,
93 QSize size = QSize(16, 16));
94
102 ContrastAdaptIcon(const QString &svg_resource_path,
103 const QColor &explicit_background,
104 QSize size = QSize(16, 16));
105
111 explicit ContrastAdaptIcon(const char *name) {
112 QString path = QStringLiteral(":/svg_icons/") + QLatin1String(name) + QStringLiteral(".svg");
113 *this = ContrastAdaptIcon(path, QPalette::Window);
114 }
115
122 void setPalette(const QPalette &palette);
123
133 void setTokenColors(const QHash<ThemeManager::ThemeToken, QColor> &colors);
134
135private:
136 // Private delegate: the engine shares @p palette and @p token_colors so
137 // setPalette() and setTokenColors() can reach them.
138 ContrastAdaptIcon(const QString &svg_resource_path,
139 QPalette::ColorRole surface_role,
140 const QColor &explicit_background,
141 QSize size, IconPaletteRef palette,
142 IconTokenColorsRef token_colors);
143
144 IconPaletteRef palette_;
145 IconTokenColorsRef token_colors_;
146};
void setTokenColors(const QHash< ThemeManager::ThemeToken, QColor > &colors)
Paint ws:map-token colours from colors instead of the live theme.
Definition contrast_adapt_icon.cpp:483
ContrastAdaptIcon(const char *name)
Convenience constructor for creating a contrast-adapted icon from a stock name.
Definition contrast_adapt_icon.h:111
void setPalette(const QPalette &palette)
Set a custom palette for drawing this icon instead of the application palette.
Definition contrast_adapt_icon.cpp:488
ContrastAdaptIcon(const QString &svg_resource_path, QPalette::ColorRole surface_role=QPalette::Window, QSize size=QSize(16, 16))
Definition contrast_adapt_icon.cpp:456
std::shared_ptr< QHash< ThemeManager::ThemeToken, QColor > > IconTokenColorsRef
Token colour overrides shared between a ContrastAdaptIcon and its engine, so that ContrastAdaptIcon::...
Definition token_palette.h:40
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:28