GUI¶
Theme¶
theme
¶
Desktop-environment detection and Qt theme application.
Detects the running desktop environment from XDG_CURRENT_DESKTOP,
DESKTOP_SESSION, or GDMSESSION and maps it to the most
appropriate Qt style and colour palette so the assistant window blends
naturally with the user's desktop.
Supported desktop environments¶
- GNOME / Budgie / Pop!_OS → Fusion style with Adwaita-inspired palette
- KDE Plasma / LXQt → native Qt style (Breeze used automatically)
- XFCE → Fusion with neutral grey palette
- MATE → Fusion with neutral palette
- Cinnamon → Fusion with Mint-green accent
- Pantheon (elementary OS) → Fusion with elementary blue accent
- Deepin → Fusion with Deepin-blue accent
- Unknown / fallback → Fusion (clean, cross-platform)
The module is pure Python — Qt is imported lazily inside
:func:apply_to_app only, so the rest of the codebase can import
:mod:src.gui.theme without PyQt5 being installed.
Example¶
from src.gui.theme import detect_desktop_environment, get_theme_for_de de = detect_desktop_environment() theme = get_theme_for_de(de) print(theme.style_name, theme.accent_hex)
ColourPalette
dataclass
¶
ColourPalette(window='#f0f0f0', window_text='#1a1a1a', base='#ffffff', alternate_base='#f5f5f5', button='#e0e0e0', button_text='#1a1a1a', text='#1a1a1a', highlight='#3584e4', highlight_text='#ffffff', tooltip_base='#ffffcc', tooltip_text='#1a1a1a', mid='#c8c8c8', shadow='#808080', dark='#a0a0a0')
RGB colour values for a Qt QPalette.
All hex strings are in #RRGGBB format.
DarkColourPalette
dataclass
¶
DarkColourPalette(window='#2d2d2d', window_text='#e0e0e0', base='#1e1e1e', alternate_base='#282828', button='#3c3c3c', button_text='#e0e0e0', text='#e0e0e0', highlight='#3584e4', highlight_text='#ffffff', tooltip_base='#3c3c3c', tooltip_text='#e0e0e0', mid='#505050', shadow='#1a1a1a', dark='#404040')
Theme
dataclass
¶
Theme(de='unknown', style_name='Fusion', light=ColourPalette(), dark=DarkColourPalette(), accent_hex='#3584e4', font_family='', font_size_pt=0, icon_theme='', extra_stylesheet='')
Complete theme description for a desktop environment.
Attributes¶
de:
Canonical DE name (e.g. "gnome", "kde", "xfce").
style_name:
Qt style name passed to QApplication.setStyle().
"" means use the system default (recommended for KDE/Plasma).
light:
Colour palette for light mode.
dark:
Colour palette for dark mode.
accent_hex:
Primary accent colour in #RRGGBB (used for highlights).
font_family:
Preferred font family (empty = Qt default).
font_size_pt:
Preferred font size in points (0 = Qt default).
icon_theme:
Preferred XDG icon theme name (empty = system default).
extra_stylesheet:
Additional QSS applied on top of the base style.
detect_desktop_environment
¶
Detect the running desktop environment.
Checks the following environment variables in order:
XDG_CURRENT_DESKTOPDESKTOP_SESSIONGDMSESSION
Returns¶
str
Lower-cased canonical DE name, e.g. "gnome", "kde",
"xfce". Returns "unknown" if detection fails.
Source code in src/gui/theme.py
get_theme_for_de
¶
Return a :class:Theme for the given desktop environment name.
Parameters¶
de:
Canonical DE name as returned by :func:detect_desktop_environment.
Returns¶
Theme Fully populated theme object. Falls back to Fusion if de is unrecognised.
Source code in src/gui/theme.py
get_current_theme
¶
Detect the desktop environment and return the matching theme.
Convenience wrapper combining :func:detect_desktop_environment and
:func:get_theme_for_de.
Source code in src/gui/theme.py
apply_to_app
¶
Apply theme to a QApplication instance.
Imports PyQt5 lazily so this module is importable without Qt installed.
Parameters¶
app:
A PyQt5.QtWidgets.QApplication instance.
theme:
Theme to apply. If None, :func:get_current_theme is called
automatically.
Returns¶
Theme The theme that was applied (useful for inspection / testing).
Raises¶
ImportError If PyQt5 is not installed.
Source code in src/gui/theme.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | |
Diagnostic Reporter¶
diagnostic_reporter
¶
Diagnostic reporter — pure-Python system status collector.
Collects the status of every major application subsystem without importing Qt, so the results are easily unit-testable and can be used from the CLI as well as the GUI.
The :class:DiagnosticReporter class is the main entry point. Call
:meth:full_report to get a single dict with all status information, or
call individual check_* methods for targeted checks.
Example¶
::
>>> from src.diagnostic_reporter import DiagnosticReporter
>>> from src.config import load as load_config
>>> reporter = DiagnosticReporter(load_config())
>>> report = reporter.full_report()
>>> print(report["backend"]["status"])
'ok'
DiagnosticReporter
¶
Collect live status information from all application subsystems.
Parameters¶
config:
The application :class:~src.config.Config object.
registry:
Optional :class:~src.tools.ToolRegistry for tool status checks.
settings_manager:
Optional :class:~src.settings.SettingsManager for settings checks.
Source code in src/gui/diagnostic_reporter.py
check_backend
¶
Check connectivity to the AI backend.
Returns¶
dict
Keys: status, backend, url, model,
latency_ms, error.
Source code in src/gui/diagnostic_reporter.py
check_npu
¶
Check AMD NPU / ONNX Runtime availability.
Returns¶
dict
Keys: status, available, providers,
onnxruntime_version, model_path, model_exists,
error.
Source code in src/gui/diagnostic_reporter.py
check_tools
¶
Return status of every registered tool.
Returns¶
list[dict]
One dict per tool with keys: name, status,
loaded, unload_after_use, description.
Source code in src/gui/diagnostic_reporter.py
check_security
¶
Run security checks on files and configuration.
Returns¶
dict
Keys: status, checks (list of individual check dicts),
issues.
Source code in src/gui/diagnostic_reporter.py
check_settings
¶
Check the settings file and manager status.
Returns¶
dict
Keys: status, path, exists, listener_count,
backend, model, error.
Source code in src/gui/diagnostic_reporter.py
check_system
¶
Collect system information.
Returns¶
dict
Keys: status, os_name, os_version, distro_id,
package_manager, desktop_environment, shell,
kernel, architecture, python_version,
is_immutable, app_version.
Source code in src/gui/diagnostic_reporter.py
check_network
¶
Check network configuration and local URL validity.
Returns¶
dict
Keys: status, allow_external, backend_url,
backend_url_is_local, error.
Source code in src/gui/diagnostic_reporter.py
check_dependencies
¶
Check availability of optional runtime dependencies.
Returns¶
list[dict]
One dict per dependency with keys: name, status,
version, required, detail.
Source code in src/gui/diagnostic_reporter.py
run_tests
¶
Run the test suite programmatically and return a summary.
Returns¶
dict
Keys: status, passed, failed, errors,
total, duration_s, output.
Source code in src/gui/diagnostic_reporter.py
full_report
¶
Collect all status checks and return a single aggregated dict.
Returns¶
dict
Keys: timestamp, app_version, overall_status,
backend, npu, tools, security, settings,
system, network, dependencies.
Note¶
The backend check makes a live HTTP probe. All other checks are
local only. Pass probe_backend=False to :meth:full_report if
you want a fully offline report (the backend entry will be skipped).