From 73aded94f3739296246fbb424ba20920ed3f7942 Mon Sep 17 00:00:00 2001 From: "beville@gmail.com" Date: Tue, 20 Nov 2012 22:38:10 +0000 Subject: [PATCH] Added some check-box dialog pop-ups git-svn-id: http://comictagger.googlecode.com/svn/trunk@76 6c5673fe-1810-88d6-992b-cd32ca31540c --- settings.py | 23 +++++++++++++++++++---- taggerwindow.py | 46 +++++++++++++++++++++++++++++++--------------- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/settings.py b/settings.py index 6fa4153..ee1e3a6 100644 --- a/settings.py +++ b/settings.py @@ -31,9 +31,10 @@ class ComicTaggerSettings: settings_file = "" folder = "" + # General Settings rar_exe_path = "" unrar_exe_path = "" - cv_api_key = "" + allow_cbi_in_rar = True # automatic settings last_selected_data_style = 0 @@ -47,6 +48,11 @@ class ComicTaggerSettings: id_length_delta_thresh = 5 id_publisher_blacklist = "Panini Comics, Abril, Scholastic Book Services" + # Show/ask dialog flags + ask_about_cbi_in_rar = True + show_disclaimer = True + + @staticmethod def getSettingsFolder(): if platform.system() == "Windows": @@ -109,7 +115,6 @@ class ComicTaggerSettings: self.rar_exe_path = self.config.get( 'settings', 'rar_exe_path' ) self.unrar_exe_path = self.config.get( 'settings', 'unrar_exe_path' ) - #self.cv_api_key = self.config.get( 'settings', 'cv_api_key' ) self.last_selected_data_style = self.config.getint( 'auto', 'last_selected_data_style' ) self.last_opened_folder = self.config.get( 'auto', 'last_opened_folder' ) @@ -126,13 +131,17 @@ class ComicTaggerSettings: self.id_length_delta_thresh = self.config.getint( 'identifier', 'id_length_delta_thresh' ) if self.config.has_option('identifier', 'id_publisher_blacklist'): self.id_publisher_blacklist = self.config.get( 'identifier', 'id_publisher_blacklist' ) + + if self.config.has_option('dialogflags', 'ask_about_cbi_in_rar'): + self.ask_about_cbi_in_rar = self.config.getboolean( 'dialogflags', 'ask_about_cbi_in_rar' ) + if self.config.has_option('dialogflags', 'show_disclaimer'): + self.show_disclaimer = self.config.getboolean( 'dialogflags', 'show_disclaimer' ) def save( self ): if not self.config.has_section( 'settings' ): self.config.add_section( 'settings' ) - #self.config.set( 'settings', 'cv_api_key', self.cv_api_key ) self.config.set( 'settings', 'rar_exe_path', self.rar_exe_path ) self.config.set( 'settings', 'unrar_exe_path', self.unrar_exe_path ) @@ -151,7 +160,13 @@ class ComicTaggerSettings: self.config.set( 'identifier', 'id_length_delta_thresh', self.id_length_delta_thresh ) self.config.set( 'identifier', 'id_publisher_blacklist', self.id_publisher_blacklist ) - + + if not self.config.has_section( 'dialogflags' ): + self.config.add_section( 'dialogflags' ) + + self.config.set( 'dialogflags', 'ask_about_cbi_in_rar', self.ask_about_cbi_in_rar ) + self.config.set( 'dialogflags', 'show_disclaimer', self.show_disclaimer ) + with open( self.settings_file, 'wb') as configfile: self.config.write(configfile) diff --git a/taggerwindow.py b/taggerwindow.py index e8ef8e9..2c66fb4 100644 --- a/taggerwindow.py +++ b/taggerwindow.py @@ -81,11 +81,10 @@ class TaggerWindow( QtGui.QMainWindow): # 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) + #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.setWindowIcon(QtGui.QIcon(os.path.join(ComicTaggerSettings.baseDir(), 'graphics/app.png' ))) @@ -135,6 +134,16 @@ class TaggerWindow( QtGui.QMainWindow): if filename is not None: self.openArchive( filename ) + if self.settings.show_disclaimer: + checked = OptionalMessageDialog.msg( self, "Disclaimer", + "Thanks for trying Comic Tagger!\n\n" + + "Be aware that is beta-level software, and the developers\n" + + "of this program can take no responsibility for any loss of data due\n" + + "to its use.\n\n" + + "That said, have fun!\n", + ) + self.settings.show_disclaimer = not checked + def sigint_handler(self, *args): # defer the actual close in the app loop thread QtCore.QTimer.singleShot(200, self.close) @@ -718,13 +727,6 @@ class TaggerWindow( QtGui.QMainWindow): def queryOnline(self, autoselect=False): - #if self.settings.cv_api_key == "": - # QtGui.QMessageBox.warning(self, self.tr("Online Search"), - # self.tr("You need an API key from ComicVine to search online. " + - # "Go to settings and enter it.")) - # return - - issue_number = str(self.leIssueNum.text()).strip() if autoselect and issue_number == "": @@ -742,20 +744,19 @@ class TaggerWindow( QtGui.QMainWindow): if year == "": year = None - selector = VolumeSelectionWindow( self, self.settings.cv_api_key, series_name, issue_number, year, self.comic_archive, self.settings, autoselect ) + selector = VolumeSelectionWindow( self, series_name, issue_number, year, self.comic_archive, self.settings, autoselect ) title = "Search: '" + series_name + "' - " selector.setWindowTitle( title + "Select Series") selector.setModal(True) selector.exec_() - if selector.result(): #we should now have a volume ID QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) - comicVine = ComicVineTalker( self.settings.cv_api_key ) + comicVine = ComicVineTalker( ) self.metadata = comicVine.fetchIssueData( selector.volume_id, selector.issue_number ) # Now push the right data into the edit controls @@ -767,6 +768,21 @@ class TaggerWindow( QtGui.QMainWindow): if ( self.metadata is not None and self.comic_archive is not None): + if self.comic_archive.isRar() and self.data_style == MetaDataStyle.CBI: + if self.settings.ask_about_cbi_in_rar: + answered_yes, checked = OptionalMessageDialog.question( self, "RAR and ComicBookLover", + "You are about to write a CBL tag block to a RAR archive!\n\n" + + "While technically possible, no known reader can read those tags from RAR\n" + + "yet. If you would like this feature from ComicBookLover, please go their\n" + + "forums and add a feature request!\n\n" + + "http://forums.comicbooklover.com/categories/ipad-features\n\n" + + "Do you want to continue with the save?\n", + ) + self.settings.ask_about_cbi_in_rar = not checked + if not answered_yes: + return + + reply = QtGui.QMessageBox.question(self, self.tr("Save Tags"), self.tr("Are you sure you wish to save " + MetaDataStyle.name[self.data_style] + " tags to this archive?"),