49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
# -*- 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").
|