mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-07-01 04:16:26 +00:00
feat: export scores entry
This commit is contained in:
@ -45,6 +45,27 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="exportScoresButton">
|
||||
<property name="text">
|
||||
<string>exportScoresButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>exportScores.description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -3,7 +3,7 @@
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'tabDb_Manage.ui'
|
||||
##
|
||||
## Created by: Qt User Interface Compiler version 6.5.1
|
||||
## Created by: Qt User Interface Compiler version 6.5.2
|
||||
##
|
||||
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
################################################################################
|
||||
@ -15,8 +15,8 @@ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QFont, QFontDatabase, QGradient, QIcon,
|
||||
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QApplication, QFormLayout, QLabel, QPushButton,
|
||||
QSizePolicy, QWidget)
|
||||
from PySide6.QtWidgets import (QApplication, QFormLayout, QFrame, QLabel,
|
||||
QPushButton, QSizePolicy, QWidget)
|
||||
|
||||
class Ui_TabDb_Manage(object):
|
||||
def setupUi(self, TabDb_Manage):
|
||||
@ -47,6 +47,23 @@ class Ui_TabDb_Manage(object):
|
||||
|
||||
self.formLayout.setWidget(1, QFormLayout.FieldRole, self.label_2)
|
||||
|
||||
self.line = QFrame(TabDb_Manage)
|
||||
self.line.setObjectName(u"line")
|
||||
self.line.setFrameShape(QFrame.HLine)
|
||||
self.line.setFrameShadow(QFrame.Sunken)
|
||||
|
||||
self.formLayout.setWidget(2, QFormLayout.SpanningRole, self.line)
|
||||
|
||||
self.exportScoresButton = QPushButton(TabDb_Manage)
|
||||
self.exportScoresButton.setObjectName(u"exportScoresButton")
|
||||
|
||||
self.formLayout.setWidget(3, QFormLayout.LabelRole, self.exportScoresButton)
|
||||
|
||||
self.label_3 = QLabel(TabDb_Manage)
|
||||
self.label_3.setObjectName(u"label_3")
|
||||
|
||||
self.formLayout.setWidget(3, QFormLayout.FieldRole, self.label_3)
|
||||
|
||||
|
||||
self.retranslateUi(TabDb_Manage)
|
||||
|
||||
@ -58,6 +75,8 @@ class Ui_TabDb_Manage(object):
|
||||
self.label.setText(QCoreApplication.translate("TabDb_Manage", u"syncArcSongDb.description", None))
|
||||
self.importSt3Button.setText(QCoreApplication.translate("TabDb_Manage", u"importSt3Button", None))
|
||||
self.label_2.setText(QCoreApplication.translate("TabDb_Manage", u"importSt3.description", None))
|
||||
self.exportScoresButton.setText(QCoreApplication.translate("TabDb_Manage", u"exportScoresButton", None))
|
||||
self.label_3.setText(QCoreApplication.translate("TabDb_Manage", u"exportScores.description", None))
|
||||
pass
|
||||
# retranslateUi
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
import json
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from arcaea_offline.database import Database
|
||||
from arcaea_offline.external.arcaea.st3 import St3ScoreParser
|
||||
from arcaea_offline.external.arcsong import ArcsongDbParser
|
||||
from PySide6.QtCore import Slot
|
||||
from PySide6.QtCore import QDir, Slot
|
||||
from PySide6.QtWidgets import QFileDialog, QMessageBox, QWidget
|
||||
|
||||
from ui.designer.tabs.tabDb.tabDb_Manage_ui import Ui_TabDb_Manage
|
||||
@ -61,3 +62,18 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
||||
QMessageBox.critical(
|
||||
self, "Import Error", "\n".join(traceback.format_exception(e))
|
||||
)
|
||||
|
||||
@Slot()
|
||||
def on_exportScoresButton_clicked(self):
|
||||
scores = Database().export_scores()
|
||||
version = Database().version()
|
||||
content = json.dumps(scores, ensure_ascii=False)
|
||||
|
||||
exportLocation, _filter = QFileDialog.getSaveFileName(
|
||||
self,
|
||||
"Save your scores to...",
|
||||
QDir.current().filePath(f"arcaea-offline-scores-v{version}.json"),
|
||||
"JSON (*.json);;*",
|
||||
)
|
||||
with open(exportLocation, "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
Reference in New Issue
Block a user