from PySide6.QtCore import QSettings, Signal, QObject

class ThemeManager(QObject):
    theme_changed = Signal(str)

    def __init__(self):
        super().__init__()
        self.settings = QSettings("yobble_messenger", "Theme")
        self.theme = self.settings.value("theme", "dark")

    def get_theme(self):
        return self.theme

    def is_dark(self):
        return self.theme == "dark"

    def set_theme(self, theme: str):
        if theme in ("dark", "light"):
            self.theme = theme
            self.settings.setValue("theme", theme)
            self.theme_changed.emit(self.theme)

# Глобальный экземпляр
theme_manager = ThemeManager()
