← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~suutari-olli/openlp/default-visibility-preset-fixes into lp:openlp

 

Azaziah has proposed merging lp:~suutari-olli/openlp/default-visibility-preset-fixes into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)
Related bugs:
  Bug #1565447 in OpenLP: "Unable to save Panel visibility If View > Mode is set to "Setup" or "Live""
  https://bugs.launchpad.net/openlp/+bug/1565447

For more details, see:
https://code.launchpad.net/~suutari-olli/openlp/default-visibility-preset-fixes/+merge/292187

In this re-proposal:

- Changed how the setting is called
- Reformatted short  description for projectors and presentations
- Added two tests for checking if projectors is visible or not after the wizard.

lp:~suutari-olli/openlp/default-visibility-preset-fixes (revision 2650)
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-01-Pull/1461/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-02-Functional-Tests/1378/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-03-Interface-Tests/1316/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1118/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/709/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-05a-Code_Analysis/776/
[←[1;32mSUCCESS←[1;m] https://ci.openlp.io/job/Branch-05b-Test_Coverage/644/

----------------------------------------------------------------------------
This branch introduces the following fixes/features:

- Fixed bug 1565447 (Unable to save panel visibility if View mode is used)
  (Added a hidden setting for controlling this)
- Locking Panels now also locks “View” menu so view menu can’t
  be set if panels are locked.
- Panels are now locked by default, this prevents users from
  totally messing their UI so easily.
- Added a checkbox for disabling/enabling Projectors during first time wizard
  (By default disabled, added a hidden setting for controlling this.)
- Improved UI messages on 1st time wizard Enable/Disable plugins page
-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/common/settings.py'
--- openlp/core/common/settings.py	2016-04-16 21:01:22 +0000
+++ openlp/core/common/settings.py	2016-04-18 19:01:19 +0000
@@ -182,13 +182,15 @@
         'themes/wrap footer': False,
         'user interface/live panel': True,
         'user interface/live splitter geometry': QtCore.QByteArray(),
-        'user interface/lock panel': False,
+        'user interface/lock panel': True,
         'user interface/main window geometry': QtCore.QByteArray(),
         'user interface/main window position': QtCore.QPoint(0, 0),
         'user interface/main window splitter geometry': QtCore.QByteArray(),
         'user interface/main window state': QtCore.QByteArray(),
         'user interface/preview panel': True,
         'user interface/preview splitter geometry': QtCore.QByteArray(),
+        'user interface/is preset layout': False,
+        'projector/show after wizard': False,
         'projector/db type': 'sqlite',
         'projector/db username': '',
         'projector/db password': '',

=== modified file 'openlp/core/ui/firsttimewizard.py'
--- openlp/core/ui/firsttimewizard.py	2016-03-23 11:55:54 +0000
+++ openlp/core/ui/firsttimewizard.py	2016-04-18 19:01:19 +0000
@@ -24,7 +24,7 @@
 """
 from PyQt5 import QtCore, QtGui, QtWidgets
 
-from openlp.core.common import translate, is_macosx, clean_button_text
+from openlp.core.common import translate, is_macosx, clean_button_text, Settings
 from openlp.core.lib import build_icon
 from openlp.core.lib.ui import add_welcome_page
 
@@ -136,6 +136,13 @@
         self.alert_check_box.setChecked(True)
         self.alert_check_box.setObjectName('alert_check_box')
         self.plugin_layout.addWidget(self.alert_check_box)
+        self.projectors_check_box = QtWidgets.QCheckBox(self.plugin_page)
+        # If visibility setting for projector panel is True, check the box.
+        if Settings().value('projector/show after wizard'):
+            self.projectors_check_box.setChecked(True)
+        self.projectors_check_box.setObjectName('projectors_check_box')
+        self.projectors_check_box.clicked.connect(self.on_projectors_check_box_clicked)
+        self.plugin_layout.addWidget(self.projectors_check_box)
         first_time_wizard.setPage(FirstTimePage.Plugins, self.plugin_page)
         # The song samples page
         self.songs_page = QtWidgets.QWizardPage()
@@ -232,17 +239,28 @@
                                                                            'downloaded.'))
         self.download_label.setText(translate('OpenLP.FirstTimeWizard', 'Please wait while OpenLP downloads the '
                                                                         'resource index file...'))
-        self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Activate required Plugins'))
-        self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select the Plugins you wish to use. '))
+        self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Select parts of the program you wish to use'))
+        self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard',
+                                               'You can also change these settings after the Wizard.'))
         self.songs_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Songs'))
-        self.custom_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Custom Slides'))
-        self.bible_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Bible'))
-        self.image_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Images'))
-        self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Presentations'))
-        self.media_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Media (Audio and Video)'))
-        self.remote_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Allow remote access'))
-        self.song_usage_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Monitor Song Usage'))
-        self.alert_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Allow Alerts'))
+        self.custom_check_box.setText(translate('OpenLP.FirstTimeWizard',
+                                                'Custom Slides – Easier to manage than songs and they have their own'
+                                                ' list of slides'))
+        self.bible_check_box.setText(translate('OpenLP.FirstTimeWizard',
+                                               'Bibles – Import and show Bibles'))
+        self.image_check_box.setText(translate('OpenLP.FirstTimeWizard',
+                                               'Images – Show images or replace background with them'))
+        self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard',
+                                                      'Presentations – Show .ppt, .odp and .pdf files'))
+        self.media_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Media – Playback of Audio and Video files'))
+        self.remote_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Remote – Control OpenLP via browser or smart'
+                                                                          'phone app'))
+        self.song_usage_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Song Usage Monitor'))
+        self.alert_check_box.setText(translate('OpenLP.FirstTimeWizard',
+                                               'Alerts – Display informative messages while showing other slides'))
+        self.projectors_check_box.setText(translate('OpenLP.FirstTimeWizard',
+                                                    'Projectors – Control PJLink compatible projects on your network'
+                                                    ' from OpenLP'))
         self.no_internet_page.setTitle(translate('OpenLP.FirstTimeWizard', 'No Internet Connection'))
         self.no_internet_page.setSubTitle(
             translate('OpenLP.FirstTimeWizard', 'Unable to detect an Internet connection.'))
@@ -277,3 +295,10 @@
                                         clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.FinishButton)))
         first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton2,
                                         clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.CancelButton)))
+
+    def on_projectors_check_box_clicked(self):
+        # When clicking projectors_check box, change the visibility setting for Projectors panel.
+        if Settings().value('projector/show after wizard'):
+            Settings().setValue('projector/show after wizard', False)
+        else:
+            Settings().setValue('projector/show after wizard', True)

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2016-04-04 19:53:54 +0000
+++ openlp/core/ui/mainwindow.py	2016-04-18 19:01:19 +0000
@@ -638,13 +638,15 @@
             self.open_cmd_line_files(self.arguments)
         elif Settings().value(self.general_settings_section + '/auto open'):
             self.service_manager_contents.load_last_file()
+        # This will store currently used layout preset so it remains enabled on next startup.
+        # If any panel is enabled/disabled after preset is set, this setting is not saved.
         view_mode = Settings().value('%s/view mode' % self.general_settings_section)
-        if view_mode == 'default':
+        if view_mode == 'default' and Settings().value('user interface/is preset layout'):
             self.mode_default_item.setChecked(True)
-        elif view_mode == 'setup':
+        elif view_mode == 'setup' and Settings().value('user interface/is preset layout'):
             self.set_view_mode(True, True, False, True, False, True)
             self.mode_setup_item.setChecked(True)
-        elif view_mode == 'live':
+        elif view_mode == 'live' and Settings().value('user interface/is preset layout'):
             self.set_view_mode(False, True, False, False, True, True)
             self.mode_live_item.setChecked(True)
 
@@ -696,6 +698,11 @@
             return
         self.application.set_busy_cursor()
         self.first_time()
+        # Check if Projectors panel should be visible or not after wizard.
+        if Settings().value('projector/show after wizard'):
+            self.projector_manager_dock.setVisible(True)
+        else:
+            self.projector_manager_dock.setVisible(False)
         for plugin in self.plugin_manager.plugins:
             self.active_plugin = plugin
             old_status = self.active_plugin.status
@@ -1027,18 +1034,24 @@
         Put OpenLP into "Default" view mode.
         """
         self.set_view_mode(True, True, True, True, True, True, 'default')
+        Settings().setValue('user interface/is preset layout', True)
+        Settings().setValue('projector/show after wizard', True)
 
     def on_mode_setup_item_clicked(self):
         """
         Put OpenLP into "Setup" view mode.
         """
         self.set_view_mode(True, True, False, True, False, True, 'setup')
+        Settings().setValue('user interface/is preset layout', True)
+        Settings().setValue('projector/show after wizard', True)
 
     def on_mode_live_item_clicked(self):
         """
         Put OpenLP into "Live" view mode.
         """
         self.set_view_mode(False, True, False, False, True, True, 'live')
+        Settings().setValue('user interface/is preset layout', True)
+        Settings().setValue('projector/show after wizard', True)
 
     def set_view_mode(self, media=True, service=True, theme=True, preview=True, live=True, projector=True, mode=''):
         """
@@ -1176,24 +1189,33 @@
         Toggle the visibility of the media manager
         """
         self.media_manager_dock.setVisible(not self.media_manager_dock.isVisible())
+        Settings().setValue('user interface/is preset layout', False)
 
     def toggle_projector_manager(self):
         """
         Toggle visibility of the projector manager
         """
         self.projector_manager_dock.setVisible(not self.projector_manager_dock.isVisible())
+        Settings().setValue('user interface/is preset layout', False)
+        # Check/uncheck checkbox on First time wizard based on visibility of this panel.
+        if not Settings().value('projector/show after wizard'):
+            Settings().setValue('projector/show after wizard', True)
+        else:
+            Settings().setValue('projector/show after wizard', False)
 
     def toggle_service_manager(self):
         """
         Toggle the visibility of the service manager
         """
         self.service_manager_dock.setVisible(not self.service_manager_dock.isVisible())
+        Settings().setValue('user interface/is preset layout', False)
 
     def toggle_theme_manager(self):
         """
         Toggle the visibility of the theme manager
         """
         self.theme_manager_dock.setVisible(not self.theme_manager_dock.isVisible())
+        Settings().setValue('user interface/is preset layout', False)
 
     def set_preview_panel_visibility(self, visible):
         """
@@ -1207,6 +1229,7 @@
         self.preview_controller.panel.setVisible(visible)
         Settings().setValue('user interface/preview panel', visible)
         self.view_preview_panel.setChecked(visible)
+        Settings().setValue('user interface/is preset layout', False)
 
     def set_lock_panel(self, lock):
         """
@@ -1217,6 +1240,7 @@
             self.service_manager_dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)
             self.media_manager_dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)
             self.projector_manager_dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures)
