GUI appearance
Apply the shared colors, fonts, icons, and widget styles.
mtc_gui.theme · Source
Operator GUI · Guide · Symbol index
How it is used
Call apply() on the QApplication during startup. toggle_dark_mode() applies the same dark theme or restores the style’s standard palette and clears the stylesheet; it leaves the existing font and Fusion style in place. The main window’s appearance menu calls this helper.
Widgets use the module’s constants and icon() helper for consistent appearance. Call restyle() after changing a dynamic property, such as the plan-cache badge’s status. Use these helpers on the GUI thread. Missing icon support falls back to an empty icon, and unavailable Inter fonts fall back to Sans Serif.
Start here
Callable |
Purpose |
|---|---|
Apply the shared Qt style, font, palette, and stylesheet. |
|
Apply the shared dark theme when enabled, or restore the style’s standard palette and clear the stylesheet when disabled. |
|
Create a qtawesome icon and degrade to an empty QIcon if icon generation fails. |
|
Reapply a widget’s stylesheet selectors after a property changes. |
Functions
apply()
Apply the shared Qt style, font, palette, and stylesheet.
Entry point · Source
apply(app: QApplication) -> None
Parameter |
Meaning |
|---|---|
|
Running QApplication to style globally. |
Returns: None.
Errors: Qt/font-loading errors propagate.
Side effects: Changes application style/font/palette/stylesheet and may register font files.
Referenced in source (2)
main— mtc_gui.maintoggle_dark_mode— mtc_gui.theme
toggle_dark_mode()
Apply the shared dark theme when enabled, or restore the style’s standard palette and clear the stylesheet when disabled.
Function · Source
toggle_dark_mode(app: QApplication, enabled: bool) -> None
Parameter |
Meaning |
|---|---|
|
QApplication to update. |
|
Truthy selects the shared theme; false selects palette/stylesheet reset. |
Returns: None.
Errors: Qt/theme exceptions propagate.
Side effects: Updates application appearance. The disabled branch does not undo the font or Fusion style previously set by theme.apply.
Referenced in source (1)
MTCMainWindow._toggle_dark_mode— mtc_gui.main_window
icon()
Create a qtawesome icon and degrade to an empty QIcon if icon generation fails.
Function · Source
icon(name: str, color: str=ON_SURFACE)
Parameter |
Meaning |
|---|---|
|
qtawesome icon identifier, for example “mdi6.play”. |
|
Icon color passed to qtawesome, defaulting to the theme’s primary text color. |
Returns: QIcon from qtawesome, or an empty QIcon.
Errors: Catches every Exception from qtawesome import/icon creation; fallback QIcon import/construction errors propagate.
Side effects: Lazily imports qtawesome and allocates an icon.
Referenced in source (1)
MTCMainWindow._build_center_pane— mtc_gui.main_window
restyle()
Reapply a widget’s stylesheet selectors after a property changes.
Function · Source
restyle(widget: QWidget) -> None
Parameter |
Meaning |
|---|---|
|
QWidget whose style must be unpolished and polished again. |
Returns: None.
Errors: Invalid-widget/Qt errors propagate.
Side effects: Calls style.unpolish, style.polish, and widget.update.
Referenced in source (2)
MTCMainWindow._clear_plan_cache_warning— mtc_gui.main_windowMTCMainWindow._set_plan_cached— mtc_gui.main_window
Internal callbacks and helpers
_palette()
Build the dark palette used alongside the shared stylesheet.
Internal helper · Source
_palette() -> QPalette
Returns: New QPalette with themed window/base/text/button/link/highlight/placeholder roles and disabled text roles.
Errors: Qt color/palette errors propagate.
Side effects: Allocates a palette; does not apply it to the application.
Referenced in source (1)
apply— mtc_gui.theme
_load_fonts()
Find or register Inter, falling back to Sans Serif when unavailable.
Internal helper · Source
_load_fonts() -> str
Returns: Resolved family-name string; explicit file loading returns the first family exposed by that font.
Errors: Unsuccessful addApplicationFont results are skipped; unexpected Qt errors propagate.
Side effects: May register /usr/share/fonts/truetype/inter-vf/InterVariable.ttf or /usr/share/fonts/truetype/inter/Inter-Regular.otf with QFontDatabase.
Referenced in source (1)
apply— mtc_gui.theme