← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol/openlp/screen into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol/openlp/screen into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)
  Raoul Snyman (raoul-snyman)

For more details, see:
https://code.launchpad.net/~googol/openlp/screen/+merge/148893

Hello,

- use own ScreenList() call instead of using parents to access it

-- 
https://code.launchpad.net/~googol/openlp/screen/+merge/148893
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py	2013-02-04 21:26:27 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py	2013-02-16 18:40:28 +0000
@@ -58,6 +58,7 @@
 
 from PyQt4 import QtCore
 
+from openlp.core.lib import ScreenList
 from openlp.core.utils import delete_file, get_uno_command, get_uno_instance
 from presentationcontroller import PresentationController, PresentationDocument
 
@@ -254,7 +255,7 @@
             window = self.document.getCurrentController().getFrame().getContainerWindow()
             window.setVisible(False)
         self.presentation = self.document.getPresentation()
-        self.presentation.Display = self.controller.plugin.renderer.screens.current[u'number'] + 1
+        self.presentation.Display = ScreenList().current[u'number'] + 1
         self.control = None
         self.create_thumbnails()
         return True

=== modified file 'openlp/plugins/presentations/lib/powerpointcontroller.py'
--- openlp/plugins/presentations/lib/powerpointcontroller.py	2013-01-05 22:17:30 +0000
+++ openlp/plugins/presentations/lib/powerpointcontroller.py	2013-02-16 18:40:28 +0000
@@ -36,6 +36,7 @@
     import win32ui
     import pywintypes
 
+from openlp.core.lib import ScreenList
 from presentationcontroller import PresentationController, PresentationDocument
 
 log = logging.getLogger(__name__)
@@ -252,8 +253,7 @@
                     dpi = win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88)
                 except win32ui.error:
                     dpi = 96
-            renderer = self.controller.plugin.renderer
-            rect = renderer.screens.current[u'size']
+            rect = ScreenList().current[u'size']
             ppt_window = self.presentation.SlideShowSettings.Run()
             if not ppt_window:
                 return

=== modified file 'openlp/plugins/presentations/lib/pptviewcontroller.py'
--- openlp/plugins/presentations/lib/pptviewcontroller.py	2013-02-02 14:09:22 +0000
+++ openlp/plugins/presentations/lib/pptviewcontroller.py	2013-02-16 18:40:28 +0000
@@ -34,6 +34,7 @@
     from ctypes import cdll
     from ctypes.wintypes import RECT
 
+from openlp.core.lib import ScreenList
 from presentationcontroller import PresentationController, PresentationDocument
 
 log = logging.getLogger(__name__)
@@ -120,8 +121,7 @@
         PptView task started earlier.
         """
         log.debug(u'LoadPresentation')
-        renderer = self.controller.plugin.renderer
-        rect = renderer.screens.current[u'size']
+        rect = ScreenList().current[u'size']
         rect = RECT(rect.x(), rect.y(), rect.right(), rect.bottom())
         filepath = str(self.filepath.replace(u'/', u'\\'))
         if not os.path.isdir(self.get_temp_folder()):

=== modified file 'tests/functional/__init__.py'
--- tests/functional/__init__.py	2013-02-14 17:30:28 +0000
+++ tests/functional/__init__.py	2013-02-16 18:40:28 +0000
@@ -5,4 +5,9 @@
 sip.setapi(u'QTextStream', 2)
 sip.setapi(u'QTime', 2)
 sip.setapi(u'QUrl', 2)
-sip.setapi(u'QVariant', 2)
\ No newline at end of file
+sip.setapi(u'QVariant', 2)
+
+from PyQt4 import QtGui
+
+# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a  QApplication.
+application = QtGui.QApplication([])

=== modified file 'tests/functional/openlp_core_lib/test_image_manager.py'
--- tests/functional/openlp_core_lib/test_image_manager.py	2013-02-16 10:15:49 +0000
+++ tests/functional/openlp_core_lib/test_image_manager.py	2013-02-16 18:40:28 +0000
@@ -20,7 +20,7 @@
         Create the UI
         """
         Registry.create()
-        self.app = QtGui.QApplication([])
+        self.app = QtGui.QApplication.instance()
         ScreenList.create(self.app.desktop())
         self.image_manager = ImageManager()
 

=== added file 'tests/functional/openlp_core_lib/test_screen.py'
--- tests/functional/openlp_core_lib/test_screen.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_core_lib/test_screen.py	2013-02-16 18:40:28 +0000
@@ -0,0 +1,55 @@
+"""
+Package to test the openlp.core.lib.screenlist package.
+"""
+import copy
+from unittest import TestCase
+
+from mock import MagicMock
+from PyQt4 import QtGui, QtCore
+
+from openlp.core.lib import ScreenList
+
+
+SCREEN = {
+    u'primary': False,
+    u'number': 1,
+    u'size': QtCore.QRect(0, 0, 1024, 768)
+}
+
+
+class TestScreenList(TestCase):
+
+    def setUp(self):
+        """
+        Set up the components need for all tests.
+        """
+        self.application = QtGui.QApplication.instance()
+        self.screens = ScreenList.create(self.application.desktop())
+
+    def tearDown(self):
+        """
+        Delete QApplication.
+        """
+        del self.application
+
+    def add_desktop_test(self):
+        """
+        Test the ScreenList class' screen_count_changed method to check if new monitors are detected by OpenLP.
+        """
+        # GIVEN: The screen list.
+        old_screens = copy.deepcopy(self.screens.screen_list)
+        # Mock the attributes.
+        self.screens.desktop.primaryScreen = MagicMock(return_value=SCREEN[u'primary'])
+        self.screens.desktop.screenCount = MagicMock(return_value=SCREEN[u'number'] + 1)
+        self.screens.desktop.screenGeometry = MagicMock(return_value=SCREEN[u'size'])
+
+        # WHEN: Add a new screen.
+        self.screens.screen_count_changed(len(old_screens))
+
+        # THEN: The screen should have been added.
+        new_screens = self.screens.screen_list
+        assert len(old_screens) + 1 == len(new_screens), u'The new_screens list should be bigger.'
+
+        # THEN: The screens should be identically.
+        assert SCREEN == new_screens.pop(), u'The new screen should be identically to the screen defined above.'
+

