← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/tweaks into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/tweaks into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/tweaks/+merge/60680

- (re)moved obsolete code from settingsmanager
Some instance variables were just not needed (see loadSettings/saveSettings in mainwindow). One or two weren't used at all and the rest could be moved to the dockwidget.

- removed redundant code from ScreenList
The instance variable current_display can be obtained by using current[u'number']. I didn't figure out myself what monitor_number was for (on the one hand it was used for logging which suggests that it were equal to current_display, but on the other hand it was use to check if it is a single or dual setup). For the second case display_count is used.

- removed redundant code form MainDisplay
The DisplayWidget did not do anything (dead code)

- made the start up logic easier
Make sure we figure out what screen size we want and then load the rest. In addition the ScreenList instance does not have to be passed from parent to child to grandchild instead we use ScreenList.get_instance().

- fixed use of negative x and y values
When you change the second display to be on the left the x and y values are negative (as the origin is the upper left corner of the primary monitor), but the spin boxes didn't allow negative values and consequently you could not use the override.

- fixed ratio of images (in the small preview frame) after changing the screen ratio (1. preview image 2. change screen ratio 3. aspect ratio is ignored).
-- 
https://code.launchpad.net/~googol-hush/openlp/tweaks/+merge/60680
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp.pyw'
--- openlp.pyw	2011-05-02 17:35:40 +0000
+++ openlp.pyw	2011-05-11 19:06:13 +0000
@@ -115,8 +115,7 @@
         # make sure Qt really display the splash screen
         self.processEvents()
         # start the main app window
-        self.mainWindow = MainWindow(screens, self.clipboard(),
-            self.arguments())
+        self.mainWindow = MainWindow(self.clipboard(), self.arguments())
         self.mainWindow.show()
         if show_splash:
             # now kill the splashscreen

=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2011-05-08 11:35:10 +0000
+++ openlp/core/lib/__init__.py	2011-05-11 19:06:13 +0000
@@ -299,7 +299,6 @@
 from displaytags import DisplayTags
 from eventreceiver import Receiver
 from spelltextedit import SpellTextEdit
-from imagemanager import ImageManager
 from settingsmanager import SettingsManager
 from plugin import PluginStatus, StringContent, Plugin
 from pluginmanager import PluginManager
@@ -311,6 +310,7 @@
     build_lyrics_outline_css
 from toolbar import OpenLPToolbar
 from dockwidget import OpenLPDockWidget
+from imagemanager import ImageManager
 from renderer import Renderer
 from mediamanageritem import MediaManagerItem
 from openlp.core.utils.actions import ActionList

=== modified file 'openlp/core/lib/dockwidget.py'
--- openlp/core/lib/dockwidget.py	2011-03-24 19:04:02 +0000
+++ openlp/core/lib/dockwidget.py	2011-05-11 19:06:13 +0000
@@ -32,6 +32,7 @@
 from PyQt4 import QtGui
 
 from openlp.core.lib import build_icon
+from openlp.core.ui import ScreenList
 
 log = logging.getLogger(__name__)
 
@@ -50,3 +51,11 @@
             self.setObjectName(name)
         if icon:
             self.setWindowIcon(build_icon(icon))
+        # Sort out the minimum width.
+        screens = ScreenList.get_instance()
+        screen_width = screens.current[u'size'].width()
+        mainwindow_docbars = screen_width / 5
+        if mainwindow_docbars > 300:
+            self.setMinimumWidth(300)
+        else:
+            self.setMinimumWidth(mainwindow_docbars)

=== modified file 'openlp/core/lib/htmlbuilder.py'
--- openlp/core/lib/htmlbuilder.py	2011-04-14 21:34:01 +0000
+++ openlp/core/lib/htmlbuilder.py	2011-05-11 19:06:13 +0000
@@ -324,17 +324,22 @@
     """
     Build the full web paged structure for display
 
-    `item`
+    ``item``
         Service Item to be displayed
-    `screen`
+
+    ``screen``
         Current display information
-    `alert`
+
+    ``alert``
         Alert display display information
-    `islive`
+
+    ``islive``
         Item is going live, rather than preview/theme building
-    `background`
+
+    ``background``
         Theme background image - bytes
-    `image`
+
+    ``image``
         Image media item - bytes
     """
     width = screen[u'size'].width()
@@ -379,7 +384,7 @@
     """
     Build the background css
 
-    `item`
+    ``item``
         Service Item containing theme and location information
 
     """
@@ -432,10 +437,10 @@
     """
     Build the lyrics display css
 
-    `item`
+    ``item``
         Service Item containing theme and location information
 
-    `webkitvers`
+    ``webkitvers``
         The version of qtwebkit we're using
 
     """
@@ -509,10 +514,10 @@
     Build the css which controls the theme outline
     Also used by renderer for splitting verses
 
-    `theme`
+    ``theme``
         Object containing theme information
 
-    `is_shadow`
+    ``is_shadow``
         If true, use the shadow colors instead
     """
     if theme.font_main_outline:
@@ -533,13 +538,13 @@
     Build the css which controls the theme format
     Also used by renderer for splitting verses
 
-    `theme`
+    ``theme``
         Object containing theme information
 
-    `width`
+    ``width``
         Width of the lyrics block
 
-    `height`
+    ``height``
         Height of the lyrics block
 
     """
