diff --git a/comictaggerlib/options.py b/comictaggerlib/options.py
index fda12e6..3cc619a 100644
--- a/comictaggerlib/options.py
+++ b/comictaggerlib/options.py
@@ -251,7 +251,12 @@ For more help visit the wiki at: http://code.google.com/p/comictagger/
self.no_overwrite = True
if o == "--version":
print "ComicTagger {0}: Copyright (c) 2012-2013 Anthony Beville".format(ctversion.version)
- print "Distributed under Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)"
+ print "Distributed under Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)"
+ new_version = utils.getLatestVersion()
+ if new_version is not None:
+ print "----------------------------------------"
+ print "New version available online: {0}".format(new_version)
+ print "----------------------------------------"
sys.exit(0)
if o in ("-t", "--type"):
if a.lower() == "cr":
diff --git a/comictaggerlib/settings.py b/comictaggerlib/settings.py
index 2a54ab5..f5b1b75 100644
--- a/comictaggerlib/settings.py
+++ b/comictaggerlib/settings.py
@@ -67,6 +67,7 @@ class ComicTaggerSettings:
self.rar_exe_path = ""
self.unrar_exe_path = ""
self.allow_cbi_in_rar = True
+ self.check_for_new_version = True
# automatic settings
self.last_selected_save_data_style = 0
@@ -86,6 +87,7 @@ class ComicTaggerSettings:
# Show/ask dialog flags
self.ask_about_cbi_in_rar = True
self.show_disclaimer = True
+ self.dont_notify_about_this_version = ""
# Comic Vine settings
self.use_series_start_as_volume = False
@@ -159,11 +161,20 @@ class ComicTaggerSettings:
self.__init__()
def load(self):
-
- self.config.readfp(codecs.open(self.settings_file, "r", "utf8"))
+
+ def readline_generator(f):
+ line = f.readline()
+ while line:
+ yield line
+ line = f.readline()
+
+ #self.config.readfp(codecs.open(self.settings_file, "r", "utf8"))
+ self.config.read_file(readline_generator(codecs.open(self.settings_file, "r", "utf8")))
self.rar_exe_path = self.config.get( 'settings', 'rar_exe_path' )
self.unrar_exe_path = self.config.get( 'settings', 'unrar_exe_path' )
+ if self.config.has_option('settings', 'check_for_new_version'):
+ self.check_for_new_version = self.config.getboolean( 'settings', 'check_for_new_version' )
if self.config.has_option('auto', 'last_selected_load_data_style'):
self.last_selected_load_data_style = self.config.getint( 'auto', 'last_selected_load_data_style' )
@@ -193,7 +204,9 @@ class ComicTaggerSettings:
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' )
-
+ if self.config.has_option('dialogflags', 'dont_notify_about_this_version'):
+ self.dont_notify_about_this_version = self.config.get( 'dialogflags', 'dont_notify_about_this_version' )
+
if self.config.has_option('comicvine', 'use_series_start_as_volume'):
self.use_series_start_as_volume = self.config.getboolean( 'comicvine', 'use_series_start_as_volume' )
@@ -227,7 +240,8 @@ class ComicTaggerSettings:
if not self.config.has_section( 'settings' ):
self.config.add_section( 'settings' )
-
+
+ self.config.set( 'settings', 'check_for_new_version', self.check_for_new_version )
self.config.set( 'settings', 'rar_exe_path', self.rar_exe_path )
self.config.set( 'settings', 'unrar_exe_path', self.unrar_exe_path )
@@ -255,7 +269,8 @@ class ComicTaggerSettings:
self.config.set( 'dialogflags', 'ask_about_cbi_in_rar', self.ask_about_cbi_in_rar )
self.config.set( 'dialogflags', 'show_disclaimer', self.show_disclaimer )
-
+ self.config.set( 'dialogflags', 'dont_notify_about_this_version', self.dont_notify_about_this_version )
+
if not self.config.has_section( 'comicvine' ):
self.config.add_section( 'comicvine' )
diff --git a/comictaggerlib/settingswindow.py b/comictaggerlib/settingswindow.py
index 54e03ee..3a37990 100644
--- a/comictaggerlib/settingswindow.py
+++ b/comictaggerlib/settingswindow.py
@@ -119,6 +119,9 @@ class SettingsWindow(QtGui.QDialog):
self.leNameLengthDeltaThresh.setText( str(self.settings.id_length_delta_thresh) )
self.tePublisherBlacklist.setPlainText( self.settings.id_publisher_blacklist )
+ if self.settings.check_for_new_version:
+ self.cbxCheckForNewVersion.setCheckState( QtCore.Qt.Checked)
+
if self.settings.use_series_start_as_volume:
self.cbxUseSeriesStartAsVolume.setCheckState( QtCore.Qt.Checked)
@@ -162,6 +165,8 @@ class SettingsWindow(QtGui.QDialog):
if not str(self.leIssueNumPadding.text()).isdigit():
self.leIssueNumPadding.setText("0")
+
+ self.settings.check_for_new_version = self.cbxCheckForNewVersion.isChecked()
self.settings.id_length_delta_thresh = int(self.leNameLengthDeltaThresh.text())
self.settings.id_publisher_blacklist = str(self.tePublisherBlacklist.toPlainText())
@@ -185,7 +190,6 @@ class SettingsWindow(QtGui.QDialog):
self.settings.save()
QtGui.QDialog.accept(self)
-
def selectRar( self ):
self.selectFile( self.leRarExePath, "RAR" )
diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py
index 2ae59a2..a80fd5f 100644
--- a/comictaggerlib/taggerwindow.py
+++ b/comictaggerlib/taggerwindow.py
@@ -203,7 +203,10 @@ class TaggerWindow( QtGui.QMainWindow):
"""
)
self.settings.show_disclaimer = not checked
-
+
+ if self.settings.check_for_new_version:
+ QtCore.QTimer.singleShot(1, self.checkLatestVersionOnline)
+
def sigint_handler(self, *args):
# defer the actual close in the app loop thread
QtCore.QTimer.singleShot(200, self.close)
@@ -1835,4 +1838,21 @@ class TaggerWindow( QtGui.QMainWindow):
def tabChanged( self, idx ):
if idx == 0:
self.splitterMovedEvent( 0, 0)
+
+ def checkLatestVersionOnline( self ):
+ new_version = utils.getLatestVersion()
+ if new_version is None:
+ return
+
+ if ( new_version != self.version and
+ new_version != self.settings.dont_notify_about_this_version):
+ website = "http://code.google.com/p/comictagger"
+ checked = OptionalMessageDialog.msg( self, "New version available!",
+ "New version ({0}) available!
(You are currently running {1})
".format( new_version, self.version) +
+ "Visit {0} for more info.
".format(website),
+ QtCore.Qt.Unchecked,
+ "Don't tell me about this version again")
+ if checked:
+ self.settings.dont_notify_about_this_version = new_version
+
diff --git a/comictaggerlib/ui/settingswindow.ui b/comictaggerlib/ui/settingswindow.ui
index 4eb4d8a..35b447b 100644
--- a/comictaggerlib/ui/settingswindow.ui
+++ b/comictaggerlib/ui/settingswindow.ui
@@ -35,7 +35,7 @@
- -
+
-
@@ -48,7 +48,7 @@
- -
+
-
@@ -64,7 +64,7 @@
- -
+
-
@@ -77,7 +77,7 @@
- -
+
-
@@ -93,6 +93,13 @@
+ -
+
+
+ Check for new version on startup
+
+
+
diff --git a/comictaggerlib/utils.py b/comictaggerlib/utils.py
index 75d960a..8d1f042 100644
--- a/comictaggerlib/utils.py
+++ b/comictaggerlib/utils.py
@@ -25,6 +25,7 @@ import re
import platform
import locale
import codecs
+import urllib,urllib2
class UtilsVars:
already_fixed_encoding = False
@@ -626,3 +627,15 @@ if qt_available:
vpos = ( main_window_size.height() - window.height() ) / 2
# And the move call repositions the window
window.move(hpos + main_window_size.left(), vpos + main_window_size.top())
+
+ def getLatestVersion():
+ try:
+ resp = urllib2.urlopen( "https://comictagger.googlecode.com/svn/trunk/current_version.txt" )
+ new_version = resp.read()
+ except Exception as e:
+ return None
+
+ if new_version is None or new_version == "":
+ return None
+
+ return new_version.strip()
\ No newline at end of file