Улучшен дизайн кнопок SpinBox: добавлены современные стили, улучшена визуальная обратная связь, добавлены SVG иконки, оптимизированы размеры и отступы, улучшена читаемость значени
This commit is contained in:
1 parent
2b9165771b
commit
29dce906c5
6110 files changed
+775979
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,93 @@
|
||||
from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
|
||||
QTextEdit, QPushButton, QDialog)
|
||||
from PyQt6.QtCore import Qt, pyqtSignal
|
||||
from PyQt6.QtGui import QClipboard, QTextCursor
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
|
||||
class ConsoleWindow(QDialog):
|
||||
console_closed = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setWindowTitle("Консоль")
|
||||
self.setModal(False)
|
||||
self.setup_ui()
|
||||
self.log_messages = []
|
||||
|
||||
def setup_ui(self):
|
||||
self.setStyleSheet("""
|
||||
QDialog {
|
||||
background-color: #2b2b2b;
|
||||
min-width: 600px;
|
||||
min-height: 400px;
|
||||
}
|
||||
QTextEdit {
|
||||
background-color: #1e1e1e;
|
||||
color: #ffffff;
|
||||
border: 1px solid #3b3b3b;
|
||||
border-radius: 4px;
|
||||
font-family: 'Consolas', 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
padding: 8px;
|
||||
}
|
||||
QPushButton {
|
||||
background-color: #0d6efd;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
padding: 8px 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
QPushButton:hover {
|
||||
background-color: #0b5ed7;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #0a58ca;
|
||||
}
|
||||
""")
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
# Область для логов
|
||||
self.console_output = QTextEdit()
|
||||
self.console_output.setReadOnly(True)
|
||||
layout.addWidget(self.console_output)
|
||||
|
||||
# Кнопки управления
|
||||
buttons_layout = QHBoxLayout()
|
||||
|
||||
copy_button = QPushButton("Копировать всё")
|
||||
copy_button.clicked.connect(self.copy_all)
|
||||
|
||||
clear_button = QPushButton("Очистить")
|
||||
clear_button.clicked.connect(self.clear_console)
|
||||
|
||||
buttons_layout.addWidget(copy_button)
|
||||
buttons_layout.addWidget(clear_button)
|
||||
buttons_layout.addStretch()
|
||||
|
||||
layout.addLayout(buttons_layout)
|
||||
|
||||
def log(self, message):
|
||||
"""Добавить сообщение в консоль"""
|
||||
self.log_messages.append(message)
|
||||
self.console_output.append(message)
|
||||
# Прокрутка к последнему сообщению
|
||||
cursor = self.console_output.textCursor()
|
||||
cursor.movePosition(QTextCursor.MoveOperation.End)
|
||||
self.console_output.setTextCursor(cursor)
|
||||
|
||||
def copy_all(self):
|
||||
"""Копировать весь текст в буфер обмена"""
|
||||
clipboard = QApplication.clipboard()
|
||||
clipboard.setText(self.console_output.toPlainText())
|
||||
|
||||
def clear_console(self):
|
||||
"""Очистить консоль"""
|
||||
self.console_output.clear()
|
||||
self.log_messages.clear()
|
||||
|
||||
def closeEvent(self, event):
|
||||
"""Обработка закрытия окна"""
|
||||
self.console_closed.emit()
|
||||
event.accept()
|
||||
@@ -0,0 +1,70 @@
|
||||
from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
|
||||
QComboBox, QPushButton, QLabel)
|
||||
from PyQt6.QtCore import pyqtSignal
|
||||
import requests
|
||||
|
||||
class ModelManager(QWidget):
|
||||
model_changed = pyqtSignal(str)
|
||||
|
||||
def __init__(self, api_url, parent=None):
|
||||
super().__init__(parent)
|
||||
self.api_url = api_url
|
||||
self.setup_ui()
|
||||
self.load_models()
|
||||
|
||||
def setup_ui(self):
|
||||
layout = QHBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
# Метка
|
||||
label = QLabel("Модель:")
|
||||
layout.addWidget(label)
|
||||
|
||||
# Выпадающий список моделей
|
||||
self.model_combo = QComboBox()
|
||||
self.model_combo.currentTextChanged.connect(self.on_model_changed)
|
||||
layout.addWidget(self.model_combo)
|
||||
|
||||
# Кнопка обновления
|
||||
refresh_button = QPushButton("🔄")
|
||||
refresh_button.setToolTip("Обновить список моделей")
|
||||
refresh_button.clicked.connect(self.load_models)
|
||||
layout.addWidget(refresh_button)
|
||||
|
||||
layout.addStretch()
|
||||
|
||||
def load_models(self):
|
||||
"""Загрузить список доступных моделей"""
|
||||
try:
|
||||
response = requests.get(f"{self.api_url}/sdapi/v1/sd-models")
|
||||
if response.status_code == 200:
|
||||
models = response.json()
|
||||
current_model = self.model_combo.currentText()
|
||||
|
||||
self.model_combo.clear()
|
||||
for model in models:
|
||||
self.model_combo.addItem(model.get('title', ''))
|
||||
|
||||
# Восстанавливаем выбранную модель, если она всё ещё доступна
|
||||
index = self.model_combo.findText(current_model)
|
||||
if index >= 0:
|
||||
self.model_combo.setCurrentIndex(index)
|
||||
except Exception as e:
|
||||
print(f"Ошибка при загрузке моделей: {str(e)}")
|
||||
|
||||
def on_model_changed(self, model_name):
|
||||
"""Обработка смены модели"""
|
||||
try:
|
||||
response = requests.post(
|
||||
f"{self.api_url}/sdapi/v1/options",
|
||||
json={"sd_model_checkpoint": model_name}
|
||||
)
|
||||
if response.status_code == 200:
|
||||
self.model_changed.emit(model_name)
|
||||
except Exception as e:
|
||||
print(f"Ошибка при смене модели: {str(e)}")
|
||||
|
||||
def update_api_url(self, new_url):
|
||||
"""Обновить URL API"""
|
||||
self.api_url = new_url
|
||||
self.load_models()
|
||||
@@ -0,0 +1,65 @@
|
||||
from PyQt6.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout,
|
||||
QComboBox, QLabel)
|
||||
from PyQt6.QtCore import pyqtSignal
|
||||
import requests
|
||||
|
||||
class SamplerManager(QWidget):
|
||||
sampler_changed = pyqtSignal(str)
|
||||
|
||||
def __init__(self, api_url, parent=None):
|
||||
super().__init__(parent)
|
||||
self.api_url = api_url
|
||||
self.setup_ui()
|
||||
self.load_samplers()
|
||||
|
||||
def setup_ui(self):
|
||||
layout = QHBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
# Метка
|
||||
label = QLabel("Сэмплер:")
|
||||
layout.addWidget(label)
|
||||
|
||||
# Выпадающий список сэмплеров
|
||||
self.sampler_combo = QComboBox()
|
||||
self.sampler_combo.currentTextChanged.connect(self.on_sampler_changed)
|
||||
layout.addWidget(self.sampler_combo)
|
||||
|
||||
layout.addStretch()
|
||||
|
||||
def load_samplers(self):
|
||||
"""Загрузить список доступных сэмплеров"""
|
||||
try:
|
||||
response = requests.get(f"{self.api_url}/sdapi/v1/samplers")
|
||||
if response.status_code == 200:
|
||||
samplers = response.json()
|
||||
current_sampler = self.sampler_combo.currentText()
|
||||
|
||||
self.sampler_combo.clear()
|
||||
for sampler in samplers:
|
||||
self.sampler_combo.addItem(sampler.get('name', ''))
|
||||
|
||||
# Восстанавливаем выбранный сэмплер, если он всё ещё доступен
|
||||
index = self.sampler_combo.findText(current_sampler)
|
||||
if index >= 0:
|
||||
self.sampler_combo.setCurrentIndex(index)
|
||||
elif self.sampler_combo.count() > 0:
|
||||
# По умолчанию выбираем Euler a
|
||||
default_index = self.sampler_combo.findText("Euler a")
|
||||
if default_index >= 0:
|
||||
self.sampler_combo.setCurrentIndex(default_index)
|
||||
except Exception as e:
|
||||
print(f"Ошибка при загрузке сэмплеров: {str(e)}")
|
||||
|
||||
def on_sampler_changed(self, sampler_name):
|
||||
"""Обработка смены сэмплера"""
|
||||
self.sampler_changed.emit(sampler_name)
|
||||
|
||||
def update_api_url(self, new_url):
|
||||
"""Обновить URL API"""
|
||||
self.api_url = new_url
|
||||
self.load_samplers()
|
||||
|
||||
def get_current_sampler(self):
|
||||
"""Получить текущий выбранный сэмплер"""
|
||||
return self.sampler_combo.currentText()
|
||||
Reference in new issue
Block a user