forked from openlp/openlp
- (re)moved obsolete code from SettingsManager
- removed redundant code from ScreenList - removed redundant code form MainDisplay - made the start up logic easier - fixed use of negative x and y values - fixed ratio of images (in the small preview frame) after changing the screen ratio bzr-revno: 1533
This commit is contained in:
commit
7b12c9ef88
@ -115,8 +115,7 @@ class OpenLP(QtGui.QApplication):
|
||||
# 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
|
||||
|
@ -299,7 +299,6 @@ from listwidgetwithdnd import ListWidgetWithDnD
|
||||
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 @@ from htmlbuilder import build_html, build_lyrics_format_css, \
|
||||
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
|
||||
|
@ -32,6 +32,7 @@ import logging
|
||||
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 @@ class OpenLPDockWidget(QtGui.QDockWidget):
|
||||
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)
|
||||
|
@ -324,17 +324,22 @@ def build_html(item, screen, alert, islive, background, image=None):
|
||||
"""
|
||||
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 @@ def build_background_css(item, width, height):
|
||||
"""
|
||||
Build the background css
|
||||
|
||||
`item`
|
||||
``item``
|
||||
Service Item containing theme and location information
|
||||
|
||||
"""
|
||||
@ -432,10 +437,10 @@ def build_lyrics_css(item, webkitvers):
|
||||
"""
|
||||
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 @@ def build_lyrics_outline_css(theme, is_shadow=False):
|
||||
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 @@ def build_lyrics_format_css(theme, width, height):
|
||||
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 @@ def build_lyrics_html(item, webkitvers):
|
||||
"""
|
||||
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 @@ def build_footer_css(item, height):
|
||||
"""
|
||||
Build the display of the item footer
|
||||
|
||||
`item`
|
||||
``item``
|
||||
Service Item to be processed.
|
||||
"""
|
||||
style = """
|
||||
@ -624,7 +629,7 @@ def build_alert_css(alertTab, width):
|
||||
"""
|
||||
Build the display of the footer
|
||||
|
||||
`alertTab`
|
||||
``alertTab``
|
||||
Details from the Alert tab for fonts etc
|
||||
"""
|
||||
style = """
|
||||
|
@ -35,6 +35,7 @@ import time
|
||||
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 @@ class ImageManager(QtCore.QObject):
|
||||
|
||||
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]
|
||||
|
@ -28,11 +28,11 @@ import logging
|
||||
|
||||
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 Renderer(object):
|
||||
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.
|
||||
|
||||
``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):
|
||||
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.
|
||||
"""
|
||||
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 @@ class Renderer(object):
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
|
@ -37,26 +37,9 @@ from openlp.core.utils import AppLocation
|
||||
|
||||
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):
|
||||
|
@ -56,10 +56,10 @@ from firsttimelanguageform import FirstTimeLanguageForm
|
||||
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
|
||||
|
@ -29,6 +29,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
"""
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
"""
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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 @@ class GeneralTab(SettingsTab):
|
||||
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
|
||||
|
@ -36,35 +36,23 @@ from PyQt4.phonon import Phonon
|
||||
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):
|
||||
QtGui.QGraphicsView.__init__(self)
|
||||
self.parent = parent
|
||||
self.live = live
|
||||
|
||||
|
||||
class MainDisplay(DisplayWidget):
|
||||
class MainDisplay(QtGui.QGraphicsView):
|
||||
"""
|
||||
This is the display screen.
|
||||
"""
|
||||
def __init__(self, parent, screens, live):
|
||||
DisplayWidget.__init__(self, live, parent=None)
|
||||
def __init__(self, parent, image_manager, live):
|
||||
QtGui.QGraphicsView.__init__(self)
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
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 @@ class MainDisplay(DisplayWidget):
|
||||
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,
|
||||
|
@ -31,7 +31,7 @@ from tempfile import gettempdir
|
||||
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 @@ class Ui_MainWindow(object):
|
||||
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 @@ class Ui_MainWindow(object):
|
||||
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 @@ class Ui_MainWindow(object):
|
||||
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 @@ class Ui_MainWindow(object):
|
||||
# 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 @@ class Ui_MainWindow(object):
|
||||
# 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
"""
|
||||
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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
# 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
# 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 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
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()
|
||||
|
||||
|
@ -38,9 +38,16 @@ log = logging.getLogger(__name__)
|
||||
|
||||
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 @@ class ScreenList(object):
|
||||
``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 @@ class ScreenList(object):
|
||||
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 @@ class ScreenList(object):
|
||||
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 @@ class ScreenList(object):
|
||||
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()
|
||||
|
@ -40,14 +40,14 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
|
||||
"""
|
||||
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
|
||||
|
@ -33,7 +33,7 @@ from PyQt4.phonon import Phonon
|
||||
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 @@ class SlideController(QtGui.QWidget):
|
||||
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 @@ class SlideController(QtGui.QWidget):
|
||||
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 @@ class SlideController(QtGui.QWidget):
|
||||
if self.isLive:
|
||||
self.setLiveHotkeys(self)
|
||||
self.__addActionsToWidget(self.previewListWidget)
|
||||
self.__addActionsToWidget(self.display)
|
||||
else:
|
||||
self.setPreviewHotkeys()
|
||||
self.previewListWidget.addActions(
|
||||
@ -371,8 +366,6 @@ class SlideController(QtGui.QWidget):
|
||||
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 @@ class SlideController(QtGui.QWidget):
|
||||
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 @@ class SlideController(QtGui.QWidget):
|
||||
# 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
|
||||
|
@ -119,3 +119,4 @@ class AlertsPlugin(Plugin):
|
||||
self.textStrings[StringContent.VisibleName] = {
|
||||
u'title': translate('AlertsPlugin', 'Alerts', 'container title')
|
||||
}
|
||||
|
||||
|
@ -192,3 +192,4 @@ class AlertsTab(SettingsTab):
|
||||
self.FontPreview.setFont(font)
|
||||
self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' %
|
||||
(self.bg_color, self.font_color))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user