about summary refs log tree commit diff
path: root/kindlecomicconverter/KCC_gui.py
diff options
context:
space:
mode:
authorPaweł Jastrzębski <pawelj@iosphe.re>2017-10-14 17:57:00 +0200
committerPaweł Jastrzębski <pawelj@iosphe.re>2017-10-14 17:57:00 +0200
commit08ed304f8e4c64b7537f188c6e2014e78438976c (patch)
tree9dde4f6c90c154646272812fd772c39faf6debf6 /kindlecomicconverter/KCC_gui.py
parentFixed directory sorting (close #235) (diff)
downloadkcc-08ed304f8e4c64b7537f188c6e2014e78438976c.tar.gz
kcc-08ed304f8e4c64b7537f188c6e2014e78438976c.tar.bz2
kcc-08ed304f8e4c64b7537f188c6e2014e78438976c.zip
Allow metadata editor to embed directories
Diffstat (limited to 'kindlecomicconverter/KCC_gui.py')
-rw-r--r--kindlecomicconverter/KCC_gui.py53
1 files changed, 33 insertions, 20 deletions
diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py
index 9191a49..a98585a 100644
--- a/kindlecomicconverter/KCC_gui.py
+++ b/kindlecomicconverter/KCC_gui.py
@@ -500,28 +500,38 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
                 GUI.jobList.scrollToBottom()
 
     def selectFileMetaEditor(self):
-        if self.UnRAR:
-            if self.sevenza:
-                fname = QtWidgets.QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
-                                                              'Comic (*.cbz *.cbr *.cb7)')
-            else:
-                fname = QtWidgets.QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
-                                                              'Comic (*.cbz *.cbr)')
+        sname = ''
+        if QtWidgets.QApplication.keyboardModifiers() == QtCore.Qt.ShiftModifier:
+            dname = QtWidgets.QFileDialog.getExistingDirectory(MW, 'Select directory', self.lastPath)
+            if dname != '':
+                sname = os.path.join(dname, 'ComicInfo.xml')
+                if sys.platform.startswith('win'):
+                    sname = sname.replace('/', '\\')
+                self.lastPath = os.path.abspath(sname)
         else:
-            if self.sevenza:
-                fname = QtWidgets.QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
-                                                              'Comic (*.cbz *.cb7)')
-            else:
-                fname = QtWidgets.QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
-                                                              'Comic (*.cbz)')
-        if fname[0] != '':
-            if sys.platform.startswith('win'):
-                fname = fname[0].replace('/', '\\')
+            if self.UnRAR:
+                if self.sevenza:
+                    fname = QtWidgets.QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
+                                                                  'Comic (*.cbz *.cbr *.cb7)')
+                else:
+                    fname = QtWidgets.QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
+                                                                  'Comic (*.cbz *.cbr)')
             else:
-                fname = fname[0]
-            self.lastPath = os.path.abspath(os.path.join(fname, os.pardir))
+                if self.sevenza:
+                    fname = QtWidgets.QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
+                                                                  'Comic (*.cbz *.cb7)')
+                else:
+                    fname = QtWidgets.QFileDialog.getOpenFileName(MW, 'Select file', self.lastPath,
+                                                                  'Comic (*.cbz)')
+            if fname[0] != '':
+                if sys.platform.startswith('win'):
+                    sname = fname[0].replace('/', '\\')
+                else:
+                    sname = fname[0]
+                self.lastPath = os.path.abspath(os.path.join(sname, os.pardir))
+        if sname != '':
             try:
-                self.editor.loadData(fname)
+                self.editor.loadData(sname)
             except Exception as err:
                 _, _, traceback = sys.exc_info()
                 GUI.sentry.captureException()
@@ -1109,7 +1119,10 @@ class KCCGUI_MetaEditor(KCC_ui_editor.Ui_editorDialog):
         for field in (self.writerLine, self.pencillerLine, self.inkerLine, self.coloristLine):
             field.setText(', '.join(self.parser.data[field.objectName().capitalize()[:-4] + 's']))
         if self.seriesLine.text() == '':
-            self.seriesLine.setText(file.split('\\')[-1].split('/')[-1].split('.')[0])
+            if file.endswith('.xml'):
+                self.seriesLine.setText(file.split('\\')[-2])
+            else:
+                self.seriesLine.setText(file.split('\\')[-1].split('/')[-1].split('.')[0])
 
     def saveData(self):
         for field in (self.volumeLine, self.numberLine, self.muidLine):