From 18cd55f439e1764c60f8b33f789a0dd99e6da72a Mon Sep 17 00:00:00 2001 From: kiryl85 Date: Sat, 11 Oct 2025 04:38:41 +0200 Subject: [PATCH] Open metadata editor after doubleclick on source (#1102) --- gui/KCC.ui | 3 +++ kindlecomicconverter/KCC_gui.py | 46 +++++++++++++++++++-------------- kindlecomicconverter/KCC_ui.py | 3 +++ 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/gui/KCC.ui b/gui/KCC.ui index a612533..b2b1c35 100644 --- a/gui/KCC.ui +++ b/gui/KCC.ui @@ -30,6 +30,9 @@ 150 + + <html><head/><body><p>Double click on source to open it in metadata editor.</p></body></html> + diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index a19cddb..404c67a 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -607,26 +607,26 @@ class KCCGUI(KCC_ui.Ui_mainWindow): GUI.jobList.addItem(fname) GUI.jobList.scrollToBottom() - def selectFileMetaEditor(self): - sname = '' - if QApplication.keyboardModifiers() == Qt.ShiftModifier: - dname = QFileDialog.getExistingDirectory(MW, 'Select directory', self.lastPath) - if dname != '': - sname = os.path.join(dname, 'ComicInfo.xml') - self.lastPath = os.path.abspath(sname) - else: - if self.sevenzip: - fname = QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath, - 'Comic (*.cbz *.cbr *.cb7)') + def selectFileMetaEditor(self, sname): + if not sname: + if QApplication.keyboardModifiers() == Qt.ShiftModifier: + dname = QFileDialog.getExistingDirectory(MW, 'Select directory', self.lastPath) + if dname != '': + sname = os.path.join(dname, 'ComicInfo.xml') + self.lastPath = os.path.dirname(sname) else: - fname = [''] - self.showDialog("Editor is disabled due to a lack of 7z.", 'error') - self.addMessage('Install 7z (link)' - ' to enable metadata editing.', 'warning') - if fname[0] != '': - sname = fname[0] - self.lastPath = os.path.abspath(os.path.join(sname, os.pardir)) - if sname != '': + if self.sevenzip: + fname = QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath, + 'Comic (*.cbz *.cbr *.cb7)') + else: + fname = [''] + self.showDialog("Editor is disabled due to a lack of 7z.", 'error') + self.addMessage('Install 7z (link)' + ' 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: self.editor.loadData(sname) except Exception as err: @@ -767,6 +767,13 @@ class KCCGUI(KCC_ui.Ui_mainWindow): if value: 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): valueRaw = int(5 * round(float(value) / 5)) value = '%.2f' % (float(valueRaw) / 100) @@ -1282,6 +1289,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow): GUI.titleEdit.textChanged.connect(self.toggletitleEdit) GUI.fileFusionBox.stateChanged.connect(self.togglefileFusionBox) GUI.metadataTitleBox.stateChanged.connect(self.togglemetadataTitleBox) + GUI.jobList.itemDoubleClicked.connect(self.editSourceMetadata) MW.progressBarTick.connect(self.updateProgressbar) MW.modeConvert.connect(self.modeConvert) MW.addMessage.connect(self.addMessage) diff --git a/kindlecomicconverter/KCC_ui.py b/kindlecomicconverter/KCC_ui.py index 7db3e4f..1eb8c92 100644 --- a/kindlecomicconverter/KCC_ui.py +++ b/kindlecomicconverter/KCC_ui.py @@ -500,6 +500,9 @@ class Ui_mainWindow(object): def retranslateUi(self, mainWindow): mainWindow.setWindowTitle(QCoreApplication.translate("mainWindow", u"Kindle Comic Converter", None)) +#if QT_CONFIG(tooltip) + self.jobList.setToolTip(QCoreApplication.translate("mainWindow", u"

Double click on source to open metadata editor.

", None)) +#endif // QT_CONFIG(tooltip) #if QT_CONFIG(tooltip) self.editorButton.setToolTip(QCoreApplication.translate("mainWindow", u"

Shift+Click to edit directory.

", None)) #endif // QT_CONFIG(tooltip)