Added a "Finish" button to the "No-internet" window of the First Time Wizard.

Added code to this button to process any changes made in the plugin screen.

bzr-revno: 1749
This commit is contained in:
Stevan Pettit 2011-09-18 14:09:32 +01:00 committed by Tim Bentley
commit 0b6cc6134a
3 changed files with 81 additions and 33 deletions

View File

@ -28,7 +28,9 @@
import io import io
import logging import logging
import os import os
import urllib, urllib2 import sys
import urllib
import urllib2
from tempfile import gettempdir from tempfile import gettempdir
from ConfigParser import SafeConfigParser from ConfigParser import SafeConfigParser
@ -65,6 +67,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
'Downloading %s...')) 'Downloading %s...'))
QtCore.QObject.connect(self.cancelButton,QtCore.SIGNAL('clicked()'), QtCore.QObject.connect(self.cancelButton,QtCore.SIGNAL('clicked()'),
self.onCancelButtonClicked) self.onCancelButtonClicked)
QtCore.QObject.connect(self.noInternetFinishButton,
QtCore.SIGNAL('clicked()'), self.onNoInternetFinishButtonClicked)
QtCore.QObject.connect(self, QtCore.QObject.connect(self,
QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged) QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -83,6 +87,10 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
""" """
self.restart() self.restart()
check_directory_exists(os.path.join(gettempdir(), u'openlp')) check_directory_exists(os.path.join(gettempdir(), u'openlp'))
self.noInternetFinishButton.setVisible(False)
# Check if this is a re-run of the wizard.
self.hasRunWizard = QtCore.QSettings().value(
u'general/has run wizard', QtCore.QVariant(False)).toBool()
# Sort out internet access for downloads # Sort out internet access for downloads
if self.webAccess: if self.webAccess:
songs = self.config.get(u'songs', u'languages') songs = self.config.get(u'songs', u'languages')
@ -155,17 +163,24 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
""" """
Detects Page changes and updates as approprate. Detects Page changes and updates as approprate.
""" """
# Keep track of the page we are at. Pressing "Cancel" causes pageId
# to be a -1.
if pageId != -1:
self.lastId = pageId
if pageId == FirstTimePage.Plugins: if pageId == FirstTimePage.Plugins:
# Check if this is a re-run of the wizard. # Set the no internet page text.
self.has_run_wizard = QtCore.QSettings().value( if self.hasRunWizard:
u'general/has run wizard', QtCore.QVariant(False)).toBool() self.noInternetLabel.setText(self.noInternetText)
else:
self.noInternetLabel.setText(self.noInternetText +
self.cancelWizardText)
elif pageId == FirstTimePage.Defaults: elif pageId == FirstTimePage.Defaults:
self.themeComboBox.clear() self.themeComboBox.clear()
for iter in xrange(self.themesListWidget.count()): for iter in xrange(self.themesListWidget.count()):
item = self.themesListWidget.item(iter) item = self.themesListWidget.item(iter)
if item.checkState() == QtCore.Qt.Checked: if item.checkState() == QtCore.Qt.Checked:
self.themeComboBox.addItem(item.text()) self.themeComboBox.addItem(item.text())
if self.has_run_wizard: if self.hasRunWizard:
# Add any existing themes to list. # Add any existing themes to list.
for theme in self.parent().themeManagerContents.getThemes(): for theme in self.parent().themeManagerContents.getThemes():
index = self.themeComboBox.findText(theme) index = self.themeComboBox.findText(theme)
@ -177,6 +192,12 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
# Pre-select the current default theme. # Pre-select the current default theme.
index = self.themeComboBox.findText(default_theme) index = self.themeComboBox.findText(default_theme)
self.themeComboBox.setCurrentIndex(index) self.themeComboBox.setCurrentIndex(index)
elif pageId == FirstTimePage.NoInternet:
self.backButton.setVisible(False)
self.nextButton.setVisible(False)
self.noInternetFinishButton.setVisible(True)
if self.hasRunWizard:
self.cancelButton.setVisible(False)
elif pageId == FirstTimePage.Progress: elif pageId == FirstTimePage.Progress:
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
self._preWizard() self._preWizard()
@ -197,9 +218,29 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
self.displayComboBox.setCurrentIndex(self.displayComboBox.count() - 1) self.displayComboBox.setCurrentIndex(self.displayComboBox.count() - 1)
def onCancelButtonClicked(self): def onCancelButtonClicked(self):
"""
Process the pressing of the cancel button.
"""
if self.lastId == FirstTimePage.NoInternet or \
(self.lastId <= FirstTimePage.Plugins and \
not self.hasRunWizard):
QtCore.QCoreApplication.exit()
sys.exit()
self.downloadCanceled = True self.downloadCanceled = True
Receiver.send_message(u'cursor_normal') Receiver.send_message(u'cursor_normal')
def onNoInternetFinishButtonClicked(self):
"""
Process the pressing of the "Finish" button on the No Internet page.
"""
Receiver.send_message(u'cursor_busy')
self._performWizard()
Receiver.send_message(u'openlp_process_events')
Receiver.send_message(u'cursor_normal')
QtCore.QSettings().setValue(u'general/has run wizard',
QtCore.QVariant(True))
self.close()
def urlGetFile(self, url, fpath): def urlGetFile(self, url, fpath):
"""" """"
Download a file given a URL. The file is retrieved in chunks, giving Download a file given a URL. The file is retrieved in chunks, giving
@ -302,7 +343,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
""" """
if self.max_progress: if self.max_progress:
self.progressBar.setValue(self.progressBar.maximum()) self.progressBar.setValue(self.progressBar.maximum())
if self.has_run_wizard: if self.hasRunWizard:
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
'Download complete.' 'Download complete.'
' Click the finish button to return to OpenLP.')) ' Click the finish button to return to OpenLP.'))
@ -311,7 +352,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
'Download complete.' 'Download complete.'
' Click the finish button to start OpenLP.')) ' Click the finish button to start OpenLP.'))
else: else:
if self.has_run_wizard: if self.hasRunWizard:
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
'Click the finish button to return to OpenLP.')) 'Click the finish button to return to OpenLP.'))
else: else:

