forked from openlp/openlp
Last few changes to the wizard.
This commit is contained in:
parent
0d0e76601d
commit
6448ac5092
@ -171,8 +171,8 @@ class OpenLP(QtGui.QApplication):
|
|||||||
screens = ScreenList(self.desktop())
|
screens = ScreenList(self.desktop())
|
||||||
# First time checks in settings
|
# First time checks in settings
|
||||||
firstTime = QtCore.QSettings().value(
|
firstTime = QtCore.QSettings().value(
|
||||||
u'general/first time', QtCore.QVariant(True)).toBool()
|
u'general/has run wizard', QtCore.QVariant(False)).toBool()
|
||||||
if firstTime:
|
if not firstTime:
|
||||||
FirstTimeForm(screens).exec_()
|
FirstTimeForm(screens).exec_()
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
self.setStyleSheet(application_stylesheet)
|
self.setStyleSheet(application_stylesheet)
|
||||||
|
@ -54,19 +54,14 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
|||||||
# check to see if we have web access
|
# check to see if we have web access
|
||||||
self.web = u'http://openlp.org/files/frw/'
|
self.web = u'http://openlp.org/files/frw/'
|
||||||
self.config = SafeConfigParser()
|
self.config = SafeConfigParser()
|
||||||
self.webAccess = get_web_page(u'%s%s' % (self.web, u'download.cfg?%s' % randint(0, 20)))
|
self.webAccess = get_web_page(u'%s%s' % (self.web, u'download.cfg'))
|
||||||
if self.webAccess:
|
if self.webAccess:
|
||||||
files = self.webAccess.read()
|
files = self.webAccess.read()
|
||||||
self.config.readfp(io.BytesIO(files))
|
self.config.readfp(io.BytesIO(files))
|
||||||
for screen in screens.get_screen_list():
|
for screen in screens.get_screen_list():
|
||||||
self.displayComboBox.addItem(screen)
|
self.displayComboBox.addItem(screen)
|
||||||
self.songsText = translate('OpenLP.FirstTimeWizard', 'Songs')
|
|
||||||
self.biblesText = translate('OpenLP.FirstTimeWizard', 'Bibles')
|
|
||||||
self.themesText = translate('OpenLP.FirstTimeWizard', 'Themes')
|
|
||||||
self.startUpdates = translate('OpenLP.FirstTimeWizard',
|
|
||||||
'Starting Updates')
|
|
||||||
self.downloading = unicode(translate('OpenLP.FirstTimeWizard',
|
self.downloading = unicode(translate('OpenLP.FirstTimeWizard',
|
||||||
'Downloading %s'))
|
'Downloading %s...'))
|
||||||
QtCore.QObject.connect(self,
|
QtCore.QObject.connect(self,
|
||||||
QtCore.SIGNAL(u'currentIdChanged(int)'),
|
QtCore.SIGNAL(u'currentIdChanged(int)'),
|
||||||
self.onCurrentIdChanged)
|
self.onCurrentIdChanged)
|
||||||
@ -141,6 +136,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
|||||||
return FirstTimePage.NoInternet
|
return FirstTimePage.NoInternet
|
||||||
else:
|
else:
|
||||||
return FirstTimePage.Songs
|
return FirstTimePage.Songs
|
||||||
|
elif self.currentId() == FirstTimePage.Progress:
|
||||||
|
return -1
|
||||||
else:
|
else:
|
||||||
return self.currentId() + 1
|
return self.currentId() + 1
|
||||||
|
|
||||||
@ -158,54 +155,128 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
|||||||
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())
|
||||||
|
elif pageId == FirstTimePage.Progress:
|
||||||
|
self._preWizard()
|
||||||
|
self._performWizard()
|
||||||
|
self._postWizard()
|
||||||
|
|
||||||
def accept(self):
|
def _incrementProgressBar(self, status_text, increment=1):
|
||||||
Receiver.send_message(u'cursor_busy')
|
"""
|
||||||
self._updateMessage(self.startUpdates)
|
Update the wizard progress page.
|
||||||
# Set up the Plugin status's
|
|
||||||
self._pluginStatus(self.songsCheckBox, u'songs/status')
|
``status_text``
|
||||||
self._pluginStatus(self.bibleCheckBox, u'bibles/status')
|
Current status information to display.
|
||||||
self._pluginStatus(self.presentationCheckBox, u'presentations/status')
|
|
||||||
self._pluginStatus(self.imageCheckBox, u'images/status')
|
``increment``
|
||||||
self._pluginStatus(self.mediaCheckBox, u'media/status')
|
The value to increment the progress bar by.
|
||||||
self._pluginStatus(self.remoteCheckBox, u'remotes/status')
|
"""
|
||||||
self._pluginStatus(self.customCheckBox, u'custom/status')
|
if status_text:
|
||||||
self._pluginStatus(self.songUsageCheckBox, u'songusage/status')
|
self.progressLabel.setText(status_text)
|
||||||
self._pluginStatus(self.alertCheckBox, u'alerts/status')
|
if increment > 0:
|
||||||
|
self.progressBar.setValue(self.progressBar.value() + increment)
|
||||||
|
Receiver.send_message(u'openlp_process_events')
|
||||||
|
|
||||||
|
def _preWizard(self):
|
||||||
|
"""
|
||||||
|
Prepare the UI for the process.
|
||||||
|
"""
|
||||||
|
# We start on 9 for the 9 plugins
|
||||||
|
max_progress = 9
|
||||||
|
# Loop through the songs list and increase for each selected item
|
||||||
|
for i in xrange(self.songsListWidget.count()):
|
||||||
|
if self.songsListWidget.item(i).checkState() == QtCore.Qt.Checked:
|
||||||
|
max_progress += 1
|
||||||
|
# Loop through the Bibles list and increase for each selected item
|
||||||
|
iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
|
||||||
|
while iterator.value():
|
||||||
|
item = iterator.value()
|
||||||
|
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
|
||||||
|
max_progress += 1
|
||||||
|
iterator += 1
|
||||||
|
# Loop through the themes list and increase for each selected item
|
||||||
|
for i in xrange(self.themesListWidget.count()):
|
||||||
|
if self.themesListWidget.item(i).checkState() == QtCore.Qt.Checked:
|
||||||
|
max_progress += 1
|
||||||
|
self.finishButton.setVisible(False)
|
||||||
|
self.progressBar.setValue(0)
|
||||||
|
self.progressBar.setMinimum(0)
|
||||||
|
self.progressBar.setMaximum(max_progress)
|
||||||
|
|
||||||
|
def _postWizard(self):
|
||||||
|
"""
|
||||||
|
Clean up the UI after the process has finished.
|
||||||
|
"""
|
||||||
|
self.progressBar.setValue(self.progressBar.maximum())
|
||||||
|
self.finishButton.setVisible(True)
|
||||||
|
self.finishButton.setEnabled(True)
|
||||||
|
self.cancelButton.setVisible(False)
|
||||||
|
self.nextButton.setVisible(False)
|
||||||
|
Receiver.send_message(u'openlp_process_events')
|
||||||
|
|
||||||
|
def _performWizard(self):
|
||||||
|
"""
|
||||||
|
Run the tasks in the wizard.
|
||||||
|
"""
|
||||||
|
# Set plugin states
|
||||||
|
self._incrementProgressBar(translate('OpenLP.FirstTimeWizard',
|
||||||
|
'Enabling selected plugins...'))
|
||||||
|
self._setPluginStatus(self.songsCheckBox, u'songs/status')
|
||||||
|
self._incrementProgressBar(None)
|
||||||
|
self._setPluginStatus(self.bibleCheckBox, u'bibles/status')
|
||||||
|
self._incrementProgressBar(None)
|
||||||
|
self._setPluginStatus(self.presentationCheckBox, u'presentations/status')
|
||||||
|
self._incrementProgressBar(None)
|
||||||
|
self._setPluginStatus(self.imageCheckBox, u'images/status')
|
||||||
|
self._incrementProgressBar(None)
|
||||||
|
self._setPluginStatus(self.mediaCheckBox, u'media/status')
|
||||||
|
self._incrementProgressBar(None)
|
||||||
|
self._setPluginStatus(self.remoteCheckBox, u'remotes/status')
|
||||||
|
self._incrementProgressBar(None)
|
||||||
|
self._setPluginStatus(self.customCheckBox, u'custom/status')
|
||||||
|
self._incrementProgressBar(None)
|
||||||
|
self._setPluginStatus(self.songUsageCheckBox, u'songusage/status')
|
||||||
|
self._incrementProgressBar(None)
|
||||||
|
self._setPluginStatus(self.alertCheckBox, u'alerts/status')
|
||||||
# Build directories for downloads
|
# Build directories for downloads
|
||||||
destination = AppLocation.get_temp_path()
|
songs_destination = AppLocation.get_section_data_path(u'songs')
|
||||||
check_directory_exists(destination)
|
|
||||||
bibles_destination = AppLocation.get_section_data_path(u'bibles')
|
bibles_destination = AppLocation.get_section_data_path(u'bibles')
|
||||||
check_directory_exists(bibles_destination)
|
|
||||||
themes_destination = AppLocation.get_section_data_path(u'themes')
|
themes_destination = AppLocation.get_section_data_path(u'themes')
|
||||||
check_directory_exists(destination)
|
|
||||||
# Install songs
|
# Install songs
|
||||||
songs_iterator = QtGui.QListWidgetItemIterator(self.songsListWidget)
|
for i in xrange(self.songsListWidget.count()):
|
||||||
while songs_iterator.value():
|
item = self.songsListWidget.item(i)
|
||||||
item = songs_iterator.value()
|
|
||||||
if item.checkState() == QtCore.Qt.Checked:
|
if item.checkState() == QtCore.Qt.Checked:
|
||||||
filename = item.data(QtCore.Qt.UserRole).toString()
|
filename = item.data(QtCore.Qt.UserRole).toString()
|
||||||
urllib.urlretrieve(u'%s%s' % (self.web, filename),
|
self._incrementProgressBar(self.downloading % filename)
|
||||||
os.path.join(destination, filename))
|
destination = os.path.join(songs_destination, u'songs.sqlite')
|
||||||
#importer = SongImporter()
|
if os.path.exists(destination):
|
||||||
songs_iterator += 1
|
if QtGui.QMessageBox.question(self,
|
||||||
|
translate('OpenLP.FirstTimeWizard',
|
||||||
|
'Overwrite Existing Songs?'),
|
||||||
|
translate('OpenLP.FirstTimeWizard', 'Your songs '
|
||||||
|
'database already exists, are you sure you want to '
|
||||||
|
'overwrite it?'),
|
||||||
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||||
|
QtGui.QMessageBox.No) != QtGui.QMessageBox.Yes:
|
||||||
|
continue
|
||||||
|
urllib.urlretrieve(u'%s%s' % (self.web, filename), destination)
|
||||||
# Install Bibles
|
# Install Bibles
|
||||||
bibles_iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
|
bibles_iterator = QtGui.QTreeWidgetItemIterator(self.biblesTreeWidget)
|
||||||
while bibles_iterator.value():
|
while bibles_iterator.value():
|
||||||
item = bibles_iterator.value()
|
item = bibles_iterator.value()
|
||||||
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
|
if item.parent() and item.checkState(0) == QtCore.Qt.Checked:
|
||||||
bible = unicode(item.data(0, QtCore.Qt.UserRole).toString())
|
bible = unicode(item.data(0, QtCore.Qt.UserRole).toString())
|
||||||
|
self._incrementProgressBar(self.downloading % bible)
|
||||||
urllib.urlretrieve(u'%s%s' % (self.web, bible),
|
urllib.urlretrieve(u'%s%s' % (self.web, bible),
|
||||||
os.path.join(bibles_destination, bible))
|
os.path.join(bibles_destination, bible))
|
||||||
bibles_iterator += 1
|
bibles_iterator += 1
|
||||||
themes_iterator = QtGui.QListWidgetItemIterator(self.themesListWidget)
|
# Install themes
|
||||||
while themes_iterator.value():
|
for i in xrange(self.themesListWidget.count()):
|
||||||
item = themes_iterator.value()
|
item = self.themesListWidget.item(i)
|
||||||
if item.checkState() == QtCore.Qt.Checked:
|
if item.checkState() == QtCore.Qt.Checked:
|
||||||
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
|
theme = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
|
self._incrementProgressBar(self.downloading % theme)
|
||||||
urllib.urlretrieve(u'%s%s' % (self.web, theme),
|
urllib.urlretrieve(u'%s%s' % (self.web, theme),
|
||||||
os.path.join(theme_destination, theme))
|
os.path.join(themes_destination, theme))
|
||||||
themes_iterator += 1
|
|
||||||
# Set Default Display
|
# Set Default Display
|
||||||
if self.displayComboBox.currentIndex() != -1:
|
if self.displayComboBox.currentIndex() != -1:
|
||||||
QtCore.QSettings().setValue(u'General/monitor',
|
QtCore.QSettings().setValue(u'General/monitor',
|
||||||
@ -214,19 +285,11 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
|||||||
if self.themeComboBox.currentIndex() != -1:
|
if self.themeComboBox.currentIndex() != -1:
|
||||||
QtCore.QSettings().setValue(u'themes/global theme',
|
QtCore.QSettings().setValue(u'themes/global theme',
|
||||||
QtCore.QVariant(self.themeComboBox.currentText()))
|
QtCore.QVariant(self.themeComboBox.currentText()))
|
||||||
QtCore.QSettings().setValue(u'general/first time',
|
QtCore.QSettings().setValue(u'general/has run wizard',
|
||||||
QtCore.QVariant(False))
|
QtCore.QVariant(True))
|
||||||
Receiver.send_message(u'cursor_normal')
|
|
||||||
return QtGui.QWizard.accept(self)
|
|
||||||
|
|
||||||
def _pluginStatus(self, field, tag):
|
def _setPluginStatus(self, field, tag):
|
||||||
status = PluginStatus.Active if field.checkState() \
|
status = PluginStatus.Active if field.checkState() \
|
||||||
== QtCore.Qt.Checked else PluginStatus.Inactive
|
== QtCore.Qt.Checked else PluginStatus.Inactive
|
||||||
QtCore.QSettings().setValue(tag, QtCore.QVariant(status))
|
QtCore.QSettings().setValue(tag, QtCore.QVariant(status))
|
||||||
|
|
||||||
def _updateMessage(self, text):
|
|
||||||
"""
|
|
||||||
Keep screen up to date
|
|
||||||
"""
|
|
||||||
self.updateLabel.setText(text)
|
|
||||||
Receiver.send_message(u'openlp_process_events')
|
|
||||||
|
@ -37,6 +37,7 @@ class FirstTimePage(object):
|
|||||||
Bibles = 4
|
Bibles = 4
|
||||||
Themes = 5
|
Themes = 5
|
||||||
Defaults = 6
|
Defaults = 6
|
||||||
|
Progress = 7
|
||||||
|
|
||||||
|
|
||||||
class Ui_FirstTimeWizard(object):
|
class Ui_FirstTimeWizard(object):
|
||||||
@ -46,10 +47,12 @@ class Ui_FirstTimeWizard(object):
|
|||||||
FirstTimeWizard.setModal(True)
|
FirstTimeWizard.setModal(True)
|
||||||
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)
|
||||||
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
self.finishButton = self.button(QtGui.QWizard.FinishButton)
|
||||||
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)
|
||||||
add_welcome_page(FirstTimeWizard, u':/wizards/wizard_firsttime.bmp')
|
add_welcome_page(FirstTimeWizard, u':/wizards/wizard_firsttime.bmp')
|
||||||
# The plugins page
|
# The plugins page
|
||||||
self.pluginPage = QtGui.QWizardPage()
|
self.pluginPage = QtGui.QWizardPage()
|
||||||
@ -169,6 +172,19 @@ class Ui_FirstTimeWizard(object):
|
|||||||
self.themeComboBox.setObjectName(u'themeComboBox')
|
self.themeComboBox.setObjectName(u'themeComboBox')
|
||||||
self.defaultsLayout.addRow(self.themeLabel, self.themeComboBox)
|
self.defaultsLayout.addRow(self.themeLabel, self.themeComboBox)
|
||||||
FirstTimeWizard.setPage(FirstTimePage.Defaults, self.defaultsPage)
|
FirstTimeWizard.setPage(FirstTimePage.Defaults, self.defaultsPage)
|
||||||
|
# Progress page
|
||||||
|
self.progressPage = QtGui.QWizardPage()
|
||||||
|
self.progressPage.setObjectName(u'progressPage')
|
||||||
|
self.progressLayout = QtGui.QVBoxLayout(self.progressPage)
|
||||||
|
self.progressLayout.setMargin(48)
|
||||||
|
self.progressLayout.setObjectName(u'progressLayout')
|
||||||
|
self.progressLabel = QtGui.QLabel(self.progressPage)
|
||||||
|
self.progressLabel.setObjectName(u'progressLabel')
|
||||||
|
self.progressLayout.addWidget(self.progressLabel)
|
||||||
|
self.progressBar = QtGui.QProgressBar(self.progressPage)
|
||||||
|
self.progressBar.setObjectName(u'progressBar')
|
||||||
|
self.progressLayout.addWidget(self.progressBar)
|
||||||
|
FirstTimeWizard.setPage(FirstTimePage.Progress, self.progressPage)
|
||||||
|
|
||||||
self.retranslateUi(FirstTimeWizard)
|
self.retranslateUi(FirstTimeWizard)
|
||||||
QtCore.QMetaObject.connectSlotsByName(FirstTimeWizard)
|
QtCore.QMetaObject.connectSlotsByName(FirstTimeWizard)
|
||||||
@ -233,7 +249,13 @@ class Ui_FirstTimeWizard(object):
|
|||||||
'Default Settings'))
|
'Default Settings'))
|
||||||
self.defaultsPage.setSubTitle(translate('OpenLP.FirstTimeWizard',
|
self.defaultsPage.setSubTitle(translate('OpenLP.FirstTimeWizard',
|
||||||
'Set up default settings to be used by OpenLP.'))
|
'Set up default settings to be used by OpenLP.'))
|
||||||
|
self.progressPage.setTitle(translate('OpenLP.FirstTimeWizard',
|
||||||
|
'Setting Up And Importing'))
|
||||||
|
self.progressPage.setSubTitle(translate('OpenLP.FirstTimeWizard',
|
||||||
|
'Please wait while OpenLP is set up and your data is imported.'))
|
||||||
self.displayLabel.setText(translate('OpenLP.FirstTimeWizard',
|
self.displayLabel.setText(translate('OpenLP.FirstTimeWizard',
|
||||||
'Default output display:'))
|
'Default output display:'))
|
||||||
self.themeLabel.setText(translate('OpenLP.FirstTimeWizard',
|
self.themeLabel.setText(translate('OpenLP.FirstTimeWizard',
|
||||||
'Select default theme:'))
|
'Select default theme:'))
|
||||||
|
self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
|
||||||
|
'Starting configuration process...'))
|
||||||
|
Loading…
Reference in New Issue
Block a user