1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +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>
</size>
</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">
<string notr="true"/>
</property>

View File

@@ -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('<a href="https://github.com/ciromattia/kcc#7-zip">Install 7z (link)</a>'
' 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('<a href="https://github.com/ciromattia/kcc#7-zip">Install 7z (link)</a>'
' 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)

View File

@@ -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"<html><head/><body><p>Double click on source to open metadata editor.</p></body></html>", None))
#endif // 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))
#endif // QT_CONFIG(tooltip)