From cfca394bcbb5d8b0bb2b1432cc5700c41ec93763 Mon Sep 17 00:00:00 2001 From: "beville@gmail.com" Date: Fri, 18 Jan 2013 00:52:42 +0000 Subject: [PATCH] More work on managing mutiple files in the GUI git-svn-id: http://comictagger.googlecode.com/svn/trunk@310 6c5673fe-1810-88d6-992b-cd32ca31540c --- comictagger.py | 7 ++-- fileselectionlist.py | 33 ++++++----------- taggerwindow.py | 84 +++++++++++++++++++++++++------------------- taggerwindow.ui | 67 +++++++++++++++++++++++++++++++---- 4 files changed, 120 insertions(+), 71 deletions(-) diff --git a/comictagger.py b/comictagger.py index aa6e943..1a745af 100755 --- a/comictagger.py +++ b/comictagger.py @@ -486,11 +486,8 @@ def main(): splash.raise_() app.processEvents() - try: - fname = None - if opts.filename is not None: - fname = opts.filename.decode(filename_encoding, 'replace') - tagger_window = TaggerWindow( fname, settings ) + try: + tagger_window = TaggerWindow( opts.file_list, settings ) tagger_window.show() if platform.system() != "Linux": diff --git a/fileselectionlist.py b/fileselectionlist.py index b588b72..86ae001 100644 --- a/fileselectionlist.py +++ b/fileselectionlist.py @@ -69,7 +69,6 @@ class FileSelectionList(QWidget): #self.twList = FileTableWidget( self ) #gridlayout = QGridLayout( self ) #gridlayout.addWidget( self.twList ) - self.setAcceptDrops(True) self.twList.itemSelectionChanged.connect( self.itemSelectionChangedCB ) @@ -111,25 +110,6 @@ class FileSelectionList(QWidget): self.twList.selectRow(0) else: self.listCleared.emit() - - - def dragEnterEvent(self, event): - self.droppedFiles = None - if event.mimeData().hasUrls(): - - # walk through the URL list and build a file list - for url in event.mimeData().urls(): - if url.isValid() and url.scheme() == "file": - if self.droppedFiles is None: - self.droppedFiles = [] - self.droppedFiles.append(url.toLocalFile()) - - if self.droppedFiles is not None: - event.accept() - - def dropEvent(self, event): - self.addPathList( self.droppedFiles) - event.accept() def addPathList( self, pathlist ): filelist = [] @@ -148,15 +128,21 @@ class FileSelectionList(QWidget): progdialog.setWindowTitle( "Adding Files" ) progdialog.setWindowModality(Qt.WindowModal) + firstAdded = None self.twList.setSortingEnabled(False) for idx,f in enumerate(filelist): QCoreApplication.processEvents() if progdialog.wasCanceled(): break progdialog.setValue(idx) - self.addPathItem( f ) - + row = self.addPathItem( f ) + if firstAdded is None and row is not None: + firstAdded = row + progdialog.close() + if firstAdded is not None: + self.twList.selectRow(firstAdded) + self.twList.setSortingEnabled(True) #Maybe set a max size?? @@ -178,7 +164,7 @@ class FileSelectionList(QWidget): #print "processing", path if self.isListDupe(path): - return + return None ca = ComicArchive( path ) if self.settings.rar_exe_path != "": @@ -246,6 +232,7 @@ class FileSelectionList(QWidget): else: item.setData(Qt.UserRole, False) self.twList.setItem(row, 3, item) + return row def itemSelectionChangedCB( self ): idx = self.twList.currentRow() diff --git a/taggerwindow.py b/taggerwindow.py index 0196c81..23aa585 100644 --- a/taggerwindow.py +++ b/taggerwindow.py @@ -82,16 +82,9 @@ class TaggerWindow( QtGui.QMainWindow): appName = "ComicTagger" version = ctversion.version - def __init__(self, filename, settings, parent = None): + def __init__(self, file_list, settings, parent = None): super(TaggerWindow, self).__init__(parent) - # Set up a timer so the interpreter runs every so often - # This helps catch and process SIGINT from console - #self.timer = QtCore.QTimer() - #self.timer.start(500) - #self.timer.timeout.connect(lambda: None) - #signal.signal(signal.SIGINT, self.sigint_handler) - uic.loadUi(os.path.join(ComicTaggerSettings.baseDir(), 'taggerwindow.ui' ), self) self.settings = settings @@ -143,6 +136,10 @@ class TaggerWindow( QtGui.QMainWindow): #TODO set up an RE validator for issueNum that allows # for all sorts of wacky things + + #make sure some editable comboboxes don't take drop actions + self.cbFormat.lineEdit().setAcceptDrops(False) + self.cbMaturityRating.lineEdit().setAcceptDrops(False) # hook up the callbacks self.cbDataStyle.currentIndexChanged.connect(self.setDataStyle) @@ -165,9 +162,9 @@ class TaggerWindow( QtGui.QMainWindow): self.raise_() QtCore.QCoreApplication.processEvents() - if filename is not None: - self.openArchive( filename ) - + if len(file_list) != 0: + self.fileSelectionList.addPathList( file_list ) + if self.settings.show_disclaimer: checked = OptionalMessageDialog.msg( self, "Welcome!", """ @@ -232,6 +229,10 @@ class TaggerWindow( QtGui.QMainWindow): self.actionLoad.setStatusTip( 'Load comic archive' ) self.actionLoad.triggered.connect( self.selectFile ) + #self.actionLoadFolder.setShortcut( 'Ctrl+F' ) + self.actionLoadFolder.setStatusTip( 'Load folder with comic archives' ) + self.actionLoadFolder.triggered.connect( self.selectFolder ) + self.actionWrite_Tags.setShortcut( 'Ctrl+S' ) self.actionWrite_Tags.setStatusTip( 'Save tags to comic archive' ) self.actionWrite_Tags.triggered.connect( self.commitMetadata ) @@ -388,19 +389,26 @@ class TaggerWindow( QtGui.QMainWindow): msgBox.exec_() def dragEnterEvent(self, event): - self.droppedFile=None + self.droppedFiles = None if event.mimeData().hasUrls(): - url=event.mimeData().urls()[0] - if url.isValid(): - if url.scheme()=="file": - self.droppedFile=url.toLocalFile() - event.accept() - + + # walk through the URL list and build a file list + for url in event.mimeData().urls(): + if url.isValid() and url.scheme() == "file": + if self.droppedFiles is None: + self.droppedFiles = [] + self.droppedFiles.append(url.toLocalFile()) + + if self.droppedFiles is not None: + event.accept() + def dropEvent(self, event): if self.dirtyFlagVerification( "Open Archive", "If you open a new archive now, data in the form will be lost. Are you sure?"): - self.openArchive( unicode(self.droppedFile)) - + #self.openArchive( unicode(self.droppedFile)) + self.fileSelectionList.addPathList( self.droppedFiles ) + event.accept() + def openArchive( self, path, explicit_style=None, clear_form=True ): if path is None or path == "": @@ -845,33 +853,37 @@ class TaggerWindow( QtGui.QMainWindow): self.metadata.overlay( new_metadata ) self.metadataToForm() - def selectFile( self ): + def selectFolder( self ): + self.selectFile( folder_mode=True ) + + def selectFile( self , folder_mode = False): dialog = QtGui.QFileDialog(self) - dialog.setFileMode(QtGui.QFileDialog.ExistingFile) + if folder_mode: + dialog.setFileMode(QtGui.QFileDialog.Directory) + else: + dialog.setFileMode(QtGui.QFileDialog.ExistingFiles) + if self.settings.last_opened_folder is not None: dialog.setDirectory( self.settings.last_opened_folder ) #dialog.setFileMode(QtGui.QFileDialog.Directory ) - if platform.system() != "Windows" and utils.which("unrar") is None: - archive_filter = "Comic archive files (*.cbz *.zip)" - else: - archive_filter = "Comic archive files (*.cbz *.zip *.cbr *.rar)" - - filters = [ - archive_filter, - "Any files (*)" - ] - - dialog.setNameFilters(filters) - #dialog.setFilter (self, QString filter) + if not folder_mode: + if platform.system() != "Windows" and utils.which("unrar") is None: + archive_filter = "Comic archive files (*.cbz *.zip)" + else: + archive_filter = "Comic archive files (*.cbz *.zip *.cbr *.rar)" + filters = [ + archive_filter, + "Any files (*)" + ] + dialog.setNameFilters(filters) if (dialog.exec_()): fileList = dialog.selectedFiles() if self.dirtyFlagVerification( "Open Archive", "If you open a new archive now, data in the form will be lost. Are you sure?"): - self.openArchive( unicode(fileList[0]) ) - + self.fileSelectionList.addPathList( fileList ) def autoSelectSearch(self): if self.comic_archive is None: diff --git a/taggerwindow.ui b/taggerwindow.ui index bcd79e2..f8ec243 100644 --- a/taggerwindow.ui +++ b/taggerwindow.ui @@ -254,7 +254,7 @@ true - true + false 0 @@ -544,7 +544,11 @@ - + + + false + + @@ -554,7 +558,11 @@ - + + + false + + @@ -577,6 +585,9 @@ 16777215 + + false + Qt::ImhDigitsOnly @@ -598,6 +609,9 @@ + + false + Qt::ImhDigitsOnly @@ -612,6 +626,9 @@ + + false + Qt::ImhDigitsOnly @@ -638,6 +655,9 @@ 16777215 + + false + Qt::ImhDigitsOnly @@ -923,7 +943,11 @@ - + + + false + + @@ -933,7 +957,11 @@ - + + + false + + @@ -943,7 +971,11 @@ - + + + false + + @@ -966,6 +998,9 @@ 16777215 + + false + @@ -1012,6 +1047,9 @@ 16777215 + + false + @@ -1035,6 +1073,9 @@ 16777215 + + false + @@ -1058,6 +1099,9 @@ 16777215 + + false + @@ -1087,6 +1131,9 @@ 100 + + false + @@ -1119,7 +1166,7 @@ 0 0 968 - 25 + 28 @@ -1150,6 +1197,7 @@ + @@ -1353,6 +1401,11 @@ Apply CBL Transform + + + Open Folder + +