mirror of
https://github.com/283375/arcaea-offline-pyside-ui.git
synced 2025-04-11 05:30:17 +00:00
feat: OCR score date source (#9)
* New settings entries * Choose `birthTime`/`lastModified` for OCR score date source if the image EXIF fails
This commit is contained in:
parent
d5895fe230
commit
d9c163431c
@ -22,39 +22,6 @@
|
||||
<string>queue.title</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>iccOptionsGroupBox</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="iccUseQtRadioButton">
|
||||
<property name="text">
|
||||
<string>icc.useQt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="iccUsePILRadioButton">
|
||||
<property name="text">
|
||||
<string>icc.usePIL</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="iccTryFixRadioButton">
|
||||
<property name="text">
|
||||
<string>icc.tryFix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ocr_addImageButton">
|
||||
<property name="text">
|
||||
@ -95,6 +62,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="optionsDialogButton">
|
||||
<property name="text">
|
||||
<string>queue.optionsButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ocr_startButton">
|
||||
<property name="text">
|
||||
|
140
ui/designer/components/ocrQueueOptionsDialog.ui
Normal file
140
ui/designer/components/ocrQueueOptionsDialog.ui
Normal file
@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OcrQueueOptionsDialog</class>
|
||||
<widget class="QDialog" name="OcrQueueOptionsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>331</width>
|
||||
<height>157</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>OCR Options</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>iccOptionsGroupBox</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="iccUseQtRadioButton">
|
||||
<property name="text">
|
||||
<string>icc.useQt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="iccUsePILRadioButton">
|
||||
<property name="text">
|
||||
<string>icc.usePIL</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="iccTryFixRadioButton">
|
||||
<property name="text">
|
||||
<string>icc.tryFix</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>dateOptionsGroupBox</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="dateReadFromExifCheckbox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>date.readFromExif</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="dateUseCreationDateRadioButton">
|
||||
<property name="text">
|
||||
<string>date.useCreationDate</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="dateUseModifyDateRadioButton">
|
||||
<property name="text">
|
||||
<string>date.useModifyDate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>OcrQueueOptionsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>OcrQueueOptionsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
107
ui/designer/components/ocrQueueOptionsDialog_ui.py
Normal file
107
ui/designer/components/ocrQueueOptionsDialog_ui.py
Normal file
@ -0,0 +1,107 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
################################################################################
|
||||
## Form generated from reading UI file 'ocrQueueOptionsDialog.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 (QAbstractButton, QApplication, QCheckBox, QDialog,
|
||||
QDialogButtonBox, QGroupBox, QHBoxLayout, QRadioButton,
|
||||
QSizePolicy, QVBoxLayout, QWidget)
|
||||
|
||||
class Ui_OcrQueueOptionsDialog(object):
|
||||
def setupUi(self, OcrQueueOptionsDialog):
|
||||
if not OcrQueueOptionsDialog.objectName():
|
||||
OcrQueueOptionsDialog.setObjectName(u"OcrQueueOptionsDialog")
|
||||
OcrQueueOptionsDialog.resize(331, 157)
|
||||
self.verticalLayout = QVBoxLayout(OcrQueueOptionsDialog)
|
||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||
self.horizontalLayout = QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName(u"horizontalLayout")
|
||||
self.groupBox = QGroupBox(OcrQueueOptionsDialog)
|
||||
self.groupBox.setObjectName(u"groupBox")
|
||||
self.verticalLayout_2 = QVBoxLayout(self.groupBox)
|
||||
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||
self.iccUseQtRadioButton = QRadioButton(self.groupBox)
|
||||
self.iccUseQtRadioButton.setObjectName(u"iccUseQtRadioButton")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.iccUseQtRadioButton)
|
||||
|
||||
self.iccUsePILRadioButton = QRadioButton(self.groupBox)
|
||||
self.iccUsePILRadioButton.setObjectName(u"iccUsePILRadioButton")
|
||||
self.iccUsePILRadioButton.setChecked(True)
|
||||
|
||||
self.verticalLayout_2.addWidget(self.iccUsePILRadioButton)
|
||||
|
||||
self.iccTryFixRadioButton = QRadioButton(self.groupBox)
|
||||
self.iccTryFixRadioButton.setObjectName(u"iccTryFixRadioButton")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.iccTryFixRadioButton)
|
||||
|
||||
|
||||
self.horizontalLayout.addWidget(self.groupBox)
|
||||
|
||||
self.groupBox_2 = QGroupBox(OcrQueueOptionsDialog)
|
||||
self.groupBox_2.setObjectName(u"groupBox_2")
|
||||
self.verticalLayout_3 = QVBoxLayout(self.groupBox_2)
|
||||
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
|
||||
self.dateReadFromExifCheckbox = QCheckBox(self.groupBox_2)
|
||||
self.dateReadFromExifCheckbox.setObjectName(u"dateReadFromExifCheckbox")
|
||||
self.dateReadFromExifCheckbox.setEnabled(False)
|
||||
self.dateReadFromExifCheckbox.setChecked(True)
|
||||
|
||||
self.verticalLayout_3.addWidget(self.dateReadFromExifCheckbox)
|
||||
|
||||
self.dateUseCreationDateRadioButton = QRadioButton(self.groupBox_2)
|
||||
self.dateUseCreationDateRadioButton.setObjectName(u"dateUseCreationDateRadioButton")
|
||||
self.dateUseCreationDateRadioButton.setChecked(True)
|
||||
|
||||
self.verticalLayout_3.addWidget(self.dateUseCreationDateRadioButton)
|
||||
|
||||
self.dateUseModifyDateRadioButton = QRadioButton(self.groupBox_2)
|
||||
self.dateUseModifyDateRadioButton.setObjectName(u"dateUseModifyDateRadioButton")
|
||||
|
||||
self.verticalLayout_3.addWidget(self.dateUseModifyDateRadioButton)
|
||||
|
||||
|
||||
self.horizontalLayout.addWidget(self.groupBox_2)
|
||||
|
||||
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
|
||||
self.buttonBox = QDialogButtonBox(OcrQueueOptionsDialog)
|
||||
self.buttonBox.setObjectName(u"buttonBox")
|
||||
self.buttonBox.setOrientation(Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
|
||||
|
||||
self.verticalLayout.addWidget(self.buttonBox)
|
||||
|
||||
|
||||
self.retranslateUi(OcrQueueOptionsDialog)
|
||||
self.buttonBox.accepted.connect(OcrQueueOptionsDialog.accept)
|
||||
self.buttonBox.rejected.connect(OcrQueueOptionsDialog.reject)
|
||||
|
||||
QMetaObject.connectSlotsByName(OcrQueueOptionsDialog)
|
||||
# setupUi
|
||||
|
||||
def retranslateUi(self, OcrQueueOptionsDialog):
|
||||
OcrQueueOptionsDialog.setWindowTitle(QCoreApplication.translate("OcrQueueOptionsDialog", u"OCR Options", None))
|
||||
self.groupBox.setTitle(QCoreApplication.translate("OcrQueueOptionsDialog", u"iccOptionsGroupBox", None))
|
||||
self.iccUseQtRadioButton.setText(QCoreApplication.translate("OcrQueueOptionsDialog", u"icc.useQt", None))
|
||||
self.iccUsePILRadioButton.setText(QCoreApplication.translate("OcrQueueOptionsDialog", u"icc.usePIL", None))
|
||||
self.iccTryFixRadioButton.setText(QCoreApplication.translate("OcrQueueOptionsDialog", u"icc.tryFix", None))
|
||||
self.groupBox_2.setTitle(QCoreApplication.translate("OcrQueueOptionsDialog", u"dateOptionsGroupBox", None))
|
||||
self.dateReadFromExifCheckbox.setText(QCoreApplication.translate("OcrQueueOptionsDialog", u"date.readFromExif", None))
|
||||
self.dateUseCreationDateRadioButton.setText(QCoreApplication.translate("OcrQueueOptionsDialog", u"date.useCreationDate", None))
|
||||
self.dateUseModifyDateRadioButton.setText(QCoreApplication.translate("OcrQueueOptionsDialog", u"date.useModifyDate", None))
|
||||
# retranslateUi
|
@ -17,8 +17,8 @@ from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||
from PySide6.QtWidgets import (QAbstractItemView, QApplication, QCheckBox, QGroupBox,
|
||||
QHBoxLayout, QHeaderView, QLabel, QProgressBar,
|
||||
QPushButton, QRadioButton, QSizePolicy, QSpacerItem,
|
||||
QTableView, QVBoxLayout, QWidget)
|
||||
QPushButton, QSizePolicy, QSpacerItem, QTableView,
|
||||
QVBoxLayout, QWidget)
|
||||
|
||||
class Ui_OcrQueue(object):
|
||||
def setupUi(self, OcrQueue):
|
||||
@ -34,29 +34,6 @@ class Ui_OcrQueue(object):
|
||||
self.groupBox_3.setObjectName(u"groupBox_3")
|
||||
self.verticalLayout_2 = QVBoxLayout(self.groupBox_3)
|
||||
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||
self.groupBox = QGroupBox(self.groupBox_3)
|
||||
self.groupBox.setObjectName(u"groupBox")
|
||||
self.verticalLayout = QVBoxLayout(self.groupBox)
|
||||
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||
self.iccUseQtRadioButton = QRadioButton(self.groupBox)
|
||||
self.iccUseQtRadioButton.setObjectName(u"iccUseQtRadioButton")
|
||||
|
||||
self.verticalLayout.addWidget(self.iccUseQtRadioButton)
|
||||
|
||||
self.iccUsePILRadioButton = QRadioButton(self.groupBox)
|
||||
self.iccUsePILRadioButton.setObjectName(u"iccUsePILRadioButton")
|
||||
self.iccUsePILRadioButton.setChecked(True)
|
||||
|
||||
self.verticalLayout.addWidget(self.iccUsePILRadioButton)
|
||||
|
||||
self.iccTryFixRadioButton = QRadioButton(self.groupBox)
|
||||
self.iccTryFixRadioButton.setObjectName(u"iccTryFixRadioButton")
|
||||
|
||||
self.verticalLayout.addWidget(self.iccTryFixRadioButton)
|
||||
|
||||
|
||||
self.verticalLayout_2.addWidget(self.groupBox)
|
||||
|
||||
self.ocr_addImageButton = QPushButton(self.groupBox_3)
|
||||
self.ocr_addImageButton.setObjectName(u"ocr_addImageButton")
|
||||
|
||||
@ -78,6 +55,11 @@ class Ui_OcrQueue(object):
|
||||
|
||||
self.verticalLayout_2.addItem(self.verticalSpacer)
|
||||
|
||||
self.optionsDialogButton = QPushButton(self.groupBox_3)
|
||||
self.optionsDialogButton.setObjectName(u"optionsDialogButton")
|
||||
|
||||
self.verticalLayout_2.addWidget(self.optionsDialogButton)
|
||||
|
||||
self.ocr_startButton = QPushButton(self.groupBox_3)
|
||||
self.ocr_startButton.setObjectName(u"ocr_startButton")
|
||||
|
||||
@ -154,13 +136,10 @@ class Ui_OcrQueue(object):
|
||||
|
||||
def retranslateUi(self, OcrQueue):
|
||||
self.groupBox_3.setTitle(QCoreApplication.translate("OcrQueue", u"queue.title", None))
|
||||
self.groupBox.setTitle(QCoreApplication.translate("OcrQueue", u"iccOptionsGroupBox", None))
|
||||
self.iccUseQtRadioButton.setText(QCoreApplication.translate("OcrQueue", u"icc.useQt", None))
|
||||
self.iccUsePILRadioButton.setText(QCoreApplication.translate("OcrQueue", u"icc.usePIL", None))
|
||||
self.iccTryFixRadioButton.setText(QCoreApplication.translate("OcrQueue", u"icc.tryFix", None))
|
||||
self.ocr_addImageButton.setText(QCoreApplication.translate("OcrQueue", u"queue.addImageButton", None))
|
||||
self.ocr_removeSelectedButton.setText(QCoreApplication.translate("OcrQueue", u"queue.removeSelected", None))
|
||||
self.ocr_removeAllButton.setText(QCoreApplication.translate("OcrQueue", u"queue.removeAll", None))
|
||||
self.optionsDialogButton.setText(QCoreApplication.translate("OcrQueue", u"queue.optionsButton", None))
|
||||
self.ocr_startButton.setText(QCoreApplication.translate("OcrQueue", u"queue.startOcrButton", None))
|
||||
self.groupBox_5.setTitle(QCoreApplication.translate("OcrQueue", u"results", None))
|
||||
self.ocr_acceptSelectedButton.setText(QCoreApplication.translate("OcrQueue", u"results.acceptSelectedButton", None))
|
||||
@ -169,4 +148,3 @@ class Ui_OcrQueue(object):
|
||||
self.statusLabel.setText("")
|
||||
pass
|
||||
# retranslateUi
|
||||
|
||||
|
@ -150,6 +150,7 @@ class OcrQueueModel(QAbstractListModel):
|
||||
|
||||
@iccOption.setter
|
||||
def iccOption(self, opt: IccOption):
|
||||
logger.debug(f"ICC option changed to {opt}")
|
||||
self.__iccOption = opt
|
||||
|
||||
@overload
|
||||
@ -344,8 +345,12 @@ class OcrQueueTableProxyModel(QAbstractTableModel):
|
||||
def retranslateHeaders(self):
|
||||
self.__horizontalHeaders = [
|
||||
# fmt: off
|
||||
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.select"),
|
||||
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.imagePreview"),
|
||||
QCoreApplication.translate(
|
||||
"OcrTableModel", "horizontalHeader.title.select"
|
||||
),
|
||||
QCoreApplication.translate(
|
||||
"OcrTableModel", "horizontalHeader.title.imagePreview"
|
||||
),
|
||||
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.chart"),
|
||||
QCoreApplication.translate("OcrTableModel", "horizontalHeader.title.score"),
|
||||
# fmt: on
|
||||
|
@ -10,6 +10,7 @@ __all__ = [
|
||||
"KNN_MODEL_FILE",
|
||||
"B30_KNN_MODEL_FILE",
|
||||
"PHASH_DATABASE_FILE",
|
||||
"SCORE_DATE_SOURCE",
|
||||
"ANDREAL_FOLDER",
|
||||
"ANDREAL_EXECUTABLE",
|
||||
"Settings",
|
||||
@ -23,6 +24,7 @@ DATABASE_URL = "DatabaseUrl"
|
||||
KNN_MODEL_FILE = "Ocr/KnnModelFile"
|
||||
B30_KNN_MODEL_FILE = "Ocr/B30KnnModelFile"
|
||||
PHASH_DATABASE_FILE = "Ocr/PHashDatabaseFile"
|
||||
SCORE_DATE_SOURCE = "Ocr/DateSource"
|
||||
|
||||
ANDREAL_FOLDER = "Andreal/AndrealFolder"
|
||||
ANDREAL_EXECUTABLE = "Andreal/AndrealExecutable"
|
||||
@ -92,6 +94,15 @@ class Settings(QSettings, metaclass=QObjectSingleton):
|
||||
def resetPHashDatabaseFile(self):
|
||||
self._resetStrItem(PHASH_DATABASE_FILE)
|
||||
|
||||
def scoreDateSource(self):
|
||||
return self._strItem(SCORE_DATE_SOURCE)
|
||||
|
||||
def setScoreDateSource(self, value: str):
|
||||
self._setStrItem(SCORE_DATE_SOURCE, value)
|
||||
|
||||
def resetScoreDateSource(self):
|
||||
self._resetStrItem(SCORE_DATE_SOURCE)
|
||||
|
||||
def andrealFolder(self):
|
||||
return self._strItem(ANDREAL_FOLDER)
|
||||
|
||||
|
@ -21,6 +21,7 @@ from PySide6.QtCore import QDateTime, QFileInfo
|
||||
|
||||
from ui.extends.components.ocrQueue import OcrRunnable
|
||||
from ui.extends.shared.data import Data
|
||||
from ui.extends.shared.settings import Settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -67,8 +68,14 @@ def getImageDate(imagePath: str) -> QDateTime:
|
||||
if exifImage.has_exif and exifImage.get("datetime_original"):
|
||||
datetimeStr = exifImage.get("datetime_original")
|
||||
datetime = QDateTime.fromString(datetimeStr, "yyyy:MM:dd hh:mm:ss")
|
||||
|
||||
if not isinstance(datetime, QDateTime):
|
||||
datetime = QFileInfo(imagePath).birthTime()
|
||||
dateSource = Settings().scoreDateSource()
|
||||
if dateSource == "lastModified":
|
||||
datetime = QFileInfo(imagePath).lastModified()
|
||||
else:
|
||||
datetime = QFileInfo(imagePath).birthTime()
|
||||
|
||||
return datetime
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ from typing import Optional
|
||||
|
||||
from PySide6.QtCore import Qt, QTimer, Slot
|
||||
from PySide6.QtGui import QColor, QPalette
|
||||
from PySide6.QtWidgets import QButtonGroup, QWidget
|
||||
from PySide6.QtWidgets import QWidget
|
||||
|
||||
from ui.designer.components.ocrQueue_ui import Ui_OcrQueue
|
||||
from ui.extends.components.ocrQueue import (
|
||||
@ -13,6 +13,7 @@ from ui.extends.components.ocrQueue import (
|
||||
OcrScoreDelegate,
|
||||
)
|
||||
from ui.extends.shared.language import LanguageChangeEventFilter
|
||||
from ui.implements.components.ocrQueueOptionsDialog import OcrQueueOptionsDialog
|
||||
|
||||
|
||||
class OcrQueue(Ui_OcrQueue, QWidget):
|
||||
@ -26,6 +27,9 @@ class OcrQueue(Ui_OcrQueue, QWidget):
|
||||
self.__model: Optional[OcrQueueModel] = None
|
||||
self.__tableProxyModel: Optional[OcrQueueTableProxyModel] = None
|
||||
|
||||
self.optionsDialog = OcrQueueOptionsDialog(self)
|
||||
self.optionsDialog.iccOptionsChanged.connect(self.setIccOption)
|
||||
|
||||
self.__firstResizeDone = False
|
||||
self.resizeTimer = QTimer(self)
|
||||
self.resizeTimer.timeout.connect(self.tableView.resizeRowsToContents)
|
||||
@ -41,13 +45,6 @@ class OcrQueue(Ui_OcrQueue, QWidget):
|
||||
tableViewPalette.setColor(QPalette.ColorRole.Highlight, highlightColor)
|
||||
self.tableView.setPalette(tableViewPalette)
|
||||
|
||||
self.iccOptionButtonGroup = QButtonGroup(self)
|
||||
self.iccOptionButtonGroup.buttonToggled.connect(self.updateIccOption)
|
||||
self.iccOptionButtonGroup.addButton(self.iccUseQtRadioButton, 0)
|
||||
self.iccOptionButtonGroup.addButton(self.iccUsePILRadioButton, 1)
|
||||
self.iccOptionButtonGroup.addButton(self.iccTryFixRadioButton, 2)
|
||||
self.updateIccOption()
|
||||
|
||||
self.statusLabelClearTimer = QTimer(self)
|
||||
self.statusLabelClearTimer.setSingleShot(True)
|
||||
self.statusLabelClearTimer.timeout.connect(self.clearStatusMessage)
|
||||
@ -93,9 +90,10 @@ class OcrQueue(Ui_OcrQueue, QWidget):
|
||||
self.ocr_acceptAllButton.setEnabled(__bool)
|
||||
self.ocr_ignoreValidateCheckBox.setEnabled(__bool)
|
||||
|
||||
def updateIccOption(self):
|
||||
@Slot(int)
|
||||
def setIccOption(self, option):
|
||||
if self.model():
|
||||
self.model().iccOption = self.iccOptionButtonGroup.checkedId()
|
||||
self.model().iccOption = option
|
||||
|
||||
def showStatusMessage(self, message: str):
|
||||
self.statusLabel.setText(message)
|
||||
@ -131,6 +129,10 @@ class OcrQueue(Ui_OcrQueue, QWidget):
|
||||
def modelReseted(self):
|
||||
self.progressBar.setMaximum(0)
|
||||
|
||||
@Slot()
|
||||
def on_optionsDialogButton_clicked(self):
|
||||
self.optionsDialog.exec()
|
||||
|
||||
@Slot()
|
||||
def on_ocr_removeSelectedButton_clicked(self):
|
||||
if self.model():
|
||||
|
48
ui/implements/components/ocrQueueOptionsDialog.py
Normal file
48
ui/implements/components/ocrQueueOptionsDialog.py
Normal file
@ -0,0 +1,48 @@
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QButtonGroup, QDialog
|
||||
|
||||
from ui.designer.components.ocrQueueOptionsDialog_ui import Ui_OcrQueueOptionsDialog
|
||||
from ui.extends.shared.settings import Settings
|
||||
|
||||
|
||||
class OcrQueueOptionsDialog(QDialog, Ui_OcrQueueOptionsDialog):
|
||||
iccOptionsChanged = Signal(int)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(OcrQueueOptionsDialog, self).__init__(parent)
|
||||
self.setupUi(self)
|
||||
|
||||
self.iccOptionButtonGroup = QButtonGroup(self)
|
||||
self.iccOptionButtonGroup.buttonToggled.connect(
|
||||
lambda: self.iccOptionsChanged.emit(self.iccOptionButtonGroup.checkedId())
|
||||
)
|
||||
self.iccOptionButtonGroup.addButton(self.iccUseQtRadioButton, 0)
|
||||
self.iccOptionButtonGroup.addButton(self.iccUsePILRadioButton, 1)
|
||||
self.iccOptionButtonGroup.addButton(self.iccTryFixRadioButton, 2)
|
||||
|
||||
self.scoreDateSourceButtonGroup = QButtonGroup(self)
|
||||
self.scoreDateSourceButtonGroup.addButton(
|
||||
self.dateUseCreationDateRadioButton, 0
|
||||
)
|
||||
self.scoreDateSourceButtonGroup.addButton(self.dateUseModifyDateRadioButton, 1)
|
||||
self.scoreDateSourceButtonGroup.buttonClicked.connect(
|
||||
self.on_scoreDateSourceButtonGroup_buttonClicked
|
||||
)
|
||||
|
||||
self.settings = Settings()
|
||||
self.settings.updated.connect(self.syncCheckboxesFromSettings)
|
||||
self.syncCheckboxesFromSettings()
|
||||
|
||||
def syncCheckboxesFromSettings(self):
|
||||
scoreDateSource = self.settings.scoreDateSource()
|
||||
if scoreDateSource == "lastModified":
|
||||
self.dateUseModifyDateRadioButton.setChecked(True)
|
||||
else:
|
||||
self.dateUseCreationDateRadioButton.setChecked(True)
|
||||
|
||||
def on_scoreDateSourceButtonGroup_buttonClicked(self, button):
|
||||
buttonId = self.scoreDateSourceButtonGroup.id(button)
|
||||
if buttonId == 1:
|
||||
self.settings.setScoreDateSource("lastModified")
|
||||
else:
|
||||
self.settings.setScoreDateSource("birthTime")
|
@ -70,12 +70,12 @@
|
||||
<translation>Continue</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../startup/databaseChecker.py" line="117"/>
|
||||
<location filename="../../startup/databaseChecker.py" line="122"/>
|
||||
<source>dialog.tryInitExistingDatabase</source>
|
||||
<translation>The existing database doesn't seem to be initialized properly, try initialize again?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../startup/databaseChecker.py" line="133"/>
|
||||
<location filename="../../startup/databaseChecker.py" line="138"/>
|
||||
<source>dialog.confirmNewDatabase</source>
|
||||
<translation>Database file does not exist. Create now?</translation>
|
||||
</message>
|
||||
@ -224,85 +224,118 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="28"/>
|
||||
<source>iccOptionsGroupBox</source>
|
||||
<translation>ICC Profile Options</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="34"/>
|
||||
<source>icc.useQt</source>
|
||||
<translation>Use Qt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="41"/>
|
||||
<source>icc.usePIL</source>
|
||||
<translation>Use PIL</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="51"/>
|
||||
<source>icc.tryFix</source>
|
||||
<translation>Try fix</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="61"/>
|
||||
<source>queue.addImageButton</source>
|
||||
<translation>Add Image</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="71"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="38"/>
|
||||
<source>queue.removeSelected</source>
|
||||
<translation>Remove Selected</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="81"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="48"/>
|
||||
<source>queue.removeAll</source>
|
||||
<translation>Remove All</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="101"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="68"/>
|
||||
<source>queue.optionsButton</source>
|
||||
<translation>Options</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="75"/>
|
||||
<source>queue.startOcrButton</source>
|
||||
<translation>Start OCR</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="153"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="127"/>
|
||||
<source>results</source>
|
||||
<translation>Results</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="162"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="136"/>
|
||||
<source>results.acceptSelectedButton</source>
|
||||
<translation>Accept Selected</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="169"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="143"/>
|
||||
<source>results.acceptAllButton</source>
|
||||
<translation>Accept All</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="189"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="163"/>
|
||||
<source>results.ignoreValidate</source>
|
||||
<translation>Ignore
|
||||
validation</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>OcrQueueOptionsDialog</name>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="14"/>
|
||||
<source>OCR Options</source>
|
||||
<translation>OCR Options</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="22"/>
|
||||
<source>iccOptionsGroupBox</source>
|
||||
<translation>ICC Profile Options</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="28"/>
|
||||
<source>icc.useQt</source>
|
||||
<translation>Use Qt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="35"/>
|
||||
<source>icc.usePIL</source>
|
||||
<translation>Use PIL</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="45"/>
|
||||
<source>icc.tryFix</source>
|
||||
<translation>Try fix</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="55"/>
|
||||
<source>dateOptionsGroupBox</source>
|
||||
<translation>Date Source</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="64"/>
|
||||
<source>date.readFromExif</source>
|
||||
<translation>Read from image EXIF</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="74"/>
|
||||
<source>date.useCreationDate</source>
|
||||
<translation>File creation time</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="84"/>
|
||||
<source>date.useModifyDate</source>
|
||||
<translation>File last modification time</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>OcrTableModel</name>
|
||||
<message>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="347"/>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="348"/>
|
||||
<source>horizontalHeader.title.select</source>
|
||||
<translation>Select</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="348"/>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="351"/>
|
||||
<source>horizontalHeader.title.imagePreview</source>
|
||||
<translation>Image Preview</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="349"/>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="352"/>
|
||||
<source>horizontalHeader.title.chart</source>
|
||||
<translation>Chart</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="350"/>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="353"/>
|
||||
<source>horizontalHeader.title.score</source>
|
||||
<translation>Score</translation>
|
||||
</message>
|
||||
|
@ -70,12 +70,12 @@
|
||||
<translation>继续</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../startup/databaseChecker.py" line="117"/>
|
||||
<location filename="../../startup/databaseChecker.py" line="122"/>
|
||||
<source>dialog.tryInitExistingDatabase</source>
|
||||
<translation>现有的数据库似乎没有正确初始化,是否尝试再次初始化?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../startup/databaseChecker.py" line="133"/>
|
||||
<location filename="../../startup/databaseChecker.py" line="138"/>
|
||||
<source>dialog.confirmNewDatabase</source>
|
||||
<translation>数据库文件不存在,是否创建?</translation>
|
||||
</message>
|
||||
@ -224,84 +224,117 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="28"/>
|
||||
<source>iccOptionsGroupBox</source>
|
||||
<translation>ICC 文件选项</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="34"/>
|
||||
<source>icc.useQt</source>
|
||||
<translation>使用 Qt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="41"/>
|
||||
<source>icc.usePIL</source>
|
||||
<translation>使用 PIL</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="51"/>
|
||||
<source>icc.tryFix</source>
|
||||
<translation>尝试修复</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="61"/>
|
||||
<source>queue.addImageButton</source>
|
||||
<translation>添加图像文件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="71"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="38"/>
|
||||
<source>queue.removeSelected</source>
|
||||
<translation>移除选中</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="81"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="48"/>
|
||||
<source>queue.removeAll</source>
|
||||
<translation>移除所有</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="101"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="68"/>
|
||||
<source>queue.optionsButton</source>
|
||||
<translation>选项</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="75"/>
|
||||
<source>queue.startOcrButton</source>
|
||||
<translation>开始 OCR</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="153"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="127"/>
|
||||
<source>results</source>
|
||||
<translation>结果</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="162"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="136"/>
|
||||
<source>results.acceptSelectedButton</source>
|
||||
<translation>提交选中</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="169"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="143"/>
|
||||
<source>results.acceptAllButton</source>
|
||||
<translation>提交所有</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="189"/>
|
||||
<location filename="../../designer/components/ocrQueue.ui" line="163"/>
|
||||
<source>results.ignoreValidate</source>
|
||||
<translation>忽略验证</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>OcrQueueOptionsDialog</name>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="14"/>
|
||||
<source>OCR Options</source>
|
||||
<translation>OCR 选项</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="22"/>
|
||||
<source>iccOptionsGroupBox</source>
|
||||
<translation>ICC 文件选项</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="28"/>
|
||||
<source>icc.useQt</source>
|
||||
<translation>使用 Qt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="35"/>
|
||||
<source>icc.usePIL</source>
|
||||
<translation>使用 PIL</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="45"/>
|
||||
<source>icc.tryFix</source>
|
||||
<translation>尝试修复</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="55"/>
|
||||
<source>dateOptionsGroupBox</source>
|
||||
<translation>日期来源</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="64"/>
|
||||
<source>date.readFromExif</source>
|
||||
<translation>从 EXIF 读取</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="74"/>
|
||||
<source>date.useCreationDate</source>
|
||||
<translation>文件创建时间</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../designer/components/ocrQueueOptionsDialog.ui" line="84"/>
|
||||
<source>date.useModifyDate</source>
|
||||
<translation>文件最后修改时间</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>OcrTableModel</name>
|
||||
<message>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="347"/>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="348"/>
|
||||
<source>horizontalHeader.title.select</source>
|
||||
<translation>选择</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="348"/>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="351"/>
|
||||
<source>horizontalHeader.title.imagePreview</source>
|
||||
<translation>图像预览</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="349"/>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="352"/>
|
||||
<source>horizontalHeader.title.chart</source>
|
||||
<translation>谱面</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="350"/>
|
||||
<location filename="../../extends/components/ocrQueue.py" line="353"/>
|
||||
<source>horizontalHeader.title.score</source>
|
||||
<translation>分数</translation>
|
||||
</message>
|
||||
|
Loading…
x
Reference in New Issue
Block a user