Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
theme_styler.h
Go to the documentation of this file.
1
9
10#ifndef THEME_STYLER_H
11#define THEME_STYLER_H
12
13#include <QProxyStyle>
14
15class QStyleOptionButton;
16#ifdef Q_OS_MACOS
17namespace NativePushButton { struct BezelState; }
18#endif
19
20class ThemeStyler : public QProxyStyle {
21 Q_OBJECT
22public:
23 ThemeStyler(QStyle *style = nullptr);
24 ThemeStyler(const QString &key);
25
26 int styleHint(StyleHint hint, const QStyleOption *option = nullptr,
27 const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override;
28
49 int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr,
50 const QWidget *widget = nullptr) const override;
51
74 QSize sizeFromContents(ContentsType type, const QStyleOption *option,
75 const QSize &contentsSize, const QWidget *widget = nullptr) const override;
76
91 void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
92 QPainter *painter, const QWidget *widget = nullptr) const override;
93
94 using QProxyStyle::polish;
95 using QProxyStyle::unpolish;
96
115 void drawControl(ControlElement element, const QStyleOption *option,
116 QPainter *painter, const QWidget *widget = nullptr) const override;
117
123 void polish(QWidget *widget) override;
124
126 void unpolish(QWidget *widget) override;
127
128 // The object name of the underlying (native) style, e.g. "windows11",
129 // "windowsvista", "fusion", or "macos". QApplication::style() returns
130 // either this proxy or a QStyleSheetStyle wrapping it, neither of which
131 // has a useful objectName().
132 static QString baseStyleName();
133
145 static QString buttonStyleSheet(const QString &objectname, const QColor &baseColor);
146
147protected:
152 bool eventFilter(QObject *watched, QEvent *event) override;
153
154private:
155 // Nesting depth of pixelMetric() calls. Styles run on the GUI thread
156 // only, so a plain counter is enough.
157 mutable int metric_depth_ = 0;
158
159#ifdef Q_OS_MACOS
170 int pushButtonBezelHeight(const QStyleOptionButton *button, int contentsWidth,
171 const QWidget *widget) const;
172
184 bool takesFlexibleBezel(const QStyleOptionButton *button, const QWidget *widget) const;
185
194 static bool pushButtonEmphasized(const QStyleOptionButton *button);
195
205 static NativePushButton::BezelState flexibleBezelState(const QStyleOptionButton *button);
206
216 QRect flexibleBezelRect(const QStyleOptionButton *button, const QWidget *widget) const;
217#endif
218};
219
220
221#endif /* THEME_STYLER_H */
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
Definition theme_styler.cpp:255
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
Definition theme_styler.cpp:138
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
Definition theme_styler.cpp:310
void polish(QWidget *widget) override
Definition theme_styler.cpp:447
bool eventFilter(QObject *watched, QEvent *event) override
Definition theme_styler.cpp:470
static QString buttonStyleSheet(const QString &objectname, const QColor &baseColor)
Definition theme_styler.cpp:498
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget=nullptr) const override
Definition theme_styler.cpp:158
void unpolish(QWidget *widget) override
Definition theme_styler.cpp:461