112 lines
4.0 KiB
Python
112 lines
4.0 KiB
Python
from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
|
|
QPushButton, QLabel, QFrame)
|
|
from PyQt6.QtCore import Qt, QPropertyAnimation, QEasingCurve, pyqtSignal
|
|
from .icons import IconManager, IconType
|
|
from .theme import Theme, Colors, Spacing
|
|
from .theme_manager import ThemeManager
|
|
|
|
class NavigationButton(QPushButton):
|
|
def __init__(self, icon_type: IconType, text: str, parent=None):
|
|
super().__init__(parent)
|
|
self.icon_manager = IconManager.get_instance()
|
|
self.icon_type = icon_type
|
|
self.setup_ui(text)
|
|
|
|
def setup_ui(self, text: str):
|
|
self.icon_manager = IconManager.get_instance()
|
|
self.setIcon(self.icon_manager.get_icon(self.icon_type))
|
|
self.setText(text)
|
|
self.setCheckable(True)
|
|
self.setFixedHeight(40)
|
|
|
|
self.setStyleSheet("""
|
|
QPushButton {
|
|
background-color: transparent;
|
|
border: none;
|
|
border-radius: 8px;
|
|
padding: 8px 16px;
|
|
text-align: left;
|
|
font-size: 14px;
|
|
}
|
|
|
|
QPushButton:hover {
|
|
background-color: rgba(255, 255, 255, 0.1);
|
|
}
|
|
|
|
QPushButton:checked {
|
|
background-color: rgba(255, 255, 255, 0.15);
|
|
font-weight: bold;
|
|
}
|
|
""")
|
|
|
|
class NavigationPanel(QFrame):
|
|
page_changed = pyqtSignal(str)
|
|
|
|
def __init__(self, parent=None):
|
|
super().__init__(parent)
|
|
self.theme_manager = ThemeManager.get_instance()
|
|
self.setup_ui()
|
|
|
|
def setup_ui(self):
|
|
colors = self.theme_manager.current_theme.get_colors()
|
|
self.setStyleSheet(f"""
|
|
QFrame {{
|
|
background-color: {colors['surface']};
|
|
border-right: 1px solid {colors['border']};
|
|
}}
|
|
""")
|
|
|
|
# Основной layout
|
|
layout = QVBoxLayout(self)
|
|
layout.setContentsMargins(8, 16, 8, 16)
|
|
layout.setSpacing(8)
|
|
|
|
# Заголовок
|
|
header = QLabel("Stable Diffusion UI")
|
|
header.setStyleSheet(f"""
|
|
QLabel {{
|
|
color: {colors['text']};
|
|
font-size: 18px;
|
|
font-weight: bold;
|
|
padding: 16px;
|
|
}}
|
|
""")
|
|
layout.addWidget(header)
|
|
|
|
# Кнопки навигации
|
|
self.home_btn = NavigationButton(IconType.HOME, "Главная")
|
|
self.models_btn = NavigationButton(IconType.IMAGE, "Модели")
|
|
self.settings_btn = NavigationButton(IconType.SETTINGS, "Настройки")
|
|
|
|
# Добавляем кнопки
|
|
layout.addWidget(self.home_btn)
|
|
layout.addWidget(self.models_btn)
|
|
layout.addWidget(self.settings_btn)
|
|
|
|
# Растягиваем пространство
|
|
layout.addStretch()
|
|
|
|
# Подключаем сигналы
|
|
self.home_btn.clicked.connect(lambda: self.change_page("home"))
|
|
self.models_btn.clicked.connect(lambda: self.change_page("models"))
|
|
self.settings_btn.clicked.connect(lambda: self.change_page("settings"))
|
|
|
|
# Устанавливаем фиксированную ширину
|
|
self.setFixedWidth(250)
|
|
|
|
def change_page(self, page_name: str):
|
|
"""Смена активной страницы"""
|
|
# Отключаем все кнопки
|
|
for btn in self.findChildren(NavigationButton):
|
|
btn.setChecked(False)
|
|
|
|
# Включаем нужную кнопку
|
|
if page_name == "home":
|
|
self.home_btn.setChecked(True)
|
|
elif page_name == "models":
|
|
self.models_btn.setChecked(True)
|
|
elif page_name == "settings":
|
|
self.settings_btn.setChecked(True)
|
|
|
|
# Отправляем сигнал о смене страницы
|
|
self.page_changed.emit(page_name) |