feat(gui): add shared zoomable image preview
This commit is contained in:
@@ -13,7 +13,6 @@ from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QCheckBox,
|
||||
QComboBox,
|
||||
QDialog,
|
||||
QFileDialog,
|
||||
QFrame,
|
||||
QGridLayout,
|
||||
@@ -43,6 +42,7 @@ from PySide6.QtWidgets import (
|
||||
|
||||
from ... import accounts, appconfig, diagnostics, image_studio, image_studio_images, product_suite
|
||||
from .. import file_manager
|
||||
from ..image_preview import ImagePreviewDialog
|
||||
from ..widgets import COLOR_DANGER, _emit_status, run_worker
|
||||
from ..workers import (
|
||||
ImageStudioDownloadOriginalWorker,
|
||||
@@ -109,42 +109,8 @@ def _user_error(error):
|
||||
return text if len(text) <= 90 else text[:87] + "..."
|
||||
|
||||
|
||||
class ProductSuitePreviewDialog(QDialog):
|
||||
"""Responsive preview for product originals and generated assets."""
|
||||
|
||||
def __init__(self, path, title="图片预览", parent=None):
|
||||
super().__init__(parent)
|
||||
self._source = QPixmap(str(path or ""))
|
||||
self.setWindowTitle(str(title or "图片预览"))
|
||||
layout = QVBoxLayout(self)
|
||||
self.image_label = QLabel()
|
||||
self.image_label.setAlignment(Qt.AlignCenter)
|
||||
self.image_label.setMinimumSize(320, 240)
|
||||
layout.addWidget(self.image_label, 1)
|
||||
close_button = QPushButton("关闭")
|
||||
close_button.clicked.connect(self.accept)
|
||||
button_row = QHBoxLayout()
|
||||
button_row.addStretch(1)
|
||||
button_row.addWidget(close_button)
|
||||
layout.addLayout(button_row)
|
||||
self.resize(820, 620)
|
||||
self._render()
|
||||
|
||||
def resizeEvent(self, event):
|
||||
super().resizeEvent(event)
|
||||
self._render()
|
||||
|
||||
def _render(self):
|
||||
if self._source.isNull():
|
||||
self.image_label.setText("图片文件不存在或无法读取")
|
||||
self.image_label.setPixmap(QPixmap())
|
||||
return
|
||||
target = self.image_label.size() - QSize(16, 16)
|
||||
if target.width() <= 0 or target.height() <= 0:
|
||||
return
|
||||
self.image_label.setPixmap(
|
||||
self._source.scaled(target, Qt.KeepAspectRatio, Qt.SmoothTransformation)
|
||||
)
|
||||
class ProductSuitePreviewDialog(ImagePreviewDialog):
|
||||
"""Current product-suite wrapper for the shared full-image preview."""
|
||||
|
||||
|
||||
class ProductOriginalDelegate(QStyledItemDelegate):
|
||||
|
||||
Reference in New Issue
Block a user