1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-15 02:36:44 +00:00

Open metadata editor after doubleclick on source (#1102)

This commit is contained in:
kiryl85
2025-10-11 04:38:41 +02:00
committed by GitHub
parent 7ce4438886
commit 18cd55f439
3 changed files with 33 additions and 19 deletions

View File

@@ -30,6 +30,9 @@
<height>150</height> <height>150</height>
</size> </size>
</property> </property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Double click on source to open it in metadata editor.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
</property> </property>

View File

@@ -607,26 +607,26 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.jobList.addItem(fname) GUI.jobList.addItem(fname)
GUI.jobList.scrollToBottom() GUI.jobList.scrollToBottom()
def selectFileMetaEditor(self): def selectFileMetaEditor(self, sname):
sname = '' if not sname:
if QApplication.keyboardModifiers() == Qt.ShiftModifier: if QApplication.keyboardModifiers() == Qt.ShiftModifier:
dname = QFileDialog.getExistingDirectory(MW, 'Select directory', self.lastPath) dname = QFileDialog.getExistingDirectory(MW, 'Select directory', self.lastPath)
if dname != '': if dname != '':
sname = os.path.join(dname, 'ComicInfo.xml') sname = os.path.join(dname, 'ComicInfo.xml')
self.lastPath = os.path.abspath(sname) self.lastPath = os.path.dirname(sname)
else:
if self.sevenzip:
fname = QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
'Comic (*.cbz *.cbr *.cb7)')
else: else:
fname = [''] if self.sevenzip:
self.showDialog("Editor is disabled due to a lack of 7z.", 'error') fname = QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
self.addMessage('<a href="https://github.com/ciromattia/kcc#7-zip">Install 7z (link)</a>' 'Comic (*.cbz *.cbr *.cb7)')
' to enable metadata editing.', 'warning') else:
if fname[0] != '': fname = ['']
sname = fname[0] self.showDialog("Editor is disabled due to a lack of 7z.", 'error')
self.lastPath = os.path.abspath(os.path.join(sname, os.pardir)) self.addMessage('<a href="https://github.com/ciromattia/kcc#7-zip">Install 7z (link)</a>'
if sname != '': ' to enable metadata editing.', 'warning')
if fname[0] != '':
sname = fname[0]
self.lastPath = os.path.abspath(os.path.join(sname, os.pardir))
if sname:
try: try:
self.editor.loadData(sname) self.editor.loadData(sname)
except Exception as err: except Exception as err:
@@ -767,6 +767,13 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
if value: if value:
GUI.titleEdit.setText(None) GUI.titleEdit.setText(None)
def editSourceMetadata(self, item):
if item.icon().isNull():
sname = item.text()
if os.path.isdir(sname):
sname = os.path.join(sname, "ComicInfo.xml")
self.selectFileMetaEditor(sname)
def changeGamma(self, value): def changeGamma(self, value):
valueRaw = int(5 * round(float(value) / 5)) valueRaw = int(5 * round(float(value) / 5))
value = '%.2f' % (float(valueRaw) / 100) value = '%.2f' % (float(valueRaw) / 100)
@@ -1282,6 +1289,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.titleEdit.textChanged.connect(self.toggletitleEdit) GUI.titleEdit.textChanged.connect(self.toggletitleEdit)
GUI.fileFusionBox.stateChanged.connect(self.togglefileFusionBox) GUI.fileFusionBox.stateChanged.connect(self.togglefileFusionBox)
GUI.metadataTitleBox.stateChanged.connect(self.togglemetadataTitleBox) GUI.metadataTitleBox.stateChanged.connect(self.togglemetadataTitleBox)
GUI.jobList.itemDoubleClicked.connect(self.editSourceMetadata)
MW.progressBarTick.connect(self.updateProgressbar) MW.progressBarTick.connect(self.updateProgressbar)
MW.modeConvert.connect(self.modeConvert) MW.modeConvert.connect(self.modeConvert)
MW.addMessage.connect(self.addMessage) MW.addMessage.connect(self.addMessage)

View File

@@ -500,6 +500,9 @@ class Ui_mainWindow(object):
def retranslateUi(self, mainWindow): def retranslateUi(self, mainWindow):
mainWindow.setWindowTitle(QCoreApplication.translate("mainWindow", u"Kindle Comic Converter", None)) mainWindow.setWindowTitle(QCoreApplication.translate("mainWindow", u"Kindle Comic Converter", None))
#if QT_CONFIG(tooltip)
self.jobList.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p>Double click on source to open metadata editor.</p></body></html>", None))
#endif // QT_CONFIG(tooltip)
#if QT_CONFIG(tooltip) #if QT_CONFIG(tooltip)
self.editorButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Shift+Click to edit directory.</p></body></html>", None)) self.editorButton.setToolTip(QCoreApplication.translate("mainWindow", u"<html><head/><body><p style='white-space:pre'>Shift+Click to edit directory.</p></body></html>", None))
#endif // QT_CONFIG(tooltip) #endif // QT_CONFIG(tooltip)