fixed bug 970436 ('Display if a single screen' always in effect) and clean ups

bzr-revno: 1939
Fixes: https://launchpad.net/bugs/970436
This commit is contained in:
Andreas Preikschat 2012-04-09 21:26:57 +01:00 committed by Jonathan Corwin
commit cb2e2b3248
2 changed files with 30 additions and 37 deletions

View File

@ -65,42 +65,42 @@ class GeneralTab(SettingsTab):
self.monitorComboBox = QtGui.QComboBox(self.monitorGroupBox) self.monitorComboBox = QtGui.QComboBox(self.monitorGroupBox)
self.monitorComboBox.setObjectName(u'monitorComboBox') self.monitorComboBox.setObjectName(u'monitorComboBox')
self.monitorLayout.addWidget(self.monitorComboBox, 1, 1, 1, 4) self.monitorLayout.addWidget(self.monitorComboBox, 1, 1, 1, 4)
self.displayOnMonitorCheck = QtGui.QCheckBox(self.monitorGroupBox)
self.displayOnMonitorCheck.setObjectName(u'monitorComboBox')
self.monitorLayout.addWidget(self.displayOnMonitorCheck, 2, 1, 1, 4)
# Display Position # Display Position
self.overrideRadioButton = QtGui.QRadioButton(self.monitorGroupBox) self.overrideRadioButton = QtGui.QRadioButton(self.monitorGroupBox)
self.overrideRadioButton.setObjectName(u'overrideRadioButton') self.overrideRadioButton.setObjectName(u'overrideRadioButton')
self.monitorLayout.addWidget(self.overrideRadioButton, 3, 0, 1, 5) self.monitorLayout.addWidget(self.overrideRadioButton, 2, 0, 1, 5)
# Custom position # Custom position
self.customXLabel = QtGui.QLabel(self.monitorGroupBox) self.customXLabel = QtGui.QLabel(self.monitorGroupBox)
self.customXLabel.setObjectName(u'customXLabel') self.customXLabel.setObjectName(u'customXLabel')
self.monitorLayout.addWidget(self.customXLabel, 4, 1) self.monitorLayout.addWidget(self.customXLabel, 3, 1)
self.customXValueEdit = QtGui.QSpinBox(self.monitorGroupBox) self.customXValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
self.customXValueEdit.setObjectName(u'customXValueEdit') self.customXValueEdit.setObjectName(u'customXValueEdit')
self.customXValueEdit.setRange(-9999, 9999) self.customXValueEdit.setRange(-9999, 9999)
self.monitorLayout.addWidget(self.customXValueEdit, 5, 1) self.monitorLayout.addWidget(self.customXValueEdit, 4, 1)
self.customYLabel = QtGui.QLabel(self.monitorGroupBox) self.customYLabel = QtGui.QLabel(self.monitorGroupBox)
self.customYLabel.setObjectName(u'customYLabel') self.customYLabel.setObjectName(u'customYLabel')
self.monitorLayout.addWidget(self.customYLabel, 4, 2) self.monitorLayout.addWidget(self.customYLabel, 3, 2)
self.customYValueEdit = QtGui.QSpinBox(self.monitorGroupBox) self.customYValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
self.customYValueEdit.setObjectName(u'customYValueEdit') self.customYValueEdit.setObjectName(u'customYValueEdit')
self.customYValueEdit.setRange(-9999, 9999) self.customYValueEdit.setRange(-9999, 9999)
self.monitorLayout.addWidget(self.customYValueEdit, 5, 2) self.monitorLayout.addWidget(self.customYValueEdit, 4, 2)
self.customWidthLabel = QtGui.QLabel(self.monitorGroupBox) self.customWidthLabel = QtGui.QLabel(self.monitorGroupBox)
self.customWidthLabel.setObjectName(u'customWidthLabel') self.customWidthLabel.setObjectName(u'customWidthLabel')
self.monitorLayout.addWidget(self.customWidthLabel, 4, 3) self.monitorLayout.addWidget(self.customWidthLabel, 3, 3)
self.customWidthValueEdit = QtGui.QSpinBox(self.monitorGroupBox) self.customWidthValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
self.customWidthValueEdit.setObjectName(u'customWidthValueEdit') self.customWidthValueEdit.setObjectName(u'customWidthValueEdit')
self.customWidthValueEdit.setMaximum(9999) self.customWidthValueEdit.setMaximum(9999)
self.monitorLayout.addWidget(self.customWidthValueEdit, 5, 3) self.monitorLayout.addWidget(self.customWidthValueEdit, 4, 3)
self.customHeightLabel = QtGui.QLabel(self.monitorGroupBox) self.customHeightLabel = QtGui.QLabel(self.monitorGroupBox)
self.customHeightLabel.setObjectName(u'customHeightLabel') self.customHeightLabel.setObjectName(u'customHeightLabel')
self.monitorLayout.addWidget(self.customHeightLabel, 4, 4) self.monitorLayout.addWidget(self.customHeightLabel, 3, 4)
self.customHeightValueEdit = QtGui.QSpinBox(self.monitorGroupBox) self.customHeightValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') self.customHeightValueEdit.setObjectName(u'customHeightValueEdit')
self.customHeightValueEdit.setMaximum(9999) self.customHeightValueEdit.setMaximum(9999)
self.monitorLayout.addWidget(self.customHeightValueEdit, 5, 4) self.monitorLayout.addWidget(self.customHeightValueEdit, 4, 4)
self.displayOnMonitorCheck = QtGui.QCheckBox(self.monitorGroupBox)
self.displayOnMonitorCheck.setObjectName(u'monitorComboBox')
self.monitorLayout.addWidget(self.displayOnMonitorCheck, 5, 0, 1, 5)
# Set up the stretchiness of each column, so that the first column # Set up the stretchiness of each column, so that the first column
# less stretchy (and therefore smaller) than the others # less stretchy (and therefore smaller) than the others
self.monitorLayout.setColumnStretch(0, 1) self.monitorLayout.setColumnStretch(0, 1)
@ -314,8 +314,6 @@ class GeneralTab(SettingsTab):
u'audio repeat list', QtCore.QVariant(False)).toBool()) u'audio repeat list', QtCore.QVariant(False)).toBool())
settings.endGroup() settings.endGroup()
self.monitorComboBox.setDisabled(self.overrideRadioButton.isChecked()) self.monitorComboBox.setDisabled(self.overrideRadioButton.isChecked())
self.displayOnMonitorCheck.setDisabled(
self.overrideRadioButton.isChecked())
self.customXValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.customXValueEdit.setEnabled(self.overrideRadioButton.isChecked())
self.customYValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.customYValueEdit.setEnabled(self.overrideRadioButton.isChecked())
self.customHeightValueEdit.setEnabled( self.customHeightValueEdit.setEnabled(
@ -408,7 +406,6 @@ class GeneralTab(SettingsTab):
The state of the check box (boolean). The state of the check box (boolean).
""" """
self.monitorComboBox.setDisabled(checked) self.monitorComboBox.setDisabled(checked)
self.displayOnMonitorCheck.setDisabled(checked)
self.customXValueEdit.setEnabled(checked) self.customXValueEdit.setEnabled(checked)
self.customYValueEdit.setEnabled(checked) self.customYValueEdit.setEnabled(checked)
self.customHeightValueEdit.setEnabled(checked) self.customHeightValueEdit.setEnabled(checked)

View File

@ -221,11 +221,6 @@ class MainDisplay(Display):
self.webView.setHtml(build_html(serviceItem, self.screen, self.webView.setHtml(build_html(serviceItem, self.screen,
self.isLive, None, plugins=self.plugins)) self.isLive, None, plugins=self.plugins))
self.__hideMouse() self.__hideMouse()
# To display or not to display?
if not self.screen[u'primary']:
self.primary = False
else:
self.primary = True
log.debug(u'Finished MainDisplay setup') log.debug(u'Finished MainDisplay setup')
def text(self, slide): def text(self, slide):
@ -253,10 +248,10 @@ class MainDisplay(Display):
log.debug(u'alert to display') log.debug(u'alert to display')
# First we convert <>& marks to html variants, then apply # First we convert <>& marks to html variants, then apply
# formattingtags, finally we double all backslashes for JavaScript. # formattingtags, finally we double all backslashes for JavaScript.
text_prepared = expand_tags(cgi.escape(text)) \ text_prepared = expand_tags(
.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"') cgi.escape(text)).replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')
if self.height() != self.screen[u'size'].height() or \ if self.height() != self.screen[u'size'].height() or not \
not self.isVisible(): self.isVisible():
shrink = True shrink = True
js = u'show_alert("%s", "%s")' % (text_prepared, u'top') js = u'show_alert("%s", "%s")' % (text_prepared, u'top')
else: else:
@ -336,7 +331,7 @@ class MainDisplay(Display):
""" """
log.debug(u'preview for %s', self.isLive) log.debug(u'preview for %s', self.isLive)
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
# We must have a service item to preview # We must have a service item to preview.
if self.isLive and hasattr(self, u'serviceItem'): if self.isLive and hasattr(self, u'serviceItem'):
# Wait for the fade to finish before geting the preview. # Wait for the fade to finish before geting the preview.
# Important otherwise preview will have incorrect text if at all! # Important otherwise preview will have incorrect text if at all!
@ -345,7 +340,7 @@ class MainDisplay(Display):
while self.frame.evaluateJavaScript(u'show_text_complete()') \ while self.frame.evaluateJavaScript(u'show_text_complete()') \
.toString() == u'false': .toString() == u'false':
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
# Wait for the webview to update before geting the preview. # Wait for the webview to update before getting the preview.
# Important otherwise first preview will miss the background ! # Important otherwise first preview will miss the background !
while not self.webLoaded: while not self.webLoaded:
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
@ -356,7 +351,7 @@ class MainDisplay(Display):
else: else:
# Single screen active # Single screen active
if self.screens.display_count == 1: if self.screens.display_count == 1:
# Only make visible if setting enabled # Only make visible if setting enabled.
if QtCore.QSettings().value(u'general/display on monitor', if QtCore.QSettings().value(u'general/display on monitor',
QtCore.QVariant(True)).toBool(): QtCore.QVariant(True)).toBool():
self.setVisible(True) self.setVisible(True)
@ -374,9 +369,9 @@ class MainDisplay(Display):
self.initialFrame = None self.initialFrame = None
self.serviceItem = serviceItem self.serviceItem = serviceItem
background = None background = None
# We have an image override so keep the image till the theme changes # We have an image override so keep the image till the theme changes.
if self.override: if self.override:
# We have an video override so allow it to be stopped # We have an video override so allow it to be stopped.
if u'video' in self.override: if u'video' in self.override:
Receiver.send_message(u'video_background_replaced') Receiver.send_message(u'video_background_replaced')
self.override = {} self.override = {}
@ -429,7 +424,7 @@ class MainDisplay(Display):
""" """
log.debug(u'hideDisplay mode = %d', mode) log.debug(u'hideDisplay mode = %d', mode)
if self.screens.display_count == 1: if self.screens.display_count == 1:
# Only make visible if setting enabled # Only make visible if setting enabled.
if not QtCore.QSettings().value(u'general/display on monitor', if not QtCore.QSettings().value(u'general/display on monitor',
QtCore.QVariant(True)).toBool(): QtCore.QVariant(True)).toBool():
return return
@ -454,7 +449,7 @@ class MainDisplay(Display):
""" """
log.debug(u'showDisplay') log.debug(u'showDisplay')
if self.screens.display_count == 1: if self.screens.display_count == 1:
# Only make visible if setting enabled # Only make visible if setting enabled.
if not QtCore.QSettings().value(u'general/display on monitor', if not QtCore.QSettings().value(u'general/display on monitor',
QtCore.QVariant(True)).toBool(): QtCore.QVariant(True)).toBool():
return return
@ -462,12 +457,14 @@ class MainDisplay(Display):
if self.isHidden(): if self.isHidden():
self.setVisible(True) self.setVisible(True)
self.hideMode = None self.hideMode = None
# Trigger actions when display is active again # Trigger actions when display is active again.
if self.isLive: if self.isLive:
Receiver.send_message(u'live_display_active') Receiver.send_message(u'live_display_active')
def __hideMouse(self): def __hideMouse(self):
# Hide mouse cursor when moved over display if enabled in settings """
Hide mouse cursor when moved over display.
"""
if QtCore.QSettings().value(u'advanced/hide mouse', if QtCore.QSettings().value(u'advanced/hide mouse',
QtCore.QVariant(False)).toBool(): QtCore.QVariant(False)).toBool():
self.setCursor(QtCore.Qt.BlankCursor) self.setCursor(QtCore.Qt.BlankCursor)
@ -569,13 +566,12 @@ class AudioPlayer(QtCore.QObject):
""" """
Add another file to the playlist. Add another file to the playlist.
``filename`` ``filenames``
The file to add to the playlist. A list with files to be added to the playlist.
""" """
if not isinstance(filenames, list): if not isinstance(filenames, list):
filenames = [filenames] filenames = [filenames]
for filename in filenames: self.playlist.extend(map(Phonon.MediaSource, filenames))
self.playlist.append(Phonon.MediaSource(filename))
def next(self): def next(self):
if not self.repeat and self.currentIndex + 1 == len(self.playlist): if not self.repeat and self.currentIndex + 1 == len(self.playlist):