Files
Dispatch/Dispatch_V0.1.1/gui/theme_bus.py
2026-04-29 08:18:54 +04:00

49 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
# gui/theme_bus.py
from PySide6.QtCore import QObject, Signal
class ThemeBus(QObject):
theme_changed = Signal(str) # "dark" | "light"
theme_bus = ThemeBus()
# для использования снаружи:
# theme_bus.theme_changed.emit("light")
# theme_bus.theme_changed.emit("dark")
# Подключение снаружи:
# from gui.theme.theme_bus import ThemeBus
# from gui.theme.theme_bus import theme_bus
# theme_bus = ThemeBus()
# btn = Button("Склад", index=0, theme_source=theme_bus)
# theme_bus.theme_changed.emit("light")
# theme_bus.theme_changed.emit("dark")
# ---------------------------------------------------------------------------
# Module workflow notes (compact)
# ---------------------------------------------------------------------------
#
# 1) Назначение модуля:
# Глобальная шина событий для переключения темы (dark/light).
# Содержит QObject-синглтон theme_bus с сигналом theme_changed(str).
# Все StylableMixin-виджеты подписаны на этот сигнал.
#
# 2) Зависимости модуля:
# Импорты: QObject, Signal (PySide6.QtCore)
# Хост/базовый класс: QObject
# Внешние библиотеки: PySide6
#
# 3) Экспорт:
# Класс ThemeBus — QObject с сигналом theme_changed: Signal(str).
# Экземпляр theme_bus — глобальный синглтон.
# Использование: theme_bus.theme_changed.emit("light"|"dark").