This commit is contained in:
Samuel Findlay 2012-05-24 20:07:00 +10:00
commit b7cde8938c
10 changed files with 45 additions and 52 deletions

View File

@ -109,7 +109,7 @@ class OpenLP(QtGui.QApplication):
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'cursor_normal'), self.setNormalCursor)
# Decide how many screens we have and their size
screens = ScreenList(self.desktop())
screens = ScreenList.create(self.desktop())
# First time checks in settings
has_run_wizard = QtCore.QSettings().value(
u'general/has run wizard', QtCore.QVariant(False)).toBool()

View File

@ -52,7 +52,7 @@ class OpenLPDockWidget(QtGui.QDockWidget):
if icon:
self.setWindowIcon(build_icon(icon))
# Sort out the minimum width.
screens = ScreenList.get_instance()
screens = ScreenList()
mainwindow_docbars = screens.current[u'size'].width() / 5
if mainwindow_docbars > 300:
self.setMinimumWidth(300)

View File

@ -163,7 +163,7 @@ class ImageManager(QtCore.QObject):
def __init__(self):
QtCore.QObject.__init__(self)
current_screen = ScreenList.get_instance().current
current_screen = ScreenList().current
self.width = current_screen[u'size'].width()
self.height = current_screen[u'size'].height()
self._cache = {}
@ -177,7 +177,7 @@ class ImageManager(QtCore.QObject):
Screen has changed size so rebuild the cache to new size.
"""
log.debug(u'update_display')
current_screen = ScreenList.get_instance().current
current_screen = ScreenList().current
self.width = current_screen[u'size'].width()
self.height = current_screen[u'size'].height()
# Mark the images as dirty for a rebuild by setting the image and byte

View File

@ -69,7 +69,7 @@ class Renderer(object):
log.debug(u'Initialisation started')
self.themeManager = themeManager
self.imageManager = imageManager
self.screens = ScreenList.get_instance()
self.screens = ScreenList()
self.service_theme = u''
self.theme_level = u''
self.override_background = None

View File

@ -42,7 +42,7 @@ class GeneralTab(SettingsTab):
"""
Initialise the general settings tab
"""
self.screens = ScreenList.get_instance()
self.screens = ScreenList()
self.iconPath = u':/icon/openlp-logo-16x16.png'
generalTranslated = translate('OpenLP.GeneralTab', 'General')
SettingsTab.__init__(self, parent, u'General', generalTranslated)

View File

@ -119,7 +119,7 @@ class MainDisplay(Display):
def __init__(self, parent, imageManager, live, controller):
Display.__init__(self, parent, live, controller)
self.imageManager = imageManager
self.screens = ScreenList.get_instance()
self.screens = ScreenList()
self.plugins = PluginManager.get_instance().plugins
self.rebuildCSS = False
self.hideMode = None

View File

@ -795,7 +795,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if answer == QtGui.QMessageBox.No:
return
Receiver.send_message(u'cursor_busy')
screens = ScreenList.get_instance()
screens = ScreenList()
FirstTimeForm(screens, self).exec_()
self.firstTime()
for plugin in self.pluginManager.plugins:

View File

@ -41,36 +41,40 @@ class ScreenList(object):
"""
Wrapper to handle the parameters of the display screen.
To get access to the screen list call ``ScreenList.get_instance()``.
To get access to the screen list call ``ScreenList()``.
"""
log.info(u'Screen loaded')
instance = None
__instance__ = None
@staticmethod
def get_instance():
return ScreenList.instance
def __new__(cls):
if not cls.__instance__:
cls.__instance__ = object.__new__(cls)
return cls.__instance__
def __init__(self, desktop):
@classmethod
def create(cls, desktop):
"""
Initialise the screen list.
``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
self.screen_count_changed()
self._load_screen_settings()
screen_list = cls()
screen_list.desktop = desktop
screen_list.preview = None
screen_list.current = None
screen_list.override = None
screen_list.screen_list = []
screen_list.display_count = 0
screen_list.screen_count_changed()
screen_list._load_screen_settings()
QtCore.QObject.connect(desktop,
QtCore.SIGNAL(u'resized(int)'), self.screen_resolution_changed)
QtCore.SIGNAL(u'resized(int)'),
screen_list.screen_resolution_changed)
QtCore.QObject.connect(desktop,
QtCore.SIGNAL(u'screenCountChanged(int)'),
self.screen_count_changed)
screen_list.screen_count_changed)
return screen_list
def screen_resolution_changed(self, number):
"""
@ -233,8 +237,8 @@ class ScreenList(object):
y = window.y() + (window.height() / 2)
for screen in self.screen_list:
size = screen[u'size']
if x >= size.x() and x <= (size.x() + size.width()) \
and y >= size.y() and y <= (size.y() + size.height()):
if x >= size.x() and x <= (size.x() + size.width()) and \
y >= size.y() and y <= (size.y() + size.height()):
return screen[u'number']
def _load_screen_settings(self):

View File

@ -83,7 +83,7 @@ class SlideController(Controller):
Set up the Slide Controller.
"""
Controller.__init__(self, parent, isLive)
self.screens = ScreenList.get_instance()
self.screens = ScreenList()
try:
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())

