feat: TabTools_ChartInfoEditor

This commit is contained in:
283375 2023-10-16 01:16:11 +08:00
parent dc795f739e
commit 263386e2f1
Signed by: 283375
SSH Key Fingerprint: SHA256:UcX0qg6ZOSDOeieKPGokA5h7soykG61nz2uxuQgVLSk
8 changed files with 886 additions and 45 deletions

View File

@ -0,0 +1,263 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TabDb_ChartInfoEditor</class>
<widget class="QWidget" name="TabDb_ChartInfoEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>659</width>
<height>570</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">TabDb_ChartInfoEditor</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>editor.title</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QFormLayout" name="formLayout">
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>editor.constant</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>editor.notes</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="notesLineEdit">
<property name="font">
<font>
<family>GeosansLight</family>
<pointsize>14</pointsize>
<bold>true</bold>
</font>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="jacketLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ratingLabel">
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QWidget" name="horizontalWidget_2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="constantLineEdit">
<property name="font">
<font>
<family>GeosansLight</family>
<pointsize>14</pointsize>
<bold>true</bold>
</font>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="constantPreviewLabel">
<property name="text">
<string notr="true">&gt; ...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>editor.tip</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>editor.tip.content</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="deleteButton">
<property name="text">
<string>editor.delete</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="commitButton">
<property name="text">
<string>editor.commit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="ChartSelector" name="chartSelector" native="true"/>
</item>
<item row="1" column="0">
<widget class="QListView" name="listView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ChartSelector</class>
<extends>QWidget</extends>
<header>ui.implements.components.chartSelector</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,198 @@
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'tabDb_ChartInfoEditor.ui'
##
## Created by: Qt User Interface Compiler version 6.5.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QAbstractItemView, QApplication, QFormLayout, QGridLayout,
QGroupBox, QHBoxLayout, QLabel, QLineEdit,
QListView, QPushButton, QSizePolicy, QSpacerItem,
QVBoxLayout, QWidget)
from ui.implements.components.chartSelector import ChartSelector
class Ui_TabDb_ChartInfoEditor(object):
def setupUi(self, TabDb_ChartInfoEditor):
if not TabDb_ChartInfoEditor.objectName():
TabDb_ChartInfoEditor.setObjectName(u"TabDb_ChartInfoEditor")
TabDb_ChartInfoEditor.resize(659, 570)
TabDb_ChartInfoEditor.setWindowTitle(u"TabDb_ChartInfoEditor")
self.gridLayout = QGridLayout(TabDb_ChartInfoEditor)
self.gridLayout.setObjectName(u"gridLayout")
self.groupBox = QGroupBox(TabDb_ChartInfoEditor)
self.groupBox.setObjectName(u"groupBox")
self.verticalLayout_2 = QVBoxLayout(self.groupBox)
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
self.widget = QWidget(self.groupBox)
self.widget.setObjectName(u"widget")
self.formLayout = QFormLayout(self.widget)
self.formLayout.setObjectName(u"formLayout")
self.formLayout.setLabelAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
self.label = QLabel(self.widget)
self.label.setObjectName(u"label")
self.formLayout.setWidget(1, QFormLayout.LabelRole, self.label)
self.label_2 = QLabel(self.widget)
self.label_2.setObjectName(u"label_2")
self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label_2)
self.notesLineEdit = QLineEdit(self.widget)
self.notesLineEdit.setObjectName(u"notesLineEdit")
font = QFont()
font.setFamilies([u"GeosansLight"])
font.setPointSize(14)
font.setBold(True)
self.notesLineEdit.setFont(font)
self.formLayout.setWidget(2, QFormLayout.FieldRole, self.notesLineEdit)
self.jacketLabel = QLabel(self.widget)
self.jacketLabel.setObjectName(u"jacketLabel")
self.jacketLabel.setMinimumSize(QSize(100, 100))
self.jacketLabel.setMaximumSize(QSize(100, 100))
self.jacketLabel.setText(u"")
self.formLayout.setWidget(0, QFormLayout.LabelRole, self.jacketLabel)
self.verticalLayout = QVBoxLayout()
self.verticalLayout.setObjectName(u"verticalLayout")
self.verticalSpacer = QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.verticalLayout.addItem(self.verticalSpacer)
self.titleLabel = QLabel(self.widget)
self.titleLabel.setObjectName(u"titleLabel")
self.titleLabel.setText(u"...")
self.verticalLayout.addWidget(self.titleLabel)
self.ratingLabel = QLabel(self.widget)
self.ratingLabel.setObjectName(u"ratingLabel")
self.ratingLabel.setText(u"...")
self.verticalLayout.addWidget(self.ratingLabel)
self.verticalSpacer_2 = QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.verticalLayout.addItem(self.verticalSpacer_2)
self.formLayout.setLayout(0, QFormLayout.FieldRole, self.verticalLayout)
self.horizontalWidget_2 = QWidget(self.widget)
self.horizontalWidget_2.setObjectName(u"horizontalWidget_2")
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
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.constantLineEdit = QLineEdit(self.horizontalWidget_2)
self.constantLineEdit.setObjectName(u"constantLineEdit")
self.constantLineEdit.setFont(font)
self.horizontalLayout_2.addWidget(self.constantLineEdit)
self.constantPreviewLabel = QLabel(self.horizontalWidget_2)
self.constantPreviewLabel.setObjectName(u"constantPreviewLabel")
self.constantPreviewLabel.setText(u"> ...")
self.horizontalLayout_2.addWidget(self.constantPreviewLabel)
self.formLayout.setWidget(1, QFormLayout.FieldRole, self.horizontalWidget_2)
self.label_3 = QLabel(self.widget)
self.label_3.setObjectName(u"label_3")
sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.MinimumExpanding)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
self.label_3.setSizePolicy(sizePolicy1)
self.formLayout.setWidget(3, QFormLayout.LabelRole, self.label_3)
self.label_4 = QLabel(self.widget)
self.label_4.setObjectName(u"label_4")
self.formLayout.setWidget(3, QFormLayout.FieldRole, self.label_4)
self.verticalLayout_2.addWidget(self.widget)
self.verticalSpacer_3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.verticalLayout_2.addItem(self.verticalSpacer_3)
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout.addItem(self.horizontalSpacer)
self.deleteButton = QPushButton(self.groupBox)
self.deleteButton.setObjectName(u"deleteButton")
self.horizontalLayout.addWidget(self.deleteButton)
self.commitButton = QPushButton(self.groupBox)
self.commitButton.setObjectName(u"commitButton")
self.horizontalLayout.addWidget(self.commitButton)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.gridLayout.addWidget(self.groupBox, 1, 1, 1, 1)
self.chartSelector = ChartSelector(TabDb_ChartInfoEditor)
self.chartSelector.setObjectName(u"chartSelector")
self.gridLayout.addWidget(self.chartSelector, 0, 0, 1, 2)
self.listView = QListView(TabDb_ChartInfoEditor)
self.listView.setObjectName(u"listView")
sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
sizePolicy2.setHeightForWidth(self.listView.sizePolicy().hasHeightForWidth())
self.listView.setSizePolicy(sizePolicy2)
self.listView.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.listView.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
self.listView.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
self.gridLayout.addWidget(self.listView, 1, 0, 1, 1)
self.retranslateUi(TabDb_ChartInfoEditor)
QMetaObject.connectSlotsByName(TabDb_ChartInfoEditor)
# setupUi
def retranslateUi(self, TabDb_ChartInfoEditor):
self.groupBox.setTitle(QCoreApplication.translate("TabDb_ChartInfoEditor", u"editor.title", None))
self.label.setText(QCoreApplication.translate("TabDb_ChartInfoEditor", u"editor.constant", None))
self.label_2.setText(QCoreApplication.translate("TabDb_ChartInfoEditor", u"editor.notes", None))
self.label_3.setText(QCoreApplication.translate("TabDb_ChartInfoEditor", u"editor.tip", None))
self.label_4.setText(QCoreApplication.translate("TabDb_ChartInfoEditor", u"editor.tip.content", None))
self.deleteButton.setText(QCoreApplication.translate("TabDb_ChartInfoEditor", u"editor.delete", None))
self.commitButton.setText(QCoreApplication.translate("TabDb_ChartInfoEditor", u"editor.commit", None))
pass
# retranslateUi