+            self.view_mode_menu.setEnabled(False)
             self.view_media_manager_item.setEnabled(False)
             self.view_service_manager_item.setEnabled(False)
             self.view_theme_manager_item.setEnabled(False)
@@ -1228,6 +1252,7 @@
             self.service_manager_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
             self.media_manager_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
             self.projector_manager_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures)
+            self.view_mode_menu.setEnabled(True)
             self.view_media_manager_item.setEnabled(True)
             self.view_service_manager_item.setEnabled(True)
             self.view_theme_manager_item.setEnabled(True)
@@ -1248,6 +1273,7 @@
         self.live_controller.panel.setVisible(visible)
         Settings().setValue('user interface/live panel', visible)
         self.view_live_panel.setChecked(visible)
+        Settings().setValue('user interface/is preset layout', False)
 
     def load_settings(self):
         """

=== modified file 'tests/functional/openlp_core_ui/test_mainwindow.py'
--- tests/functional/openlp_core_ui/test_mainwindow.py	2016-04-12 20:45:50 +0000
+++ tests/functional/openlp_core_ui/test_mainwindow.py	2016-04-18 19:01:19 +0000
@@ -26,6 +26,8 @@
 
 from unittest import TestCase
 
+from PyQt5 import QtWidgets
+
 from openlp.core.ui.mainwindow import MainWindow
 from openlp.core.lib.ui import UiStrings
 from openlp.core.common.registry import Registry
@@ -189,3 +191,57 @@
             # THEN: The media manager dock is made visible
             self.assertEqual(0, mocked_media_manager_dock.setVisible.call_count)
             mocked_widget.on_focus.assert_called_with()
+
+    @patch('openlp.core.ui.mainwindow.MainWindow.plugin_manager')
+    @patch('openlp.core.ui.mainwindow.MainWindow.first_time')
+    @patch('openlp.core.ui.mainwindow.MainWindow.application')
+    @patch('openlp.core.ui.mainwindow.FirstTimeForm')
+    @patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.warning')
+    @patch('openlp.core.ui.mainwindow.Settings')
+    def on_first_time_wizard_clicked_show_projectors_after_test(self, mocked_Settings, mocked_warning,
+                                                                mocked_FirstTimeForm, mocked_application,
+                                                                mocked_first_time,
+                                                                mocked_plugin_manager):
+        # GIVEN: Main_window, patched things, patched "Yes" as confirmation to re-run wizard, settings to True.
+        mocked_Settings_obj = MagicMock()
+        mocked_Settings_obj.value.return_value = True
+        mocked_Settings.return_value = mocked_Settings_obj
+        mocked_warning.return_value = QtWidgets.QMessageBox.Yes
+        mocked_FirstTimeForm_obj = MagicMock()
+        mocked_FirstTimeForm_obj.was_cancelled = False
+        mocked_FirstTimeForm.return_value = mocked_FirstTimeForm_obj
+        mocked_plugin_manager.plugins = []
+        self.main_window.projector_manager_dock = MagicMock()
+
+        # WHEN: on_first_time_wizard_clicked is called
+        self.main_window.on_first_time_wizard_clicked()
+
+        # THEN: projector_manager_dock.setVisible should had been called once
+        self.main_window.projector_manager_dock.setVisible.assert_called_once_with(True)
+
+    @patch('openlp.core.ui.mainwindow.MainWindow.plugin_manager')
+    @patch('openlp.core.ui.mainwindow.MainWindow.first_time')
+    @patch('openlp.core.ui.mainwindow.MainWindow.application')
+    @patch('openlp.core.ui.mainwindow.FirstTimeForm')
+    @patch('openlp.core.ui.mainwindow.QtWidgets.QMessageBox.warning')
+    @patch('openlp.core.ui.mainwindow.Settings')
+    def on_first_time_wizard_clicked_hide_projectors_after_test(self, mocked_Settings, mocked_warning,
+                                                                mocked_FirstTimeForm, mocked_application,
+                                                                mocked_first_time,
+                                                                mocked_plugin_manager):
+        # GIVEN: Main_window, patched things, patched "Yes" as confirmation to re-run wizard, settings to False.
+        mocked_Settings_obj = MagicMock()
+        mocked_Settings_obj.value.return_value = False
+        mocked_Settings.return_value = mocked_Settings_obj
+        mocked_warning.return_value = QtWidgets.QMessageBox.Yes
+        mocked_FirstTimeForm_obj = MagicMock()
+        mocked_FirstTimeForm_obj.was_cancelled = False
+        mocked_FirstTimeForm.return_value = mocked_FirstTimeForm_obj
+        mocked_plugin_manager.plugins = []
+        self.main_window.projector_manager_dock = MagicMock()
+
+        # WHEN: on_first_time_wizard_clicked is called
+        self.main_window.on_first_time_wizard_clicked()
+
+        # THEN: projector_manager_dock.setVisible should had been called once
+        self.main_window.projector_manager_dock.setVisible.assert_called_once_with(False)


References