from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QLineEdit, QTextEdit, QSpinBox, QDoubleSpinBox, QComboBox) from PyQt6.QtCore import Qt from ..styles.page import BasePage from ..styles.theme import Colors, Spacing, Fonts from ..styles.theme_manager import ThemeManager class HomePage(BasePage): def __init__(self, parent=None): super().__init__(parent) self.theme_manager = ThemeManager.get_instance() self.setup_content() def setup_content(self): """Настройка содержимого страницы""" colors = self.theme_manager.current_theme.get_colors() spacing = self.theme_manager.current_theme.get_spacing() # Заголовок header = QLabel("Генерация изображений") header.setStyleSheet(f""" QLabel {{ color: {colors['text']}; font-size: 18px; font-weight: bold; }} """) self.layout.addWidget(header) # Промпт prompt_layout = QVBoxLayout() prompt_label = QLabel("Промпт:") prompt_label.setStyleSheet(f""" QLabel {{ color: {colors['text']}; font-size: 14px; font-weight: 500; }} """) self.prompt_input = QTextEdit() self.prompt_input.setPlaceholderText("Опишите изображение, которое хотите сгенерировать...") self.prompt_input.setMinimumHeight(100) prompt_layout.addWidget(prompt_label) prompt_layout.addWidget(self.prompt_input) self.layout.addLayout(prompt_layout) # Негативный промпт negative_prompt_layout = QVBoxLayout() negative_prompt_label = QLabel("Негативный промпт:") negative_prompt_label.setStyleSheet(f""" QLabel {{ color: {colors['text']}; font-size: 14px; font-weight: 500; }} """) self.negative_prompt_input = QTextEdit() self.negative_prompt_input.setPlaceholderText("Опишите, что не должно появиться на изображении...") self.negative_prompt_input.setMinimumHeight(100) negative_prompt_layout.addWidget(negative_prompt_label) negative_prompt_layout.addWidget(self.negative_prompt_input) self.layout.addLayout(negative_prompt_layout) # Параметры генерации params_layout = QHBoxLayout() # Размер изображения size_layout = QVBoxLayout() size_label = QLabel("Размер:") size_label.setStyleSheet(f""" QLabel {{ color: {colors['text']}; font-size: 14px; font-weight: 500; }} """) self.size_combo = QComboBox() self.size_combo.addItems(["512x512", "768x768", "1024x1024"]) size_layout.addWidget(size_label) size_layout.addWidget(self.size_combo) params_layout.addLayout(size_layout) # Количество шагов steps_layout = QVBoxLayout() steps_label = QLabel("Шаги:") steps_label.setStyleSheet(f""" QLabel {{ color: {colors['text']}; font-size: 14px; font-weight: 500; }} """) self.steps_spin = QSpinBox() self.steps_spin.setRange(1, 150) self.steps_spin.setValue(20) steps_layout.addWidget(steps_label) steps_layout.addWidget(self.steps_spin) params_layout.addLayout(steps_layout) # CFG Scale cfg_layout = QVBoxLayout() cfg_label = QLabel("CFG Scale:") cfg_label.setStyleSheet(f""" QLabel {{ color: {colors['text']}; font-size: 14px; font-weight: 500; }} """) self.cfg_spin = QDoubleSpinBox() self.cfg_spin.setRange(1.0, 30.0) self.cfg_spin.setValue(7.0) self.cfg_spin.setSingleStep(0.5) cfg_layout.addWidget(cfg_label) cfg_layout.addWidget(self.cfg_spin) params_layout.addLayout(cfg_layout) # Сэмплер sampler_layout = QVBoxLayout() sampler_label = QLabel("Сэмплер:") sampler_label.setStyleSheet(f""" QLabel {{ color: {colors['text']}; font-size: 14px; font-weight: 500; }} """) self.sampler_combo = QComboBox() self.sampler_combo.addItems(["Euler a", "Euler", "DPM++ 2M Karras"]) sampler_layout.addWidget(sampler_label) sampler_layout.addWidget(self.sampler_combo) params_layout.addLayout(sampler_layout) # Добавляем параметры на страницу self.layout.addLayout(params_layout) # Кнопки управления buttons_layout = QHBoxLayout() buttons_layout.setSpacing(spacing.MEDIUM) self.generate_button = QPushButton("Сгенерировать") self.generate_button.setStyleSheet(f""" QPushButton {{ min-width: 150px; background-color: {colors['primary']}; color: white; border: none; border-radius: {spacing.TINY}px; padding: {spacing.SMALL}px {spacing.MEDIUM}px; }} QPushButton:hover {{ background-color: {colors['hover']}; }} QPushButton:pressed {{ background-color: {colors['active']}; }} """) self.clear_button = QPushButton("Очистить") self.clear_button.setStyleSheet(f""" QPushButton {{ min-width: 150px; background-color: transparent; color: {colors['primary']}; border: 1px solid {colors['primary']}; border-radius: {spacing.TINY}px; padding: {spacing.SMALL}px {spacing.MEDIUM}px; }} QPushButton:hover {{ background-color: {colors['hover']}; color: white; border: none; }} QPushButton:pressed {{ background-color: {colors['active']}; color: white; border: none; }} """) buttons_layout.addWidget(self.generate_button) buttons_layout.addWidget(self.clear_button) buttons_layout.addStretch() self.layout.addLayout(buttons_layout) # Растягиваем пространство self.layout.addStretch()