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

#include <theme_writer.h>

Classes

struct  KeyInfo

Static Public Member Functions

static const QList< KeyInfo > & keyTable ()
static QString keyPath (ThemeManager::ThemeToken token)
static QString keyPath (const KeyInfo &info)
static QString colorText (const QColor &color)
static QByteArray toJsonc (const ThemeDraft &draft)
static QString sanitizeStem (const QString &name)
static QString uniqueStem (const QString &wanted, const QString &ignoreStem=QString())
static bool writeFile (const ThemeDraft &draft, const QString &path, QString *errorString=nullptr)

Detailed Description

Serializes a ThemeDraft to a theme file (JSONC) and names theme files.

The output is the one canonical form: fixed section order, schema key spelling, one color per line. Only the keys a draft sets are written.

Member Function Documentation

◆ colorText()

QString ThemeWriter::colorText ( const QColor & color)
static
Parameters
colorthe color.
Returns
"#rrggbb" for an opaque color, "#aarrggbb" otherwise (the form QColor reads back), or an empty string for an invalid color.

◆ keyPath() [1/2]

QString ThemeWriter::keyPath ( const KeyInfo & info)
static
Parameters
infoa row of keyTable().
Returns
"<section>.<key>" as written in the file.

◆ keyPath() [2/2]

QString ThemeWriter::keyPath ( ThemeManager::ThemeToken token)
static
Parameters
tokenthe color token.
Returns
"<section>.<key>" as written in the file, or an empty string for a token that is not in keyTable().

◆ keyTable()

const QList< ThemeWriter::KeyInfo > & ThemeWriter::keyTable ( )
static

All settable color keys in the order they are written. The rows come from ThemeManager::settableKeys() (enum order); the descriptions come from the writer's own table and are shown by the Theme Designer. Rows of one section are contiguous; the order of the sections' first rows is the order toJsonc() writes them in.

◆ sanitizeStem()

QString ThemeWriter::sanitizeStem ( const QString & name)
static

Turns a theme name into a safe file stem: lowercase letters, digits, '-' and '_'; anything else becomes '-'.

Parameters
nametheme name.
Returns
the stem, never empty.

◆ toJsonc()

QByteArray ThemeWriter::toJsonc ( const ThemeDraft & draft)
static

Serializes a draft. Color entries and graph slots with an invalid side are skipped; callers clean the draft with ThemeDraft::removeInvalidEntries() first.

Parameters
draftthe draft to serialize.
Returns
UTF-8 theme file content.

◆ uniqueStem()

QString ThemeWriter::uniqueStem ( const QString & wanted,
const QString & ignoreStem = QString() )
static

Returns a stem for wanted that is neither a bundled theme nor an existing personal theme file, appending -2, -3, ... when needed.

Parameters
wantedtheme name or stem.
ignoreStemstem that counts as free (a rename keeping its stem).

◆ writeFile()

bool ThemeWriter::writeFile ( const ThemeDraft & draft,
const QString & path,
QString * errorString = nullptr )
static

Writes a draft to path, creating the parent directory.

Parameters
draftthe draft to write.
pathdestination file.
errorStringoptional; set on failure.
Returns
true when the file was written completely.

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