@@ -569,10 +574,10 @@
     """
     Build the HTML required to show the lyrics
 
-    `item`
+    ``item``
         Service Item containing theme and location information
 
-    `webkitvers`
+    ``webkitvers``
         The version of qtwebkit we're using
     """
     # Bugs in some versions of QtWebKit mean we sometimes need additional
@@ -598,7 +603,7 @@
     """
     Build the display of the item footer
 
-    `item`
+    ``item``
         Service Item to be processed.
     """
     style = """
@@ -624,7 +629,7 @@
     """
     Build the display of the footer
 
-    `alertTab`
+    ``alertTab``
         Details from the Alert tab for fonts etc
     """
     style = """

=== modified file 'openlp/core/lib/imagemanager.py'
--- openlp/core/lib/imagemanager.py	2011-03-24 19:04:02 +0000
+++ openlp/core/lib/imagemanager.py	2011-05-11 19:06:13 +0000
@@ -35,6 +35,7 @@
 from PyQt4 import QtCore
 
 from openlp.core.lib import resize_image, image_to_byte
+from openlp.core.ui import ScreenList
 
 log = logging.getLogger(__name__)
 
@@ -70,18 +71,22 @@
 
     def __init__(self):
         QtCore.QObject.__init__(self)
+        current_screen = ScreenList.get_instance().current
+        self.width = current_screen[u'size'].width()
+        self.height = current_screen[u'size'].height()
         self._cache = {}
         self._thread_running = False
         self._cache_dirty = False
         self.image_thread = ImageThread(self)
 
-    def update_display(self, width, height):
+    def update_display(self):
         """
         Screen has changed size so rebuild the cache to new size
         """
         log.debug(u'update_display')
-        self.width = width
-        self.height = height
+        current_screen = ScreenList.get_instance().current
+        self.width = current_screen[u'size'].width()
+        self.height = current_screen[u'size'].height()
         # mark the images as dirty for a rebuild
         for key in self._cache.keys():
             image = self._cache[key]

=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py	2011-04-29 19:24:21 +0000
+++ openlp/core/lib/renderer.py	2011-05-11 19:06:13 +0000
@@ -28,11 +28,11 @@
 
 from PyQt4 import QtCore, QtWebKit
 
-from openlp.core.lib import ServiceItem, ImageManager, expand_tags, \
+from openlp.core.lib import ServiceItem, expand_tags, \
     build_lyrics_format_css, build_lyrics_outline_css, Receiver, \
     ItemCapabilities
 from openlp.core.lib.theme import ThemeLevel
-from openlp.core.ui import MainDisplay
+from openlp.core.ui import MainDisplay, ScreenList
 
 log = logging.getLogger(__name__)
 
@@ -52,33 +52,32 @@
     Class to pull all Renderer interactions into one place. The plugins will
     call helper methods to do the rendering but this class will provide
     display defense code.
+    """
+    log.info(u'Renderer Loaded')
+
+    def __init__(self, image_manager, theme_manager):
+        """
+        Initialise the render manager.
+
+    ``image_manager``
+        A ImageManager instance which takes care of e. g. caching and resizing
+        images.
 
     ``theme_manager``
         The ThemeManager instance, used to get the current theme details.
-
-    ``screens``
-        Contains information about the Screens.
-
-    ``screen_number``
-        Defaults to *0*. The index of the output/display screen.
-    """
-    log.info(u'Renderer Loaded')
-
-    def __init__(self, theme_manager, screens):
-        """
-        Initialise the render manager.
         """
         log.debug(u'Initilisation started')
-        self.screens = screens
-        self.image_manager = ImageManager()
-        self.display = MainDisplay(self, screens, False)
-        self.display.imageManager = self.image_manager
         self.theme_manager = theme_manager
+        self.image_manager = image_manager
+        self.screens = ScreenList.get_instance()
         self.service_theme = u''
         self.theme_level = u''
         self.override_background = None
         self.theme_data = None
+        self.bg_frame = None
         self.force_page = False
+        self.display = MainDisplay(self, self.image_manager, False)
+        self.display.setup()
 
     def update_display(self):
         """
@@ -86,12 +85,10 @@
         """
         log.debug(u'Update Display')
         self._calculate_default(self.screens.current[u'size'])
-        self.display = MainDisplay(self, self.screens, False)
-        self.display.imageManager = self.image_manager
+        self.display = MainDisplay(self, self.image_manager, False)
         self.display.setup()
         self.bg_frame = None
         self.theme_data = None
-        self.image_manager.update_display(self.width, self.height)
 
     def set_global_theme(self, global_theme, theme_level=ThemeLevel.Global):
         """

=== modified file 'openlp/core/lib/settingsmanager.py'
--- openlp/core/lib/settingsmanager.py	2011-03-24 19:04:02 +0000
+++ openlp/core/lib/settingsmanager.py	2011-05-11 19:06:13 +0000
@@ -37,26 +37,9 @@
 
 class SettingsManager(object):
     """
-    Class to control the initial settings for the UI and provide helper
-    functions for the loading and saving of application settings.
+    Class to provide helper functions for the loading and saving of application
+    settings.
     """
