Добавлены пресеты размеров изображения с красивыми кнопками

This commit is contained in:
kromskii2 committed 2025-03-14 20:03:37 +07:00
1 parent 41999b31c1
commit 603f6827b6
3 files changed
+82

No files matched your search

+62
View File
@@ -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)
+8
View File
@@ -0,0 +1,8 @@
SIZE_PRESETS = {
"Портрет (512x768)": (512, 768),
"Пейзаж (768x512)": (768, 512),
"Квадрат (512x512)": (512, 512),
"Широкий (768x432)": (768, 432),
"Высокий (432x768)": (432, 768),
"Вертикальный (600x800)": (600, 800)
}