← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~smpettit/openlp/ftf-no-internet into lp:openlp

 

Stevan Pettit has proposed merging lp:~smpettit/openlp/ftf-no-internet into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #844826 in OpenLP: "First Time Wizard "no internet connection" message contains errors."
  https://bugs.launchpad.net/openlp/+bug/844826

For more details, see:
https://code.launchpad.net/~smpettit/openlp/ftf-no-internet/+merge/75200

Bug #844826

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.

Modified code to cancel the FTW if user presses "Cancel" any time on or before the plugin screen.
Modified the "No-internet" message to more accurately notify the user of options available.

I used sys.exit() instead of QtCore.QCoreApplication.exit() because the latter was not completely exiting from the program.


-- 
https://code.launchpad.net/~smpettit/openlp/ftf-no-internet/+merge/75200
Your team OpenLP Core is requested to review the proposed merge of lp:~smpettit/openlp/ftf-no-internet into lp:openlp.
=== modified file 'openlp/core/ui/firsttimeform.py'
--- openlp/core/ui/firsttimeform.py	2011-09-08 13:14:51 +0000
+++ openlp/core/ui/firsttimeform.py	2011-09-13 15:07:27 +0000
@@ -27,7 +27,7 @@
 
 import io
 import logging
-import os
+import os, sys
 import urllib, urllib2
 from tempfile import gettempdir
 from ConfigParser import SafeConfigParser
@@ -65,6 +65,8 @@
             '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 +85,10 @@
         """
         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 +161,24 @@
         """
         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 +190,12 @@
                 # 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 +216,28 @@
         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):
+            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 +340,7 @@
         """
         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 +349,7 @@
                     '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:

=== modified file 'openlp/core/ui/firsttimewizard.py'
--- openlp/core/ui/firsttimewizard.py	2011-09-08 13:14:51 +0000
+++ openlp/core/ui/firsttimewizard.py	2011-09-13 15:07:27 +0000
@@ -51,8 +51,10 @@
         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 @@
         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 @@
             'Select default theme:'))
         self.progressLabel.setText(translate('OpenLP.FirstTimeWizard',
             'Starting configuration process...'))
+        FirstTimeWizard.setButtonText(QtGui.QWizard.CustomButton1, 
+            translate('OpenLP.FirstTimeWizard', 'Finish'))

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2011-09-11 12:29:08 +0000
+++ openlp/core/ui/mainwindow.py	2011-09-13 15:07:27 +0000
@@ -776,25 +776,25 @@
             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):
         """