forked from openlp/openlp
Fix start up thread timer
This commit is contained in:
parent
f8fc418925
commit
f5f8c1ce08
@ -154,7 +154,8 @@ class OpenLP(OpenLPMixin, QtGui.QApplication):
|
|||||||
self.main_window.first_time()
|
self.main_window.first_time()
|
||||||
update_check = Settings().value('core/update check')
|
update_check = Settings().value('core/update check')
|
||||||
if update_check:
|
if update_check:
|
||||||
VersionThread(self.main_window).start()
|
version = VersionThread(self.main_window)
|
||||||
|
version.start()
|
||||||
self.main_window.is_display_blank()
|
self.main_window.is_display_blank()
|
||||||
self.main_window.app_startup()
|
self.main_window.app_startup()
|
||||||
return self.exec_()
|
return self.exec_()
|
||||||
|
@ -490,7 +490,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
self.header_section = 'SettingsImport'
|
self.header_section = 'SettingsImport'
|
||||||
self.recent_files = []
|
self.recent_files = []
|
||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.timer_version_id = 0
|
|
||||||
self.new_data_path = None
|
self.new_data_path = None
|
||||||
self.copy_data = False
|
self.copy_data = False
|
||||||
Settings().set_up_default_values()
|
Settings().set_up_default_values()
|
||||||
@ -536,7 +535,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
self.application.set_busy_cursor()
|
self.application.set_busy_cursor()
|
||||||
# Simple message boxes
|
# Simple message boxes
|
||||||
Registry().register_function('theme_update_global', self.default_theme_changed)
|
Registry().register_function('theme_update_global', self.default_theme_changed)
|
||||||
Registry().register_function('openlp_version_check', self.version_notice)
|
QtCore.QObject.connect(self, QtCore.SIGNAL('openlp_version_check'), self.version_notice)
|
||||||
Registry().register_function('config_screen_changed', self.screen_changed)
|
Registry().register_function('config_screen_changed', self.screen_changed)
|
||||||
Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up)
|
Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up)
|
||||||
# Reset the cursor
|
# Reset the cursor
|
||||||
@ -585,12 +584,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
Notifies the user that a newer version of OpenLP is available.
|
Notifies the user that a newer version of OpenLP is available.
|
||||||
Triggered by delay thread and cannot display popup.
|
Triggered by delay thread and cannot display popup.
|
||||||
|
|
||||||
|
:param version: The Version to be displayed.
|
||||||
"""
|
"""
|
||||||
log.debug('version_notice')
|
log.debug('version_notice')
|
||||||
version_text = translate('OpenLP.MainWindow', 'Version %s of OpenLP is now available for download (you are '
|
version_text = translate('OpenLP.MainWindow', 'Version %s of OpenLP is now available for download (you are '
|
||||||
'currently running version %s). \n\nYou can download the latest version from '
|
'currently running version %s). \n\nYou can download the latest version from '
|
||||||
'http://openlp.org/.')
|
'http://openlp.org/.')
|
||||||
self.version_text = version_text % (version, get_application_version()['full'])
|
QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
|
||||||
|
version_text % (version, get_application_version()[u'full']))
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
"""
|
"""
|
||||||
@ -604,7 +606,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
self.open_cmd_line_files()
|
self.open_cmd_line_files()
|
||||||
elif Settings().value(self.general_settings_section + '/auto open'):
|
elif Settings().value(self.general_settings_section + '/auto open'):
|
||||||
self.service_manager_contents.load_last_file()
|
self.service_manager_contents.load_last_file()
|
||||||
self.timer_version_id = self.startTimer(1000)
|
|
||||||
view_mode = Settings().value('%s/view mode' % self.general_settings_section)
|
view_mode = Settings().value('%s/view mode' % self.general_settings_section)
|
||||||
if view_mode == 'default':
|
if view_mode == 'default':
|
||||||
self.mode_default_item.setChecked(True)
|
self.mode_default_item.setChecked(True)
|
||||||
@ -1304,17 +1305,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties):
|
|||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.load_progress_bar.hide()
|
self.load_progress_bar.hide()
|
||||||
self.application.process_events()
|
self.application.process_events()
|
||||||
if event.timerId() == self.timer_version_id:
|
|
||||||
self.timer_version_id = 0
|
|
||||||
# Has the thread passed some data to be displayed so display it and stop all waiting
|
|
||||||
if hasattr(self, 'version_text'):
|
|
||||||
QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'),
|
|
||||||
self.version_text)
|
|
||||||
else:
|
|
||||||
# the thread has not confirmed it is running or it has not yet sent any data so lets keep waiting
|
|
||||||
if not hasattr(self, 'version_update_running') or self.version_update_running:
|
|
||||||
self.timer_version_id = self.startTimer(1000)
|
|
||||||
self.application.process_events()
|
|
||||||
|
|
||||||
def set_new_data_path(self, new_data_path):
|
def set_new_data_path(self, new_data_path):
|
||||||
"""
|
"""
|
||||||
|
@ -97,6 +97,16 @@ class VersionThread(QtCore.QThread):
|
|||||||
A special Qt thread class to fetch the version of OpenLP from the website.
|
A special Qt thread class to fetch the version of OpenLP from the website.
|
||||||
This is threaded so that it doesn't affect the loading time of OpenLP.
|
This is threaded so that it doesn't affect the loading time of OpenLP.
|
||||||
"""
|
"""
|
||||||
|
def __init__(self, main_window):
|
||||||
|
"""
|
||||||
|
Constructor for the thread class.
|
||||||
|
|
||||||
|
:param main_window: The main window Object.
|
||||||
|
"""
|
||||||
|
log.debug("VersionThread - Initialise")
|
||||||
|
super(VersionThread, self).__init__(None)
|
||||||
|
self.main_window = main_window
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
Run the thread.
|
Run the thread.
|
||||||
@ -105,8 +115,9 @@ class VersionThread(QtCore.QThread):
|
|||||||
log.debug('Version thread - run')
|
log.debug('Version thread - run')
|
||||||
app_version = get_application_version()
|
app_version = get_application_version()
|
||||||
version = check_latest_version(app_version)
|
version = check_latest_version(app_version)
|
||||||
if LooseVersion(str(version)) > LooseVersion(str(app_version['full'])):
|
log.debug("Versions %s and %s " % (LooseVersion(str(version)), LooseVersion(str(app_version['full']))))
|
||||||
Registry().execute('openlp_version_check', '%s' % version)
|
#if LooseVersion(str(version)) > LooseVersion(str(app_version['full'])):
|
||||||
|
self.main_window.emit(QtCore.SIGNAL('openlp_version_check'), '%s' % version)
|
||||||
|
|
||||||
|
|
||||||
class HTTPRedirectHandlerFixed(urllib.request.HTTPRedirectHandler):
|
class HTTPRedirectHandlerFixed(urllib.request.HTTPRedirectHandler):
|
||||||
|
Loading…
Reference in New Issue
Block a user