← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~alisonken1/openlp/bug-1386913 into lp:openlp

 

Ken Roberts has proposed merging lp:~alisonken1/openlp/bug-1386913 into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)
Related bugs:
  Bug #1386913 in OpenLP: "Remove "Discard" option when selecting source input"
  https://bugs.launchpad.net/openlp/+bug/1386913

For more details, see:
https://code.launchpad.net/~alisonken1/openlp/bug-1386913/+merge/243297

bugfix #1386913

Fix "Discard" and "Reset" dialog buttons calling wrong functions (swapttped)
Fix dialog title text to reflect proper "Select" or "Edit" title
Fix tabbed dialog width to be consistent
Added calls to translate for user text
Added basic test for openlp.core.ui.projector.sourceselectform
Change double quotes to single quotes
* NOTE: Jenkins broken - only change was changing double quotes to single quotes and add .bzrignore from trunk

lp:~alisonken1/openlp/bug-1386913 (revision 2442)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/765/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/703/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/647/
[SUCCESS] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/586/
[SUCCESS] http://ci.openlp.org/job/Branch-04b-Windows_Interface_Tests/195/
[SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/400/
[SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/274/

-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== added file '.bzrignore'
--- .bzrignore	1970-01-01 00:00:00 +0000
+++ .bzrignore	2014-12-01 15:41:31 +0000
@@ -0,0 +1,42 @@
+*.pyc
+*.*~
+\#*\#
+*.eric4project
+*.eric5project
+*.ropeproject
+*.e4*
+.eric4project
+.komodotools
+*.komodoproject
+list
+openlp.org 2.0.e4*
+documentation/build/html
+documentation/build/doctrees
+*.log*
+dist
+OpenLP.egg-info
+build
+resources/innosetup/Output
+_eric4project
+.pylint.d
+*.qm
+openlp/core/resources.py.old
+*.qm
+resources/windows/warnOpenLP.txt
+openlp.cfg
+.idea
+openlp.pro
+.kdev4
+tests.kdev4
+*.nja
+*.orig
+__pycache__
+*.dll
+.directory
+*.kate-swp
+# Git files
+.git
+.gitignore
+# Rejected diff's
+*.rej
+*.~\?~

=== removed file '.bzrignore'
--- .bzrignore	2014-10-07 19:37:55 +0000
+++ .bzrignore	1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
-*.pyc
-*.*~
-\#*\#
-*.eric4project
-*.eric5project
-*.ropeproject
-*.e4*
-.eric4project
-.komodotools
-*.komodoproject
-list
-openlp.org 2.0.e4*
-documentation/build/html
-documentation/build/doctrees
-*.log*
-dist
-OpenLP.egg-info
-build
-resources/innosetup/Output
-_eric4project
-.pylint.d
-*.qm
-openlp/core/resources.py.old
-*.qm
-resources/windows/warnOpenLP.txt
-openlp.cfg
-.idea
-openlp.pro
-.kdev4
-tests.kdev4
-*.nja
-*.orig
-__pycache__
-*.dll
-.directory
-*.kate-swp
-# Git files
-.git
-.gitignore
-# Rejected diff's
-*.rej
-*.~\?~

=== modified file 'openlp/core/ui/projector/sourceselectform.py'
--- openlp/core/ui/projector/sourceselectform.py	2014-10-23 21:00:06 +0000
+++ openlp/core/ui/projector/sourceselectform.py	2014-12-01 15:41:31 +0000
@@ -152,16 +152,19 @@
     """
     for button in bar.buttons():
         if bar.standardButton(button) == QDialogButtonBox.Cancel:
-            tip = "Ignoring current changes and return to OpenLP"
+            button.setToolTip(translate('OpenLP.SourceSelectForm',
+                                        'Ignoring current changes and return to OpenLP'))
         elif bar.standardButton(button) == QDialogButtonBox.Reset:
-            tip = "Delete all user-defined text and revert to PJLink default text"
+            button.setToolTip(translate('OpenLP.SourceSelectForm',
+                                        'Delete all user-defined text and revert to PJLink default text'))
         elif bar.standardButton(button) == QDialogButtonBox.Discard:
-            tip = "Discard changes and reset to previous user-defined text"
+            button.setToolTip(translate('OpenLP.SourceSelectForm',
+                                        'Discard changes and reset to previous user-defined text'))
         elif bar.standardButton(button) == QDialogButtonBox.Ok:
-            tip = "Save changes and return to OpenLP"
+            button.setToolTip(translate('OpenLP.SourceSelectForm',
+                                        'Save changes and return to OpenLP'))
         else:
-            tip = ""
-        button.setToolTip(tip)
+            log.debug('No tooltip for button {}'.format(button.text()))
 
 
 class FingerTabBarWidget(QTabBar):
@@ -237,12 +240,13 @@
         """
         log.debug('Initializing SourceSelectTabs()')
         super(SourceSelectTabs, self).__init__(parent)
+        self.setMinimumWidth(350)
         self.projectordb = projectordb
         self.edit = edit
         if self.edit:
+            title = translate('OpenLP.SourceSelectForm', 'Edit Projector Source Text')
+        else:
             title = translate('OpenLP.SourceSelectForm', 'Select Projector Source')
-        else:
-            title = translate('OpenLP.SourceSelectForm', 'Edit Projector Source Text')
         self.setWindowTitle(title)
         self.setObjectName('source_select_tabs')
         self.setWindowIcon(build_icon(':/icon/openlp-log-32x32.png'))
@@ -286,6 +290,10 @@
                 thistab = self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key])
                 if buttonchecked:
                     self.tabwidget.setCurrentIndex(thistab)
