Улучшен интерфейс менеджера пресетов размеров: добавлен фрейм для кнопок, изменены стили кнопок и заголовка, улучшено разделение пресетов на две группы. Изменены названия пресетов для упрощения. Добавлен метод создания кнопок с улучшенным дизайном.
This commit is contained in:
1 parent
8e6e54c802
commit
02c7b9483b
4 files changed
+69
-38
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel
|
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QFrame
|
||||||
from PyQt6.QtCore import Qt, pyqtSignal
|
from PyQt6.QtCore import Qt, pyqtSignal
|
||||||
from .size_presets import SIZE_PRESETS
|
from .size_presets import SIZE_PRESETS
|
||||||
|
|
||||||
@@ -11,51 +11,82 @@ class SizePresetManager(QWidget):
|
|||||||
|
|
||||||
def setup_ui(self):
|
def setup_ui(self):
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
|
layout.setSpacing(2)
|
||||||
|
|
||||||
# Заголовок
|
# Заголовок
|
||||||
title = QLabel("Пресеты размеров:")
|
title = QLabel("Размеры:")
|
||||||
title.setStyleSheet("""
|
title.setStyleSheet("""
|
||||||
QLabel {
|
QLabel {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-size: 14px;
|
font-size: 12px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 8px;
|
padding: 4px;
|
||||||
background-color: #3b3b3b;
|
background-color: #3b3b3b;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
layout.addWidget(title)
|
layout.addWidget(title)
|
||||||
|
|
||||||
# Создаем сетку кнопок
|
# Создаем фрейм для кнопок
|
||||||
grid_layout = QHBoxLayout()
|
buttons_frame = QFrame()
|
||||||
grid_layout.setSpacing(5)
|
buttons_frame.setStyleSheet("""
|
||||||
|
QFrame {
|
||||||
|
background-color: #2b2b2b;
|
||||||
|
border: 1px solid #3b3b3b;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
""")
|
||||||
|
buttons_layout = QVBoxLayout(buttons_frame)
|
||||||
|
buttons_layout.setSpacing(2)
|
||||||
|
|
||||||
# Добавляем кнопки пресетов
|
# Создаем две строки кнопок
|
||||||
for name, (width, height) in SIZE_PRESETS.items():
|
row1_layout = QHBoxLayout()
|
||||||
button = QPushButton(name)
|
row2_layout = QHBoxLayout()
|
||||||
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)
|
# Разделяем пресеты на две группы
|
||||||
|
presets = list(SIZE_PRESETS.items())
|
||||||
|
half = len(presets) // 2
|
||||||
|
|
||||||
|
# Добавляем кнопки в первую строку
|
||||||
|
for name, (width, height) in presets[:half]:
|
||||||
|
button = self.create_preset_button(name, width, height)
|
||||||
|
row1_layout.addWidget(button)
|
||||||
|
|
||||||
|
# Добавляем кнопки во вторую строку
|
||||||
|
for name, (width, height) in presets[half:]:
|
||||||
|
button = self.create_preset_button(name, width, height)
|
||||||
|
row2_layout.addWidget(button)
|
||||||
|
|
||||||
|
buttons_layout.addLayout(row1_layout)
|
||||||
|
buttons_layout.addLayout(row2_layout)
|
||||||
|
layout.addWidget(buttons_frame)
|
||||||
|
|
||||||
|
def create_preset_button(self, name, width, height):
|
||||||
|
"""Создание кнопки пресета с улучшенным дизайном"""
|
||||||
|
button = QPushButton(name)
|
||||||
|
button.setStyleSheet(f"""
|
||||||
|
QPushButton {{
|
||||||
|
background-color: #3b3b3b;
|
||||||
|
color: white;
|
||||||
|
border: 1px solid #555555;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 4px;
|
||||||
|
font-size: 11px;
|
||||||
|
min-width: 80px;
|
||||||
|
text-align: center;
|
||||||
|
}}
|
||||||
|
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))
|
||||||
|
return button
|
||||||
|
|
||||||
def on_preset_clicked(self, width, height):
|
def on_preset_clicked(self, width, height):
|
||||||
"""Обработчик нажатия на кнопку пресета"""
|
"""Обработчик нажатия на кнопку пресета"""
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
SIZE_PRESETS = {
|
SIZE_PRESETS = {
|
||||||
"Портрет (512x768)": (512, 768),
|
"512x768": (512, 768),
|
||||||
"Пейзаж (768x512)": (768, 512),
|
"768x512": (768, 512),
|
||||||
"Квадрат (512x512)": (512, 512),
|
"512x512": (512, 512),
|
||||||
"Широкий (768x432)": (768, 432),
|
"768x432": (768, 432),
|
||||||
"Высокий (432x768)": (432, 768),
|
"432x768": (432, 768),
|
||||||
"Вертикальный (600x800)": (600, 800)
|
"600x800": (600, 800)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user