← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/themefixes into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/themefixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~trb143/openlp/themefixes/+merge/290340

Service Manager themes are not updated in service items when the settings theme is changed.

Set the tab_visited correctly as it was being set on setup!

lp:~trb143/openlp/themefixes (revision 2635)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1343/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1263/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1202/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1037/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/628/
[SUCCESS] https://ci.openlp.io/job/Branch-05a-Code_Analysis/695/
[SUCCESS] https://ci.openlp.io/job/Branch-05b-Test_Coverage/563/
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/themefixes into lp:openlp.
=== modified file 'openlp/core/lib/settingstab.py'
--- openlp/core/lib/settingstab.py	2015-12-31 22:46:06 +0000
+++ openlp/core/lib/settingstab.py	2016-03-29 17:09:30 +0000
@@ -135,4 +135,4 @@
         """
         Tab has just been made visible to the user
         """
-        self.tab_visited = True
+        pass

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2016-01-19 07:02:47 +0000
+++ openlp/core/ui/servicemanager.py	2016-03-29 17:09:30 +0000
@@ -1326,6 +1326,7 @@
         visible = self.renderer.theme_level == ThemeLevel.Global
         self.theme_label.setVisible(visible)
         self.theme_combo_box.setVisible(visible)
+        self.regenerate_service_items()
 
     def regenerate_service_items(self, changed=False):
         """

=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py	2016-01-09 16:26:14 +0000
+++ openlp/core/ui/settingsform.py	2016-03-29 17:09:30 +0000
@@ -60,7 +60,8 @@
         """
         Execute the form
         """
-        # load all the settings
+        # load all the
+        self.setting_list_widget.blockSignals(True)
         self.setting_list_widget.clear()
         while self.stacked_layout.count():
             # take at 0 and the rest shuffle up.
@@ -74,6 +75,7 @@
             if plugin.settings_tab:
                 self.insert_tab(plugin.settings_tab, plugin.is_active())
         self.setting_list_widget.setCurrentRow(0)
+        self.setting_list_widget.blockSignals(False)
         return QtWidgets.QDialog.exec(self)
 
     def insert_tab(self, tab_widget, is_visible=True):
@@ -177,6 +179,7 @@
             # Check that the title of the tab (i.e. plugin name) is the same as the data in the list item
             if tab_widget.tab_title == list_item.data(QtCore.Qt.UserRole):
                 # Make the matching tab visible
+                tab_widget.tab_visited = True
                 self.stacked_layout.setCurrentIndex(tab_index)
                 self.stacked_layout.currentWidget().tab_visible()
 

=== added file 'tests/functional/openlp_core_ui/test_themetab.py'
--- tests/functional/openlp_core_ui/test_themetab.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_ui/test_themetab.py	2016-03-29 17:09:30 +0000
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2016 OpenLP Developers                                   #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; version 2 of the License.                              #
+#                                                                             #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
+# more details.                                                               #
+#                                                                             #
+# You should have received a copy of the GNU General Public License along     #
+# with this program; if not, write to the Free Software Foundation, Inc., 59  #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
+###############################################################################
+"""
+Package to test the openlp.core.ui.ThemeTab package.
+"""
+from unittest import TestCase
+
+from openlp.core.common import Registry
+from openlp.core.ui.themestab import ThemesTab
+from openlp.core.ui.settingsform import SettingsForm
+
+from tests.helpers.testmixin import TestMixin
+from tests.functional import MagicMock
+
+
+class TestThemeTab(TestCase, TestMixin):
+
+    def setUp(self):
+        """
+        Set up a few things for the tests
+        """
+        Registry.create()
+
+    def test_creation(self):
+        """
+        Test that  Themes Tab is created.
+        """
+        # GIVEN: A new Advanced Tab
+        settings_form = SettingsForm(None)
+
+        # WHEN: I create an advanced tab
+        themes_tab = ThemesTab(settings_form)
+
+        # THEN:
+        self.assertEqual("Themes", themes_tab.tab_title, 'The tab title should be Theme')
+
+    def test_save_triggers_processes_true(self):
+        """
+        Test that the global theme event is triggered when the tab is visited.
+        """
+        # GIVEN: A new Advanced Tab
+        settings_form = SettingsForm(None)
+        themes_tab = ThemesTab(settings_form)
+        Registry().register('renderer', MagicMock())
+        themes_tab.tab_visited = True
+        # WHEN: I change search as type check box
+        themes_tab.save()
+
+        # THEN: we should have two post save processed to run
+        self.assertEqual(1, len(settings_form.processes), 'One post save processes should be created')
+
+    def test_save_triggers_processes_false(self):
+        """
+        Test that the global theme event is not triggered when the tab is not visited.
+        """
+        # GIVEN: A new Advanced Tab
+        settings_form = SettingsForm(None)
+        themes_tab = ThemesTab(settings_form)
+        Registry().register('renderer', MagicMock())
+        themes_tab.tab_visited = False
+        # WHEN: I change search as type check box
+        themes_tab.save()
+
+        # THEN: we should have two post save processed to run
+        self.assertEqual(0, len(settings_form.processes), 'No post save processes should be created')


Follow ups