+            self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Reset |
+                                               QtGui.QDialogButtonBox.Discard |
+                                               QtGui.QDialogButtonBox.Ok |
+                                               QtGui.QDialogButtonBox.Cancel)
         else:
             for key in keys:
                 (tab, button_count, buttonchecked) = Build_Tab(group=self.button_group,
@@ -297,10 +305,8 @@
                 thistab = self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key])
                 if buttonchecked:
                     self.tabwidget.setCurrentIndex(thistab)
-        self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Reset |
-                                           QtGui.QDialogButtonBox.Discard |
-                                           QtGui.QDialogButtonBox.Ok |
-                                           QtGui.QDialogButtonBox.Cancel)
+            self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Ok |
+                                               QtGui.QDialogButtonBox.Cancel)
         self.button_box.clicked.connect(self.button_clicked)
         self.layout.addWidget(self.button_box)
         set_button_tooltip(self.button_box)
@@ -321,9 +327,9 @@
         if self.button_box.standardButton(button) == self.button_box.Cancel:
             self.done(0)
         elif self.button_box.standardButton(button) == self.button_box.Reset:
+            self.done(100)
+        elif self.button_box.standardButton(button) == self.button_box.Discard:
             self.delete_sources()
-        elif self.button_box.standardButton(button) == self.button_box.Discard:
-            self.done(100)
         elif self.button_box.standardButton(button) == self.button_box.Ok:
             return self.accept_me()
         else:
@@ -331,9 +337,11 @@
 
     def delete_sources(self):
         msg = QtGui.QMessageBox()
-        msg.setText('Delete entries for this projector')
-        msg.setInformativeText('Are you sure you want to delete ALL user-defined '
-                               'source input text for this projector?')
+        msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector'))
+        msg.setInformativeText(translate('OpenLP.SourceSelectForm',
+                                         'Are you sure you want to delete ALL user-defined '),
+                               translate('OpenLP.SourceSelectForm',
+                                         'source input text for this projector?'))
         msg.setStandardButtons(msg.Cancel | msg.Ok)
         msg.setDefaultButton(msg.Cancel)
         ans = msg.exec_()
@@ -382,7 +390,11 @@
         log.debug('Initializing SourceSelectSingle()')
         self.projectordb = projectordb
         super(SourceSelectSingle, self).__init__(parent)
-        self.setWindowTitle(translate('OpenLP.SourceSelectSingle', 'Select Projector Source'))
+        self.edit = edit
+        if self.edit:
+            title = translate('OpenLP.SourceSelectForm', 'Edit Projector Source Text')
+        else:
+            title = translate('OpenLP.SourceSelectForm', 'Select Projector Source')
         self.setObjectName('source_select_single')
         self.setWindowIcon(build_icon(':/icon/openlp-log-32x32.png'))
         self.setModal(True)
@@ -418,6 +430,10 @@
                     item.setText(source_item.text)
                 self.layout.addRow(PJLINK_DEFAULT_CODES[key], item)
                 self.button_group.append(item)
+            self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Reset |
+                                               QtGui.QDialogButtonBox.Discard |
+                                               QtGui.QDialogButtonBox.Ok |
+                                               QtGui.QDialogButtonBox.Cancel)
         else:
             for key in keys:
                 source_text = self.projectordb.get_source_by_code(code=key, projector_id=self.projector.db_item.id)
@@ -427,10 +443,8 @@
                 self.layout.addWidget(button)
                 self.button_group.addButton(button, int(key))
                 button_list.append(key)
-        self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Reset |
-                                           QtGui.QDialogButtonBox.Discard |
-                                           QtGui.QDialogButtonBox.Ok |
-                                           QtGui.QDialogButtonBox.Cancel)
+            self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Ok |
+                                               QtGui.QDialogButtonBox.Cancel)
         self.button_box.clicked.connect(self.button_clicked)
         self.layout.addWidget(self.button_box)
         self.setMinimumHeight(key_count*25)
