From 603f6827b61dc39258a41479db532457312ba852 Mon Sep 17 00:00:00 2001 From: kromskii2 <146603192+kromskii2@users.noreply.github.com> Date: Fri, 14 Mar 2025 20:03:37 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BF=D1=80=D0=B5=D1=81=D0=B5=D1=82=D1=8B=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=80=D0=BE=D0=B2=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81?= =?UTF-8?q?=20=D0=BA=D1=80=D0=B0=D1=81=D0=B8=D0=B2=D1=8B=D0=BC=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 12 +++++++ modules/size_preset_manager.py | 62 ++++++++++++++++++++++++++++++++++ modules/size_presets.py | 8 +++++ 3 files changed, 82 insertions(+) create mode 100644 modules/size_preset_manager.py create mode 100644 modules/size_presets.py diff --git a/main.py b/main.py index 1895e37..67c98cf 100644 --- a/main.py +++ b/main.py @@ -18,6 +18,7 @@ from modules.model_manager import ModelManager from modules.sampler_manager import SamplerManager from modules.prompt_window import PromptWindow from modules.negative_prompt_window import NegativePromptWindow +from modules.size_preset_manager import SizePresetManager class GenerationThread(QThread): progress_updated = pyqtSignal(float, str) @@ -202,6 +203,11 @@ class MainWindow(QMainWindow): self.sampler_manager = SamplerManager(self.api_url) settings_layout.addWidget(self.sampler_manager) + # Добавляем менеджер пресетов размеров + self.size_preset_manager = SizePresetManager() + self.size_preset_manager.size_changed.connect(self.on_size_preset_changed) + settings_layout.addWidget(self.size_preset_manager) + # Параметры генерации params_layout = QVBoxLayout() @@ -503,6 +509,12 @@ class MainWindow(QMainWindow): self.sampler_manager.update_api_url(new_url) self.log_to_console(f"API URL обновлен: {new_url}") + def on_size_preset_changed(self, width, height): + """Обработчик изменения размера через пресет""" + self.width_input.setValue(width) + self.height_input.setValue(height) + self.log_to_console(f"Размер изменен на: {width}x{height}") + if __name__ == '__main__': app = QApplication(sys.argv) window = MainWindow() diff --git a/modules/size_preset_manager.py b/modules/size_preset_manager.py new file mode 100644 index 0000000..39f0aee --- /dev/null +++ b/modules/size_preset_manager.py @@ -0,0 +1,62 @@ +from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel +from PyQt6.QtCore import Qt, pyqtSignal +from .size_presets import SIZE_PRESETS + +class SizePresetManager(QWidget): + size_changed = pyqtSignal(int, int) # Сигнал для изменения размера + + def __init__(self, parent=None): + super().__init__(parent) + self.setup_ui() + + def setup_ui(self): + layout = QVBoxLayout(self) + + # Заголовок + title = QLabel("Пресеты размеров:") + title.setStyleSheet(""" + QLabel { + color: #ffffff; + font-size: 14px; + font-weight: bold; + padding: 8px; + background-color: #3b3b3b; + border-radius: 4px; + } + """) + layout.addWidget(title) + + # Создаем сетку кнопок + grid_layout = QHBoxLayout() + grid_layout.setSpacing(5) + + # Добавляем кнопки пресетов + for name, (width, height) in SIZE_PRESETS.items(): + button = QPushButton(name) + button.setStyleSheet(""" + QPushButton { + background-color: #3b3b3b; + color: white; + border: 1px solid #555555; + border-radius: 4px; + padding: 8px; + font-size: 12px; + min-width: 120px; + } + QPushButton:hover { + background-color: #4a4a4a; + border-color: #666666; + } + QPushButton:pressed { + background-color: #0d6efd; + border-color: #0b5ed7; + } + """) + button.clicked.connect(lambda checked, w=width, h=height: self.on_preset_clicked(w, h)) + grid_layout.addWidget(button) + + layout.addLayout(grid_layout) + + def on_preset_clicked(self, width, height): + """Обработчик нажатия на кнопку пресета""" + self.size_changed.emit(width, height) \ No newline at end of file diff --git a/modules/size_presets.py b/modules/size_presets.py new file mode 100644 index 0000000..80ff667 --- /dev/null +++ b/modules/size_presets.py @@ -0,0 +1,8 @@ +SIZE_PRESETS = { + "Портрет (512x768)": (512, 768), + "Пейзаж (768x512)": (768, 512), + "Квадрат (512x512)": (512, 512), + "Широкий (768x432)": (768, 432), + "Высокий (432x768)": (432, 768), + "Вертикальный (600x800)": (600, 800) +} \ No newline at end of file