Added a No Internet page to the wizard.

This commit is contained in:
Raoul Snyman 2011-03-09 19:37:25 +02:00
parent 6b437a120c
commit b609a8de03
2 changed files with 79 additions and 23 deletions

View File

@ -32,11 +32,10 @@ import urllib
from PyQt4 import QtCore, QtGui
from firsttimewizard import Ui_FirstTimeWizard
from openlp.core.lib import translate, PluginStatus, check_directory_exists, \
from openlp.core.lib import translate, PluginStatus, check_directory_exists, \
Receiver
from openlp.core.utils import get_web_page, AppLocation
from firsttimewizard import Ui_FirstTimeWizard, FirstTimePage
log = logging.getLogger(__name__)
@ -49,6 +48,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
def __init__(self, screens, parent=None):
QtGui.QWizard.__init__(self, parent)
self.setupUi(self)
# check to see if we have web access
self.web = u'http://openlp.org/files/frw/'
self.config = ConfigParser.ConfigParser()
@ -56,7 +56,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
if self.webAccess:
files = self.webAccess.read()
self.config.readfp(io.BytesIO(files))
self.setupUi(self)
for screen in screens.get_screen_list():
self.displaySelectionComboBox.addItem(screen)
self.songsText = translate('OpenLP.FirstTimeWizard', 'Songs')
@ -85,7 +84,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
# Sort out internet access for downloads
if self.webAccess:
self.internetGroupBox.setVisible(True)
self.noInternetLabel.setVisible(False)
# If songs database exists do not allow a copy
songs = os.path.join(AppLocation.get_section_data_path(u'songs'),
u'songs.sqlite')
@ -100,9 +98,9 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget)
treewidgetitem.setText(0, self.themesText)
self._loadChild(treewidgetitem, u'themes', u'files', 'theme')
else:
self.internetGroupBox.setVisible(False)
self.noInternetLabel.setVisible(True)
# else:
# self.internetGroupBox.setVisible(False)
# self.noInternetLabel.setVisible(True)
def _loadChild(self, tree, list, tag, root):
files = self.config.get(list, tag)
@ -119,11 +117,27 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
child.setFlags(QtCore.Qt.ItemIsUserCheckable |
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
def nextId(self):
"""
Determine the next page in the Wizard to go to.
"""
if self.currentId() == FirstTimePage.Plugins:
if not self.webAccess:
return FirstTimePage.NoInternet
else:
return FirstTimePage.Songs
else:
return self.currentId() + 1
def onCurrentIdChanged(self, pageId):
"""
Detects Page changes and updates as approprate.
"""
if self.page(pageId) == self.DefaultsPage:
if pageId == FirstTimePage.NoInternet:
self.finishButton.setVisible(True)
self.finishButton.setEnabled(True)
self.nextButton.setVisible(False)
elif self.page(pageId) == self.DefaultsPage:
self.themeSelectionComboBox.clear()
listIterator = QtGui.QTreeWidgetItemIterator(
self.selectionTreeWidget)

View File

@ -29,6 +29,15 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from openlp.core.lib.ui import add_welcome_page
class FirstTimePage(object):
Welcome = 0
Plugins = 1
NoInternet = 2
Songs = 3
Bibles = 4
Defaults = 5
class Ui_FirstTimeWizard(object):
def setupUi(self, FirstTimeWizard):
FirstTimeWizard.setObjectName(u'FirstTimeWizard')
@ -37,6 +46,9 @@ class Ui_FirstTimeWizard(object):
FirstTimeWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
FirstTimeWizard.setOptions(QtGui.QWizard.IndependentPages|
QtGui.QWizard.NoBackButtonOnStartPage)
self.finishButton = self.button(QtGui.QWizard.FinishButton)
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
self.nextButton = self.button(QtGui.QWizard.NextButton)
add_welcome_page(FirstTimeWizard, u':/wizards/wizard_firsttime.bmp')
# The plugins page
self.pluginPage = QtGui.QWizardPage()
@ -79,14 +91,28 @@ class Ui_FirstTimeWizard(object):
self.alertCheckBox.setChecked(True)
self.alertCheckBox.setObjectName(u'alertCheckBox')
self.pluginLayout.addWidget(self.alertCheckBox)
FirstTimeWizard.addPage(self.pluginPage)
# The song samples page
self.downloadDefaultsPage = QtGui.QWizardPage()
self.downloadDefaultsPage.setObjectName(u'downloadDefaultsPage')
self.noInternetLabel = QtGui.QLabel(self.downloadDefaultsPage)
self.noInternetLabel.setGeometry(QtCore.QRect(20, 20, 461, 17))
FirstTimeWizard.setPage(FirstTimePage.Plugins, self.pluginPage)
# The "you don't have an internet connection" page.
self.noInternetPage = QtGui.QWizardPage()
self.noInternetPage.setObjectName(u'noInternetPage')
self.noInternetLayout = QtGui.QVBoxLayout(self.noInternetPage)
self.noInternetLayout.setContentsMargins(50, 40, 50, 40)
self.noInternetLayout.setObjectName(u'noInternetLayout')
self.noInternetLabel = QtGui.QLabel(self.noInternetPage)
self.noInternetLabel.setWordWrap(True)
self.noInternetLabel.setObjectName(u'noInternetLabel')
self.internetGroupBox = QtGui.QGroupBox(self.downloadDefaultsPage)
self.noInternetLayout.addWidget(self.noInternetLabel)
FirstTimeWizard.setPage(FirstTimePage.NoInternet, self.noInternetPage)
# The song samples page
self.songsPage = QtGui.QWizardPage()
self.songsPage.setObjectName(u'songsPage')
FirstTimeWizard.setPage(FirstTimePage.Songs, self.songsPage)
# download page
self.biblesPage = QtGui.QWizardPage()
self.biblesPage.setObjectName(u'biblesPage')
self.internetGroupBox = QtGui.QGroupBox(self.biblesPage)
self.internetGroupBox.setGeometry(QtCore.QRect(20, 10, 501, 271))
self.internetGroupBox.setObjectName(u'internetGroupBox')
self.pluginLayout_4 = QtGui.QVBoxLayout(self.internetGroupBox)
@ -100,7 +126,8 @@ class Ui_FirstTimeWizard(object):
self.selectionTreeWidget.headerItem().setText(0, u'1')
self.selectionTreeWidget.header().setVisible(False)
self.pluginLayout_4.addWidget(self.selectionTreeWidget)
FirstTimeWizard.addPage(self.downloadDefaultsPage)
FirstTimeWizard.setPage(FirstTimePage.Bibles, self.biblesPage)
self.DefaultsPage = QtGui.QWizardPage()
self.DefaultsPage.setObjectName(u'DefaultsPage')
self.layoutWidget = QtGui.QWidget(self.DefaultsPage)
@ -133,7 +160,7 @@ class Ui_FirstTimeWizard(object):
self.updateLabel = QtGui.QLabel(self.DefaultsPage)
self.updateLabel.setGeometry(QtCore.QRect(60, 220, 351, 17))
self.updateLabel.setObjectName(u'updateLabel')
FirstTimeWizard.addPage(self.DefaultsPage)
FirstTimeWizard.setPage(FirstTimePage.Defaults, self.DefaultsPage)
self.retranslateUi(FirstTimeWizard)
QtCore.QMetaObject.connectSlotsByName(FirstTimeWizard)
@ -169,14 +196,29 @@ class Ui_FirstTimeWizard(object):
'Monitor Song Usage'))
self.alertCheckBox.setText(translate('OpenLP.FirstTimeWizard',
'Allow Alerts'))
self.downloadDefaultsPage.setTitle(translate('OpenLP.FirstTimeWizard',
self.noInternetPage.setTitle(translate('OpenLP.FirstTimeWizard',
'No Internet Connection'))
self.noInternetPage.setSubTitle(translate(
'OpenLP.FirstTimeWizard',
'Unable to detect an Internet connection.'))
self.noInternetLabel.setText(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.'))
self.songsPage.setTitle(translate('OpenLP.FirstTimeWizard',
'Sample Songs'))
self.songsPage.setSubTitle(translate(
'OpenLP.FirstTimeWizard',
'Select and download public domain songs.'))
self.biblesPage.setTitle(translate('OpenLP.FirstTimeWizard',
'Download Samples from OpenLP.org'))
self.downloadDefaultsPage.setSubTitle(translate(
self.biblesPage.setSubTitle(translate(
'OpenLP.FirstTimeWizard',
'Select samples to downlaod and install for use.'))
self.noInternetLabel.setText(translate('OpenLP.FirstTimeWizard',
'No Internet connection found so unable to download any default'
' files.'))
self.internetGroupBox.setTitle(translate('OpenLP.FirstTimeWizard',
'Download Example Files'))
self.DefaultsPage.setTitle(translate('OpenLP.FirstTimeWizard',