forked from openlp/openlp
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:
commit
0b6cc6134a
@ -28,7 +28,9 @@
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
import urllib, urllib2
|
||||
import sys
|
||||
import urllib
|
||||
import urllib2
|
||||
from tempfile import gettempdir
|
||||
from ConfigParser import SafeConfigParser
|
||||
|
||||
@ -65,6 +67,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
'Downloading %s...'))
|
||||
QtCore.QObject.connect(self.cancelButton,QtCore.SIGNAL('clicked()'),
|
||||
self.onCancelButtonClicked)
|
||||
QtCore.QObject.connect(self.noInternetFinishButton,
|
||||
QtCore.SIGNAL('clicked()'), self.onNoInternetFinishButtonClicked)
|
||||
QtCore.QObject.connect(self,
|
||||
QtCore.SIGNAL(u'currentIdChanged(int)'), self.onCurrentIdChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
@ -83,6 +87,10 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
"""
|
||||
self.restart()
|
||||
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
|
||||
if self.webAccess:
|
||||
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.
|
||||
"""
|
||||
# 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:
|
||||
# Check if this is a re-run of the wizard.
|
||||
self.has_run_wizard = QtCore.QSettings().value(
|
||||
u'general/has run wizard', QtCore.QVariant(False)).toBool()
|
||||
# Set the no internet page text.
|
||||
if self.hasRunWizard:
|
||||
self.noInternetLabel.setText(self.noInternetText)
|
||||
else:
|
||||
self.noInternetLabel.setText(self.noInternetText +
|
||||
self.cancelWizardText)
|
||||
elif pageId == FirstTimePage.Defaults:
|
||||
self.themeComboBox.clear()
|
||||
for iter in xrange(self.themesListWidget.count()):
|
||||
item = self.themesListWidget.item(iter)
|
||||
if item.checkState() == QtCore.Qt.Checked:
|
||||
self.themeComboBox.addItem(item.text())
|
||||
if self.has_run_wizard:
|
||||
if self.hasRunWizard:
|
||||
# Add any existing themes to list.
|
||||
for theme in self.parent().themeManagerContents.getThemes():
|
||||
index = self.themeComboBox.findText(theme)
|
||||
@ -177,6 +192,12 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
# Pre-select the current default theme.
|
||||
index = self.themeComboBox.findText(default_theme)
|
||||
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:
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
self._preWizard()
|
||||
@ -197,9 +218,29 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
self.displayComboBox.setCurrentIndex(self.displayComboBox.count() - 1)
|
||||
|
||||
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
|
||||
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):
|
||||
""""
|
||||
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:
|
||||
self.progressBar.setValue(self.progressBar.maximum())
|
||||
if self.has_run_wizard:
|
||||
if self.hasRunWizard:
|
||||
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
|
||||
'Download complete.'
|
||||
' Click the finish button to return to OpenLP.'))
|
||||
@ -311,7 +352,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
'Download complete.'
|
||||
' Click the finish button to start OpenLP.'))
|
||||
else:
|
||||
if self.has_run_wizard:
|
||||
if self.hasRunWizard:
|
||||
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
|
||||
'Click the finish button to return to OpenLP.'))
|
||||
else:
|
||||
|
@ -51,8 +51,10 @@ class Ui_FirstTimeWizard(object):
|
||||
FirstTimeWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
|
||||
FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages |
|
||||
QtGui.QWizard.NoBackButtonOnStartPage |
|
||||
QtGui.QWizard.NoBackButtonOnLastPage)
|
||||
QtGui.QWizard.NoBackButtonOnLastPage |
|
||||
QtGui.QWizard.HaveCustomButton1)
|
||||
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
||||
self.noInternetFinishButton = self.button(QtGui.QWizard.CustomButton1)
|
||||
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
|
||||
self.nextButton = self.button(QtGui.QWizard.NextButton)
|
||||
self.backButton = self.button(QtGui.QWizard.BackButton)
|
||||
@ -228,14 +230,17 @@ class Ui_FirstTimeWizard(object):
|
||||
self.noInternetPage.setSubTitle(translate(
|
||||
'OpenLP.FirstTimeWizard',
|
||||
'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 '
|
||||
'Internet connection in order to be able to download sample '
|
||||
'songs, Bibles and themes.\n\nTo re-run the First Time Wizard and '
|
||||
'import this sample data at a later stage, press the cancel '
|
||||
'button now, check your Internet connection, and restart OpenLP.'
|
||||
'\n\nTo cancel the First Time Wizard completely, press the finish '
|
||||
'button now.'))
|
||||
'songs, Bibles and themes. Press the Finish button now to start '
|
||||
'OpenLP with initial settings and no sample data.\n\nTo re-run the '
|
||||
'First Time Wizard and import this sample data at a later time, '
|
||||
'check your Internet connection and re-run this wizard by '
|
||||
'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',
|
||||
'Sample Songs'))
|
||||
self.songsPage.setSubTitle(translate('OpenLP.FirstTimeWizard',
|
||||
@ -258,3 +263,5 @@ class Ui_FirstTimeWizard(object):
|
||||
'Select default theme:'))
|
||||
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
|
||||
'Starting configuration process...'))
|
||||
FirstTimeWizard.setButtonText(QtGui.QWizard.CustomButton1,
|
||||
translate('OpenLP.FirstTimeWizard', 'Finish'))
|
||||
|
@ -776,25 +776,25 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
return
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
screens = ScreenList.get_instance()
|
||||
if FirstTimeForm(screens, self).exec_() == QtGui.QDialog.Accepted:
|
||||
self.firstTime()
|
||||
for plugin in self.pluginManager.plugins:
|
||||
self.activePlugin = plugin
|
||||
oldStatus = self.activePlugin.status
|
||||
self.activePlugin.setStatus()
|
||||
if oldStatus != self.activePlugin.status:
|
||||
if self.activePlugin.status == PluginStatus.Active:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Active)
|
||||
self.activePlugin.appStartup()
|
||||
else:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||
self.themeManagerContents.configUpdated()
|
||||
self.themeManagerContents.loadThemes(True)
|
||||
Receiver.send_message(u'theme_update_global',
|
||||
self.themeManagerContents.global_theme)
|
||||
# Check if any Bibles downloaded. If there are, they will be
|
||||
# processed.
|
||||
Receiver.send_message(u'bibles_load_list', True)
|
||||
FirstTimeForm(screens, self).exec_()
|
||||
self.firstTime()
|
||||
for plugin in self.pluginManager.plugins:
|
||||
self.activePlugin = plugin
|
||||
oldStatus = self.activePlugin.status
|
||||
self.activePlugin.setStatus()
|
||||
if oldStatus != self.activePlugin.status:
|
||||
if self.activePlugin.status == PluginStatus.Active:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Active)
|
||||
self.activePlugin.appStartup()
|
||||
else:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||
self.themeManagerContents.configUpdated()
|
||||
self.themeManagerContents.loadThemes(True)
|
||||
Receiver.send_message(u'theme_update_global',
|
||||
self.themeManagerContents.global_theme)
|
||||
# Check if any Bibles downloaded. If there are, they will be
|
||||
# processed.
|
||||
Receiver.send_message(u'bibles_load_list', True)
|
||||
|
||||
def blankCheck(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user