-    def __init__(self, screen):
-        self.screen = screen.current
-        self.width = self.screen[u'size'].width()
-        self.height = self.screen[u'size'].height()
-        self.mainwindow_height = self.height * 0.8
-        mainwindow_docbars = self.width / 5
-        self.mainwindow_left = 0
-        self.mainwindow_right = 0
-        if mainwindow_docbars > 300:
-            self.mainwindow_left = 300
-            self.mainwindow_right = 300
-        else:
-            self.mainwindow_left = mainwindow_docbars
-            self.mainwindow_right = mainwindow_docbars
-        self.slidecontroller = (self.width - (
-            self.mainwindow_left + self.mainwindow_right) - 100) / 2
-        self.slidecontroller_image = self.slidecontroller - 50
 
     @staticmethod
     def get_last_dir(section, num=None):

=== modified file 'openlp/core/ui/__init__.py'
--- openlp/core/ui/__init__.py	2011-03-24 19:04:02 +0000
+++ openlp/core/ui/__init__.py	2011-05-11 19:06:13 +0000
@@ -56,10 +56,10 @@
 from themeform import ThemeForm
 from filerenameform import FileRenameForm
 from starttimeform import StartTimeForm
+from screen import ScreenList
 from maindisplay import MainDisplay
 from servicenoteform import ServiceNoteForm
 from serviceitemeditform import ServiceItemEditForm
-from screen import ScreenList
 from slidecontroller import SlideController
 from splashscreen import SplashScreen
 from generaltab import GeneralTab

=== modified file 'openlp/core/ui/generaltab.py'
--- openlp/core/ui/generaltab.py	2011-05-04 17:35:24 +0000
+++ openlp/core/ui/generaltab.py	2011-05-11 19:06:13 +0000
@@ -29,6 +29,7 @@
 
 from openlp.core.lib import SettingsTab, Receiver, translate
 from openlp.core.lib.ui import UiStrings
+from openlp.core.ui import ScreenList
 
 log = logging.getLogger(__name__)
 
@@ -36,33 +37,15 @@
     """
     GeneralTab is the general settings tab in the settings dialog.
     """
-    def __init__(self, parent, screens):
+    def __init__(self, parent):
         """
         Initialise the general settings tab
         """
-        self.screens = screens
-        self.monitorNumber = 0
-        # Set to True to allow PostSetup to work on application start up
-        self.overrideChanged = True
+        self.screens = ScreenList.get_instance()
         self.icon_path = u':/icon/openlp-logo-16x16.png'
         generalTranslated = translate('GeneralTab', 'General')
         SettingsTab.__init__(self, parent, u'General', generalTranslated)
 
-    def preLoad(self):
-        """
-        Set up the display screen and set correct screen values.
-        If not set before default to last screen.
-        """
-        settings = QtCore.QSettings()
-        settings.beginGroup(self.settingsSection)
-        self.monitorNumber = settings.value(u'monitor',
-            QtCore.QVariant(self.screens.display_count - 1)).toInt()[0]
-        self.screens.set_current_display(self.monitorNumber)
-        self.screens.monitor_number = self.monitorNumber
-        self.screens.display = settings.value(
-            u'display on monitor', QtCore.QVariant(True)).toBool()
-        settings.endGroup()
-
     def setupUi(self):
         """
         Create the user interface for the general settings tab
@@ -158,14 +141,14 @@
         self.displayLayout.addWidget(self.customXLabel, 3, 0)
         self.customXValueEdit = QtGui.QSpinBox(self.displayGroupBox)
         self.customXValueEdit.setObjectName(u'customXValueEdit')
-        self.customXValueEdit.setMaximum(9999)
+        self.customXValueEdit.setRange(-9999, 9999)
         self.displayLayout.addWidget(self.customXValueEdit, 4, 0)
         self.customYLabel = QtGui.QLabel(self.displayGroupBox)
         self.customYLabel.setObjectName(u'customYLabel')
         self.displayLayout.addWidget(self.customYLabel, 3, 1)
         self.customYValueEdit = QtGui.QSpinBox(self.displayGroupBox)
         self.customYValueEdit.setObjectName(u'customYValueEdit')
-        self.customYValueEdit.setMaximum(9999)
+        self.customYValueEdit.setRange(-9999, 9999)
         self.displayLayout.addWidget(self.customYValueEdit, 4, 1)
         self.customWidthLabel = QtGui.QLabel(self.displayGroupBox)
         self.customWidthLabel.setObjectName(u'customWidthLabel')
@@ -187,13 +170,15 @@
         QtCore.QObject.connect(self.overrideCheckBox,
             QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideCheckBoxToggled)
         QtCore.QObject.connect(self.customHeightValueEdit,
-            QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
+            QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
         QtCore.QObject.connect(self.customWidthValueEdit,
-            QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
+            QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
         QtCore.QObject.connect(self.customYValueEdit,
-            QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
+            QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
         QtCore.QObject.connect(self.customXValueEdit,
-            QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayPositionChanged)
+            QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged)
+        QtCore.QObject.connect(self.monitorComboBox,
+            QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onDisplayChanged)
         # Reload the tab, as the screen resolution/count may have changed.
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'config_screen_changed'), self.load)
@@ -203,7 +188,6 @@
         self.passwordLabel.setVisible(False)
         self.passwordEdit.setVisible(False)
 
-
     def retranslateUi(self):
         """
         Translate the general settings tab to the currently selected language
