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

#include <theme_parser.h>

Classes

struct  Result

Public Member Functions

 ThemeParser (const QHash< QString, ThemeSectionInfo > &sections, const QHash< QString, ThemeManager::ThemeToken > &roleCache)
bool parse (const QString &internalName, const QString &resourcePath, Result &out, QString *errorString=nullptr)
bool parseData (const QString &internalName, const QByteArray &raw, Result &out, QString *errorString=nullptr)

Static Public Member Functions

static QString fontDescriptor (const ThemeFontHint &hint)

Detailed Description

Companion parser for ThemeManager. Handles every aspect of reading a theme.jsonc file: JSONC reading (JsoncDocument), JSON parsing, section/role/color decoding, graph colors, font hints. Has no opinion on palette application, derived tokens, stylesheets, or runtime mode — those remain ThemeManager's responsibility.

Constructed with const references to the section definitions and the role-name → ThemeToken cache owned by ThemeManager; never modifies them. A single ThemeParser instance can parse successive themes.

Private to the theme subsystem. Outside callers should go through ThemeManager.

Member Function Documentation

◆ fontDescriptor()

QString ThemeParser::fontDescriptor ( const ThemeFontHint & hint)
static

QFont::toString() descriptor of the font hint asks for, or an empty string when the hint is unset. No resolution happens here; FontManager::themeFont() owns it.

◆ parse()

bool ThemeParser::parse ( const QString & internalName,
const QString & resourcePath,
Result & out,
QString * errorString = nullptr )

Reads and parses the theme JSONC at the given Qt resource path.

Parameters
internalNameshort name (e.g. "default"); stored on the result.
resourcePathfull Qt resource URL (e.g. ":/themes/default/theme.jsonc").
outpopulated on success.
errorStringoptional; set to the fatal error on failure.
Returns
true on a usable parse, false on a hard error (file missing, invalid JSON, required section missing).

◆ parseData()

bool ThemeParser::parseData ( const QString & internalName,
const QByteArray & raw,
Result & out,
QString * errorString = nullptr )

Parses theme JSONC that is already in memory. parse() reads the file and delegates here.

JSON syntax errors are reported as "Line L, column C: <message>". Non-fatal findings (invalid colors, unknown keys, ...) go to out.report.

Parameters
internalNameshort name; stored on the result.
rawtheme file content, comments allowed.
outpopulated on success.
errorStringoptional; set to the fatal error on failure.
Returns
true on a usable parse, false on a hard error.

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