Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ThemeStyler Class Reference
Inheritance diagram for ThemeStyler:

Public Member Functions

 ThemeStyler (QStyle *style=nullptr)
 ThemeStyler (const QString &key)
int styleHint (StyleHint hint, const QStyleOption *option=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
int pixelMetric (PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
QSize sizeFromContents (ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget=nullptr) const override
void drawPrimitive (PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
void drawControl (ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget=nullptr) const override
void polish (QWidget *widget) override
void unpolish (QWidget *widget) override

Static Public Member Functions

static QString baseStyleName ()
static QString buttonStyleSheet (const QString &objectname, const QColor &baseColor)

Protected Member Functions

bool eventFilter (QObject *watched, QEvent *event) override

Member Function Documentation

◆ buttonStyleSheet()

QString ThemeStyler::buttonStyleSheet ( const QString & objectname,
const QColor & baseColor )
static

Style sheet for a filled push button.

Parameters
objectnameObject name the rules are scoped to (QPushButton#objectname).
baseColorFill seed, darkened until a white label reaches the active readable-text ratio; hover and pressed are darker still, and the label is white in every state.
Returns
The style sheet text.

◆ drawControl()

void ThemeStyler::drawControl ( ControlElement element,
const QStyleOption * option,
QPainter * painter,
const QWidget * widget = nullptr ) const
override

Draw a control through the base style, with adjustments on macOS.

The native style erases top toolbars in a main window's unified title and toolbar area to transparent, so the system content border shows instead of the palette. When the active theme sets palette.window, those toolbars are filled with the palette window color, with a separator line below the last visible toolbar row. Themes without palette.window keep the native look.

A non-flat push button taller than the native bezel is drawn by the native style as a flat square bezel. For those buttons the bevel (CE_PushButtonBevel) is drawn as AppKit's flexible-height rounded push bezel, the label color (CE_PushButtonLabel) follows that bezel's accent state, and the keyboard focus ring (CE_FocusFrame) is the native ring of that bezel. Buttons of the native bezel height are left to the base style.

◆ drawPrimitive()

void ThemeStyler::drawPrimitive ( PrimitiveElement element,
const QStyleOption * option,
QPainter * painter,
const QWidget * widget = nullptr ) const
override

Draw a primitive through the base style, with two adjustments.

On macOS 26 and later, item view check boxes are drawn on a translated painter, since the native style ignores the indicator position there.

At High contrast with the Fusion base style, push button, combo box and line edit frames (PE_PanelButtonCommand, PE_FrameLineEdit) are painted again in the ControlBorder color. Fusion's own outline is Window.darker(140), about 2:1, below the non-text contrast target. Native styles (macOS, windows11, windowsvista) draw their frames from their own colors and are left alone.

◆ eventFilter()

bool ThemeStyler::eventFilter ( QObject * watched,
QEvent * event )
overrideprotected

On macOS, repaint the other top toolbars of a unified main window when one of its toolbars is shown, hidden, moved or resized.

◆ pixelMetric()

int ThemeStyler::pixelMetric ( PixelMetric metric,
const QStyleOption * option = nullptr,
const QWidget * widget = nullptr ) const
override

Return a pixel metric of the base style, scaled with the application zoom for a fixed set of metrics.

Icon sizes and the splitter width are scaled on every base style. Indicator (check box, radio button), scroll bar, slider and tool bar extension/handle metrics are scaled on every base style except macOS, where AppKit draws those controls at fixed control sizes. All other metrics are returned unchanged.

Native styles compute some metrics from other metrics through proxy()->pixelMetric(), which calls back into this proxy. Only the outermost call is scaled; nested calls return the base value, so no metric is scaled twice. At Normal Size the base value is returned.

Parameters
metricThe metric to return.
optionThe style option, may be null.
widgetThe widget the metric is for, may be null.
Returns
The metric in pixels.

◆ polish()

void ThemeStyler::polish ( QWidget * widget)
override

Polish a widget through the base style. On macOS, toolbars also get this style as event filter, so the separator below the last toolbar row moves when a toolbar is shown, hidden or moved.

◆ sizeFromContents()

QSize ThemeStyler::sizeFromContents ( ContentsType type,
const QStyleOption * option,
const QSize & contentsSize,
const QWidget * widget = nullptr ) const
override

Return the size of a control for the given contents size.

The macOS style draws a non-flat push button as the rounded themed bezel only when the button has exactly its default height. Zoomed fonts make the content taller, the base style then returns a taller button and draws it as an opaque square bezel. On the macOS base style the push button height is held at the bezel height as long as the content still fits the bezel's title rect; above that the base result stands, so the text is never clipped, and drawControl() draws AppKit's flexible-height rounded bezel instead of the square one. The macOS style also gives OK and Cancel buttons a fixed width whatever their font, so on the macOS base style a non-flat push button is widened until its title rect holds the content. The limits are queried from the base style. On all other styles and controls the base result is returned unchanged.

Parameters
typeThe contents type.
optionThe style option, may be null.
contentsSizeThe size of the contents.
widgetThe widget the size is for, may be null.
Returns
The size of the control.

◆ unpolish()

void ThemeStyler::unpolish ( QWidget * widget)
override

Undo polish(): remove the toolbar event filter, then unpolish.


The documentation for this class was generated from the following files: