diff --git a/ui/designer/tabs/tabTools/tabTools_Andreal.ui b/ui/designer/tabs/tabTools/tabTools_Andreal.ui
index faa61c5..f1a04df 100644
--- a/ui/designer/tabs/tabTools/tabTools_Andreal.ui
+++ b/ui/designer/tabs/tabTools/tabTools_Andreal.ui
@@ -62,7 +62,7 @@
-
- /a
+ /a
true
@@ -72,14 +72,14 @@
-
- /a b30
+ /a b30
-
- /a info
+ /a info
@@ -113,6 +113,47 @@
+ -
+
+
+ false
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+
+ 100
+ 100
+
+
+
+ chart.selectButton
+
+
+
+ -
+
+
+ ...
+
+
+
+
+
+
-
@@ -137,6 +178,47 @@
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ JPG
+
+
+ true
+
+
+
+ -
+
+
+ PNG
+
+
+
+
+
+
-
@@ -144,6 +226,53 @@
+ -
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ 10
+
+
+ 100
+
+
+ 90
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ 10
+
+
+ 100
+
+
+ 90
+
+
+
+
+
+
-
-
@@ -200,158 +329,6 @@
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- JPG
-
-
- true
-
-
-
- -
-
-
- PNG
-
-
-
-
-
-
- -
-
-
- preview
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- QLabel { color: red }
-
-
-
-
-
-
- -
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- 10
-
-
- 100
-
-
- 90
-
-
- Qt::Horizontal
-
-
-
- -
-
-
- 10
-
-
- 100
-
-
- 90
-
-
-
-
-
-
- -
-
-
- false
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
- 100
- 100
-
-
-
- chart.selectButton
-
-
-
- -
-
-
- ...
-
-
-
-
-
-
diff --git a/ui/designer/tabs/tabTools/tabTools_Andreal_ui.py b/ui/designer/tabs/tabTools/tabTools_Andreal_ui.py
index 11a8761..ea2012f 100644
--- a/ui/designer/tabs/tabTools/tabTools_Andreal_ui.py
+++ b/ui/designer/tabs/tabTools/tabTools_Andreal_ui.py
@@ -62,17 +62,20 @@ class Ui_TabTools_Andreal(object):
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.imageType_infoRadioButton = QRadioButton(self.horizontalWidget)
self.imageType_infoRadioButton.setObjectName(u"imageType_infoRadioButton")
+ self.imageType_infoRadioButton.setText(u"/a")
self.imageType_infoRadioButton.setChecked(True)
self.horizontalLayout.addWidget(self.imageType_infoRadioButton)
self.imageType_best30RadioButton = QRadioButton(self.horizontalWidget)
self.imageType_best30RadioButton.setObjectName(u"imageType_best30RadioButton")
+ self.imageType_best30RadioButton.setText(u"/a b30")
self.horizontalLayout.addWidget(self.imageType_best30RadioButton)
self.imageType_bestRadioButton = QRadioButton(self.horizontalWidget)
self.imageType_bestRadioButton.setObjectName(u"imageType_bestRadioButton")
+ self.imageType_bestRadioButton.setText(u"/a info")
self.horizontalLayout.addWidget(self.imageType_bestRadioButton)
@@ -93,6 +96,27 @@ class Ui_TabTools_Andreal(object):
self.formLayout.setWidget(3, QFormLayout.LabelRole, self.chartFormLabel)
+ self.chartHolderWidget = QWidget(TabTools_Andreal)
+ self.chartHolderWidget.setObjectName(u"chartHolderWidget")
+ self.chartHolderWidget.setEnabled(False)
+ self.horizontalLayout_8 = QHBoxLayout(self.chartHolderWidget)
+ self.horizontalLayout_8.setObjectName(u"horizontalLayout_8")
+ self.horizontalLayout_8.setContentsMargins(0, 0, 0, 0)
+ self.chartSelectButton = QPushButton(self.chartHolderWidget)
+ self.chartSelectButton.setObjectName(u"chartSelectButton")
+ self.chartSelectButton.setMaximumSize(QSize(100, 100))
+
+ self.horizontalLayout_8.addWidget(self.chartSelectButton)
+
+ self.chartSelectLabel = QLabel(self.chartHolderWidget)
+ self.chartSelectLabel.setObjectName(u"chartSelectLabel")
+ self.chartSelectLabel.setText(u"...")
+
+ self.horizontalLayout_8.addWidget(self.chartSelectLabel)
+
+
+ self.formLayout.setWidget(3, QFormLayout.FieldRole, self.chartHolderWidget)
+
self.label_5 = QLabel(TabTools_Andreal)
self.label_5.setObjectName(u"label_5")
@@ -109,11 +133,62 @@ class Ui_TabTools_Andreal(object):
self.formLayout.setWidget(5, QFormLayout.LabelRole, self.label_6)
+ self.horizontalWidget_2 = QWidget(TabTools_Andreal)
+ self.horizontalWidget_2.setObjectName(u"horizontalWidget_2")
+ sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.horizontalWidget_2.sizePolicy().hasHeightForWidth())
+ self.horizontalWidget_2.setSizePolicy(sizePolicy)
+ self.horizontalLayout_2 = QHBoxLayout(self.horizontalWidget_2)
+ self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
+ self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
+ self.imageFormat_jpgRadioButton = QRadioButton(self.horizontalWidget_2)
+ self.imageFormat_jpgRadioButton.setObjectName(u"imageFormat_jpgRadioButton")
+ self.imageFormat_jpgRadioButton.setText(u"JPG")
+ self.imageFormat_jpgRadioButton.setChecked(True)
+
+ self.horizontalLayout_2.addWidget(self.imageFormat_jpgRadioButton)
+
+ self.imageFormat_pngRadioButton = QRadioButton(self.horizontalWidget_2)
+ self.imageFormat_pngRadioButton.setObjectName(u"imageFormat_pngRadioButton")
+ self.imageFormat_pngRadioButton.setText(u"PNG")
+
+ self.horizontalLayout_2.addWidget(self.imageFormat_pngRadioButton)
+
+
+ self.formLayout.setWidget(5, QFormLayout.FieldRole, self.horizontalWidget_2)
+
self.jpgQualityFormLabel = QLabel(TabTools_Andreal)
self.jpgQualityFormLabel.setObjectName(u"jpgQualityFormLabel")
self.formLayout.setWidget(6, QFormLayout.LabelRole, self.jpgQualityFormLabel)
+ self.jpgQualityHolderWidget = QWidget(TabTools_Andreal)
+ self.jpgQualityHolderWidget.setObjectName(u"jpgQualityHolderWidget")
+ self.horizontalLayout_3 = QHBoxLayout(self.jpgQualityHolderWidget)
+ self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
+ self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
+ self.jpgQualitySlider = QSlider(self.jpgQualityHolderWidget)
+ self.jpgQualitySlider.setObjectName(u"jpgQualitySlider")
+ self.jpgQualitySlider.setMinimum(10)
+ self.jpgQualitySlider.setMaximum(100)
+ self.jpgQualitySlider.setValue(90)
+ self.jpgQualitySlider.setOrientation(Qt.Horizontal)
+
+ self.horizontalLayout_3.addWidget(self.jpgQualitySlider)
+
+ self.jpgQualitySpinBox = QSpinBox(self.jpgQualityHolderWidget)
+ self.jpgQualitySpinBox.setObjectName(u"jpgQualitySpinBox")
+ self.jpgQualitySpinBox.setMinimum(10)
+ self.jpgQualitySpinBox.setMaximum(100)
+ self.jpgQualitySpinBox.setValue(90)
+
+ self.horizontalLayout_3.addWidget(self.jpgQualitySpinBox)
+
+
+ self.formLayout.setWidget(6, QFormLayout.FieldRole, self.jpgQualityHolderWidget)
+
self.horizontalLayout_5 = QHBoxLayout()
self.horizontalLayout_5.setObjectName(u"horizontalLayout_5")
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
@@ -145,95 +220,6 @@ class Ui_TabTools_Andreal(object):
self.formLayout.setLayout(7, QFormLayout.SpanningRole, self.horizontalLayout_5)
- self.horizontalWidget_2 = QWidget(TabTools_Andreal)
- self.horizontalWidget_2.setObjectName(u"horizontalWidget_2")
- sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.horizontalWidget_2.sizePolicy().hasHeightForWidth())
- self.horizontalWidget_2.setSizePolicy(sizePolicy)
- self.horizontalLayout_2 = QHBoxLayout(self.horizontalWidget_2)
- self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
- self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
- self.imageFormat_jpgRadioButton = QRadioButton(self.horizontalWidget_2)
- self.imageFormat_jpgRadioButton.setObjectName(u"imageFormat_jpgRadioButton")
- self.imageFormat_jpgRadioButton.setText(u"JPG")
- self.imageFormat_jpgRadioButton.setChecked(True)
-
- self.horizontalLayout_2.addWidget(self.imageFormat_jpgRadioButton)
-
- self.imageFormat_pngRadioButton = QRadioButton(self.horizontalWidget_2)
- self.imageFormat_pngRadioButton.setObjectName(u"imageFormat_pngRadioButton")
- self.imageFormat_pngRadioButton.setText(u"PNG")
-
- self.horizontalLayout_2.addWidget(self.imageFormat_pngRadioButton)
-
-
- self.formLayout.setWidget(5, QFormLayout.FieldRole, self.horizontalWidget_2)
-
- self.label_8 = QLabel(TabTools_Andreal)
- self.label_8.setObjectName(u"label_8")
-
- self.formLayout.setWidget(8, QFormLayout.LabelRole, self.label_8)
-
- self.previewLabel = QLabel(TabTools_Andreal)
- self.previewLabel.setObjectName(u"previewLabel")
- sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
- sizePolicy1.setHorizontalStretch(0)
- sizePolicy1.setVerticalStretch(0)
- sizePolicy1.setHeightForWidth(self.previewLabel.sizePolicy().hasHeightForWidth())
- self.previewLabel.setSizePolicy(sizePolicy1)
- self.previewLabel.setStyleSheet(u"QLabel { color: red }")
- self.previewLabel.setText(u"")
-
- self.formLayout.setWidget(8, QFormLayout.FieldRole, self.previewLabel)
-
- self.jpgQualityHolderWidget = QWidget(TabTools_Andreal)
- self.jpgQualityHolderWidget.setObjectName(u"jpgQualityHolderWidget")
- self.horizontalLayout_3 = QHBoxLayout(self.jpgQualityHolderWidget)
- self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
- self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
- self.jpgQualitySlider = QSlider(self.jpgQualityHolderWidget)
- self.jpgQualitySlider.setObjectName(u"jpgQualitySlider")
- self.jpgQualitySlider.setMinimum(10)
- self.jpgQualitySlider.setMaximum(100)
- self.jpgQualitySlider.setValue(90)
- self.jpgQualitySlider.setOrientation(Qt.Horizontal)
-
- self.horizontalLayout_3.addWidget(self.jpgQualitySlider)
-
- self.jpgQualitySpinBox = QSpinBox(self.jpgQualityHolderWidget)
- self.jpgQualitySpinBox.setObjectName(u"jpgQualitySpinBox")
- self.jpgQualitySpinBox.setMinimum(10)
- self.jpgQualitySpinBox.setMaximum(100)
- self.jpgQualitySpinBox.setValue(90)
-
- self.horizontalLayout_3.addWidget(self.jpgQualitySpinBox)
-
-
- self.formLayout.setWidget(6, QFormLayout.FieldRole, self.jpgQualityHolderWidget)
-
- self.chartHolderWidget = QWidget(TabTools_Andreal)
- self.chartHolderWidget.setObjectName(u"chartHolderWidget")
- self.chartHolderWidget.setEnabled(False)
- self.horizontalLayout_8 = QHBoxLayout(self.chartHolderWidget)
- self.horizontalLayout_8.setObjectName(u"horizontalLayout_8")
- self.horizontalLayout_8.setContentsMargins(0, 0, 0, 0)
- self.chartSelectButton = QPushButton(self.chartHolderWidget)
- self.chartSelectButton.setObjectName(u"chartSelectButton")
- self.chartSelectButton.setMaximumSize(QSize(100, 100))
-
- self.horizontalLayout_8.addWidget(self.chartSelectButton)
-
- self.chartSelectLabel = QLabel(self.chartHolderWidget)
- self.chartSelectLabel.setObjectName(u"chartSelectLabel")
- self.chartSelectLabel.setText(u"...")
-
- self.horizontalLayout_8.addWidget(self.chartSelectLabel)
-
-
- self.formLayout.setWidget(3, QFormLayout.FieldRole, self.chartHolderWidget)
-
self.retranslateUi(TabTools_Andreal)
self.imageFormat_jpgRadioButton.toggled.connect(self.jpgQualityHolderWidget.setEnabled)
@@ -246,19 +232,15 @@ class Ui_TabTools_Andreal(object):
self.label.setText(QCoreApplication.translate("TabTools_Andreal", u"andrealFolder", None))
self.label_2.setText(QCoreApplication.translate("TabTools_Andreal", u"andrealExecutable", None))
self.label_3.setText(QCoreApplication.translate("TabTools_Andreal", u"imageType", None))
- self.imageType_infoRadioButton.setText(QCoreApplication.translate("TabTools_Andreal", u"/a", None))
- self.imageType_best30RadioButton.setText(QCoreApplication.translate("TabTools_Andreal", u"/a b30", None))
- self.imageType_bestRadioButton.setText(QCoreApplication.translate("TabTools_Andreal", u"/a info", None))
self.imageTypeWhatIsThisButton.setText(QCoreApplication.translate("TabTools_Andreal", u"imageTypeWhatIsThisButton", None))
self.chartFormLabel.setText(QCoreApplication.translate("TabTools_Andreal", u"chart", None))
+ self.chartSelectButton.setText(QCoreApplication.translate("TabTools_Andreal", u"chart.selectButton", None))
self.label_5.setText(QCoreApplication.translate("TabTools_Andreal", u"imageVersion", None))
self.label_6.setText(QCoreApplication.translate("TabTools_Andreal", u"imageFormat", None))
self.jpgQualityFormLabel.setText(QCoreApplication.translate("TabTools_Andreal", u"jpgQuality", None))
self.exportJsonButton.setText(QCoreApplication.translate("TabTools_Andreal", u"exportJsonButton", None))
self.generatePreviewButton.setText(QCoreApplication.translate("TabTools_Andreal", u"generatePreviewButton", None))
self.generateImageButton.setText(QCoreApplication.translate("TabTools_Andreal", u"generateImageButton", None))
- self.label_8.setText(QCoreApplication.translate("TabTools_Andreal", u"preview", None))
- self.chartSelectButton.setText(QCoreApplication.translate("TabTools_Andreal", u"chart.selectButton", None))
pass
# retranslateUi
diff --git a/ui/extends/tabs/tabTools/tabTools_Andreal.py b/ui/extends/tabs/tabTools/tabTools_Andreal.py
index 6b233b0..4233417 100644
--- a/ui/extends/tabs/tabTools/tabTools_Andreal.py
+++ b/ui/extends/tabs/tabTools/tabTools_Andreal.py
@@ -74,6 +74,9 @@ class AndrealHelper(QObject):
return base64.b64decode(b64result)
def request(self, jsonPath: str, arguments: list[str]):
+ logger.debug(
+ f"{self.__class__.__name__} received request {jsonPath=} {arguments=}"
+ )
runnable = AndrealExecuteRunnable(self.andrealExecutable, jsonPath, arguments)
runnable.signals.error.connect(self.error)
runnable.signals.completed.connect(self.ready)
diff --git a/ui/implements/tabs/tabTools/tabTools_Andreal.py b/ui/implements/tabs/tabTools/tabTools_Andreal.py
index ff53822..82d1273 100644
--- a/ui/implements/tabs/tabTools/tabTools_Andreal.py
+++ b/ui/implements/tabs/tabTools/tabTools_Andreal.py
@@ -7,10 +7,18 @@ from arcaea_offline.external.andreal.api_data import (
AndrealImageGeneratorApiDataConverter,
)
from arcaea_offline.models import Chart
-from arcaea_offline.utils.rating import rating_class_to_short_text
-from PySide6.QtCore import QDir, QFileInfo, Qt, Slot
-from PySide6.QtGui import QImage
-from PySide6.QtWidgets import QButtonGroup, QFileDialog, QLabel, QMessageBox, QWidget
+from PySide6.QtCore import QCoreApplication, QDir, QFileInfo, Qt, Slot
+from PySide6.QtGui import QGuiApplication, QImage, QPainter, QPaintEvent, QPixmap
+from PySide6.QtWidgets import (
+ QButtonGroup,
+ QDialog,
+ QDialogButtonBox,
+ QFileDialog,
+ QLabel,
+ QMessageBox,
+ QVBoxLayout,
+ QWidget,
+)
from ui.designer.tabs.tabTools.tabTools_Andreal_ui import Ui_TabTools_Andreal
from ui.extends.shared.settings import ANDREAL_EXECUTABLE, ANDREAL_FOLDER
@@ -22,7 +30,36 @@ logger = logging.getLogger(__name__)
class PreviewLabel(QLabel):
- ...
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.setWindowFlag(Qt.WindowType.Window, True)
+
+ def show(self):
+ super().show()
+ # center the window
+ width = self.width()
+ height = self.height()
+ screen = QGuiApplication.primaryScreen()
+ screenWidth = screen.size().width()
+ screenHeight = screen.size().height()
+ self.setGeometry(
+ max(0, screenWidth / 2 - width / 2),
+ max(0, screenHeight / 2 - height / 2),
+ min(width, screenWidth),
+ min(height, screenHeight),
+ )
+
+ def paintEvent(self, e: QPaintEvent) -> None:
+ size = self.size()
+ painter = QPainter(self)
+ scaledPixmap = self.pixmap().scaled(
+ size,
+ Qt.AspectRatioMode.KeepAspectRatio,
+ Qt.TransformationMode.SmoothTransformation,
+ )
+ x = (size.width() - scaledPixmap.width()) / 2
+ y = (size.height() - scaledPixmap.height()) / 2
+ painter.drawPixmap(x, y, scaledPixmap)
class ChartSelectorDialog(ChartSelector):
@@ -32,6 +69,27 @@ class ChartSelectorDialog(ChartSelector):
self.setSongIdSelectorMode(SongIdSelectorMode.Chart)
+class ImageTypeWhatIsThisDialog(QDialog):
+ def __init__(self, parent=None):
+ super().__init__(parent)
+ self.verticalLayout = QVBoxLayout(self)
+
+ self.label = QLabel(
+ # fmt: off
+ QCoreApplication.translate('TabTools_Andreal', 'imageWhatIsThisDialog.description')
+ # fmt: on
+ )
+
+ self.verticalLayout.addWidget(self.label)
+
+ self.buttonBox = QDialogButtonBox(Qt.Orientation.Horizontal)
+ self.buttonBox.addButton(QDialogButtonBox.StandardButton.Ok)
+ self.buttonBox.accepted.connect(self.close)
+ self.buttonBox.rejected.connect(self.close)
+
+ self.verticalLayout.addWidget(self.buttonBox)
+
+
class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
def __init__(self, parent=None):
super().__init__(parent)
@@ -51,6 +109,7 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
self.andrealFolderSelector.connectSettings(ANDREAL_FOLDER)
self.andrealExecutableSelector.connectSettings(ANDREAL_EXECUTABLE)
+ self.generatePreviewButton.clicked.connect(self.requestPreview)
self.generateImageButton.clicked.connect(self.requestGenerate)
self.infoChart: Chart | None = None
@@ -59,10 +118,17 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
self.generateJsonPath = None
self.generateImageFormat = None
+ self.andrealHelper.error.connect(self.previewError)
+ self.andrealHelper.ready.connect(self.previewReady)
+ self.andrealHelper.finished.connect(self.previewFinished)
self.andrealHelper.error.connect(self.generateError)
self.andrealHelper.ready.connect(self.generateReady)
self.andrealHelper.finished.connect(self.generateFinished)
+ self.imageTypeWhatIsThisButton.clicked.connect(
+ lambda: ImageTypeWhatIsThisDialog(self).show()
+ )
+
self.imageTypeButtonGroup = QButtonGroup(self)
self.imageTypeButtonGroup.addButton(self.imageType_infoRadioButton, 0)
self.imageTypeButtonGroup.addButton(self.imageType_bestRadioButton, 1)
@@ -75,12 +141,24 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
self.imageTypeButtonGroup.idToggled.connect(self.fillImageVersionComboBox)
self.fillImageVersionComboBox()
+ self.chartSelectorDialog = ChartSelectorDialog(self)
+ self.chartSelectorDialog.valueChanged.connect(self.chartValueUpdated)
+ self.chartSelectButton.clicked.connect(self.chartSelectorDialog.show)
+
def setHelperPaths(self):
if selectedFiles := self.andrealFolderSelector.selectedFiles():
self.andrealHelper.andrealFolder = selectedFiles[0]
if selectedFiles := self.andrealExecutableSelector.selectedFiles():
self.andrealHelper.andrealExecutable = selectedFiles[0]
+ def chartValueUpdated(self):
+ chart = self.chartSelectorDialog.value()
+ self.infoChart = chart
+ if chart:
+ self.chartSelectLabel.setText(
+ f"{chart.title}({chart.song_id}), {chart.rating_class}"
+ )
+
def imageFormat(self):
buttonId = self.imageFormatButtonGroup.checkedId()
return ["jpg", "png"][buttonId] if buttonId > -1 else None
@@ -146,17 +224,23 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
return
jsonContentDict = {}
- with self.db.sessionmaker() as session:
- converter = AndrealImageGeneratorApiDataConverter(session)
- if imageType == "info":
- jsonContentDict = converter.user_info()
- elif imageType == "best":
- jsonContentDict = converter.user_best(
- self.infoChart.song_id, self.infoChart.rating_class
- )
- elif imageType == "best30":
- jsonContentDict = converter.user_best30()
- return json.dumps(jsonContentDict, ensure_ascii=False)
+ try:
+ with self.db.sessionmaker() as session:
+ converter = AndrealImageGeneratorApiDataConverter(session)
+ if imageType == "info":
+ jsonContentDict = converter.user_info()
+ elif imageType == "best":
+ jsonContentDict = converter.user_best(
+ self.infoChart.song_id, self.infoChart.rating_class
+ )
+ elif imageType == "best30":
+ jsonContentDict = converter.user_best30()
+ except Exception as e:
+ logger.exception("getAndrealJsonContent error")
+ QMessageBox.critical(self, None, str(e))
+ return (
+ json.dumps(jsonContentDict, ensure_ascii=False) if jsonContentDict else None
+ )
def getAndrealJsonFileName(self):
if not self.requestComplete():
@@ -167,12 +251,7 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
fileNameParts = ["andreal", imageType]
if imageType == "best":
- fileNameParts.extend(
- [
- self.infoChart.song_id,
- rating_class_to_short_text(self.infoChart.rating_class).lower(),
- ]
- )
+ fileNameParts.extend([self.infoChart.song_id, self.infoChart.rating_class])
fileNameParts.append(timestamp)
fileNameParts = [str(i) for i in fileNameParts]
fileName = "-".join(fileNameParts)
@@ -199,14 +278,15 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
def requestGenerate(self):
jsonPath = self.getTempAndrealJsonPath()
- if not jsonPath:
+ jsonContent = self.getAndrealJsonContent()
+ if not jsonPath or not jsonContent:
return
self.generateImageButton.setEnabled(False)
self.generateJsonPath = jsonPath
self.generateImageFormat = self.imageFormat()
with open(jsonPath, "w", encoding="utf-8") as jf:
- jf.write(self.getAndrealJsonContent())
+ jf.write(jsonContent)
self.andrealHelper.request(jsonPath, self.getAndrealArguments(jsonPath))
@@ -237,3 +317,46 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
if not saveFileName:
return
qImage.save(saveFileName, self.generateImageFormat)
+
+ def requestPreview(self):
+ jsonPath = self.getTempAndrealJsonPath()
+ jsonContent = self.getAndrealJsonContent()
+ if not jsonPath or not jsonContent:
+ return
+
+ self.generatePreviewButton.setEnabled(False)
+ self.previewJsonPath = jsonPath
+ with open(jsonPath, "w", encoding="utf-8") as jf:
+ jf.write(jsonContent)
+
+ self.andrealHelper.request(
+ jsonPath, self.getAndrealArguments(jsonPath, preview=True)
+ )
+
+ def previewFinished(self):
+ self.generatePreviewButton.setEnabled(True)
+
+ def previewError(self, jsonPath: str, errorMsg: str):
+ if jsonPath != self.previewJsonPath:
+ return
+ QMessageBox.critical(self, "Preview Error", errorMsg)
+
+ def previewReady(self, jsonPath: str, imageBytes: bytes):
+ if jsonPath != self.previewJsonPath:
+ return
+
+ if not imageBytes:
+ QMessageBox.critical(self, "Preview Error", "Empty bytes received.")
+ return
+
+ qImage = QImage.fromData(imageBytes)
+
+ filePathParts = jsonPath.split(".")
+ filePathParts.pop()
+ filePath = ".".join(filePathParts)
+ fileName = QFileInfo(filePath).fileName()
+
+ previewLabel = PreviewLabel(self)
+ previewLabel.setPixmap(QPixmap.fromImage(qImage))
+ previewLabel.setWindowTitle(f"preview {fileName}")
+ previewLabel.show()
diff --git a/ui/resources/lang/en_US.ts b/ui/resources/lang/en_US.ts
index dba7fe2..e470d7b 100644
--- a/ui/resources/lang/en_US.ts
+++ b/ui/resources/lang/en_US.ts
@@ -464,18 +464,18 @@ validation
Settings
-
+
andreal.title
Andreal
-
+
andreal.andrealFolder.label
- Andreal folder
+ Andreal data folder
-
+
@@ -485,7 +485,7 @@ validation
Reset
-
+
andreal.andrealExecutable.label
Andreal executable
@@ -762,6 +762,79 @@ validation
tab.stepCalculator
Step Calculator
+
+
+ tab.andreal
+ Andreal Image Generator
+
+
+
+ TabTools_Andreal
+
+
+ andrealFolder
+ Andreal data folder
+
+
+
+ andrealExecutable
+ Andreal executable
+
+
+
+ imageType
+ Image type
+
+
+
+ imageTypeWhatIsThisButton
+ What is /a?
+
+
+
+ chart
+ Select a Chart
+
+
+
+ chart.selectButton
+ Select...
+
+
+
+ imageVersion
+ Image version
+
+
+
+ imageFormat
+ Image format
+
+
+
+ jpgQuality
+ JPG quality
+
+
+
+ exportJsonButton
+ Export Request Data to JSON
+
+
+
+ generatePreviewButton
+ Generate Preview
+
+
+
+ generateImageButton
+ Generate
+
+
+
+ imageWhatIsThisDialog.description
+ Generate image of...<ul><li>/a - the most recent score</li><li>/a b30 - best30 image</li><li>/a info - best score of the selected chart</li></ul>
+
TabTools_InfoLookup
diff --git a/ui/resources/lang/zh_CN.ts b/ui/resources/lang/zh_CN.ts
index a013f40..3a94fa1 100644
--- a/ui/resources/lang/zh_CN.ts
+++ b/ui/resources/lang/zh_CN.ts
@@ -463,18 +463,18 @@
Settings
-
+
andreal.title
Andreal
-
+
andreal.andrealFolder.label
- Andreal 文件夹
+ Andreal 数据文件夹
-
+
@@ -484,7 +484,7 @@
重置
-
+
andreal.andrealExecutable.label
Andreal 可执行文件
@@ -761,6 +761,79 @@
tab.stepCalculator
步数计算器
+
+
+ tab.andreal
+ Andreal 图片生成
+
+
+
+ TabTools_Andreal
+
+
+ andrealFolder
+ Andreal 数据文件夹
+
+
+
+ andrealExecutable
+ Andreal 可执行文件
+
+
+
+ imageType
+ 图片类型
+
+
+
+ imageTypeWhatIsThisButton
+ /a 是什么?
+
+
+
+ chart
+ 选择一个谱面
+
+
+
+ chart.selectButton
+ 选择
+
+
+
+ imageVersion
+ 图片版本
+
+
+
+ imageFormat
+ 图片格式
+
+
+
+ jpgQuality
+ JPG 质量
+
+
+
+ exportJsonButton
+ 导出请求数据至 JSON
+
+
+
+ generatePreviewButton
+ 生成预览
+
+
+
+ generateImageButton
+ 生成
+
+
+
+ imageWhatIsThisDialog.description
+ 生成……<ul><li>/a - 最近一次成绩</li><li>/a b30 - /a b30</li><li>/a info - 所选谱面的最好成绩</li></ul>
+
TabTools_InfoLookup