Добавлены пресеты размеров изображения с красивыми кнопками
This commit is contained in:
1 parent
41999b31c1
commit
603f6827b6
3 files changed
+82
No files matched your search
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
@@ -0,0 +1,8 @@
|
||||
SIZE_PRESETS = {
|
||||
"Портрет (512x768)": (512, 768),
|
||||
"Пейзаж (768x512)": (768, 512),
|
||||
"Квадрат (512x512)": (512, 512),
|
||||
"Широкий (768x432)": (768, 432),
|
||||
"Высокий (432x768)": (432, 768),
|
||||
"Вертикальный (600x800)": (600, 800)
|
||||
}
|
||||
Reference in new issue
Block a user