View File

@ -51,8 +51,10 @@ class Ui_FirstTimeWizard(object):
FirstTimeWizard.setWizardStyle(QtGui.QWizard.ModernStyle) FirstTimeWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages | FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages |
QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnStartPage |
QtGui.QWizard.NoBackButtonOnLastPage) QtGui.QWizard.NoBackButtonOnLastPage |
QtGui.QWizard.HaveCustomButton1)
self.finishButton = self.button(QtGui.QWizard.FinishButton) self.finishButton = self.button(QtGui.QWizard.FinishButton)
self.noInternetFinishButton = self.button(QtGui.QWizard.CustomButton1)
self.cancelButton = self.button(QtGui.QWizard.CancelButton) self.cancelButton = self.button(QtGui.QWizard.CancelButton)
self.nextButton = self.button(QtGui.QWizard.NextButton) self.nextButton = self.button(QtGui.QWizard.NextButton)
self.backButton = self.button(QtGui.QWizard.BackButton) self.backButton = self.button(QtGui.QWizard.BackButton)
@ -228,14 +230,17 @@ class Ui_FirstTimeWizard(object):
self.noInternetPage.setSubTitle(translate( self.noInternetPage.setSubTitle(translate(
'OpenLP.FirstTimeWizard', 'OpenLP.FirstTimeWizard',
'Unable to detect an Internet connection.')) 'Unable to detect an Internet connection.'))
self.noInternetLabel.setText(translate('OpenLP.FirstTimeWizard', self.noInternetText = translate('OpenLP.FirstTimeWizard',
'No Internet connection was found. The First Time Wizard needs an ' 'No Internet connection was found. The First Time Wizard needs an '
'Internet connection in order to be able to download sample ' 'Internet connection in order to be able to download sample '
'songs, Bibles and themes.\n\nTo re-run the First Time Wizard and ' 'songs, Bibles and themes. Press the Finish button now to start '
'import this sample data at a later stage, press the cancel ' 'OpenLP with initial settings and no sample data.\n\nTo re-run the '
'button now, check your Internet connection, and restart OpenLP.' 'First Time Wizard and import this sample data at a later time, '
'\n\nTo cancel the First Time Wizard completely, press the finish ' 'check your Internet connection and re-run this wizard by '
'button now.')) 'selecting "Tools/Re-run First Time Wizard" from OpenLP.')
self.cancelWizardText = translate('OpenLP.FirstTimeWizard',
'\n\nTo cancel the First Time Wizard completely (and not start '
'OpenLP), press the Cancel button now.')
self.songsPage.setTitle(translate('OpenLP.FirstTimeWizard', self.songsPage.setTitle(translate('OpenLP.FirstTimeWizard',
'Sample Songs')) 'Sample Songs'))
self.songsPage.setSubTitle(translate('OpenLP.FirstTimeWizard', self.songsPage.setSubTitle(translate('OpenLP.FirstTimeWizard',
@ -258,3 +263,5 @@ class Ui_FirstTimeWizard(object):
'Select default theme:')) 'Select default theme:'))
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard', self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
'Starting configuration process...')) 'Starting configuration process...'))
FirstTimeWizard.setButtonText(QtGui.QWizard.CustomButton1,
translate('OpenLP.FirstTimeWizard', 'Finish'))

View File

@ -776,25 +776,25 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
return return
Receiver.send_message(u'cursor_busy') Receiver.send_message(u'cursor_busy')
screens = ScreenList.get_instance() screens = ScreenList.get_instance()
if FirstTimeForm(screens, self).exec_() == QtGui.QDialog.Accepted: FirstTimeForm(screens, self).exec_()
self.firstTime() self.firstTime()
for plugin in self.pluginManager.plugins: for plugin in self.pluginManager.plugins:
self.activePlugin = plugin self.activePlugin = plugin
oldStatus = self.activePlugin.status oldStatus = self.activePlugin.status
self.activePlugin.setStatus() self.activePlugin.setStatus()
if oldStatus != self.activePlugin.status: if oldStatus != self.activePlugin.status:
if self.activePlugin.status == PluginStatus.Active: if self.activePlugin.status == PluginStatus.Active:
self.activePlugin.toggleStatus(PluginStatus.Active) self.activePlugin.toggleStatus(PluginStatus.Active)
self.activePlugin.appStartup() self.activePlugin.appStartup()
else: else:
self.activePlugin.toggleStatus(PluginStatus.Inactive) self.activePlugin.toggleStatus(PluginStatus.Inactive)
self.themeManagerContents.configUpdated() self.themeManagerContents.configUpdated()
self.themeManagerContents.loadThemes(True) self.themeManagerContents.loadThemes(True)
Receiver.send_message(u'theme_update_global', Receiver.send_message(u'theme_update_global',
self.themeManagerContents.global_theme) self.themeManagerContents.global_theme)
# Check if any Bibles downloaded. If there are, they will be # Check if any Bibles downloaded. If there are, they will be
# processed. # processed.
Receiver.send_message(u'bibles_load_list', True) Receiver.send_message(u'bibles_load_list', True)
def blankCheck(self): def blankCheck(self):
""" """