|
Wireshark 5.1.0
The Wireshark network protocol analyzer
|
#include <theme_preview_pick.h>
Classes | |
| struct | Layer |
Public Types | |
| enum class | Role { Text , Background , Border } |
| using | TokenMap = QHash<ThemeManager::ThemeToken, ThemeColorPair> |
Static Public Member Functions | |
| static QColor | keyColor (int key) |
| static Layer | decode (QRgb rgb) |
| static TokenMap | keyTokens () |
| static QPalette | keyPalette () |
| static QFont | keyFont (const QFont &font) |
| static QImage | keyCanvas (const QSize &size) |
| static void | paintKeyGlyph (QPainter *painter, const QString &svg_path, const QRect &rect, ThemeManager::ThemeToken token) |
| static Layer | layerAt (const QImage &keys, const QPoint &pos, int text_height) |
| static QList< Layer > | layersAt (const QImage &keys, const QPoint &pos, int text_height) |
| static QString | roleName (const Layer &layer) |
| static void | saveImage (QWidget *source, const QString &suggested_name, const std::function< void()> &dialog_closed) |
Static Public Attributes | |
| static constexpr int | kLinkKey = 0x3fff |
Shared support for picking theme colors by clicking a Theme Designer sample.
A sample finds out which theme token painted a pixel by rendering a second, never shown copy of itself into an image ("key render"). That copy is themed with keyTokens() and keyPalette(): every token gets its own unique opaque key color, so each pixel of the key image names the token that painted it. The sample's own paint code and Qt's style sheet cascade decide the token; nothing here mirrors that logic. Fonts of the copy go through keyFont() so text is drawn without antialiasing and glyph pixels keep their exact key.
Text, background and border of one spot are told apart from the shape of the key regions around the pixel (see layerAt() and layersAt()), so a single key image is enough.
The class also holds the "Save Image As..." flow shared by the samples.
|
strong |
What part of a spot a color paints.
|
static |
The token a key image pixel names.
rgb is not a key color. The role is Text for the link key, else Background.
|
static |
A blank, transparent image of size for a key render. It is premultiplied because CoreGraphics cannot paint native style elements into non-premultiplied ARGB images; key decoding only reads opaque pixels, which are the same in both formats.
|
static |
The opaque key color of key.
| key | a ThemeManager::ThemeToken value, or kLinkKey. |
|
static |
font with antialiasing turned off, for the key render.
|
static |
A palette for the key render: each role with a Palette<Role> token gets that token's key color in all groups, Link gets kLinkKey when it has no token, and every other role is opaque black (never a key).
|
static |
Every token but NoRole, mapped to its key color on both sides.
|
static |
The color a click at pos picks: the token of the pixel, or of the nearest key pixel within 2 pixels, and whether it paints text, a border line or a background.
| keys | the key image. |
| pos | position in keys. |
| text_height | tallest line height of the key fonts, in image pixels. |
pos.
|
static |
All colors of the spot at pos: the picked color (layerAt()), the background under a text or line, and the border around a background.
pos.
|
static |
Paints the shape of an icon in the key color of token, without antialiasing, so every pixel of the glyph names the token.
| painter | painter of the key render. |
| svg_path | Qt resource path of the icon. |
| rect | where the icon goes. |
| token | the color the icon paints. |
|
static |
The translated role word: "Text", "Background", "Border" or "Link text".
|
static |
Asks for a file name and saves a PNG image of source.
| source | the widget to grab; also the dialogs' parent. |
| suggested_name | file name proposed in the save dialog. |
| dialog_closed | called each time a dialog of this flow closes, so the caller can restore focus or state; may be empty. |
|
staticconstexpr |
The key value QPalette::Link gets in keyPalette(). Link has no token of its own; it is derived from ThemePaletteBuilder::kLinkSourceRole.