@@ -452,9 +466,9 @@
         if self.button_box.standardButton(button) == self.button_box.Cancel:
             self.done(0)
         elif self.button_box.standardButton(button) == self.button_box.Reset:
+            self.done(100)
+        elif self.button_box.standardButton(button) == self.button_box.Discard:
             self.delete_sources()
-        elif self.button_box.standardButton(button) == self.button_box.Discard:
-            self.done(100)
         elif self.button_box.standardButton(button) == self.button_box.Ok:
             return self.accept_me()
         else:
@@ -462,9 +476,11 @@
 
     def delete_sources(self):
         msg = QtGui.QMessageBox()
-        msg.setText('Delete entries for this projector')
-        msg.setInformativeText('Are you sure you want to delete ALL user-defined '
-                               'source input text for this projector?')
+        msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector'))
+        msg.setInformativeText(translate('OpenLP.SourceSelectForm',
+                                         'Are you sure you want to delete ALL user-defined '),
+                               translate('OpenLP.SourceSelectForm',
+                                         'source input text for this projector?'))
         msg.setStandardButtons(msg.Cancel | msg.Ok)
         msg.setDefaultButton(msg.Cancel)
         ans = msg.exec_()

=== modified file 'tests/interfaces/openlp_core_ui/test_projectormanager.py'
--- tests/interfaces/openlp_core_ui/test_projectormanager.py	2014-10-24 19:17:12 +0000
+++ tests/interfaces/openlp_core_ui/test_projectormanager.py	2014-12-01 15:41:31 +0000
@@ -94,11 +94,9 @@
         self.projector_manager.bootstrap_initialise()
         self.projector_manager.bootstrap_post_set_up()
 
-        # THEN: verify calls to retrieve saved projectors
+        # THEN: verify calls to retrieve saved projectors and edit page initialized
         self.assertEqual(1, self.projector_manager._load_projectors.call_count,
                          'Initialization should have called load_projectors()')
-
-        # THEN: Verify edit page is initialized
         self.assertEqual(type(self.projector_manager.projector_form), ProjectorEditForm,
                          'Initialization should have created a Projector Edit Form')
         self.assertIs(self.projector_manager.projectordb,

=== added file 'tests/interfaces/openlp_core_ui/test_projectorsourceform.py'
--- tests/interfaces/openlp_core_ui/test_projectorsourceform.py	1970-01-01 00:00:00 +0000
+++ tests/interfaces/openlp_core_ui/test_projectorsourceform.py	2014-12-01 15:41:31 +0000
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2014 Raoul Snyman                                        #
+# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan      #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub,      #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer.   #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru,          #
+# Christian Richter, Philip Ridout, Ken Roberts, Simon Scudder,               #
+# Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon Tibble,             #
+# Dave Warnock, Frode Woldsund, Martin Zibricky, Patrick Zimmermann           #
+# --------------------------------------------------------------------------- #
+# 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                          #
+###############################################################################
+"""
+    :mod: `tests.interfaces.openlp_core_ui.test_projectorsourceform` module
+
+    Tests for the Projector Source Select form.
+"""
+import logging
+log = logging.getLogger(__name__)
+log.debug('test_projectorsourceform loaded')
+
+from unittest import TestCase
+
+from tests.helpers.testmixin import TestMixin
+from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
+
+from openlp.core.ui.projector.sourceselectform import source_group
+
+
+def build_source_dict():
+    """
+    Builds a source dictionary to verify source_group returns a valid dictionary of dictionary items
+
+    :returns: dictionary of valid PJLink source codes grouped by PJLink source group
+    """
+    test_group = {}
+    for group in PJLINK_DEFAULT_SOURCES.keys():
+        test_group[group] = {}
+    for key in PJLINK_DEFAULT_CODES:
+        test_group[key[0]][key] = PJLINK_DEFAULT_CODES[key]
+    return test_group
+
+
+class ProjectorSourceFormTest(TestCase, TestMixin):
+    """
+    Test class for the Projector Source Select form module
+    """
+    def source_dict_test(self):
+        """
+        Test that source list dict returned from sourceselectform module is a valid dict with proper entries
+        """
+        # GIVEN: A list of inputs
+        codes = []
+        for item in PJLINK_DEFAULT_CODES.keys():
+            codes.append(item)
+        codes.sort()
+
+        # WHEN: projector.sourceselectform.source_select() is called
+        check = source_group(codes, PJLINK_DEFAULT_CODES)
+
+        # THEN: return dictionary should match test dictionary
+        self.assertEquals(check, build_source_dict(),
+                          "Source group dictionary should match test dictionary")


Follow ups