@@ -261,6 +245,9 @@
         settings.beginGroup(self.settingsSection)
         self.monitorComboBox.clear()
         self.monitorComboBox.addItems(self.screens.get_screen_list())
+        monitorNumber = settings.value(u'monitor',
+            QtCore.QVariant(self.screens.display_count - 1)).toInt()[0]
+        self.monitorComboBox.setCurrentIndex(monitorNumber)
         self.numberEdit.setText(unicode(settings.value(
             u'ccli number', QtCore.QVariant(u'')).toString()))
         self.usernameEdit.setText(unicode(settings.value(
@@ -271,7 +258,6 @@
             QtCore.QVariant(False)).toBool())
         self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank',
             QtCore.QVariant(False)).toBool())
-        self.monitorComboBox.setCurrentIndex(self.monitorNumber)
         self.displayOnMonitorCheck.setChecked(self.screens.display)
         self.warningCheckBox.setChecked(settings.value(u'blank warning',
             QtCore.QVariant(False)).toBool())
@@ -300,15 +286,16 @@
         self.customYValueEdit.setEnabled(self.overrideCheckBox.isChecked())
         self.customHeightValueEdit.setEnabled(self.overrideCheckBox.isChecked())
         self.customWidthValueEdit.setEnabled(self.overrideCheckBox.isChecked())
+        self.display_changed = False
 
     def save(self):
         """
         Save the settings from the form
         """
-        self.monitorNumber = self.monitorComboBox.currentIndex()
         settings = QtCore.QSettings()
         settings.beginGroup(self.settingsSection)
