← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~sam92/openlp/bug-1296574 into lp:openlp

 

Samuel Mehrbrodt has proposed merging lp:~sam92/openlp/bug-1296574 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1296574 in OpenLP: "Missing arguments in some event handler functions"
  https://bugs.launchpad.net/openlp/+bug/1296574

For more details, see:
https://code.launchpad.net/~sam92/openlp/bug-1296574/+merge/212829
-- 
https://code.launchpad.net/~sam92/openlp/bug-1296574/+merge/212829
Your team OpenLP Core is requested to review the proposed merge of lp:~sam92/openlp/bug-1296574 into lp:openlp.
=== modified file 'openlp/core/lib/ui.py'
--- openlp/core/lib/ui.py	2014-03-17 19:05:55 +0000
+++ openlp/core/lib/ui.py	2014-03-26 12:09:19 +0000
@@ -74,11 +74,13 @@
     :param name: A string which is set as object name.
     :param standard_buttons: A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``,
     ``close``, and ``defaults``.
-    :param custom_buttons: A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added
-    with QDialogButtonBox.ActionRole. Other wise the item has to be a tuple of a button and a ButtonRole.
+    :param custom_buttons: A list of additional buttons. If an item is an instance of QtGui.QAbstractButton it is added
+    with QDialogButtonBox.ActionRole. Otherwise the item has to be a tuple of a Button and a ButtonRole.
     """
     if custom_buttons is None:
         custom_buttons = []
+    if standard_buttons is None:
+        standard_buttons = []
     buttons = QtGui.QDialogButtonBox.NoButton
     if 'ok' in standard_buttons:
         buttons |= QtGui.QDialogButtonBox.Ok

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2014-03-20 19:10:31 +0000
+++ openlp/core/ui/slidecontroller.py	2014-03-26 12:09:19 +0000
@@ -471,7 +471,7 @@
                                          category=self.category,
                                          triggers=self.live_escape)
 
-    def live_escape(self):
+    def live_escape(self, field=None):
         """
         If you press ESC on the live screen it should close the display temporarily.
         """
@@ -1243,7 +1243,7 @@
         if self.service_item:
             self.service_manager.add_service_item(self.service_item)
 
-    def on_go_live_click(self):
+    def on_go_live_click(self, field=None):
         """
         triggered by clicking the Preview slide items
         """
@@ -1256,7 +1256,7 @@
                 self.on_media_close()
             self.on_go_live()
 
-    def on_go_live(self):
+    def on_go_live(self, field=None):
         """
         If preview copy slide item to live controller from Preview Controller
         """

=== modified file 'tests/functional/openlp_core_lib/test_ui.py'
--- tests/functional/openlp_core_lib/test_ui.py	2014-03-24 13:32:28 +0000
+++ tests/functional/openlp_core_lib/test_ui.py	2014-03-26 12:09:19 +0000
@@ -53,3 +53,31 @@
         # THEN: The wizard should have one page with a pixmap.
         self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.')
         self.assertIsInstance(wizard.page(0).pixmap(QtGui.QWizard.WatermarkPixmap), QtGui.QPixmap)
+
+    def test_create_button_box(self):
+        """
+        Test creating a button box for a dialog
+        """
+        # GIVEN: A dialog
+        dialog = QtGui.QDialog()
+
+        # WHEN: We create the button box with five buttons
+        btnbox = create_button_box(dialog, 'my_btns', ['ok', 'save', 'cancel', 'close', 'defaults'])
+
+        # THEN: We should get a QDialogButtonBox with five buttons
+        self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
+        self.assertEqual(5, len(btnbox.buttons()))
+
+        # WHEN: We create the button box with a custom button
+        btnbox = create_button_box(dialog, 'my_btns', None, [QtGui.QPushButton('Custom')])
+        # THEN: We should get a QDialogButtonBox with one button
+        self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
+        self.assertEqual(1, len(btnbox.buttons()))
+
+        # WHEN: We create the button box with a custom button and a custom role
+        btnbox = create_button_box(dialog, 'my_btns', None,
+                                   [(QtGui.QPushButton('Help'), QtGui.QDialogButtonBox.HelpRole)])
+        # THEN: We should get a QDialogButtonBox with one button with a certain role
+        self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
+        self.assertEqual(1, len(btnbox.buttons()))
+        self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))


Follow ups