mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-18 16:50:17 +00:00
Compare commits
5 Commits
a9d7681ee7
...
29eb135752
Author | SHA1 | Date | |
---|---|---|---|
29eb135752 | |||
b2a10d02ce | |||
0c88302053 | |||
fe3f610878 | |||
09063cc987 |
10
core/color.py
Normal file
10
core/color.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from PySide6.QtGui import QColor
|
||||||
|
|
||||||
|
|
||||||
|
def mixColor(source: QColor, mix: QColor, ratio: float = 0.5):
|
||||||
|
r = round((mix.red() - source.red()) * ratio + source.red())
|
||||||
|
g = round((mix.green() - source.green()) * ratio + source.green())
|
||||||
|
b = round((mix.blue() - source.blue()) * ratio + source.blue())
|
||||||
|
a = round((mix.alpha() - source.alpha()) * ratio + source.alpha())
|
||||||
|
|
||||||
|
return QColor(r, g, b, a)
|
15
index.py
15
index.py
@ -18,16 +18,12 @@ from ui.startup.databaseChecker import DatabaseChecker, DatabaseCheckerResult
|
|||||||
rootLogger = logging.getLogger("root")
|
rootLogger = logging.getLogger("root")
|
||||||
rootLogger.setLevel(logging.DEBUG)
|
rootLogger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
rootLoggerFormatter = logging.Formatter(
|
|
||||||
"[{levelname}]{asctime}|{name}: {msg}", "%m-%d %H:%M:%S", "{"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def handle_exception(exc_type, exc_value, exc_traceback):
|
def handle_exception(exc_type, exc_value, exc_traceback):
|
||||||
if issubclass(exc_type, KeyboardInterrupt):
|
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
||||||
sys.__excepthook__(exc_type, exc_value, exc_traceback)
|
|
||||||
return
|
|
||||||
|
|
||||||
|
if issubclass(exc_type, KeyboardInterrupt):
|
||||||
|
return
|
||||||
rootLogger.critical(
|
rootLogger.critical(
|
||||||
"Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)
|
"Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)
|
||||||
)
|
)
|
||||||
@ -46,6 +42,11 @@ if __name__ == "__main__":
|
|||||||
ymd = now.strftime("%Y%m%d")
|
ymd = now.strftime("%Y%m%d")
|
||||||
hms = now.strftime("%H%M%S")
|
hms = now.strftime("%H%M%S")
|
||||||
|
|
||||||
|
rootLoggerFormatter = logging.Formatter(
|
||||||
|
"[%(asctime)s/%(levelname)s] %(name)s (%(tag)s): %(message)s",
|
||||||
|
"%m-%d %H:%M:%S",
|
||||||
|
defaults={"tag": "/"},
|
||||||
|
)
|
||||||
rootLoggerFileHandler = logging.FileHandler(
|
rootLoggerFileHandler = logging.FileHandler(
|
||||||
str(logFolder / f"arcaea-offline-pyside-ui-{ymd}-{hms}_debug.log"),
|
str(logFolder / f"arcaea-offline-pyside-ui-{ymd}-{hms}_debug.log"),
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
|
@ -36,7 +36,6 @@ select = [
|
|||||||
"I", # isort
|
"I", # isort
|
||||||
"PL", # pylint
|
"PL", # pylint
|
||||||
"N", # pep8-naming
|
"N", # pep8-naming
|
||||||
"FBT", # flake8-boolean-trap
|
|
||||||
"A", # flake8-builtins
|
"A", # flake8-builtins
|
||||||
"DTZ", # flake8-datetimez
|
"DTZ", # flake8-datetimez
|
||||||
"LOG", # flake8-logging
|
"LOG", # flake8-logging
|
||||||
|
@ -5,7 +5,6 @@ from typing import Any, Callable, Optional, overload
|
|||||||
from arcaea_offline.calculate import calculate_score_range
|
from arcaea_offline.calculate import calculate_score_range
|
||||||
from arcaea_offline.database import Database
|
from arcaea_offline.database import Database
|
||||||
from arcaea_offline.models import Chart, Score
|
from arcaea_offline.models import Chart, Score
|
||||||
from arcaea_offline_ocr.b30.shared import B30OcrResultItem
|
|
||||||
from arcaea_offline_ocr.device.common import DeviceOcrResult
|
from arcaea_offline_ocr.device.common import DeviceOcrResult
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL.ImageQt import ImageQt
|
from PIL.ImageQt import ImageQt
|
||||||
@ -140,7 +139,11 @@ class OcrQueueModel(QAbstractListModel):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f"{repr(self)} setData at row {index.row()} with role {role} and value {value} rejected."
|
"%r setData at row %d with role %d and value %s rejected!",
|
||||||
|
self,
|
||||||
|
index.row(),
|
||||||
|
role,
|
||||||
|
value,
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -150,7 +153,7 @@ class OcrQueueModel(QAbstractListModel):
|
|||||||
|
|
||||||
@iccOption.setter
|
@iccOption.setter
|
||||||
def iccOption(self, opt: IccOption):
|
def iccOption(self, opt: IccOption):
|
||||||
logger.debug(f"ICC option changed to {opt}")
|
logger.debug("ICC option changed to %s", opt)
|
||||||
self.__iccOption = opt
|
self.__iccOption = opt
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
@ -159,8 +162,7 @@ class OcrQueueModel(QAbstractListModel):
|
|||||||
image: str,
|
image: str,
|
||||||
runnable: OcrRunnable = None,
|
runnable: OcrRunnable = None,
|
||||||
process_func: Callable[[Optional[str], QImage, Any], Score] = None,
|
process_func: Callable[[Optional[str], QImage, Any], Score] = None,
|
||||||
):
|
): ...
|
||||||
...
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
def addItem(
|
def addItem(
|
||||||
@ -168,8 +170,7 @@ class OcrQueueModel(QAbstractListModel):
|
|||||||
image: QImage,
|
image: QImage,
|
||||||
runnable: OcrRunnable = None,
|
runnable: OcrRunnable = None,
|
||||||
process_func: Callable[[Optional[str], QImage, Any], Score] = None,
|
process_func: Callable[[Optional[str], QImage, Any], Score] = None,
|
||||||
):
|
): ...
|
||||||
...
|
|
||||||
|
|
||||||
def addItem(
|
def addItem(
|
||||||
self,
|
self,
|
||||||
@ -179,7 +180,7 @@ class OcrQueueModel(QAbstractListModel):
|
|||||||
):
|
):
|
||||||
if isinstance(image, str):
|
if isinstance(image, str):
|
||||||
if image in self.imagePaths or not QFileInfo(image).exists():
|
if image in self.imagePaths or not QFileInfo(image).exists():
|
||||||
logger.warning(f"Attempting to add an invalid file {image}")
|
logger.warning("Attempting to add an invalid file %s", image)
|
||||||
return
|
return
|
||||||
imagePath = image
|
imagePath = image
|
||||||
if self.iccOption == IccOption.TryFix:
|
if self.iccOption == IccOption.TryFix:
|
||||||
@ -223,7 +224,7 @@ class OcrQueueModel(QAbstractListModel):
|
|||||||
index = self.index(row, 0)
|
index = self.index(row, 0)
|
||||||
imagePath: str = index.data(self.ImagePathRole)
|
imagePath: str = index.data(self.ImagePathRole)
|
||||||
qImage: QImage = index.data(self.ImageQImageRole)
|
qImage: QImage = index.data(self.ImageQImageRole)
|
||||||
logger.debug(f"update request: {result}@row{row}")
|
logger.debug("update request: %r@row%d", result, row)
|
||||||
processOcrResultFunc = index.data(self.ProcessOcrResultFuncRole)
|
processOcrResultFunc = index.data(self.ProcessOcrResultFuncRole)
|
||||||
|
|
||||||
chart, scoreInsert = processOcrResultFunc(imagePath, qImage, result)
|
chart, scoreInsert = processOcrResultFunc(imagePath, qImage, result)
|
||||||
@ -294,8 +295,8 @@ class OcrQueueModel(QAbstractListModel):
|
|||||||
self.__items.pop(row)
|
self.__items.pop(row)
|
||||||
self.endRemoveRows()
|
self.endRemoveRows()
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logger.exception(f"Error accepting {repr(item)}")
|
logger.exception("Error accepting %r", item)
|
||||||
return
|
return
|
||||||
|
|
||||||
def acceptItems(self, __rows: list[int], ignoreValidate: bool = False):
|
def acceptItems(self, __rows: list[int], ignoreValidate: bool = False):
|
||||||
@ -344,17 +345,11 @@ class OcrQueueTableProxyModel(QAbstractTableModel):
|
|||||||
|
|
||||||
def retranslateHeaders(self):
|
def retranslateHeaders(self):
|
||||||
self.__horizontalHeaders = [
|
self.__horizontalHeaders = [
|
||||||
# fmt: off
|
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.select"),
|
||||||
QCoreApplication.translate(
|
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.imagePreview"),
|
||||||
"OcrTableModel", "horizontalHeader.title.select"
|
|
||||||
),
|
|
||||||
QCoreApplication.translate(
|
|
||||||
"OcrTableModel", "horizontalHeader.title.imagePreview"
|
|
||||||
),
|
|
||||||
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.chart"),
|
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.chart"),
|
||||||
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.score"),
|
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.score"),
|
||||||
# fmt: on
|
] # fmt: skip
|
||||||
]
|
|
||||||
|
|
||||||
def sourceModel(self) -> OcrQueueModel:
|
def sourceModel(self) -> OcrQueueModel:
|
||||||
return self.__sourceModel
|
return self.__sourceModel
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
from PySide6.QtGui import QColor
|
|
||||||
|
|
||||||
|
|
||||||
def mix_color(source_color: QColor, mix_color: QColor, mix_ratio: float = 0.5):
|
|
||||||
r = round((mix_color.red() - source_color.red()) * mix_ratio + source_color.red())
|
|
||||||
g = round(
|
|
||||||
(mix_color.green() - source_color.green()) * mix_ratio + source_color.green()
|
|
||||||
)
|
|
||||||
b = round(
|
|
||||||
(mix_color.blue() - source_color.blue()) * mix_ratio + source_color.blue()
|
|
||||||
)
|
|
||||||
a = round(
|
|
||||||
(mix_color.alpha() - source_color.alpha()) * mix_ratio + source_color.alpha()
|
|
||||||
)
|
|
||||||
|
|
||||||
return QColor(r, g, b, a)
|
|
@ -16,13 +16,11 @@ class DbB30TableModel(DbTableModel):
|
|||||||
|
|
||||||
def retranslateHeaders(self):
|
def retranslateHeaders(self):
|
||||||
self._horizontalHeaders = [
|
self._horizontalHeaders = [
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("DbB30TableModel", "horizontalHeader.id"),
|
QCoreApplication.translate("DbB30TableModel", "horizontalHeader.id"),
|
||||||
QCoreApplication.translate("DbB30TableModel", "horizontalHeader.chart"),
|
QCoreApplication.translate("DbB30TableModel", "horizontalHeader.chart"),
|
||||||
QCoreApplication.translate("DbB30TableModel", "horizontalHeader.score"),
|
QCoreApplication.translate("DbB30TableModel", "horizontalHeader.score"),
|
||||||
QCoreApplication.translate("DbB30TableModel", "horizontalHeader.potential"),
|
QCoreApplication.translate("DbB30TableModel", "horizontalHeader.potential"),
|
||||||
# fmt: on
|
] # fmt: skip
|
||||||
]
|
|
||||||
|
|
||||||
def syncDb(self):
|
def syncDb(self):
|
||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
|
@ -24,13 +24,11 @@ class DbScoreTableModel(DbTableModel):
|
|||||||
|
|
||||||
def retranslateHeaders(self):
|
def retranslateHeaders(self):
|
||||||
self._horizontalHeaders = [
|
self._horizontalHeaders = [
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.id"),
|
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.id"),
|
||||||
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.chart"),
|
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.chart"),
|
||||||
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.score"),
|
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.score"),
|
||||||
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.potential"),
|
QCoreApplication.translate("DbScoreTableModel", "horizontalHeader.potential"),
|
||||||
# fmt: on
|
] # fmt: skip
|
||||||
]
|
|
||||||
|
|
||||||
def syncDb(self):
|
def syncDb(self):
|
||||||
self.beginResetModel()
|
self.beginResetModel()
|
||||||
@ -154,7 +152,7 @@ class DbScoreTableModel(DbTableModel):
|
|||||||
self.syncDb()
|
self.syncDb()
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(f"Table[Score]: Cannot remove row {row}")
|
logger.exception("Table[Score]: Cannot remove row %s", row)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def removeRow(self, row: int, parent=...):
|
def removeRow(self, row: int, parent=...):
|
||||||
|
@ -6,10 +6,10 @@ from arcaea_offline_ocr.b30.chieri.v4.ocr import ChieriBotV4Ocr
|
|||||||
from arcaea_offline_ocr.b30.shared import B30OcrResultItem
|
from arcaea_offline_ocr.b30.shared import B30OcrResultItem
|
||||||
from PySide6.QtGui import QImage
|
from PySide6.QtGui import QImage
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
from ui.extends.components.ocrQueue import OcrRunnable
|
from ui.extends.components.ocrQueue import OcrRunnable
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ChieriV4OcrRunnable(OcrRunnable):
|
class ChieriV4OcrRunnable(OcrRunnable):
|
||||||
def __init__(self, ocr: ChieriBotV4Ocr, component):
|
def __init__(self, ocr: ChieriBotV4Ocr, component):
|
||||||
|
@ -41,7 +41,7 @@ class AndrealExecuteRunnable(QRunnable):
|
|||||||
self.signals.completed.emit(self.jsonPath, imageBytes)
|
self.signals.completed.emit(self.jsonPath, imageBytes)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
imageBytes = None
|
imageBytes = None
|
||||||
logger.exception(f"{self.__class__.__name__} error")
|
logger.exception("%s error", self.__class__.__name__)
|
||||||
self.signals.error.emit(self.jsonPath, str(e))
|
self.signals.error.emit(self.jsonPath, str(e))
|
||||||
finally:
|
finally:
|
||||||
os.unlink(self.jsonPath)
|
os.unlink(self.jsonPath)
|
||||||
@ -84,7 +84,10 @@ class AndrealHelper(QObject):
|
|||||||
|
|
||||||
def request(self, jsonPath: str, arguments: list[str]):
|
def request(self, jsonPath: str, arguments: list[str]):
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"{self.__class__.__name__} received request {jsonPath=} {arguments=}"
|
"%s received request jsonPath=%r arguments=%r",
|
||||||
|
self.__class__.__name__,
|
||||||
|
jsonPath,
|
||||||
|
arguments,
|
||||||
)
|
)
|
||||||
runnable = AndrealExecuteRunnable(self.andrealExecutable, jsonPath, arguments)
|
runnable = AndrealExecuteRunnable(self.andrealExecutable, jsonPath, arguments)
|
||||||
runnable.signals.error.connect(self.error)
|
runnable.signals.error.connect(self.error)
|
||||||
|
@ -2,7 +2,7 @@ from PySide6.QtCore import Slot
|
|||||||
from PySide6.QtGui import QColor
|
from PySide6.QtGui import QColor
|
||||||
from PySide6.QtWidgets import QGraphicsColorizeEffect, QRadioButton
|
from PySide6.QtWidgets import QGraphicsColorizeEffect, QRadioButton
|
||||||
|
|
||||||
from ui.extends.shared.color import mix_color
|
from core.color import mixColor
|
||||||
|
|
||||||
STYLESHEET = """
|
STYLESHEET = """
|
||||||
QRadioButton {{
|
QRadioButton {{
|
||||||
@ -40,7 +40,7 @@ class RatingClassRadioButton(QRadioButton):
|
|||||||
def setColors(self, dark_color: QColor, text_color: QColor):
|
def setColors(self, dark_color: QColor, text_color: QColor):
|
||||||
self._dark_color = dark_color
|
self._dark_color = dark_color
|
||||||
self._text_color = text_color
|
self._text_color = text_color
|
||||||
self._mid_color = mix_color(dark_color, text_color, 0.616)
|
self._mid_color = mixColor(dark_color, text_color, 0.616)
|
||||||
self.updateEffects()
|
self.updateEffects()
|
||||||
|
|
||||||
def isColorsSet(self) -> bool:
|
def isColorsSet(self) -> bool:
|
||||||
|
@ -126,7 +126,7 @@ class RatingClassSelector(QWidget):
|
|||||||
elif ratingClass in range(len(self.buttons)):
|
elif ratingClass in range(len(self.buttons)):
|
||||||
button = self.buttons[ratingClass]
|
button = self.buttons[ratingClass]
|
||||||
else:
|
else:
|
||||||
logger.debug(f"Cannot select {ratingClass=}, condition check failed")
|
logger.debug("Cannot select ratingClass=%s, condition check failed", ratingClass)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not button.isEnabled():
|
if not button.isEnabled():
|
||||||
|
@ -61,30 +61,22 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
|
|
||||||
VALIDATION_ITEMS_TEXT = [
|
VALIDATION_ITEMS_TEXT = [
|
||||||
[
|
[
|
||||||
# fmt: off
|
|
||||||
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.chartIncomplete.title"),
|
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.chartIncomplete.title"),
|
||||||
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.chartIncomplete.text"),
|
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.chartIncomplete.text"),
|
||||||
# fmt: on
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
# fmt: off
|
|
||||||
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreMismatch.title"),
|
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreMismatch.title"),
|
||||||
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreMismatch.text"),
|
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreMismatch.text"),
|
||||||
# fmt: on
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
# fmt: off
|
|
||||||
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.emptyScore.title"),
|
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.emptyScore.title"),
|
||||||
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.emptyScore.text"),
|
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.emptyScore.text"),
|
||||||
# fmt: on
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
# fmt: off
|
|
||||||
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreIncompleteForValidate.title"),
|
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreIncompleteForValidate.title"),
|
||||||
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreIncompleteForValidate.text"),
|
lambda: QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreIncompleteForValidate.text"),
|
||||||
# fmt: on,
|
|
||||||
],
|
],
|
||||||
]
|
] # fmt: skip
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -208,20 +200,16 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
if validate & ScoreValidateResult.ChartNotSet:
|
if validate & ScoreValidateResult.ChartNotSet:
|
||||||
self.__triggerMessageBox(
|
self.__triggerMessageBox(
|
||||||
"critical",
|
"critical",
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("ScoreEditor", "confirmDialog.chartNotSet.title"),
|
QCoreApplication.translate("ScoreEditor", "confirmDialog.chartNotSet.title"),
|
||||||
QCoreApplication.translate("ScoreEditor", "confirmDialog.chartNotSet.text"),
|
QCoreApplication.translate("ScoreEditor", "confirmDialog.chartNotSet.text"),
|
||||||
# fmt: on
|
) # fmt: skip
|
||||||
)
|
|
||||||
return False
|
return False
|
||||||
if validate & ScoreValidateResult.ScoreIncomplete:
|
if validate & ScoreValidateResult.ScoreIncomplete:
|
||||||
self.__triggerMessageBox(
|
self.__triggerMessageBox(
|
||||||
"critical",
|
"critical",
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreIncomplete.title"),
|
QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreIncomplete.title"),
|
||||||
QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreIncomplete.text"),
|
QCoreApplication.translate("ScoreEditor", "confirmDialog.scoreIncomplete.text"),
|
||||||
# fmt: on
|
) # fmt: skip
|
||||||
)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# since validate may have multiple results
|
# since validate may have multiple results
|
||||||
@ -347,10 +335,8 @@ class ScoreEditor(Ui_ScoreEditor, QWidget):
|
|||||||
)
|
)
|
||||||
if validate & ScoreValidateResult.ScoreIncompleteForValidate:
|
if validate & ScoreValidateResult.ScoreIncompleteForValidate:
|
||||||
texts.append(
|
texts.append(
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("ScoreEditor", "validate.scoreIncompleteForValidate")
|
QCoreApplication.translate("ScoreEditor", "validate.scoreIncompleteForValidate")
|
||||||
# fmt: on
|
) # fmt: skip
|
||||||
)
|
|
||||||
|
|
||||||
if not texts:
|
if not texts:
|
||||||
texts.append(
|
texts.append(
|
||||||
|
@ -192,7 +192,7 @@ class SongIdSelector(Ui_SongIdSelector, QWidget):
|
|||||||
self.fillSongIdComboBox()
|
self.fillSongIdComboBox()
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.warning(f'Attempting to select an unknown pack "{packId}"')
|
logger.warning("Attempting to select an unknown pack [%s]", packId)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def selectSongId(self, songId: str) -> bool:
|
def selectSongId(self, songId: str) -> bool:
|
||||||
@ -202,7 +202,8 @@ class SongIdSelector(Ui_SongIdSelector, QWidget):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
f'Attempting to select an unknown song "{songId}", maybe try selecting a pack first?'
|
"Attempting to select an unknown song [%s], maybe try selecting a pack first?",
|
||||||
|
songId,
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -163,19 +163,15 @@ class TabDb_ChartInfoEditor(Ui_TabDb_ChartInfoEditor, QWidget):
|
|||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.chartNotSelected"),
|
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.chartNotSelected"),
|
||||||
# fmt: on
|
) # fmt: skip
|
||||||
)
|
|
||||||
return
|
return
|
||||||
if not self.constantLineEdit.hasAcceptableInput():
|
if not self.constantLineEdit.hasAcceptableInput():
|
||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.constantRequired"),
|
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.constantRequired"),
|
||||||
# fmt: on
|
) # fmt: skip
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
constant = int(self.constantLineEdit.text())
|
constant = int(self.constantLineEdit.text())
|
||||||
@ -202,10 +198,8 @@ class TabDb_ChartInfoEditor(Ui_TabDb_ChartInfoEditor, QWidget):
|
|||||||
QMessageBox.critical(
|
QMessageBox.critical(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.chartNotSelected"),
|
QCoreApplication.translate("TabDb_ChartInfoEditor", "commit.chartNotSelected"),
|
||||||
# fmt: on
|
) # fmt: skip
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
chartInfo = self.db.get_chart_info(chart.song_id, chart.rating_class)
|
chartInfo = self.db.get_chart_info(chart.song_id, chart.rating_class)
|
||||||
@ -213,12 +207,10 @@ class TabDb_ChartInfoEditor(Ui_TabDb_ChartInfoEditor, QWidget):
|
|||||||
result = QMessageBox.warning(
|
result = QMessageBox.warning(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("TabDb_ChartInfoEditor", "deleteConfirm"),
|
QCoreApplication.translate("TabDb_ChartInfoEditor", "deleteConfirm"),
|
||||||
# fmt: on
|
|
||||||
QMessageBox.StandardButton.Yes,
|
QMessageBox.StandardButton.Yes,
|
||||||
QMessageBox.StandardButton.No,
|
QMessageBox.StandardButton.No,
|
||||||
)
|
) # fmt: skip
|
||||||
if result == QMessageBox.StandardButton.Yes:
|
if result == QMessageBox.StandardButton.Yes:
|
||||||
with self.db.sessionmaker() as session:
|
with self.db.sessionmaker() as session:
|
||||||
session.delete(chartInfo)
|
session.delete(chartInfo)
|
||||||
|
@ -91,7 +91,7 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
|||||||
session.commit()
|
session.commit()
|
||||||
databaseUpdateSignals.songAddOrDelete.emit()
|
databaseUpdateSignals.songAddOrDelete.emit()
|
||||||
itemNum = len([item for item in parser.parse() if isinstance(item, instance)])
|
itemNum = len([item for item in parser.parse() if isinstance(item, instance)])
|
||||||
logger.info(f"updated {itemNum} {logName} from {path}")
|
logger.info("updated %d %s from %s", itemNum, logName, path)
|
||||||
return itemNum
|
return itemNum
|
||||||
|
|
||||||
def importPacklist(self, packlistPath):
|
def importPacklist(self, packlistPath):
|
||||||
@ -161,7 +161,7 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.info(f"Importing {apkFile}")
|
logger.info("Importing %s", apkFile)
|
||||||
|
|
||||||
with zipfile.ZipFile(apkFile) as zf:
|
with zipfile.ZipFile(apkFile) as zf:
|
||||||
packlistPath = zipfile.Path(zf) / "assets" / "songs" / "packlist"
|
packlistPath = zipfile.Path(zf) / "assets" / "songs" / "packlist"
|
||||||
@ -193,7 +193,9 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
|||||||
db = Database()
|
db = Database()
|
||||||
parser = St3ScoreParser(dbFile)
|
parser = St3ScoreParser(dbFile)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Got {len(parser.parse())} items from {dbFile}, writing into database..."
|
"Got %d items from %s, writing into database...",
|
||||||
|
len(parser.parse()),
|
||||||
|
dbFile,
|
||||||
)
|
)
|
||||||
with db.sessionmaker() as session:
|
with db.sessionmaker() as session:
|
||||||
parser.write_database(session)
|
parser.write_database(session)
|
||||||
@ -218,7 +220,9 @@ class TabDb_Manage(Ui_TabDb_Manage, QWidget):
|
|||||||
db = Database()
|
db = Database()
|
||||||
parser = ArcaeaOnlineParser(apiResultFile)
|
parser = ArcaeaOnlineParser(apiResultFile)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Got {len(parser.parse())} items from {apiResultFile}, writing into database..."
|
"Got %d items from %s, writing into database...",
|
||||||
|
len(parser.parse()),
|
||||||
|
apiResultFile,
|
||||||
)
|
)
|
||||||
with db.sessionmaker() as session:
|
with db.sessionmaker() as session:
|
||||||
parser.write_database(session)
|
parser.write_database(session)
|
||||||
|
@ -154,23 +154,17 @@ class TabDb_RemoveDuplicateScores(Ui_TabDb_RemoveDuplicateScores, QWidget):
|
|||||||
self.treeView.setItemDelegateForColumn(1, self.treeViewProxyDelegate)
|
self.treeView.setItemDelegateForColumn(1, self.treeViewProxyDelegate)
|
||||||
|
|
||||||
self.quickSelect_comboBox.addItem(
|
self.quickSelect_comboBox.addItem(
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("TabDb_RemoveDuplicateScores", "quickSelectComboBox.idEarlier"),
|
QCoreApplication.translate("TabDb_RemoveDuplicateScores", "quickSelectComboBox.idEarlier"),
|
||||||
# fmt: on
|
|
||||||
QuickSelectComboBoxValues.ID_EARLIER
|
QuickSelectComboBoxValues.ID_EARLIER
|
||||||
)
|
) # fmt: skip
|
||||||
self.quickSelect_comboBox.addItem(
|
self.quickSelect_comboBox.addItem(
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("TabDb_RemoveDuplicateScores", "quickSelectComboBox.dateEarlier"),
|
QCoreApplication.translate("TabDb_RemoveDuplicateScores", "quickSelectComboBox.dateEarlier"),
|
||||||
# fmt: on
|
|
||||||
QuickSelectComboBoxValues.DATE_EARLIER
|
QuickSelectComboBoxValues.DATE_EARLIER
|
||||||
)
|
) # fmt: skip
|
||||||
self.quickSelect_comboBox.addItem(
|
self.quickSelect_comboBox.addItem(
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("TabDb_RemoveDuplicateScores", "quickSelectComboBox.columnsIntegral"),
|
QCoreApplication.translate("TabDb_RemoveDuplicateScores", "quickSelectComboBox.columnsIntegral"),
|
||||||
# fmt: on
|
|
||||||
QuickSelectComboBoxValues.COLUMNS_INTEGRAL
|
QuickSelectComboBoxValues.COLUMNS_INTEGRAL
|
||||||
)
|
) # fmt: skip
|
||||||
|
|
||||||
def getQueryColumns(self):
|
def getQueryColumns(self):
|
||||||
columns: list[InstrumentedAttribute] = [Score.song_id, Score.rating_class]
|
columns: list[InstrumentedAttribute] = [Score.song_id, Score.rating_class]
|
||||||
@ -291,12 +285,12 @@ class TabDb_RemoveDuplicateScores(Ui_TabDb_RemoveDuplicateScores, QWidget):
|
|||||||
confirm = QMessageBox.warning(
|
confirm = QMessageBox.warning(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
# fmt: off
|
QCoreApplication.translate(
|
||||||
QCoreApplication.translate("TabDb_RemoveDuplicateScores", "deleteSelectionDialog.content {}").format(len(selectedScores)),
|
"TabDb_RemoveDuplicateScores", "deleteSelectionDialog.content {}"
|
||||||
# fmt: on
|
).format(len(selectedScores)),
|
||||||
QMessageBox.StandardButton.Yes,
|
QMessageBox.StandardButton.Yes,
|
||||||
QMessageBox.StandardButton.No,
|
QMessageBox.StandardButton.No,
|
||||||
)
|
) # fmt: skip
|
||||||
if confirm != QMessageBox.StandardButton.Yes:
|
if confirm != QMessageBox.StandardButton.Yes:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -310,12 +304,11 @@ class TabDb_RemoveDuplicateScores(Ui_TabDb_RemoveDuplicateScores, QWidget):
|
|||||||
@Slot()
|
@Slot()
|
||||||
def on_scan_scanButton_clicked(self):
|
def on_scan_scanButton_clicked(self):
|
||||||
if len(self.getQueryColumns()) <= 2:
|
if len(self.getQueryColumns()) <= 2:
|
||||||
|
message = QCoreApplication.translate("TabDb_RemoveDuplicateScores", "scan_noColumnsDialog.content") # fmt: skip
|
||||||
result = QMessageBox.warning(
|
result = QMessageBox.warning(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
# fmt: off
|
message,
|
||||||
QCoreApplication.translate("TabDb_RemoveDuplicateScores", "scan_noColumnsDialog.content"),
|
|
||||||
# fmt: on
|
|
||||||
QMessageBox.StandardButton.Yes,
|
QMessageBox.StandardButton.Yes,
|
||||||
QMessageBox.StandardButton.No,
|
QMessageBox.StandardButton.No,
|
||||||
)
|
)
|
||||||
|
@ -50,6 +50,4 @@ class TabOverview(Ui_TabOverview, QWidget):
|
|||||||
|
|
||||||
def retranslateUi(self, *args):
|
def retranslateUi(self, *args):
|
||||||
super().retranslateUi(self)
|
super().retranslateUi(self)
|
||||||
# fmt: off
|
self.describeFormatString = QCoreApplication.translate("TabOverview", "databaseDescribeLabel {} {} {} {} {} {}") # fmt: skip
|
||||||
self.describeFormatString = QCoreApplication.translate("TabOverview", "databaseDescribeLabel {} {} {} {} {} {}")
|
|
||||||
# fmt: on
|
|
||||||
|
@ -131,11 +131,8 @@ class TabTools_Andreal(Ui_TabTools_Andreal, QWidget):
|
|||||||
|
|
||||||
@Slot()
|
@Slot()
|
||||||
def on_imageTypeWhatIsThisButton_clicked(self):
|
def on_imageTypeWhatIsThisButton_clicked(self):
|
||||||
QMessageBox.information(
|
message = QCoreApplication.translate("TabTools_Andreal", "imageWhatIsThisDialog.description") # fmt: skip
|
||||||
self,
|
QMessageBox.information(self, None, message)
|
||||||
None,
|
|
||||||
QCoreApplication.translate("TabTools_Andreal", "imageWhatIsThisDialog.description"),
|
|
||||||
) # fmt: skip
|
|
||||||
|
|
||||||
def imageFormat(self):
|
def imageFormat(self):
|
||||||
buttonId = self.imageFormatButtonGroup.checkedId()
|
buttonId = self.imageFormatButtonGroup.checkedId()
|
||||||
|
@ -90,10 +90,8 @@ class PlayRatingCalculatorDialog(QDialog):
|
|||||||
|
|
||||||
self.acceptButton = QPushButton(self)
|
self.acceptButton = QPushButton(self)
|
||||||
self.acceptButton.setText(
|
self.acceptButton.setText(
|
||||||
# fmt: off
|
|
||||||
QCoreApplication.translate("StepCalculator", "playRatingCalculatorDialog.acceptButton")
|
QCoreApplication.translate("StepCalculator", "playRatingCalculatorDialog.acceptButton")
|
||||||
# fmt: on
|
) # fmt: skip
|
||||||
)
|
|
||||||
self.acceptButton.setEnabled(False)
|
self.acceptButton.setEnabled(False)
|
||||||
self.verticalLayout.addWidget(self.acceptButton)
|
self.verticalLayout.addWidget(self.acceptButton)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user