Files
art/modules/size_preset_manager.py
T

62 lines
2.1 KiB
Python

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)