-        settings.setValue(u'monitor', QtCore.QVariant(self.monitorNumber))
+        settings.setValue(u'monitor',
+            QtCore.QVariant(self.monitorComboBox.currentIndex()))
         settings.setValue(u'display on monitor',
             QtCore.QVariant(self.displayOnMonitorCheck.isChecked()))
         settings.setValue(u'blank warning',
@@ -344,15 +331,8 @@
         settings.setValue(u'override position',
             QtCore.QVariant(self.overrideCheckBox.isChecked()))
         settings.endGroup()
-        self.screens.display = self.displayOnMonitorCheck.isChecked()
-        # Monitor Number has changed.
-        postUpdate = False
-        if self.screens.monitor_number != self.monitorNumber:
-            self.screens.monitor_number = self.monitorNumber
-            self.screens.set_current_display(self.monitorNumber)
-            postUpdate = True
         # On save update the screens as well
-        self.postSetUp(postUpdate)
+        self.postSetUp(True)
 
     def postSetUp(self, postUpdate=False):
         """
@@ -361,7 +341,11 @@
         """
         Receiver.send_message(u'slidecontroller_live_spin_delay',
             self.timeoutSpinBox.value())
-        # Reset screens after initial definition
+        # Do not continue on start up.
+        if not postUpdate:
+            return
+        self.screens.set_current_display(self.monitorComboBox.currentIndex())
+        self.screens.display = self.displayOnMonitorCheck.isChecked()
         self.screens.override[u'size'] = QtCore.QRect(
             self.customXValueEdit.value(),
             self.customYValueEdit.value(),
@@ -371,10 +355,9 @@
             self.screens.set_override_display()
         else:
             self.screens.reset_current_display()
-        # Order is important so be careful if you change
-        if self.overrideChanged or postUpdate:
+        if self.display_changed:
             Receiver.send_message(u'config_screen_changed')
-        self.overrideChanged = False
+        self.display_changed = False
 
     def onOverrideCheckBoxToggled(self, checked):
         """
@@ -387,10 +370,10 @@
         self.customYValueEdit.setEnabled(checked)
         self.customHeightValueEdit.setEnabled(checked)
         self.customWidthValueEdit.setEnabled(checked)
-        self.overrideChanged = True
+        self.display_changed = True
 
-    def onDisplayPositionChanged(self):
+    def onDisplayChanged(self):
         """
         Called when the width, height, x position or y position has changed.
         """
-        self.overrideChanged = True
+        self.display_changed = True

=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2011-04-29 19:24:21 +0000
+++ openlp/core/ui/maindisplay.py	2011-05-11 19:06:13 +0000
@@ -36,35 +36,23 @@
 from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
     translate
 
-from openlp.core.ui import HideMode
+from openlp.core.ui import HideMode, ScreenList
 
 log = logging.getLogger(__name__)
 
 #http://www.steveheffernan.com/html5-video-player/demo-video-player.html
 #http://html5demos.com/two-videos
 
-class DisplayWidget(QtGui.QGraphicsView):
-    """
-    Customised version of QTableWidget which can respond to keyboard
-    events.
-    """
-    log.info(u'Display Widget loaded')
-
-    def __init__(self, live, parent=None):
+class MainDisplay(QtGui.QGraphicsView):
+    """
+    This is the display screen.
+    """
+    def __init__(self, parent, image_manager, live):
         QtGui.QGraphicsView.__init__(self)
         self.parent = parent
-        self.live = live
-
-
-class MainDisplay(DisplayWidget):
-    """
-    This is the display screen.
-    """
-    def __init__(self, parent, screens, live):
-        DisplayWidget.__init__(self, live, parent=None)
-        self.parent = parent
-        self.screens = screens
         self.isLive = live
+        self.image_manager = image_manager
+        self.screens = ScreenList.get_instance()
         self.alertTab = None
         self.hideMode = None
         self.videoHide = False
@@ -94,8 +82,7 @@
         """
         Set up and build the output screen
         """
-        log.debug(u'Start setup for monitor %s (live = %s)' %
-            (self.screens.monitor_number, self.isLive))
+        log.debug(u'Start MainDisplay setup (live = %s)' % self.isLive)
         self.usePhonon = QtCore.QSettings().value(
             u'media/use phonon', QtCore.QVariant(True)).toBool()
         self.phononActive = False
@@ -106,11 +93,10 @@
         self.videoWidget.setVisible(False)
         self.videoWidget.setGeometry(QtCore.QRect(0, 0,
             self.screen[u'size'].width(), self.screen[u'size'].height()))
-        log.debug(u'Setup Phonon for monitor %s' % self.screens.monitor_number)
         if self.isLive:
             if not self.firstTime:
                 self.createMediaObject()
-        log.debug(u'Setup webView for monitor %s' % self.screens.monitor_number)
+        log.debug(u'Setup webView')
         self.webView = QtWebKit.QWebView(self)
         self.webView.setGeometry(0, 0,
             self.screen[u'size'].width(), self.screen[u'size'].height())
@@ -127,8 +113,8 @@
         if self.isLive:
             # Build the initial frame.
             self.black = QtGui.QImage(
-                self.screens.current[u'size'].width(),
-                self.screens.current[u'size'].height(),
+                self.screen[u'size'].width(),
+                self.screen[u'size'].height(),
                 QtGui.QImage.Format_ARGB32_Premultiplied)
             painter_image = QtGui.QPainter()
             painter_image.begin(self.black)
@@ -145,17 +131,16 @@
                 background_color = QtCore.Qt.white
             splash_image = QtGui.QImage(image_file)
             self.initialFrame = QtGui.QImage(
-                self.screens.current[u'size'].width(),
-                self.screens.current[u'size'].height(),
+                self.screen[u'size'].width(),
+                self.screen[u'size'].height(),
                 QtGui.QImage.Format_ARGB32_Premultiplied)
             painter_image = QtGui.QPainter()
             painter_image.begin(self.initialFrame)
             painter_image.fillRect(self.initialFrame.rect(), background_color)
             painter_image.drawImage(
-                (self.screens.current[u'size'].width() -
-                splash_image.width()) / 2,
-                (self.screens.current[u'size'].height()
-                - splash_image.height()) / 2, splash_image)
+                (self.screen[u'size'].width() - splash_image.width()) / 2,
+                (self.screen[u'size'].height() - splash_image.height()) / 2,
+                splash_image)
             serviceItem = ServiceItem()
             serviceItem.bg_image_bytes = image_to_byte(self.initialFrame)
             self.webView.setHtml(build_html(serviceItem, self.screen,
@@ -167,8 +152,7 @@
                 self.primary = False
             else:
                 self.primary = True
-        log.debug(
-            u'Finished setup for monitor %s' % self.screens.monitor_number)
+        log.debug(u'Finished MainDisplay setup')
 
     def createMediaObject(self):
         self.firstTime = False
@@ -212,8 +196,8 @@
             The slide text to be displayed
         """
         log.debug(u'alert to display')
-        if self.height() != self.screen[u'size'].height() \
-            or not self.isVisible() or self.videoWidget.isVisible():
+        if self.height() != self.screen[u'size'].height() or not \
+            self.isVisible() or self.videoWidget.isVisible():
             shrink = True
         else:
             shrink = False
@@ -244,7 +228,7 @@
         """
         API for replacement backgrounds so Images are added directly to cache
         """
-        self.imageManager.add_image(name, path)
+        self.image_manager.add_image(name, path)
         self.image(name)
         if hasattr(self, u'serviceItem'):
             self.override[u'image'] = name
@@ -259,7 +243,7 @@
             The name of the image to be displayed
         """
         log.debug(u'image to display')
-        image = self.imageManager.get_image_bytes(name)
+        image = self.image_manager.get_image_bytes(name)
         self.resetVideo()
         self.displayImage(image)
         return self.preview()
@@ -451,7 +435,7 @@
                 self.hideDisplay(self.hideMode)
             else:
                 # Single screen active
-                if self.screens.monitor_number == 0:
+                if self.screens.display_count == 1:
                     # Only make visible if setting enabled
                     if QtCore.QSettings().value(u'general/display on monitor',
                         QtCore.QVariant(True)).toBool():
@@ -489,13 +473,13 @@
                 self.override = {}
             else:
                 # replace the background
-                background = self.imageManager. \
+                background = self.image_manager. \
                     get_image_bytes(self.override[u'image'])
         if self.serviceItem.themedata.background_filename:
-            self.serviceItem.bg_image_bytes = self.imageManager. \
+            self.serviceItem.bg_image_bytes = self.image_manager. \
                 get_image_bytes(self.serviceItem.themedata.theme_name)
         if image:
-            image_bytes = self.imageManager.get_image_bytes(image)
+            image_bytes = self.image_manager.get_image_bytes(image)
         else:
             image_bytes = None
         html = build_html(self.serviceItem, self.screen, self.alertTab,

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2011-05-07 11:22:34 +0000
+++ openlp/core/ui/mainwindow.py	2011-05-11 19:06:13 +0000
@@ -31,7 +31,7 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.lib import Renderer, build_icon, OpenLPDockWidget, \
-    SettingsManager, PluginManager, Receiver, translate
+    PluginManager, Receiver, translate, ImageManager
 from openlp.core.lib.ui import UiStrings, base_action, checkable_action, \
     icon_action, shortcut_action
 from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, \
@@ -69,8 +69,6 @@
         Set up the user interface
         """
         mainWindow.setObjectName(u'MainWindow')
-        mainWindow.resize(self.settingsmanager.width,
-            self.settingsmanager.height)
         mainWindow.setWindowIcon(build_icon(u':/icon/openlp-logo-64x64.png'))
         mainWindow.setDockNestingEnabled(True)
         # Set up the main container, which contains all the other form widgets.
@@ -86,10 +84,8 @@
         self.controlSplitter.setObjectName(u'controlSplitter')
         self.mainContentLayout.addWidget(self.controlSplitter)
         # Create slide controllers
-        self.previewController = SlideController(self, self.settingsmanager,
-            self.screens)
-        self.liveController = SlideController(self, self.settingsmanager,
-            self.screens, True)
+        self.previewController = SlideController(self)
+        self.liveController = SlideController(self, True)
         previewVisible = QtCore.QSettings().value(
             u'user interface/preview panel', QtCore.QVariant(True)).toBool()
         self.previewController.panel.setVisible(previewVisible)
@@ -137,8 +133,6 @@
         self.mediaManagerDock = OpenLPDockWidget(mainWindow,
             u'mediaManagerDock', u':/system/system_mediamanager.png')
         self.mediaManagerDock.setStyleSheet(MEDIA_MANAGER_STYLE)
-        self.mediaManagerDock.setMinimumWidth(
-            self.settingsmanager.mainwindow_left)
         # Create the media toolbox
         self.MediaToolBox = QtGui.QToolBox(self.mediaManagerDock)
         self.MediaToolBox.setObjectName(u'MediaToolBox')
@@ -148,8 +142,6 @@
         # Create the service manager
         self.serviceManagerDock = OpenLPDockWidget(mainWindow,
             u'serviceManagerDock', u':/system/system_servicemanager.png')
-        self.serviceManagerDock.setMinimumWidth(
-            self.settingsmanager.mainwindow_right)
         self.ServiceManagerContents = ServiceManager(mainWindow,
             self.serviceManagerDock)
         self.serviceManagerDock.setWidget(self.ServiceManagerContents)
@@ -158,8 +150,6 @@
         # Create the theme manager
         self.themeManagerDock = OpenLPDockWidget(mainWindow,
             u'themeManagerDock', u':/system/system_thememanager.png')
-        self.themeManagerDock.setMinimumWidth(
-            self.settingsmanager.mainwindow_right)
         self.themeManagerContents = ThemeManager(mainWindow,
             self.themeManagerDock)
         self.themeManagerContents.setObjectName(u'themeManagerContents')
@@ -461,13 +451,12 @@
     """
     log.info(u'MainWindow loaded')
 
-    def __init__(self, screens, clipboard, arguments):
+    def __init__(self, clipboard, arguments):
         """
         This constructor sets up the interface, the various managers, and the
         plugins.
         """
         QtGui.QMainWindow.__init__(self)
-        self.screens = screens
         self.clipboard = clipboard
         self.arguments = arguments
         # Set up settings sections for the main application
@@ -477,9 +466,8 @@
         self.serviceSettingsSection = u'servicemanager'
         self.songsSettingsSection = u'songs'
         self.serviceNotSaved = False
-        self.settingsmanager = SettingsManager(screens)
         self.aboutForm = AboutForm(self)
-        self.settingsForm = SettingsForm(self.screens, self, self)
+        self.settingsForm = SettingsForm(self, self)
         self.displayTagForm = DisplayTagForm(self)
         self.shortcutForm = ShortcutListForm(self)
         self.recentFiles = QtCore.QStringList()
@@ -487,6 +475,7 @@
         pluginpath = AppLocation.get_directory(AppLocation.PluginsDir)
         self.pluginManager = PluginManager(pluginpath)
         self.pluginHelpers = {}
+        self.image_manager = ImageManager()
         # Set up the interface
         self.setupUi(self)
         # Load settings after setupUi so default UI sizes are overwritten
@@ -552,8 +541,7 @@
         # warning cyclic dependency
         # renderer needs to call ThemeManager and
         # ThemeManager needs to call Renderer
-        self.renderer = Renderer(
-            self.themeManagerContents, self.screens)
+        self.renderer = Renderer(self.image_manager, self.themeManagerContents)
         # Define the media Dock Manager
         self.mediaDockManager = MediaDockManager(self.MediaToolBox)
         log.info(u'Load Plugins')
@@ -585,6 +573,9 @@
         # Call the initialise method to setup plugins.
         log.info(u'initialise plugins')
         self.pluginManager.initialise_plugins()
+        # Create the displays as all necessary components are loaded.
+        self.previewController.screenSizeChanged()
+        self.liveController.screenSizeChanged()
         log.info(u'Load data from Settings')
         if QtCore.QSettings().value(u'advanced/save current plugin',
             QtCore.QVariant(False)).toBool():
@@ -788,7 +779,10 @@
         their locations
         """
         log.debug(u'screenChanged')
+        self.image_manager.update_display()
         self.renderer.update_display()
+        self.liveController.screenSizeChanged()
+        self.previewController.screenSizeChanged()
         self.setFocus()
         self.activateWindow()
 

=== modified file 'openlp/core/ui/screen.py'
--- openlp/core/ui/screen.py	2011-03-24 19:04:02 +0000
+++ openlp/core/ui/screen.py	2011-05-11 19:06:13 +0000
@@ -38,9 +38,16 @@
 
 class ScreenList(object):
     """
-    Wrapper to handle the parameters of the display screen
+    Wrapper to handle the parameters of the display screen.
+
+    To get access to the screen list call ``ScreenList.get_instance()``.
     """
     log.info(u'Screen loaded')
+    instance = None
+
+    @staticmethod
+    def get_instance():
+        return ScreenList.instance
 
     def __init__(self, desktop):
         """
@@ -49,17 +56,15 @@
         ``desktop``
             A ``QDesktopWidget`` object.
         """
+        ScreenList.instance = self
         self.desktop = desktop
         self.preview = None
         self.current = None
         self.override = None
         self.screen_list = []
         self.display_count = 0
-        # actual display number
-        self.current_display = 0
-        # save config display number
-        self.monitor_number = 0
         self.screen_count_changed()
+        self._load_screen_settings()
         QtCore.QObject.connect(desktop,
             QtCore.SIGNAL(u'resized(int)'), self.screen_resolution_changed)
         QtCore.QObject.connect(desktop,
@@ -150,6 +155,7 @@
             screen[u'number'], screen[u'size'])
         if screen[u'primary']:
             self.current = screen
+            self.override = copy.deepcopy(self.current)
         self.screen_list.append(screen)
         self.display_count += 1
 
@@ -189,13 +195,10 @@
         log.debug(u'set_current_display %s', number)
         if number + 1 > self.display_count:
             self.current = self.screen_list[0]
-            self.override = copy.deepcopy(self.current)
-            self.current_display = 0
         else:
             self.current = self.screen_list[number]
-            self.override = copy.deepcopy(self.current)
             self.preview = copy.deepcopy(self.current)
-            self.current_display = number
+        self.override = copy.deepcopy(self.current)
         if self.display_count == 1:
             self.preview = self.screen_list[0]
 
@@ -214,4 +217,31 @@
         use the correct screen attributes.
         """
         log.debug(u'reset_current_display')
-        self.set_current_display(self.current_display)
+        self.set_current_display(self.current[u'number'])
+
+    def _load_screen_settings(self):
+        """
+        Loads the screen size and the monitor number from the settings.
+        """
+        settings = QtCore.QSettings()
+        settings.beginGroup(u'general')
+        self.set_current_display(settings.value(u'monitor',
+            QtCore.QVariant(self.display_count - 1)).toInt()[0])
+        self.display = settings.value(
+            u'display on monitor', QtCore.QVariant(True)).toBool()
+        override_display = settings.value(
+            u'override position', QtCore.QVariant(False)).toBool()
+        x = settings.value(u'x position',
+            QtCore.QVariant(self.current[u'size'].x())).toInt()[0]
+        y = settings.value(u'y position',
+            QtCore.QVariant(self.current[u'size'].y())).toInt()[0]
+        width = settings.value(u'width',
+            QtCore.QVariant(self.current[u'size'].width())).toInt()[0]
+        height = settings.value(u'height',
+            QtCore.QVariant(self.current[u'size'].height())).toInt()[0]
+        self.override[u'size'] = QtCore.QRect(x, y, width, height)
+        settings.endGroup()
+        if override_display:
+            self.set_override_display()
+        else:
+            self.reset_current_display()

=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py	2011-04-18 15:31:20 +0000
+++ openlp/core/ui/settingsform.py	2011-05-11 19:06:13 +0000
@@ -40,14 +40,14 @@
     """
     Provide the form to manipulate the settings for OpenLP
     """
-    def __init__(self, screens, mainWindow, parent=None):
+    def __init__(self, mainWindow, parent=None):
         """
         Initialise the settings form
         """
         QtGui.QDialog.__init__(self, parent)
         self.setupUi(self)
         # General tab
-        self.generalTab = GeneralTab(self, screens)
+        self.generalTab = GeneralTab(self)
         # Themes tab
         self.themesTab = ThemesTab(self, mainWindow)
         # Advanced tab

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2011-04-29 18:43:29 +0000
+++ openlp/core/ui/slidecontroller.py	2011-05-11 19:06:13 +0000
@@ -33,7 +33,7 @@
 from openlp.core.lib import OpenLPToolbar, Receiver, resize_image, \
     ItemCapabilities, translate
 from openlp.core.lib.ui import UiStrings, shortcut_action
-from openlp.core.ui import HideMode, MainDisplay
+from openlp.core.ui import HideMode, MainDisplay, ScreenList
 from openlp.core.utils.actions import ActionList, CategoryOrder
 
 log = logging.getLogger(__name__)
@@ -53,18 +53,17 @@
     SlideController is the slide controller widget. This widget is what the
     user uses to control the displaying of verses/slides/etc on the screen.
     """
-    def __init__(self, parent, settingsmanager, screens, isLive=False):
+    def __init__(self, parent, isLive=False):
         """
         Set up the Slide Controller.
         """
         QtGui.QWidget.__init__(self, parent)
-        self.settingsmanager = settingsmanager
         self.isLive = isLive
         self.parent = parent
-        self.screens = screens
+        self.screens = ScreenList.get_instance()
         self.ratio = float(self.screens.current[u'size'].width()) / \
             float(self.screens.current[u'size'].height())
-        self.display = MainDisplay(self, screens, isLive)
+        self.image_manager = self.parent.image_manager
         self.loopList = [
             u'Start Loop',
             u'Loop Separator',
@@ -296,9 +295,6 @@
         sizePolicy.setHeightForWidth(
             self.slidePreview.sizePolicy().hasHeightForWidth())
         self.slidePreview.setSizePolicy(sizePolicy)
-        self.slidePreview.setFixedSize(
-            QtCore.QSize(self.settingsmanager.slidecontroller_image,
-            self.settingsmanager.slidecontroller_image / self.ratio))
         self.slidePreview.setFrameShape(QtGui.QFrame.Box)
         self.slidePreview.setFrameShadow(QtGui.QFrame.Plain)
         self.slidePreview.setLineWidth(1)
@@ -328,7 +324,6 @@
         if self.isLive:
             self.setLiveHotkeys(self)
             self.__addActionsToWidget(self.previewListWidget)
-            self.__addActionsToWidget(self.display)
         else:
             self.setPreviewHotkeys()
             self.previewListWidget.addActions(
@@ -371,8 +366,6 @@
         QtCore.QObject.connect(Receiver.get_receiver(),
             QtCore.SIGNAL(u'slidecontroller_%s_text_request' % self.typePrefix),
             self.onTextRequest)
-        QtCore.QObject.connect(Receiver.get_receiver(),
-            QtCore.SIGNAL(u'config_screen_changed'), self.screenSizeChanged)
 
     def setPreviewHotkeys(self, parent=None):
         self.previousItem.setObjectName(u'previousItemPreview')
@@ -424,8 +417,7 @@
         screen previews.
         """
         # rebuild display as screen size changed
-        self.display = MainDisplay(self, self.screens, self.isLive)
-        self.display.imageManager = self.parent.renderer.image_manager
+        self.display = MainDisplay(self, self.image_manager, self.isLive)
         self.display.alertTab = self.alertTab
         self.display.setup()
         if self.isLive:
@@ -639,10 +631,8 @@
                     # If current slide set background to image
                     if framenumber == slideno:
                         self.serviceItem.bg_image_bytes = \
-                            self.parent.renderer.image_manager. \
-                            get_image_bytes(frame[u'title'])
-                    image = self.parent.renderer.image_manager. \
-                        get_image(frame[u'title'])
+                            self.image_manager.get_image_bytes(frame[u'title'])
+                    image = self.image_manager.get_image(frame[u'title'])
                 label.setPixmap(QtGui.QPixmap.fromImage(image))
                 self.previewListWidget.setCellWidget(framenumber, 0, label)
                 slideHeight = width * self.parent.renderer.screen_ratio

=== modified file 'openlp/plugins/alerts/alertsplugin.py'
--- openlp/plugins/alerts/alertsplugin.py	2011-04-15 21:43:59 +0000
+++ openlp/plugins/alerts/alertsplugin.py	2011-05-11 19:06:13 +0000
@@ -118,4 +118,5 @@
         ## Name for MediaDockManager, SettingsManager ##
         self.textStrings[StringContent.VisibleName] = {
             u'title': translate('AlertsPlugin', 'Alerts', 'container title')
-        }
\ No newline at end of file
+        }
+

=== modified file 'openlp/plugins/alerts/lib/alertstab.py'
--- openlp/plugins/alerts/lib/alertstab.py	2011-04-15 21:43:59 +0000
+++ openlp/plugins/alerts/lib/alertstab.py	2011-05-11 19:06:13 +0000
@@ -191,4 +191,5 @@
         font.setPointSize(self.font_size)
         self.FontPreview.setFont(font)
         self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' %
-            (self.bg_color, self.font_color))
\ No newline at end of file
+            (self.bg_color, self.font_color))
+


Follow ups