Добавлен новый интерфейс с навигационной панелью и страницами для управления моделями, настройками и генерацией изображений. Реализованы стили для новых компонентов и добавлены функции для загрузки шрифтов и иконок. Обновлен основной класс окна для поддержки новых страниц.
This commit is contained in:
1 parent
df447a1ecf
commit
ac32c55ab9
25 files changed
+1496
-476
No files matched your search
@@ -0,0 +1,46 @@
|
||||
from typing import Optional
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
from .theme import Theme, StyleSheet
|
||||
|
||||
class ThemeManager:
|
||||
_instance: Optional['ThemeManager'] = None
|
||||
_current_theme = Theme.DARK
|
||||
|
||||
def __new__(cls):
|
||||
if cls._instance is None:
|
||||
cls._instance = super(ThemeManager, cls).__new__(cls)
|
||||
return cls._instance
|
||||
|
||||
@classmethod
|
||||
def get_instance(cls) -> 'ThemeManager':
|
||||
if cls._instance is None:
|
||||
cls._instance = cls()
|
||||
return cls._instance
|
||||
|
||||
@property
|
||||
def current_theme(self) -> Theme:
|
||||
return self._current_theme
|
||||
|
||||
def switch_theme(self, theme: Theme):
|
||||
"""Переключение темы приложения"""
|
||||
self._current_theme = theme
|
||||
self.apply_theme()
|
||||
|
||||
def toggle_theme(self):
|
||||
"""Переключение между светлой и темной темой"""
|
||||
new_theme = Theme.LIGHT if self._current_theme == Theme.DARK else Theme.DARK
|
||||
self.switch_theme(new_theme)
|
||||
|
||||
def apply_theme(self):
|
||||
"""Применение текущей темы ко всему приложению"""
|
||||
if not QApplication.instance():
|
||||
return
|
||||
|
||||
# Применяем базовые стили
|
||||
QApplication.instance().setStyleSheet(
|
||||
StyleSheet.get_base_styles(self._current_theme)
|
||||
)
|
||||
|
||||
def get_style(self, style_name: str) -> str:
|
||||
"""Получение конкретного стиля"""
|
||||
return StyleSheet.get_base_styles(self._current_theme)
|
||||
Reference in new issue
Block a user