|
Wireshark 4.7.2
The Wireshark network protocol analyzer
|
#include <font_manager.h>
Public Types | |
| enum class | ZoomScope { AppWide , ContentOnly } |
Signals | |
| void | applicationFontChanged (QFont font) |
| void | monospaceFontChanged (QFont font) |
| void | zoomChanged () |
Public Member Functions | |
| void | setRegularFont (const QString &fontName) |
| void | setMonospaceFont (const QString &fontName) |
| void | zoomIn () |
| void | zoomOut () |
| void | resetZoom () |
| void | setZoomLevel (int level) |
| int | zoomLevel () const |
Static Public Member Functions | |
| static FontManager * | instance () |
| static QFont | font () |
| static QFont | monospaceFont () |
| static QFont | zoomedFont () |
| static QFont | zoomedMonospaceFont () |
| static qreal | zoomFactor () |
Protected Member Functions | |
| FontManager (QObject *parent=nullptr) | |
| bool | eventFilter (QObject *watched, QEvent *event) override |
Single authority for the application's fonts.
A singleton (like ThemeManager): access via FontManager::instance(). Its lifecycle is initiated by ThemeManager at startup — ThemeManager forces the instance into existence and feeds it the configured font names — but every font decision lives here: resolution/validation, the systemwide regular-font push, zoom, catching external (OS) font changes, and notification.
ThemeManager's entire font role is to read a configured font name and hand it to setRegularFont()/setMonospaceFont(). It performs no validation, fixed-pitch checking, or fallback — that is exclusively this class.
Three independent sources can change the font, and all converge here:
Consumer contract: a font-using widget owns its own font handling. In its constructor it seeds the current font from the static accessors (e.g. zoomedMonospaceFont()) and connects to the signal it needs (applicationFontChanged and/or monospaceFontChanged) for later theme, zoom, and OS changes. No external party wires a widget's fonts for it, so a widget created at any time is correct immediately and stays in sync on its own.
|
strong |
Whether a zoom step scales the whole application or only content views.
AppWide — zoom changes the app-default font via QApplication, so chrome (menus/toolbars/dialogs) scales too. ContentOnly — the app-default font stays at the base size; only widgets that explicitly pull the zoomed fonts scale.
v1 fixes this in the constructor. v2 will drive it from a preference on the "Font & Themes" page.
|
signal |
The regular font changed (theme load excepted — see class docs).
|
static |
Base (unzoomed) regular/proportional font.
|
static |
Returns the process-wide singleton, constructing it on first use.
|
static |
Base (unzoomed) monospace font.
|
signal |
The monospace font changed (theme load excepted).
| void FontManager::setMonospaceFont | ( | const QString & | fontName | ) |
Sets the monospace font. The user preference gui.font_name always wins when set; otherwise fontName; otherwise the system fixed font. The result is guaranteed to be fixed-pitch. Emits monospaceFontChanged when the resolved font actually changes.
| fontName | font descriptor, or empty. |
| void FontManager::setRegularFont | ( | const QString & | fontName | ) |
Sets the regular (proportional) font from a font descriptor string (QFont::toString() form, or a bare family name). An empty string means "no preference" and falls back to the system general font.
Emits applicationFontChanged when the resolved font actually changes, and always reconciles the QApplication font.
| fontName | font descriptor, or empty for the system default. |
|
signal |
The zoom level changed. ThemeManager turns this into a themeChanged so stylesheet-driven widgets reload their zoom-scaled stylesheets.
|
static |
Regular font with the current zoom level applied.
|
static |
Monospace font with the current zoom level applied.
|
static |
Current zoom multiplier relative to the base regular font (1.0 at zoom level 0). Use to scale sizes that are not expressed as a QFont — e.g. absolute font sizes baked into a stylesheet.