117 lines
4.6 KiB
Python
117 lines
4.6 KiB
Python
from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
|
|
QLabel, QPushButton, QTextEdit, QComboBox,
|
|
QScrollArea, QFrame)
|
|
from PyQt6.QtCore import Qt, pyqtSignal
|
|
from ..styles.style_constants import StyleConstants
|
|
from ..styles.icons import IconManager, IconType
|
|
|
|
class PromptCategory(QFrame):
|
|
"""Виджет категории промптов"""
|
|
def __init__(self, title: str, prompts: list, parent=None):
|
|
super().__init__(parent)
|
|
self.title = title
|
|
self.prompts = prompts
|
|
self.setup_ui()
|
|
|
|
def setup_ui(self):
|
|
layout = QVBoxLayout(self)
|
|
|
|
# Заголовок категории
|
|
title_label = QLabel(self.title)
|
|
title_label.setStyleSheet(f"""
|
|
font-size: {StyleConstants.FONTS['size']['lg']};
|
|
font-weight: {StyleConstants.FONTS['weight']['bold']};
|
|
margin-bottom: {StyleConstants.SPACING['sm']};
|
|
""")
|
|
layout.addWidget(title_label)
|
|
|
|
# Список промптов
|
|
for prompt in self.prompts:
|
|
btn = QPushButton(prompt)
|
|
btn.setStyleSheet(f"""
|
|
text-align: left;
|
|
padding: {StyleConstants.SPACING['sm']};
|
|
margin-bottom: {StyleConstants.SPACING['xs']};
|
|
""")
|
|
layout.addWidget(btn)
|
|
|
|
self.setStyleSheet(f"""
|
|
QFrame {{
|
|
background-color: {StyleConstants.COLORS['light']['surface']};
|
|
border-radius: {StyleConstants.RADIUS['lg']};
|
|
padding: {StyleConstants.SPACING['md']};
|
|
margin-bottom: {StyleConstants.SPACING['md']};
|
|
}}
|
|
""")
|
|
|
|
class PromptWindow(QWidget):
|
|
"""Окно для работы с промптами"""
|
|
prompt_selected = pyqtSignal(str)
|
|
|
|
def __init__(self, parent=None):
|
|
super().__init__(parent)
|
|
self.icon_manager = IconManager.get_instance()
|
|
self.setup_ui()
|
|
|
|
def setup_ui(self):
|
|
self.setWindowTitle("Библиотека промптов")
|
|
self.resize(800, 600)
|
|
|
|
# Основной layout
|
|
layout = QVBoxLayout(self)
|
|
layout.setSpacing(StyleConstants.SPACING['md'])
|
|
layout.setContentsMargins(
|
|
StyleConstants.SPACING['lg'],
|
|
StyleConstants.SPACING['lg'],
|
|
StyleConstants.SPACING['lg'],
|
|
StyleConstants.SPACING['lg']
|
|
)
|
|
|
|
# Верхняя панель
|
|
top_panel = QHBoxLayout()
|
|
|
|
# Поиск
|
|
self.search_box = QComboBox()
|
|
self.search_box.setEditable(True)
|
|
self.search_box.setPlaceholderText("Поиск промптов...")
|
|
self.search_box.setMinimumWidth(300)
|
|
top_panel.addWidget(self.search_box)
|
|
|
|
# Кнопки
|
|
add_btn = QPushButton("Добавить промпт")
|
|
add_btn.setIcon(self.icon_manager.get_icon(IconType.ADD))
|
|
top_panel.addWidget(add_btn)
|
|
|
|
refresh_btn = QPushButton("Обновить")
|
|
refresh_btn.setIcon(self.icon_manager.get_icon(IconType.REFRESH))
|
|
top_panel.addWidget(refresh_btn)
|
|
|
|
top_panel.addStretch()
|
|
layout.addLayout(top_panel)
|
|
|
|
# Область прокрутки для категорий
|
|
scroll_area = QScrollArea()
|
|
scroll_area.setWidgetResizable(True)
|
|
scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
|
|
|
# Контейнер для категорий
|
|
categories_widget = QWidget()
|
|
self.categories_layout = QVBoxLayout(categories_widget)
|
|
|
|
# Добавляем тестовые категории
|
|
test_categories = {
|
|
"Стили": ["Фотореалистичный", "Аниме", "Масляная живопись", "Акварель"],
|
|
"Освещение": ["Дневной свет", "Закат", "Ночное освещение", "Студийный свет"],
|
|
"Композиция": ["Крупный план", "Панорама", "Портрет", "Пейзаж"]
|
|
}
|
|
|
|
for title, prompts in test_categories.items():
|
|
category = PromptCategory(title, prompts)
|
|
self.categories_layout.addWidget(category)
|
|
|
|
self.categories_layout.addStretch()
|
|
scroll_area.setWidget(categories_widget)
|
|
layout.addWidget(scroll_area)
|
|
|
|
# Применяем стили
|
|
self.setStyleSheet(StyleConstants.get_base_styles('light')) |