Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ThemePreviewWidget Class Reference

#include <theme_preview_widget.h>

Inheritance diagram for ThemePreviewWidget:

Signals

void showColoringRulesChanged (bool show)
void layerPicked (const ThemePreviewPick::Layer &layer)
void pickMenuRequested (QMenu *menu, QAction *before, const QList< ThemePreviewPick::Layer > &layers)
void childDialogClosed ()

Public Member Functions

 ThemePreviewWidget (QWidget *parent=nullptr)
void setPreviewColors (const QHash< ThemeManager::ThemeToken, QColor > &colors, bool declaresWindow=false)
void setShowColoringRules (bool show)
void setPreviewFonts (const QFont &regular, const QFont &monospace)
bool showColoringRules () const
ThemePreviewPicker & picker ()

Protected Member Functions

void paintEvent (QPaintEvent *evt) override
void contextMenuEvent (QContextMenuEvent *event) override
void mouseMoveEvent (QMouseEvent *event) override
void mousePressEvent (QMouseEvent *event) override
QSize minimumSizeHint () const override

Detailed Description

Static, hand-painted 3-pane mockup of a Wireshark capture window (filter bar + packet list + details/bytes). Used by the Font and Colors preferences page to show the user what the selected theme looks like before the change is committed.

The widget never reads from the live ThemeManager except as a fallback. Callers push a token → color hash via setPreviewColors() whenever the selection changes; missing entries fall back to the live ThemeManager value so the widget always paints something.

Member Function Documentation

◆ childDialogClosed

void ThemePreviewWidget::childDialogClosed ( )
signal

A dialog opened from the context menu was closed.

◆ layerPicked

void ThemePreviewWidget::layerPicked ( const ThemePreviewPick::Layer & layer)
signal

The user clicked a spot; layer has NoRole when it has no theme color.

◆ picker()

ThemePreviewPicker & ThemePreviewWidget::picker ( )
inline

Click-to-pick support, off by default. While on, a pickable spot shows a hand cursor, a left click emits layerPicked() and the context menu offers the colors of the spot.

◆ pickMenuRequested

void ThemePreviewWidget::pickMenuRequested ( QMenu * menu,
QAction * before,
const QList< ThemePreviewPick::Layer > & layers )
signal

Emitted synchronously before the context menu opens, only while picking is enabled. Receivers insert color actions before before.

◆ setPreviewColors()

void ThemePreviewWidget::setPreviewColors ( const QHash< ThemeManager::ThemeToken, QColor > & colors,
bool declaresWindow = false )

Replaces the preview's color table. Triggers a repaint.

Parameters
colorstoken → resolved QColor map, typically obtained from ThemeManager::previewTheme(). Passing an empty hash is valid — every lookup will fall back to the live ThemeManager.
declaresWindowwhether the previewed theme declares palette.window, as reported by ThemeManager::previewTheme(). When true the faux title bar is tinted with the previewed window color.

◆ setPreviewFonts()

void ThemePreviewWidget::setPreviewFonts ( const QFont & regular,
const QFont & monospace )

Paints the preview with regular and monospace instead of the application fonts from FontManager, so a font choice that is not applied yet can be shown. Repaints only when the fonts change.

◆ setShowColoringRules()

void ThemePreviewWidget::setShowColoringRules ( bool show)

Toggles overlaying the live coloring rules on the sample packet rows.

Off by default: the preview shows theme colors only — the base background plus the selection / marked / ignored state tokens. When on, each sample row is tinted with the matching rule from the user's current color-filter set, looked up by rule name (e.g. "TCP", "HTTP", "Bad TCP"); rows whose rule is disabled or absent keep their theme color, and the state tokens still take precedence. The rule set is snapshotted at the moment it is enabled, not re-read on every repaint.

Also reachable from the right-click menu; setting it emits showColoringRulesChanged() so an external control (e.g. a checkbox on the preferences page) can stay in sync with the menu toggle.


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