=== modified file 'tests/interfaces/__init__.py'
--- tests/interfaces/__init__.py	2013-02-14 17:30:28 +0000
+++ tests/interfaces/__init__.py	2013-02-16 18:40:28 +0000
@@ -5,4 +5,9 @@
 sip.setapi(u'QTextStream', 2)
 sip.setapi(u'QTime', 2)
 sip.setapi(u'QUrl', 2)
-sip.setapi(u'QVariant', 2)
\ No newline at end of file
+sip.setapi(u'QVariant', 2)
+
+from PyQt4 import QtGui
+
+# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a  QApplication.
+application = QtGui.QApplication([])

=== modified file 'tests/interfaces/openlp_core_lib/test_pluginmanager.py'
--- tests/interfaces/openlp_core_lib/test_pluginmanager.py	2013-02-11 21:16:30 +0000
+++ tests/interfaces/openlp_core_lib/test_pluginmanager.py	2013-02-16 18:40:28 +0000
@@ -26,13 +26,14 @@
         Settings().set_filename(self.ini_file)
         Registry.create()
         Registry().register(u'service_list', MagicMock())
-        self.app = QtGui.QApplication([])
+        self.app = QtGui.QApplication.instance()
         self.main_window = QtGui.QMainWindow()
         Registry().register(u'main_window', self.main_window)
         self.plugins_dir = os.path.abspath(os.path.join(os.path.basename(__file__), u'..', u'openlp', u'plugins'))
 
     def tearDown(self):
         os.unlink(self.ini_file)
+        del self.app
 
     def find_plugins_test(self):
         """

=== modified file 'tests/interfaces/openlp_core_ui/test_filerenamedialog.py'
--- tests/interfaces/openlp_core_ui/test_filerenamedialog.py	2013-02-12 19:26:19 +0000
+++ tests/interfaces/openlp_core_ui/test_filerenamedialog.py	2013-02-16 18:40:28 +0000
@@ -15,7 +15,7 @@
         Create the UI
         """
         registry = Registry.create()
-        self.app = QtGui.QApplication([])
+        self.app = QtGui.QApplication.instance()
         self.main_window = QtGui.QMainWindow()
         Registry().register(u'main_window', self.main_window)
         self.form = filerenameform.FileRenameForm()

=== modified file 'tests/interfaces/openlp_core_ui/test_servicemanager.py'
--- tests/interfaces/openlp_core_ui/test_servicemanager.py	2013-02-16 10:17:48 +0000
+++ tests/interfaces/openlp_core_ui/test_servicemanager.py	2013-02-16 18:40:28 +0000
@@ -18,7 +18,7 @@
         Create the UI
         """
         Registry.create()
-        self.app = QtGui.QApplication([])
+        self.app = QtGui.QApplication.instance()
         ScreenList.create(self.app.desktop())
         Registry().register(u'application', MagicMock())
         self.main_window = MainWindow()

=== modified file 'tests/interfaces/openlp_core_ui/test_servicenotedialog.py'
--- tests/interfaces/openlp_core_ui/test_servicenotedialog.py	2013-02-16 06:51:25 +0000
+++ tests/interfaces/openlp_core_ui/test_servicenotedialog.py	2013-02-16 18:40:28 +0000
@@ -17,7 +17,7 @@
         Create the UI
         """
         Registry.create()
-        self.app = QtGui.QApplication([])
+        self.app = QtGui.QApplication.instance()
         self.main_window = QtGui.QMainWindow()
         Registry().register(u'main_window', self.main_window)
         self.form = servicenoteform.ServiceNoteForm()
@@ -66,4 +66,5 @@
         QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
 
         # THEN the following text is returned
-        self.assertEqual(self.form.text_edit.toPlainText(), text, u'The new text should be returned')
\ No newline at end of file
+        self.assertEqual(self.form.text_edit.toPlainText(), text, u'The new text should be returned')
+

=== modified file 'tests/interfaces/openlp_core_ui/test_starttimedialog.py'
--- tests/interfaces/openlp_core_ui/test_starttimedialog.py	2013-02-16 06:51:25 +0000
+++ tests/interfaces/openlp_core_ui/test_starttimedialog.py	2013-02-16 18:40:28 +0000
@@ -17,7 +17,7 @@
         Create the UI
         """
         Registry.create()
-        self.app = QtGui.QApplication([])
+        self.app = QtGui.QApplication.instance()
         self.main_window = QtGui.QMainWindow()
         Registry().register(u'main_window', self.main_window)
         self.form = starttimeform.StartTimeForm()
@@ -93,4 +93,4 @@
         self.assertEqual(self.form.hourSpinBox.value(), 0)
         self.assertEqual(self.form.minuteSpinBox.value(), 2)
         self.assertEqual(self.form.secondSpinBox.value(), 3)
-        self.assertEqual(self.form.item[u'service_item'].start_time, 123, u'The start time should have changed')
\ No newline at end of file
+        self.assertEqual(self.form.item[u'service_item'].start_time, 123, u'The start time should have changed')


Follow ups