View File

@ -24,6 +24,11 @@
<string>tab.manage</string>
</attribute>
</widget>
<widget class="TabDb_ChartInfoEditor" name="tab_chartInfoEditor">
<attribute name="title">
<string>tab.chartInfoEditor</string>
</attribute>
</widget>
</widget>
</item>
</layout>
@ -35,6 +40,12 @@
<header>ui.implements.tabs.tabDb.tabDb_Manage</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TabDb_ChartInfoEditor</class>
<extends>QWidget</extends>
<header>ui.implements.tabs.tabDb.tabDb_ChartInfoEditor</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'tabDbEntry.ui'
##
## Created by: Qt User Interface Compiler version 6.5.0
## Created by: Qt User Interface Compiler version 6.5.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
@ -18,6 +18,7 @@ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
from PySide6.QtWidgets import (QApplication, QSizePolicy, QTabWidget, QVBoxLayout,
QWidget)
from ui.implements.tabs.tabDb.tabDb_ChartInfoEditor import TabDb_ChartInfoEditor
from ui.implements.tabs.tabDb.tabDb_Manage import TabDb_Manage
class Ui_TabDbEntry(object):
@ -33,6 +34,9 @@ class Ui_TabDbEntry(object):
self.tab_manage = TabDb_Manage()
self.tab_manage.setObjectName(u"tab_manage")
self.tabWidget.addTab(self.tab_manage, "")
self.tab_chartInfoEditor = TabDb_ChartInfoEditor()
self.tab_chartInfoEditor.setObjectName(u"tab_chartInfoEditor")
self.tabWidget.addTab(self.tab_chartInfoEditor, "")
self.verticalLayout.addWidget(self.tabWidget)
@ -47,6 +51,7 @@ class Ui_TabDbEntry(object):
def retranslateUi(self, TabDbEntry):
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_manage), QCoreApplication.translate("TabDbEntry", u"tab.manage", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_chartInfoEditor), QCoreApplication.translate("TabDbEntry", u"tab.chartInfoEditor", None))
pass
# retranslateUi

