mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-11 05:30:17 +00:00
impr: popup PlayRatingCalculator
when double clicking an item in TabTools_ChartRecommend
This commit is contained in:
parent
738975a83d
commit
1d01356327
@ -82,6 +82,9 @@
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
@ -325,7 +328,7 @@
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
|
@ -68,6 +68,7 @@ class Ui_TabTools_ChartRecommend(object):
|
||||
self.chartsByConstant_modelView.setMinimumSize(QSize(150, 0))
|
||||
self.chartsByConstant_modelView.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
self.chartsByConstant_modelView.setSelectionMode(QAbstractItemView.NoSelection)
|
||||
self.chartsByConstant_modelView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
self.chartsByConstant_modelView.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
|
||||
self.chartsByConstant_modelView.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
|
||||
|
||||
@ -228,7 +229,7 @@ class Ui_TabTools_ChartRecommend(object):
|
||||
self.chartsRecommendFromPlayRating_modelView.setSizePolicy(sizePolicy2)
|
||||
self.chartsRecommendFromPlayRating_modelView.setMinimumSize(QSize(200, 0))
|
||||
self.chartsRecommendFromPlayRating_modelView.setEditTriggers(QAbstractItemView.NoEditTriggers)
|
||||
self.chartsRecommendFromPlayRating_modelView.setSelectionMode(QAbstractItemView.SingleSelection)
|
||||
self.chartsRecommendFromPlayRating_modelView.setSelectionMode(QAbstractItemView.NoSelection)
|
||||
self.chartsRecommendFromPlayRating_modelView.setSelectionBehavior(QAbstractItemView.SelectRows)
|
||||
self.chartsRecommendFromPlayRating_modelView.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
|
||||
self.chartsRecommendFromPlayRating_modelView.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
|
||||
|
@ -2,11 +2,11 @@ import logging
|
||||
|
||||
from arcaea_offline.calculate import calculate_constants_from_play_rating
|
||||
from arcaea_offline.database import Database
|
||||
from arcaea_offline.models import Chart, ScoreBest
|
||||
from arcaea_offline.models import Chart, Score
|
||||
from arcaea_offline.utils.rating import rating_class_to_text
|
||||
from arcaea_offline.utils.score import score_to_grade_text
|
||||
from PySide6.QtCore import Slot
|
||||
from PySide6.QtWidgets import QWidget
|
||||
from PySide6.QtCore import QModelIndex, Qt, Slot
|
||||
from PySide6.QtGui import QColor, QPalette
|
||||
from PySide6.QtWidgets import QDialog, QLabel, QVBoxLayout, QWidget
|
||||
|
||||
from ui.designer.tabs.tabTools.tabTools_ChartRecommend_ui import (
|
||||
Ui_TabTools_ChartRecommend,
|
||||
@ -17,16 +17,37 @@ from ui.extends.tabs.tabTools.tabTools_ChartRecommend import (
|
||||
CustomChartDelegate,
|
||||
CustomScoreBestDelegate,
|
||||
)
|
||||
from ui.implements.components.playRatingCalculator import PlayRatingCalculator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def chartToText(chart: Chart):
|
||||
return f"{chart.artist} - {chart.title}<br>({chart.song_id}) {rating_class_to_text(chart.rating_class)}"
|
||||
class QuickPlayRatingCalculatorDialog(QDialog):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.verticalLayout = QVBoxLayout(self)
|
||||
|
||||
def scoreBestToText(score: ScoreBest):
|
||||
return f"{score_to_grade_text(score.score)} {score.score} > {score.potential:.4f}"
|
||||
self.chartLabel = QLabel(self)
|
||||
self.verticalLayout.addWidget(self.chartLabel)
|
||||
|
||||
self.playRatingCalculator = PlayRatingCalculator(self)
|
||||
self.verticalLayout.addWidget(self.playRatingCalculator)
|
||||
|
||||
self.setMinimumWidth(400)
|
||||
|
||||
self.playRatingCalculator.arcaeaScoreLineEdit.setFocus(
|
||||
Qt.FocusReason.PopupFocusReason
|
||||
)
|
||||
|
||||
def setChart(self, chart: Chart):
|
||||
self.chartLabel.setText(
|
||||
f"{chart.title} {rating_class_to_text(chart.rating_class)} {chart.constant / 10}"
|
||||
)
|
||||
self.playRatingCalculator.setConstant(chart.constant)
|
||||
|
||||
def setScore(self, score: Score):
|
||||
self.playRatingCalculator.arcaeaScoreLineEdit.setText(str(score))
|
||||
|
||||
|
||||
class TabTools_ChartRecommend(Ui_TabTools_ChartRecommend, QWidget):
|
||||
@ -62,6 +83,13 @@ class TabTools_ChartRecommend(Ui_TabTools_ChartRecommend, QWidget):
|
||||
self.updateChartsRecommendFromPlayRating
|
||||
)
|
||||
|
||||
self.chartsByConstant_modelView.doubleClicked.connect(
|
||||
self.openQuickPlayRatingCalculator_chartsByConstant
|
||||
)
|
||||
self.chartsRecommendFromPlayRating_modelView.doubleClicked.connect(
|
||||
self.openQuickPlayRatingCalculator_chartsRecommendFromPlayRating
|
||||
)
|
||||
|
||||
@Slot(float)
|
||||
def on_rangeFromPlayRating_playRatingSpinBox_valueChanged(self, value: float):
|
||||
try:
|
||||
@ -120,3 +148,26 @@ class TabTools_ChartRecommend(Ui_TabTools_ChartRecommend, QWidget):
|
||||
self.chartsRecommendFromPlayRatingModel.setChartAndScore(charts, scores)
|
||||
self.chartsRecommendFromPlayRating_modelView.resizeRowsToContents()
|
||||
self.chartsRecommendFromPlayRating_modelView.resizeColumnsToContents()
|
||||
|
||||
@Slot(QModelIndex)
|
||||
def openQuickPlayRatingCalculator_chartsByConstant(self, index: QModelIndex):
|
||||
dialog = QuickPlayRatingCalculatorDialog(self)
|
||||
chart = index.data(ChartsModel.ChartRole)
|
||||
dialog.setChart(chart)
|
||||
dialog.show()
|
||||
|
||||
@Slot(QModelIndex)
|
||||
def openQuickPlayRatingCalculator_chartsRecommendFromPlayRating(
|
||||
self, index: QModelIndex
|
||||
):
|
||||
dialog = QuickPlayRatingCalculatorDialog(self)
|
||||
|
||||
row = index.row()
|
||||
chartIndex = self.chartsRecommendFromPlayRatingModel.item(row, 0)
|
||||
scoreIndex = self.chartsRecommendFromPlayRatingModel.item(row, 1)
|
||||
|
||||
chart = chartIndex.data(ChartsWithScoreBestModel.ChartRole)
|
||||
score: Score = scoreIndex.data(ChartsWithScoreBestModel.ScoreBestRole)
|
||||
dialog.setChart(chart)
|
||||
dialog.setScore(score.score)
|
||||
dialog.show()
|
||||
|
Loading…
x
Reference in New Issue
Block a user