View File

@ -136,16 +136,14 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
"""
self.backgroundPage.registerField(
u'background_type', self.backgroundComboBox)
self.backgroundPage.registerField(
u'color', self.colorButton)
self.backgroundPage.registerField(u'color', self.colorButton)
self.backgroundPage.registerField(
u'grandient_start', self.gradientStartButton)
self.backgroundPage.registerField(
u'grandient_end', self.gradientEndButton)
self.backgroundPage.registerField(
u'background_image', self.imageFileEdit)
self.backgroundPage.registerField(
u'gradient', self.gradientComboBox)
self.backgroundPage.registerField(u'gradient', self.gradientComboBox)
self.mainAreaPage.registerField(
u'mainColorButton', self.mainColorButton)
self.mainAreaPage.registerField(
@ -158,8 +156,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
u'outlineColorButton', self.outlineColorButton)
self.mainAreaPage.registerField(
u'outlineSizeSpinBox', self.outlineSizeSpinBox)
self.mainAreaPage.registerField(
u'shadowCheckBox', self.shadowCheckBox)
self.mainAreaPage.registerField(u'shadowCheckBox', self.shadowCheckBox)
self.mainAreaPage.registerField(
u'mainBoldCheckBox', self.mainBoldCheckBox)
self.mainAreaPage.registerField(
@ -170,10 +167,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
u'shadowSizeSpinBox', self.shadowSizeSpinBox)
self.mainAreaPage.registerField(
u'footerSizeSpinBox', self.footerSizeSpinBox)
self.areaPositionPage.registerField(
u'mainPositionX', self.mainXSpinBox)
self.areaPositionPage.registerField(
u'mainPositionY', self.mainYSpinBox)
self.areaPositionPage.registerField(u'mainPositionX', self.mainXSpinBox)
self.areaPositionPage.registerField(u'mainPositionY', self.mainYSpinBox)
self.areaPositionPage.registerField(
u'mainPositionWidth', self.mainWidthSpinBox)
self.areaPositionPage.registerField(
@ -188,12 +183,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
u'footerPositionHeight', self.footerHeightSpinBox)
self.backgroundPage.registerField(
u'horizontal', self.horizontalComboBox)
self.backgroundPage.registerField(
u'vertical', self.verticalComboBox)
self.backgroundPage.registerField(u'vertical', self.verticalComboBox)
self.backgroundPage.registerField(
u'slideTransition', self.transitionsCheckBox)
self.backgroundPage.registerField(
u'name', self.themeNameEdit)
self.backgroundPage.registerField(u'name', self.themeNameEdit)
def calculateLines(self):
"""
@ -269,10 +262,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
Change state as Outline check box changed
"""
if self.updateThemeAllowed:
if state == QtCore.Qt.Checked:
self.theme.font_main_outline = True
else:
self.theme.font_main_outline = False
self.theme.font_main_outline = state == QtCore.Qt.Checked
self.outlineColorButton.setEnabled(self.theme.font_main_outline)
self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
self.calculateLines()
@ -350,19 +340,19 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
if self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Solid):
self.colorButton.setStyleSheet(u'background-color: %s' %
self.theme.background_color)
self.theme.background_color)
self.setField(u'background_type', QtCore.QVariant(0))
elif self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Gradient):
self.gradientStartButton.setStyleSheet(u'background-color: %s' %
self.theme.background_start_color)
self.theme.background_start_color)
self.gradientEndButton.setStyleSheet(u'background-color: %s' %
self.theme.background_end_color)
self.theme.background_end_color)
self.setField(u'background_type', QtCore.QVariant(1))
elif self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Image):
self.imageColorButton.setStyleSheet(u'background-color: %s' %
self.theme.background_border_color)
self.theme.background_border_color)
self.imageFileEdit.setText(self.theme.background_filename)
self.setField(u'background_type', QtCore.QVariant(2))
elif self.theme.background_type == \
@ -642,8 +632,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
"""
Handle Color buttons
"""
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(field), self)
new_color = QtGui.QColorDialog.getColor(QtGui.QColor(field), self)
if new_color.isValid():
field = new_color.name()
return field