View File

@ -0,0 +1,32 @@
from arcaea_offline.models import Difficulty, Song
from PySide6.QtCore import QModelIndex, Qt
from PySide6.QtGui import QStandardItem, QStandardItemModel
from ui.extends.shared.delegates.chartDelegate import ChartDelegate
class ChartInfoAbsentModel(QStandardItemModel):
SongRole = Qt.ItemDataRole.UserRole
DifficultyRole = Qt.ItemDataRole.UserRole + 1
def setCustomData(self, songs: list[Song], difficulties: list[Difficulty]):
self.clear()
for song, difficulty in zip(songs, difficulties):
item = QStandardItem()
item.setData(song, self.SongRole)
item.setData(difficulty, self.DifficultyRole)
self.appendRow(item)
def setLoading(self):
self.clear()
self.appendRow(QStandardItem("Loading..."))
class ListViewDelegate(ChartDelegate):
def getSong(self, index: QModelIndex):
return index.data(ChartInfoAbsentModel.SongRole)
def getDifficulty(self, index: QModelIndex):
return index.data(ChartInfoAbsentModel.DifficultyRole)

View File

@ -0,0 +1,226 @@
import logging
from arcaea_offline.database import Database
from arcaea_offline.models import Chart, ChartInfo, Difficulty, Song
from arcaea_offline.utils.rating import rating_class_to_text
from PySide6.QtCore import QCoreApplication, QModelIndex, Qt, Slot
from PySide6.QtGui import QPixmap, QRegularExpressionValidator, QStandardItem
from PySide6.QtWidgets import QApplication, QMessageBox, QStyledItemDelegate, QWidget
from sqlalchemy import select
from ui.designer.tabs.tabDb.tabDb_ChartInfoEditor_ui import Ui_TabDb_ChartInfoEditor
from ui.extends.shared.data import Data
from ui.extends.shared.database import databaseUpdateSignals
from ui.extends.shared.language import LanguageChangeEventFilter
from ui.extends.tabs.tabDb.tabDb_ChartInfoEditor import (
ChartInfoAbsentModel,
ListViewDelegate,
)
from ui.implements.components.songIdSelector import SongIdSelectorMode
logger = logging.getLogger(__name__)
class TabDb_ChartInfoEditor(Ui_TabDb_ChartInfoEditor, QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
self.languageChangeEventFilter = LanguageChangeEventFilter(self)
self.installEventFilter(self.languageChangeEventFilter)
self.db = Database()
self.numberRegexValidator = QRegularExpressionValidator(r"^\d+$", self)
self.constantLineEdit.setValidator(self.numberRegexValidator)
self.notesLineEdit.setValidator(self.numberRegexValidator)
self.constantLineEdit.textChanged.connect(self.updateConstantPreviewLabel)
self.chartInfoAbsentModel = ChartInfoAbsentModel(self)
self.listView.setModel(self.chartInfoAbsentModel)
self.listViewDelegate = ListViewDelegate(self)
self.listView.selectionModel().currentChanged.connect(
self.listViewSelectionChanged
)
self.chartSelector.setSongIdSelectorMode(SongIdSelectorMode.SongId)
self.chartSelector.valueChanged.connect(self.chartSelectorValueChanged)
databaseUpdateSignals.songDataUpdated.connect(self.updateChartInfoAbsentModel)
self.updateChartInfoAbsentModel()
self.commitButton.clicked.connect(self.commitChartInfo)
self.deleteButton.clicked.connect(self.deleteChartInfo)
def updateConstantPreviewLabel(self):
text = self.constantLineEdit.text()
if self.constantLineEdit.hasAcceptableInput():
self.constantPreviewLabel.setText(f"> {int(text) / 10:.1f}")
else:
self.constantPreviewLabel.setText("> ...")
def reset(self):
self.jacketLabel.clear()
self.titleLabel.setText("...")
self.ratingLabel.setText("...")
self.constantLineEdit.setText("")
self.notesLineEdit.setText("")
def updateChartInfoAbsentModel(self):
self.listView.setItemDelegate(QStyledItemDelegate())
self.chartInfoAbsentModel.clear()
self.chartInfoAbsentModel.appendRow(QStandardItem("Loading..."))
QApplication.processEvents()
with self.db.sessionmaker() as session:
stmt = (
select(Difficulty)
.join(
ChartInfo,
(Difficulty.song_id == ChartInfo.song_id)
& (Difficulty.rating_class == ChartInfo.rating_class),
isouter=True,
)
.where(ChartInfo.notes.is_(None))
)
absentInfoDifficulties = sorted(
list(session.scalars(stmt)),
key=lambda d: f"{d.song_id},{d.rating_class}",
)
songIds = sorted(list(set(d.song_id for d in absentInfoDifficulties)))
songsStmt = select(Song).where(Song.id.in_(songIds))
songs = sorted(list(session.scalars(songsStmt)), key=lambda s: s.id)
modelSongs = []
for difficulty in absentInfoDifficulties:
songIndex = songIds.index(difficulty.song_id)
modelSongs.append(songs[songIndex])
self.chartInfoAbsentModel.setCustomData(modelSongs, absentInfoDifficulties)
self.listView.setItemDelegate(self.listViewDelegate)
@Slot(QModelIndex)
def listViewSelectionChanged(self, current: QModelIndex):
if current.row() < 0 or current.column() < 0:
return
song: Song = current.data(ChartInfoAbsentModel.SongRole)
difficulty: Difficulty = current.data(ChartInfoAbsentModel.DifficultyRole)
self.chartSelector.selectChart(
Chart(
song_id=difficulty.song_id,
rating_class=difficulty.rating_class,
set=song.set,
)
)
def chartSelectorValueChanged(self):
if chart := self.chartSelector.value():
self.fillChartInfo(chart.song_id, chart.rating_class)
else:
self.reset()
def fillChartInfo(self, songId: str, ratingClass: int):
song = self.db.get_song(songId)
difficulty = self.db.get_difficulty(songId, ratingClass)
self.titleLabel.setText(difficulty.title or song.title)
self.ratingLabel.setText(
rating_class_to_text(difficulty.rating_class)
+ " "
+ str(difficulty.rating)
+ ("+" if difficulty.rating_plus else "")
)
jacketPath = Data().getJacketPath(song, difficulty)
if not jacketPath:
pixmap = QPixmap(":/images/jacket-placeholder.png")
else:
pixmap = QPixmap(str(jacketPath.resolve()))
self.jacketLabel.setPixmap(
pixmap.scaled(
self.jacketLabel.size(),
Qt.AspectRatioMode.KeepAspectRatio,
Qt.TransformationMode.SmoothTransformation,
)
)
chartInfo = self.db.get_chart_info(songId, ratingClass)
if chartInfo is not None:
if chartInfo.constant is not None:
self.constantLineEdit.setText(str(chartInfo.constant))
if chartInfo.notes is not None:
self.notesLineEdit.setText(str(chartInfo.notes))
else:
self.constantLineEdit.setText("")
self.notesLineEdit.setText("")
def commitChartInfo(self):
chart = self.chartSelector.value()
if not chart:
QMessageBox.critical(
self,
None,
# fmt: off
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.chartNotSelected"),
# fmt: on
)
return
if not self.constantLineEdit.hasAcceptableInput():
QMessageBox.critical(
self,
None,
# fmt: off
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.constantRequired"),
# fmt: on
)
return
constant = int(self.constantLineEdit.text())
notes = (
int(self.notesLineEdit.text())
if self.notesLineEdit.hasAcceptableInput()
else None
)
chartInfo = ChartInfo(
song_id=chart.song_id,
rating_class=chart.rating_class,
constant=constant,
notes=notes,
)
with self.db.sessionmaker() as session:
session.merge(chartInfo)
session.commit()
databaseUpdateSignals.songDataUpdated.emit()
def deleteChartInfo(self):
chart = self.chartSelector.value()
if not chart:
QMessageBox.critical(
self,
None,
# fmt: off
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.chartNotSelected"),
# fmt: on
)
return
chartInfo = self.db.get_chart_info(chart.song_id, chart.rating_class)
if chartInfo:
result = QMessageBox.warning(
self,
None,
# fmt: off
QCoreApplication.translate("TabDb_ChartInfoEditor", "deleteConfirm"),
# fmt: on
QMessageBox.StandardButton.Yes,
QMessageBox.StandardButton.No,
)
if result == QMessageBox.StandardButton.Yes:
with self.db.sessionmaker() as session:
session.delete(chartInfo)
session.commit()
databaseUpdateSignals.songDataUpdated.emit()

View File

@ -17,12 +17,12 @@
<context>
<name>ChartSelector</name>
<message>
<location filename="../../designer/components/chartSelector.ui" line="26"/>
<location filename="../../designer/components/chartSelector.ui" line="20"/>
<source>songIdSelector.title</source>
<translation>Select a Song</translation>
</message>
<message>
<location filename="../../designer/components/chartSelector.ui" line="71"/>
<location filename="../../designer/components/chartSelector.ui" line="65"/>
<source>resetButton</source>
<translation>Reset</translation>
</message>
@ -542,14 +542,14 @@ validation</translation>
<translation>Search...</translation>
</message>
<message>
<location filename="../../designer/components/songIdSelector.ui" line="54"/>
<location filename="../../designer/components/songIdSelector.ui" line="94"/>
<location filename="../../designer/components/songIdSelector.ui" line="41"/>
<location filename="../../designer/components/songIdSelector.ui" line="81"/>
<source>previous</source>
<translation>Previous</translation>
</message>
<message>
<location filename="../../designer/components/songIdSelector.ui" line="77"/>
<location filename="../../designer/components/songIdSelector.ui" line="117"/>
<location filename="../../designer/components/songIdSelector.ui" line="64"/>
<location filename="../../designer/components/songIdSelector.ui" line="104"/>
<source>next</source>
<translation>Next</translation>
</message>
@ -574,6 +574,11 @@ validation</translation>
<source>tab.manage</source>
<translation>Manage</translation>
</message>
<message>
<location filename="../../designer/tabs/tabDbEntry.ui" line="29"/>
<source>tab.chartInfoEditor</source>
<translation>Chart Info Editor</translation>
</message>
<message>
<location filename="../../implements/tabs/tabDbEntry.py" line="20"/>
<source>tab.scoreTableViewer</source>
@ -585,6 +590,60 @@ validation</translation>
<translation>Table [B30]</translation>
</message>
</context>
<context>
<name>TabDb_ChartInfoEditor</name>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="20"/>
<source>editor.title</source>
<translation>Editor</translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="32"/>
<source>editor.constant</source>
<translation>Constant</translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="39"/>
<source>editor.notes</source>
<translation>Notes</translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="168"/>
<source>editor.tip</source>
<translation>Tip</translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="175"/>
<source>editor.tip.content</source>
<translation>Due to the special data structure,&lt;br&gt;please fill in 10 times of the constant value.&lt;br&gt;For example, Testify [BYD] is a 12.0,&lt;br&gt;then fill &quot;120&quot; instead of &quot;12.0&quot;.</translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="213"/>
<source>editor.delete</source>
<translation>Delete</translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="220"/>
<source>editor.commit</source>
<translation>Commit</translation>
</message>
<message>
<location filename="../../implements/tabs/tabDb/tabDb_ChartInfoEditor.py" line="167"/>
<location filename="../../implements/tabs/tabDb/tabDb_ChartInfoEditor.py" line="206"/>
<source>commit.chartNotSelected</source>
<translation>Please select a chart first.</translation>
</message>
<message>
<location filename="../../implements/tabs/tabDb/tabDb_ChartInfoEditor.py" line="176"/>
<source>commit.constantRequired</source>
<translation>Constant field is required.</translation>
</message>
<message>
<location filename="../../implements/tabs/tabDb/tabDb_ChartInfoEditor.py" line="217"/>
<source>deleteConfirm</source>
<translation>Are you sure to delete this chart data?</translation>
</message>
</context>
<context>
<name>TabDb_Manage</name>
<message>
@ -783,28 +842,28 @@ validation</translation>
<translation>Rois</translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="128"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="134"/>
<source>options.masker</source>
<translation>Masker</translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="138"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="145"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="144"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="151"/>
<source>options.useCustom</source>
<translation>Use custom options</translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="203"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="215"/>
<source>dependencies.title</source>
<translation>OCR Dependencies</translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="209"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="221"/>
<source>dependencies.knnModel</source>
<translation>KNearest model</translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="246"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="258"/>
<source>dependencies.phashDatabase</source>
<translation>Image pHash database</translation>
</message>
@ -812,7 +871,7 @@ validation</translation>
<context>
<name>TabOverview</name>
<message>
<location filename="../../implements/tabs/tabOverview.py" line="43"/>
<location filename="../../implements/tabs/tabOverview.py" line="44"/>
<source>databaseDescribeLabel {} {} {} {} {} {}</source>
<translation>There are {} packs, {} songs, {} difficulties, {} chart info ({} complete) and {} scores in database.</translation>
</message>
@ -911,23 +970,17 @@ validation</translation>
<context>
<name>TabTools_ChartRecommend</name>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="20"/>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="99"/>
<source>constantRangeFromPlayRating</source>
<translation>Chart Constant Range from Play Rating</translation>
</message>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="118"/>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="20"/>
<source>chartsByConstant</source>
<translation>Charts by Constant</translation>
</message>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="174"/>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="273"/>
<source>refreshButton</source>
<translation>Roll</translation>
</message>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="197"/>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="245"/>
<source>chartsRecommendFromPlayRating</source>
<translation>Chart from Play Rating Based on Best Score</translation>
</message>

View File

@ -17,12 +17,12 @@
<context>
<name>ChartSelector</name>
<message>
<location filename="../../designer/components/chartSelector.ui" line="26"/>
<location filename="../../designer/components/chartSelector.ui" line="20"/>
<source>songIdSelector.title</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/components/chartSelector.ui" line="71"/>
<location filename="../../designer/components/chartSelector.ui" line="65"/>
<source>resetButton</source>
<translation></translation>
</message>
@ -541,14 +541,14 @@
<translation></translation>
</message>
<message>
<location filename="../../designer/components/songIdSelector.ui" line="54"/>
<location filename="../../designer/components/songIdSelector.ui" line="94"/>
<location filename="../../designer/components/songIdSelector.ui" line="41"/>
<location filename="../../designer/components/songIdSelector.ui" line="81"/>
<source>previous</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/components/songIdSelector.ui" line="77"/>
<location filename="../../designer/components/songIdSelector.ui" line="117"/>
<location filename="../../designer/components/songIdSelector.ui" line="64"/>
<location filename="../../designer/components/songIdSelector.ui" line="104"/>
<source>next</source>
<translation></translation>
</message>
@ -573,6 +573,11 @@
<source>tab.manage</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabDbEntry.ui" line="29"/>
<source>tab.chartInfoEditor</source>
<translation></translation>
</message>
<message>
<location filename="../../implements/tabs/tabDbEntry.py" line="20"/>
<source>tab.scoreTableViewer</source>
@ -584,6 +589,60 @@
<translation> [B30]</translation>
</message>
</context>
<context>
<name>TabDb_ChartInfoEditor</name>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="20"/>
<source>editor.title</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="32"/>
<source>editor.constant</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="39"/>
<source>editor.notes</source>
<translation>note </translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="168"/>
<source>editor.tip</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="175"/>
<source>editor.tip.content</source>
<translation>&lt;br&gt; 10 &lt;br&gt;Testify [BYD] 12.0&lt;br&gt; 120 12.0</translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="213"/>
<source>editor.delete</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabDb/tabDb_ChartInfoEditor.ui" line="220"/>
<source>editor.commit</source>
<translation></translation>
</message>
<message>
<location filename="../../implements/tabs/tabDb/tabDb_ChartInfoEditor.py" line="167"/>
<location filename="../../implements/tabs/tabDb/tabDb_ChartInfoEditor.py" line="206"/>
<source>commit.chartNotSelected</source>
<translation></translation>
</message>
<message>
<location filename="../../implements/tabs/tabDb/tabDb_ChartInfoEditor.py" line="176"/>
<source>commit.constantRequired</source>
<translation></translation>
</message>
<message>
<location filename="../../implements/tabs/tabDb/tabDb_ChartInfoEditor.py" line="217"/>
<source>deleteConfirm</source>
<translation></translation>
</message>
</context>
<context>
<name>TabDb_Manage</name>
<message>
@ -782,28 +841,28 @@
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="128"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="134"/>
<source>options.masker</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="138"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="145"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="144"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="151"/>
<source>options.useCustom</source>
<translation>使</translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="203"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="215"/>
<source>dependencies.title</source>
<translation>OCR </translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="209"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="221"/>
<source>dependencies.knnModel</source>
<translation>KNearest </translation>
</message>
<message>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="246"/>
<location filename="../../designer/tabs/tabOcr/tabOcr_Device.ui" line="258"/>
<source>dependencies.phashDatabase</source>
<translation> pHash </translation>
</message>
@ -811,7 +870,7 @@
<context>
<name>TabOverview</name>
<message>
<location filename="../../implements/tabs/tabOverview.py" line="43"/>
<location filename="../../implements/tabs/tabOverview.py" line="44"/>
<source>databaseDescribeLabel {} {} {} {} {} {}</source>
<translation> {} {} {} {} {} {} </translation>
</message>
@ -910,23 +969,17 @@
<context>
<name>TabTools_ChartRecommend</name>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="20"/>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="99"/>
<source>constantRangeFromPlayRating</source>
<translation> PTT </translation>
</message>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="118"/>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="20"/>
<source>chartsByConstant</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="174"/>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="273"/>
<source>refreshButton</source>
<translation></translation>
</message>
<message>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="197"/>
<location filename="../../designer/tabs/tabTools/tabTools_ChartRecommend.ui" line="245"/>
<source>chartsRecommendFromPlayRating</source>
<translation> PTT </translation>
</message>