SlideController and ServiceManager

This commit is contained in:
Tim Bentley 2012-12-10 18:04:58 +00:00
parent 564b2e41ae
commit 0ea45fd885
2 changed files with 269 additions and 509 deletions

View File

@ -167,54 +167,37 @@ class ServiceManager(QtGui.QWidget):
action_list = ActionList.get_instance()
action_list.add_category(
unicode(UiStrings().Service), CategoryOrder.standardToolbar)
self.serviceManagerList.moveTop = self.orderToolbar.addToolbarAction(
u'moveTop', text=translate('OpenLP.ServiceManager', 'Move to &top'),
icon=u':/services/service_top.png', tooltip=translate(
'OpenLP.ServiceManager', 'Move item to the top of the service.'),
shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service,
triggers=self.onServiceTop)
self.serviceManagerList.moveUp = self.orderToolbar.addToolbarAction(
u'moveUp', text=translate('OpenLP.ServiceManager', 'Move &up'),
icon=u':/services/service_up.png',
tooltip=translate('OpenLP.ServiceManager',
'Move item up one position in the service.'),
shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service,
triggers=self.onServiceUp)
self.serviceManagerList.moveDown = self.orderToolbar.addToolbarAction(
u'moveDown', text=translate('OpenLP.ServiceManager', 'Move &down'),
icon=u':/services/service_down.png',
tooltip=translate('OpenLP.ServiceManager',
'Move item down one position in the service.'),
shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service,
triggers=self.onServiceDown)
self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarAction(
u'moveBottom',
text=translate('OpenLP.ServiceManager', 'Move to &bottom'),
icon=u':/services/service_bottom.png', tooltip=translate(
'OpenLP.ServiceManager', 'Move item to the end of the service.'),
shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service,
triggers=self.onServiceEnd)
self.serviceManagerList.down = self.orderToolbar.addToolbarAction(
u'down', text=translate('OpenLP.ServiceManager', 'Move &down'),
tooltip=translate('OpenLP.ServiceManager',
'Moves the selection down the window.'), visible=False,
shortcuts=[QtCore.Qt.Key_Down], triggers=self.onMoveSelectionDown)
self.serviceManagerList.moveTop = self.orderToolbar.addToolbarAction(u'moveTop',
text=translate('OpenLP.ServiceManager', 'Move to &top'), icon=u':/services/service_top.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item to the top of the service.'),
shortcuts=[QtCore.Qt.Key_Home], category=UiStrings().Service, triggers=self.onServiceTop)
self.serviceManagerList.moveUp = self.orderToolbar.addToolbarAction(u'moveUp',
text=translate('OpenLP.ServiceManager', 'Move &up'), icon=u':/services/service_up.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item up one position in the service.'),
shortcuts=[QtCore.Qt.Key_PageUp], category=UiStrings().Service, triggers=self.onServiceUp)
self.serviceManagerList.moveDown = self.orderToolbar.addToolbarAction(u'moveDown',
text=translate('OpenLP.ServiceManager', 'Move &down'), icon=u':/services/service_down.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item down one position in the service.'),
shortcuts=[QtCore.Qt.Key_PageDown], category=UiStrings().Service, triggers=self.onServiceDown)
self.serviceManagerList.moveBottom = self.orderToolbar.addToolbarAction(u'moveBottom',
text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=u':/services/service_bottom.png',
tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'),
shortcuts=[QtCore.Qt.Key_End], category=UiStrings().Service, triggers=self.onServiceEnd)
self.serviceManagerList.down = self.orderToolbar.addToolbarAction(u'down',
text=translate('OpenLP.ServiceManager', 'Move &down'), tooltip=translate('OpenLP.ServiceManager',
'Moves the selection down the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Down],
triggers=self.onMoveSelectionDown)
action_list.add_action(self.serviceManagerList.down)
self.serviceManagerList.up = self.orderToolbar.addToolbarAction(
u'up', text=translate('OpenLP.ServiceManager', 'Move up'),
tooltip=translate('OpenLP.ServiceManager',
'Moves the selection up the window.'), visible=False,
shortcuts=[QtCore.Qt.Key_Up], triggers=self.onMoveSelectionUp)
self.serviceManagerList.up = self.orderToolbar.addToolbarAction(u'up',
text=translate('OpenLP.ServiceManager', 'Move up'), tooltip=translate('OpenLP.ServiceManager',
'Moves the selection up the window.'), visible=False, shortcuts=[QtCore.Qt.Key_Up],
triggers=self.onMoveSelectionUp)
action_list.add_action(self.serviceManagerList.up)
self.orderToolbar.addSeparator()
self.serviceManagerList.delete = self.orderToolbar.addToolbarAction(
u'delete',
text=translate('OpenLP.ServiceManager', '&Delete From Service'),
icon=u':/general/general_delete.png',
tooltip=translate('OpenLP.ServiceManager',
'Delete the selected item from the service.'),
shortcuts=[QtCore.Qt.Key_Delete],
triggers=self.onDeleteFromService)
self.serviceManagerList.delete = self.orderToolbar.addToolbarAction(u'delete',
text=translate('OpenLP.ServiceManager', '&Delete From Service'), icon=u':/general/general_delete.png',
tooltip=translate('OpenLP.ServiceManager', 'Delete the selected item from the service.'),
shortcuts=[QtCore.Qt.Key_Delete], triggers=self.onDeleteFromService)
self.orderToolbar.addSeparator()
self.serviceManagerList.expand = self.orderToolbar.addToolbarAction(
u'expand', text=translate('OpenLP.ServiceManager', '&Expand all'),
@ -222,20 +205,15 @@ class ServiceManager(QtGui.QWidget):
'OpenLP.ServiceManager', 'Expand all the service items.'),
shortcuts=[QtCore.Qt.Key_Plus], category=UiStrings().Service,
triggers=self.onExpandAll)
self.serviceManagerList.collapse = self.orderToolbar.addToolbarAction(
u'collapse',
text=translate('OpenLP.ServiceManager', '&Collapse all'),
icon=u':/services/service_collapse_all.png', tooltip=translate(
'OpenLP.ServiceManager', 'Collapse all the service items.'),
shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service,
triggers=self.onCollapseAll)
self.serviceManagerList.collapse = self.orderToolbar.addToolbarAction(u'collapse',
text=translate('OpenLP.ServiceManager', '&Collapse all'), icon=u':/services/service_collapse_all.png',
tooltip=translate('OpenLP.ServiceManager', 'Collapse all the service items.'),
shortcuts=[QtCore.Qt.Key_Minus], category=UiStrings().Service, triggers=self.onCollapseAll)
self.orderToolbar.addSeparator()
self.serviceManagerList.makeLive = self.orderToolbar.addToolbarAction(
u'makeLive', text=translate('OpenLP.ServiceManager', 'Go Live'),
icon=u':/general/general_live.png', tooltip=translate(
'OpenLP.ServiceManager', 'Send the selected item to Live.'),
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return],
category=UiStrings().Service, triggers=self.makeLive)
self.serviceManagerList.makeLive = self.orderToolbar.addToolbarAction(u'makeLive',
text=translate('OpenLP.ServiceManager', 'Go Live'), icon=u':/general/general_live.png',
tooltip=translate('OpenLP.ServiceManager', 'Send the selected item to Live.'),
shortcuts=[QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return], category=UiStrings().Service, triggers=self.makeLive)
self.layout.addWidget(self.orderToolbar)
# Connect up our signals and slots
QtCore.QObject.connect(self.themeComboBox, QtCore.SIGNAL(u'activated(int)'), self.onThemeComboBoxSelected)
@ -268,34 +246,25 @@ class ServiceManager(QtGui.QWidget):
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
# build the context menu
self.menu = QtGui.QMenu()
self.editAction = create_widget_action(self.menu,
text=translate('OpenLP.ServiceManager', '&Edit Item'),
self.editAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'),
icon=u':/general/general_edit.png', triggers=self.remoteEdit)
self.maintainAction = create_widget_action(self.menu,
text=translate('OpenLP.ServiceManager', '&Reorder Item'),
icon=u':/general/general_edit.png',
triggers=self.onServiceItemEditForm)
self.notesAction = create_widget_action(self.menu,
text=translate('OpenLP.ServiceManager', '&Notes'),
icon=u':/services/service_notes.png',
triggers=self.onServiceItemNoteForm)
self.timeAction = create_widget_action(self.menu,
text=translate('OpenLP.ServiceManager', '&Start Time'),
self.maintainAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Reorder Item'),
icon=u':/general/general_edit.png', triggers=self.onServiceItemEditForm)
self.notesAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Notes'),
icon=u':/services/service_notes.png', triggers=self.onServiceItemNoteForm)
self.timeAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Start Time'),
icon=u':/media/media_time.png', triggers=self.onStartTimeForm)
self.autoStartAction = create_widget_action(self.menu,
text=u'',
self.autoStartAction = create_widget_action(self.menu, text=u'',
icon=u':/media/auto-start_active.png', triggers=self.onAutoStart)
# Add already existing delete action to the menu.
self.menu.addAction(self.serviceManagerList.delete)
self.menu.addSeparator()
self.previewAction = create_widget_action(self.menu,
text=translate('OpenLP.ServiceManager', 'Show &Preview'),
self.previewAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'),
icon=u':/general/general_preview.png', triggers=self.makePreview)
# Add already existing make live action to the menu.
self.menu.addAction(self.serviceManagerList.makeLive)
self.menu.addSeparator()
self.themeMenu = QtGui.QMenu(
translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.themeMenu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.menu.addMenu(self.themeMenu)
self.serviceManagerList.addActions(
[self.serviceManagerList.moveDown,
@ -318,8 +287,7 @@ class ServiceManager(QtGui.QWidget):
if modified:
self.serviceId += 1
self._modified = modified
serviceFile = self.shortFileName() or translate(
'OpenLP.ServiceManager', 'Untitled Service')
serviceFile = self.shortFileName() or translate('OpenLP.ServiceManager', 'Untitled Service')
self.mainwindow.setServiceModified(modified, serviceFile)
def isModified(self):
@ -335,8 +303,7 @@ class ServiceManager(QtGui.QWidget):
self._fileName = unicode(fileName)
self.mainwindow.setServiceModified(self.isModified(),
self.shortFileName())
Settings(). \
setValue(u'servicemanager/last file',QtCore.QVariant(fileName))
Settings().setValue(u'servicemanager/last file',QtCore.QVariant(fileName))
self._saveLite = True if self._fileName.endswith(u'.oszl') else False
def fileName(self):
@ -355,9 +322,7 @@ class ServiceManager(QtGui.QWidget):
"""
Triggered when Config dialog is updated.
"""
self.expandTabs = Settings().value(
u'advanced/expand service item',
QtCore.QVariant(u'False')).toBool()
self.expandTabs = Settings().value(u'advanced/expand service item', QtCore.QVariant(u'False')).toBool()
def resetSupportedSuffixes(self):
"""
@ -405,29 +370,23 @@ class ServiceManager(QtGui.QWidget):
elif result == QtGui.QMessageBox.Save:
self.decideSaveMethod()
if not loadFile:
fileName = unicode(QtGui.QFileDialog.getOpenFileName(
self.mainwindow,
fileName = unicode(QtGui.QFileDialog.getOpenFileName(self.mainwindow,
translate('OpenLP.ServiceManager', 'Open File'),
SettingsManager.get_last_dir(
self.mainwindow.serviceManagerSettingsSection),
translate('OpenLP.ServiceManager',
'OpenLP Service Files (*.osz *.oszl)')))
SettingsManager.get_last_dir(self.mainwindow.serviceManagerSettingsSection),
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)')))
if not fileName:
return False
else:
fileName = loadFile
SettingsManager.set_last_dir(
self.mainwindow.serviceManagerSettingsSection,
split_filename(fileName)[0])
SettingsManager.set_last_dir(self.mainwindow.serviceManagerSettingsSection, split_filename(fileName)[0])
self.loadFile(fileName)
def saveModifiedService(self):
return QtGui.QMessageBox.question(self.mainwindow,
translate('OpenLP.ServiceManager', 'Modified Service'),
translate('OpenLP.ServiceManager', 'The current service has '
'been modified. Would you like to save this service?'),
QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard |
QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save)
translate('OpenLP.ServiceManager',
'The current service has been modified. Would you like to save this service?'),
QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save)
def onRecentServiceClicked(self):
sender = self.sender()
@ -442,8 +401,7 @@ class ServiceManager(QtGui.QWidget):
self.setFileName(u'')
self.serviceId += 1
self.setModified(False)
Settings(). \
setValue(u'servicemanager/last file',QtCore.QVariant(u''))
Settings().setValue(u'servicemanager/last file',QtCore.QVariant(u''))
Receiver.send_message(u'servicemanager_new_service')
def saveFile(self):
@ -491,16 +449,12 @@ class ServiceManager(QtGui.QWidget):
write_list.append(path_from)
if missing_list:
Receiver.send_message(u'cursor_normal')
title = unicode(translate('OpenLP.ServiceManager',
'Service File(s) Missing'))
title = unicode(translate('OpenLP.ServiceManager', 'Service File(s) Missing'))
message = unicode(translate('OpenLP.ServiceManager',
'The following file(s) in the service are missing:\n\t%s\n\n'
'These files will be removed if you continue to save.')
) % "\n\t".join(missing_list)
answer = QtGui.QMessageBox.critical(self, title,
message,
QtGui.QMessageBox.StandardButtons(
QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel))
'These files will be removed if you continue to save.')) % "\n\t".join(missing_list)
answer = QtGui.QMessageBox.critical(self, title, message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel))
if answer == QtGui.QMessageBox.Cancel:
self.mainwindow.finishedProgressBar()
return False
@ -519,16 +473,14 @@ class ServiceManager(QtGui.QWidget):
new_file = os.path.join(u'audio',
item[u'service_item']._uuid, filename)
audio_files.append((filename, new_file))
service_item[u'header'][u'background_audio'][i] = \
new_file
service_item[u'header'][u'background_audio'][i] = new_file
# Add the service item to the service.
service.append({u'serviceitem': service_item})
self.repaintServiceList(-1, -1)
for file in write_list:
file_size = os.path.getsize(file)
total_size += file_size
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' %
total_size)
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' % total_size)
service_content = cPickle.dumps(service)
# Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be
# extracted using unzip in UNIX.
@ -538,8 +490,7 @@ class ServiceManager(QtGui.QWidget):
success = True
self.mainwindow.incrementProgressBar()
try:
zip = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED,
allow_zip_64)
zip = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED, allow_zip_64)
# First we add service contents.
# We save ALL filenames into ZIP using UTF-8.
zip.writestr(service_file_name.encode(u'utf-8'), service_content)
@ -562,10 +513,8 @@ class ServiceManager(QtGui.QWidget):
except IOError:
log.exception(u'Failed to save service to disk: %s', temp_file_name)
Receiver.send_message(u'openlp_error_message', {
u'title': translate(u'OpenLP.ServiceManager',
u'Error Saving File'),
u'message': translate(u'OpenLP.ServiceManager',
u'There was an error saving your file.')
u'title': translate(u'OpenLP.ServiceManager', u'Error Saving File'),
u'message': translate(u'OpenLP.ServiceManager', u'There was an error saving your file.')
})
success = False
finally:
@ -603,17 +552,14 @@ class ServiceManager(QtGui.QWidget):
basename = os.path.splitext(file_name)[0]
service_file_name = '%s.osd' % basename
log.debug(u'ServiceManager.saveFile - %s', path_file_name)
SettingsManager.set_last_dir(
self.mainwindow.serviceManagerSettingsSection,
path)
SettingsManager.set_last_dir(self.mainwindow.serviceManagerSettingsSection, path)
service = []
Receiver.send_message(u'cursor_busy')
# Number of items + 1 to zip it
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
for item in self.serviceItems:
self.mainwindow.incrementProgressBar()
service_item = item[u'service_item']. \
get_service_repr(self._saveLite)
service_item = item[u'service_item'].get_service_repr(self._saveLite)
#@todo check for file item on save.
service.append({u'serviceitem': service_item})
self.mainwindow.incrementProgressBar()
@ -629,10 +575,8 @@ class ServiceManager(QtGui.QWidget):
except IOError:
log.exception(u'Failed to save service to disk: %s', temp_file_name)
Receiver.send_message(u'openlp_error_message', {
u'title': translate(u'OpenLP.ServiceManager',
u'Error Saving File'),
u'message': translate(u'OpenLP.ServiceManager',
u'There was an error saving your file.')
u'title': translate(u'OpenLP.ServiceManager', u'Error Saving File'),
u'message': translate(u'OpenLP.ServiceManager', u'There was an error saving your file.')
})
success = False
finally:
@ -655,50 +599,39 @@ class ServiceManager(QtGui.QWidget):
Get a file name and then call :func:`ServiceManager.saveFile` to
save the file.
"""
default_service_enabled = Settings().value(
u'advanced/default service enabled', QtCore.QVariant(True)).toBool()
default_service_enabled = Settings().value(u'advanced/default service enabled', QtCore.QVariant(True)).toBool()
if default_service_enabled:
service_day = Settings().value(
u'advanced/default service day', 7).toInt()[0]
service_day = Settings().value(u'advanced/default service day', 7).toInt()[0]
if service_day == 7:
local_time = datetime.now()
else:
service_hour = Settings().value(
u'advanced/default service hour', 11).toInt()[0]
service_minute = Settings().value(
u'advanced/default service minute', 0).toInt()[0]
service_hour = Settings().value(u'advanced/default service hour', 11).toInt()[0]
service_minute = Settings().value(u'advanced/default service minute', 0).toInt()[0]
now = datetime.now()
day_delta = service_day - now.weekday()
if day_delta < 0:
day_delta += 7
time = now + timedelta(days=day_delta)
local_time = time.replace(hour=service_hour, minute=service_minute)
default_pattern = unicode(Settings().value(
u'advanced/default service name',
default_pattern = unicode(Settings().value(u'advanced/default service name',
translate('OpenLP.AdvancedTab', 'Service %Y-%m-%d %H-%M',
'This may not contain any of the following characters: '
'/\\?*|<>\[\]":+\nSee http://docs.python.org/library/'
'datetime.html#strftime-strptime-behavior for more '
'information.')).toString())
'datetime.html#strftime-strptime-behavior for more information.')).toString())
default_filename = format_time(default_pattern, local_time)
else:
default_filename = u''
directory = unicode(SettingsManager.get_last_dir(
self.mainwindow.serviceManagerSettingsSection))
directory = unicode(SettingsManager.get_last_dir(self.mainwindow.serviceManagerSettingsSection))
path = os.path.join(directory, default_filename)
# SaveAs from osz to oszl is not valid as the files will be deleted
# on exit which is not sensible or usable in the long term.
if self._fileName.endswith(u'oszl') or not self._fileName:
fileName = unicode(QtGui.QFileDialog.getSaveFileName(
self.mainwindow, UiStrings().SaveService, path,
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow, UiStrings().SaveService, path,
translate('OpenLP.ServiceManager',
'OpenLP Service Files (*.osz);;'
'OpenLP Service Files - lite (*.oszl)')))
'OpenLP Service Files (*.osz);; OpenLP Service Files - lite (*.oszl)')))
else:
fileName = unicode(QtGui.QFileDialog.getSaveFileName(
self.mainwindow, UiStrings().SaveService, path,
translate('OpenLP.ServiceManager',
'OpenLP Service Files (*.osz);;')))
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow, UiStrings().SaveService, path,
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);;')))
if not fileName:
return False
if os.path.splitext(fileName)[1] == u'':
@ -737,12 +670,9 @@ class ServiceManager(QtGui.QWidget):
try:
ucsfile = zipinfo.filename.decode(u'utf-8')
except UnicodeDecodeError:
log.exception(u'Filename "%s" is not valid UTF-8' %
zipinfo.filename.decode(u'utf-8', u'replace'))
critical_error_message_box(
message=translate('OpenLP.ServiceManager',
'File is not a valid service.\n'
'The content encoding is not UTF-8.'))
log.exception(u'Filename "%s" is not valid UTF-8' % zipinfo.filename.decode(u'utf-8', u'replace'))
critical_error_message_box(message=translate('OpenLP.ServiceManager',
'File is not a valid service.\n The content encoding is not UTF-8.'))
continue
osfile = ucsfile.replace(u'/', os.path.sep)
if not osfile.startswith(u'audio'):
@ -771,8 +701,7 @@ class ServiceManager(QtGui.QWidget):
self.validateItem(serviceItem)
self.load_item_uuid = 0
if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate):
Receiver.send_message(u'%s_service_load' %
serviceItem.name.lower(), serviceItem)
Receiver.send_message(u'%s_service_load' % serviceItem.name.lower(), serviceItem)
# if the item has been processed
if serviceItem._uuid == self.load_item_uuid:
serviceItem.edit_id = int(self.load_item_edit_id)
@ -781,32 +710,25 @@ class ServiceManager(QtGui.QWidget):
delete_file(p_file)
self.mainwindow.addRecentFile(fileName)
self.setModified(False)
Settings().setValue(
'servicemanager/last file', QtCore.QVariant(fileName))
Settings().setValue(u'servicemanager/last file', QtCore.QVariant(fileName))
else:
critical_error_message_box(
message=translate('OpenLP.ServiceManager',
'File is not a valid service.'))
critical_error_message_box(message=translate('OpenLP.ServiceManager', 'File is not a valid service.'))
log.exception(u'File contains no service data')
except (IOError, NameError, zipfile.BadZipfile):
log.exception(u'Problem loading service file %s' % fileName)
critical_error_message_box(
message=translate('OpenLP.ServiceManager',
critical_error_message_box(message=translate('OpenLP.ServiceManager',
'File could not be opened because it is corrupt.'))
except zipfile.BadZipfile:
if os.path.getsize(fileName) == 0:
log.exception(u'Service file is zero sized: %s' % fileName)
QtGui.QMessageBox.information(self,
translate('OpenLP.ServiceManager', 'Empty File'),
translate('OpenLP.ServiceManager', 'This service file '
'does not contain any data.'))
QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Empty File'),
translate('OpenLP.ServiceManager', 'This service file does not contain any data.'))
else:
log.exception(u'Service file is cannot be extracted as zip: '
u'%s' % fileName)
QtGui.QMessageBox.information(self,
translate('OpenLP.ServiceManager', 'Corrupt File'),
translate('OpenLP.ServiceManager', 'This file is either '
'corrupt or it is not an OpenLP 2.0 service file.'))
QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Corrupt File'),
translate('OpenLP.ServiceManager',
'This file is either corrupt or it is not an OpenLP 2 service file.'))
return
finally:
if fileTo:
@ -823,8 +745,7 @@ class ServiceManager(QtGui.QWidget):
service was last closed. Can be blank if there was no service
present.
"""
fileName = Settings(). \
value(u'servicemanager/last file',QtCore.QVariant(u'')).toString()
fileName = Settings().value(u'servicemanager/last file',QtCore.QVariant(u'')).toString()
if fileName:
self.loadFile(fileName)
@ -842,19 +763,15 @@ class ServiceManager(QtGui.QWidget):
self.notesAction.setVisible(False)
self.timeAction.setVisible(False)
self.autoStartAction.setVisible(False)
if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanEdit)\
and serviceItem[u'service_item'].edit_id:
if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanEdit) and serviceItem[u'service_item'].edit_id:
self.editAction.setVisible(True)
if serviceItem[u'service_item']\
.is_capable(ItemCapabilities.CanMaintain):
if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanMaintain):
self.maintainAction.setVisible(True)
if item.parent() is None:
self.notesAction.setVisible(True)
if serviceItem[u'service_item']\
.is_capable(ItemCapabilities.HasVariableStartTime):
if serviceItem[u'service_item'].is_capable(ItemCapabilities.HasVariableStartTime):
self.timeAction.setVisible(True)
if serviceItem[u'service_item']\
.is_capable(ItemCapabilities.CanAutoStartForLive):
if serviceItem[u'service_item'].is_capable(ItemCapabilities.CanAutoStartForLive):
self.autoStartAction.setVisible(True)
self.autoStartAction.setIcon(self.inactive)
self.autoStartAction.setText(translate('OpenLP.ServiceManager','&Auto Start - inactive'))
@ -863,15 +780,13 @@ class ServiceManager(QtGui.QWidget):
self.autoStartAction.setIcon(self.active)
self.themeMenu.menuAction().setVisible(False)
# Set up the theme menu.
if serviceItem[u'service_item'].is_text() and \
self.mainwindow.renderer.theme_level == ThemeLevel.Song:
if serviceItem[u'service_item'].is_text() and self.mainwindow.renderer.theme_level == ThemeLevel.Song:
self.themeMenu.menuAction().setVisible(True)
# The service item does not have a theme, check the "Default".
if serviceItem[u'service_item'].theme is None:
themeAction = self.themeMenu.defaultAction()
else:
themeAction = self.themeMenu.findChild(
QtGui.QAction, serviceItem[u'service_item'].theme)
themeAction = self.themeMenu.findChild(QtGui.QAction, serviceItem[u'service_item'].theme)
if themeAction is not None:
themeAction.setChecked(True)
self.menu.exec_(self.serviceManagerList.mapToGlobal(point))
@ -881,8 +796,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceNoteForm.textEdit.setPlainText(
self.serviceItems[item][u'service_item'].notes)
if self.serviceNoteForm.exec_():
self.serviceItems[item][u'service_item'].notes = \
self.serviceNoteForm.textEdit.toPlainText()
self.serviceItems[item][u'service_item'].notes = self.serviceNoteForm.textEdit.toPlainText()
self.repaintServiceList(item, -1)
self.setModified()
@ -1128,22 +1042,18 @@ class ServiceManager(QtGui.QWidget):
if serviceitem.is_valid:
if serviceitem.notes:
icon = QtGui.QImage(serviceitem.icon)
icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)
icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
overlay = QtGui.QImage(':/services/service_item_notes.png')
overlay = overlay.scaled(80, 80, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)
overlay = overlay.scaled(80, 80, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
painter = QtGui.QPainter(icon)
painter.drawImage(0, 0, overlay)
painter.end()
treewidgetitem.setIcon(0, build_icon(icon))
elif serviceitem.temporary_edit:
icon = QtGui.QImage(serviceitem.icon)
icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)
icon = icon.scaled(80, 80, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
overlay = QtGui.QImage(':/general/general_export.png')
overlay = overlay.scaled(40, 40, QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation)
overlay = overlay.scaled(40, 40, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
painter = QtGui.QPainter(icon)
painter.drawImage(40, 0, overlay)
painter.end()
@ -1151,29 +1061,23 @@ class ServiceManager(QtGui.QWidget):
else:
treewidgetitem.setIcon(0, serviceitem.iconic_representation)
else:
treewidgetitem.setIcon(0,
build_icon(u':/general/general_delete.png'))
treewidgetitem.setIcon(0, build_icon(u':/general/general_delete.png'))
treewidgetitem.setText(0, serviceitem.get_display_title())
tips = []
if serviceitem.temporary_edit:
tips.append(u'<strong>%s:</strong> <em>%s</em>' %
(unicode(translate('OpenLP.ServiceManager', 'Edit')),
(unicode(translate('OpenLP.ServiceManager',
'Service copy only')))))
(unicode(translate('OpenLP.ServiceManager', 'Service copy only')))))
if serviceitem.theme and serviceitem.theme != -1:
tips.append(u'<strong>%s:</strong> <em>%s</em>' %
(unicode(translate('OpenLP.ServiceManager', 'Slide theme')),
serviceitem.theme))
(unicode(translate('OpenLP.ServiceManager', 'Slide theme')), serviceitem.theme))
if serviceitem.notes:
tips.append(u'<strong>%s: </strong> %s' %
(unicode(translate('OpenLP.ServiceManager', 'Notes')),
cgi.escape(unicode(serviceitem.notes))))
if item[u'service_item'] \
.is_capable(ItemCapabilities.HasVariableStartTime):
(unicode(translate('OpenLP.ServiceManager', 'Notes')), cgi.escape(unicode(serviceitem.notes))))
if item[u'service_item'].is_capable(ItemCapabilities.HasVariableStartTime):
tips.append(item[u'service_item'].get_media_time())
treewidgetitem.setToolTip(0, u'<br>'.join(tips))
treewidgetitem.setData(0, QtCore.Qt.UserRole,
QtCore.QVariant(item[u'order']))
treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order']))
treewidgetitem.setSelected(item[u'selected'])
# Add the children to their parent treewidgetitem.
for count, frame in enumerate(serviceitem.get_frames()):
@ -1218,9 +1122,7 @@ class ServiceManager(QtGui.QWidget):
log.debug(u'onThemeComboBoxSelected')
self.service_theme = unicode(self.themeComboBox.currentText())
self.mainwindow.renderer.set_service_theme(self.service_theme)
Settings().setValue(
self.mainwindow.serviceManagerSettingsSection +
u'/service theme',
Settings().setValue(self.mainwindow.serviceManagerSettingsSection + u'/service theme',
QtCore.QVariant(self.service_theme))
self.regenerateServiceItems(True)
@ -1246,8 +1148,7 @@ class ServiceManager(QtGui.QWidget):
if self.serviceItems:
for item in self.serviceItems:
item[u'selected'] = False
serviceIterator = QtGui.QTreeWidgetItemIterator(
self.serviceManagerList)
serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
selectedItem = None
while serviceIterator.value():
if serviceIterator.value().isSelected():
@ -1257,17 +1158,15 @@ class ServiceManager(QtGui.QWidget):
if selectedItem.parent() is None:
pos = selectedItem.data(0, QtCore.Qt.UserRole).toInt()[0]
else:
pos = selectedItem.parent().data(0, QtCore.Qt.UserRole). \
toInt()[0]
pos = selectedItem.parent().data(0, QtCore.Qt.UserRole).toInt()[0]
self.serviceItems[pos - 1][u'selected'] = True
tempServiceItems = self.serviceItems
self.serviceManagerList.clear()
self.serviceItems = []
self.isNew = True
for item in tempServiceItems:
self.addServiceItem(
item[u'service_item'], False, expand=item[u'expanded'],
repaint=False, selected=item[u'selected'])
self.addServiceItem(item[u'service_item'], False, expand=item[u'expanded'], repaint=False,
selected=item[u'selected'])
# Set to False as items may have changed rendering
# does not impact the saved song so True may also be valid
if changed:
@ -1291,18 +1190,15 @@ class ServiceManager(QtGui.QWidget):
if found.
"""
for itemcount, item in enumerate(self.serviceItems):
if item[u'service_item'].edit_id == newItem.edit_id and \
item[u'service_item'].name == newItem.name:
if item[u'service_item'].edit_id == newItem.edit_id and item[u'service_item'].name == newItem.name:
newItem.render()
newItem.merge(item[u'service_item'])
item[u'service_item'] = newItem
self.repaintServiceList(itemcount + 1, 0)
self.mainwindow.liveController.replaceServiceManagerItem(
newItem)
self.mainwindow.liveController.replaceServiceManagerItem(newItem)
self.setModified()
def addServiceItem(self, item, rebuild=False, expand=None, replace=False,
repaint=True, selected=False):
def addServiceItem(self, item, rebuild=False, expand=None, replace=False, repaint=True, selected=False):
"""
Add a Service item to the list
@ -1358,10 +1254,9 @@ class ServiceManager(QtGui.QWidget):
self.mainwindow.previewController.addServiceManagerItem(
self.serviceItems[item][u'service_item'], child)
else:
critical_error_message_box(
translate('OpenLP.ServiceManager', 'Missing Display Handler'),
translate('OpenLP.ServiceManager', 'Your item cannot be '
'displayed as there is no handler to display it'))
critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'),
translate('OpenLP.ServiceManager',
'Your item cannot be displayed as there is no handler to display it'))
Receiver.send_message(u'cursor_normal')
def getServiceItem(self):
@ -1404,17 +1299,13 @@ class ServiceManager(QtGui.QWidget):
QtCore.QVariant(False)).toBool():
item += 1
if self.serviceItems and item < len(self.serviceItems) and \
self.serviceItems[item][u'service_item'].is_capable(
ItemCapabilities.CanPreview):
self.mainwindow.previewController.addServiceManagerItem(
self.serviceItems[item][u'service_item'], 0)
self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanPreview):
self.mainwindow.previewController.addServiceManagerItem(self.serviceItems[item][u'service_item'], 0)
self.mainwindow.liveController.previewListWidget.setFocus()
else:
critical_error_message_box(
translate('OpenLP.ServiceManager', 'Missing Display Handler'),
translate('OpenLP.ServiceManager', 'Your item cannot be '
'displayed as the plugin required to display it is missing '
'or inactive'))
critical_error_message_box(translate('OpenLP.ServiceManager', 'Missing Display Handler'),
translate('OpenLP.ServiceManager',
'Your item cannot be displayed as the plugin required to display it is missing or inactive'))
Receiver.send_message(u'cursor_normal')
def remoteEdit(self):
@ -1422,10 +1313,8 @@ class ServiceManager(QtGui.QWidget):
Posts a remote edit message to a plugin to allow item to be edited.
"""
item = self.findServiceItem()[0]
if self.serviceItems[item][u'service_item']\
.is_capable(ItemCapabilities.CanEdit):
Receiver.send_message(u'%s_edit' %
self.serviceItems[item][u'service_item'].name.lower(),
if self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.CanEdit):
Receiver.send_message(u'%s_edit' % self.serviceItems[item][u'service_item'].name.lower(),
u'L:%s' % self.serviceItems[item][u'service_item'].edit_id)
def findServiceItem(self):
@ -1510,8 +1399,7 @@ class ServiceManager(QtGui.QWidget):
pos = self._getParentItemData(item) - 1
serviceItem = self.serviceItems[pos]
if (plugin == serviceItem[u'service_item'].name and
serviceItem[u'service_item'].is_capable(
ItemCapabilities.CanAppend)):
serviceItem[u'service_item'].is_capable(ItemCapabilities.CanAppend)):
action = self.dndMenu.exec_(QtGui.QCursor.pos())
# New action required
if action == self.newAction:
@ -1540,16 +1428,15 @@ class ServiceManager(QtGui.QWidget):
themeGroup.setObjectName(u'themeGroup')
# Create a "Default" theme, which allows the user to reset the item's
# theme to the service theme or global theme.
defaultTheme = create_widget_action(self.themeMenu,
text=UiStrings().Default, checked=False,
defaultTheme = create_widget_action(self.themeMenu, text=UiStrings().Default, checked=False,
triggers=self.onThemeChangeAction)
self.themeMenu.setDefaultAction(defaultTheme)
themeGroup.addAction(defaultTheme)
self.themeMenu.addSeparator()
for theme in theme_list:
self.themeComboBox.addItem(theme)
themeGroup.addAction(create_widget_action(self.themeMenu, theme,
text=theme, checked=False, triggers=self.onThemeChangeAction))
themeGroup.addAction(create_widget_action(self.themeMenu, theme, text=theme, checked=False,
triggers=self.onThemeChangeAction))
find_and_set_in_combo_box(self.themeComboBox, self.service_theme)
self.mainwindow.renderer.set_service_theme(self.service_theme)
self.regenerateServiceItems()

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
@ -65,8 +65,7 @@ class DisplayController(QtGui.QWidget):
created from within other plugins
This function is needed to catch the current controller
"""
sender = self.sender().objectName() if self.sender().objectName() \
else self.sender().text()
sender = self.sender().objectName() if self.sender().objectName() else self.sender().text()
controller = self
Receiver.send_message('%s' % sender, [controller, args])
@ -83,8 +82,7 @@ class SlideController(DisplayController):
DisplayController.__init__(self, parent, isLive)
self.screens = ScreenList()
try:
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())
self.ratio = float(self.screens.current[u'size'].width()) / float(self.screens.current[u'size'].height())
except ZeroDivisionError:
self.ratio = 1
self.imageManager = self.parent().imageManager
@ -120,8 +118,7 @@ class SlideController(DisplayController):
self.keypress_queue = deque()
self.keypress_loop = False
self.category = UiStrings().LiveToolbar
ActionList.get_instance().add_category(
unicode(self.category), CategoryOrder.standardToolbar)
ActionList.get_instance().add_category(unicode(self.category), CategoryOrder.standardToolbar)
else:
self.typeLabel.setText(UiStrings().Preview)
self.split = 0
@ -137,9 +134,7 @@ class SlideController(DisplayController):
# Actual controller section
self.controller = QtGui.QWidget(self.splitter)
self.controller.setGeometry(QtCore.QRect(0, 0, 100, 536))
self.controller.setSizePolicy(
QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
QtGui.QSizePolicy.Maximum))
self.controller.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Maximum))
self.controllerLayout = QtGui.QVBoxLayout(self.controller)
self.controllerLayout.setSpacing(0)
self.controllerLayout.setMargin(0)
@ -150,40 +145,29 @@ class SlideController(DisplayController):
self.previewListWidget.setColumnWidth(0, self.controller.width())
self.previewListWidget.isLive = self.isLive
self.previewListWidget.setObjectName(u'previewListWidget')
self.previewListWidget.setSelectionBehavior(
QtGui.QAbstractItemView.SelectRows)
self.previewListWidget.setSelectionMode(
QtGui.QAbstractItemView.SingleSelection)
self.previewListWidget.setEditTriggers(
QtGui.QAbstractItemView.NoEditTriggers)
self.previewListWidget.setHorizontalScrollBarPolicy(
QtCore.Qt.ScrollBarAlwaysOff)
self.previewListWidget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self.previewListWidget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self.previewListWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.previewListWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.previewListWidget.setAlternatingRowColors(True)
self.controllerLayout.addWidget(self.previewListWidget)
# Build the full toolbar
self.toolbar = OpenLPToolbar(self)
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Fixed)
sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizeToolbarPolicy.setHorizontalStretch(0)
sizeToolbarPolicy.setVerticalStretch(0)
sizeToolbarPolicy.setHeightForWidth(
self.toolbar.sizePolicy().hasHeightForWidth())
sizeToolbarPolicy.setHeightForWidth(self.toolbar.sizePolicy().hasHeightForWidth())
self.toolbar.setSizePolicy(sizeToolbarPolicy)
self.previousItem = create_action(self,
u'previousItem_' + self.typePrefix,
text=translate('OpenLP.SlideController', 'Previous Slide'),
icon=u':/slides/slide_previous.png',
self.previousItem = create_action(self, u'previousItem_' + self.typePrefix,
text=translate('OpenLP.SlideController', 'Previous Slide'), icon=u':/slides/slide_previous.png',
tooltip=translate('OpenLP.SlideController', 'Move to previous.'),
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp],
context=QtCore.Qt.WidgetWithChildrenShortcut,
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp], context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.onSlideSelectedPrevious)
self.toolbar.addAction(self.previousItem)
self.nextItem = create_action(self, u'nextItem_' + self.typePrefix,
text=translate('OpenLP.SlideController', 'Next Slide'),
icon=u':/slides/slide_next.png',
text=translate('OpenLP.SlideController', 'Next Slide'), icon=u':/slides/slide_next.png',
tooltip=translate('OpenLP.SlideController', 'Move to next.'),
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown],
context=QtCore.Qt.WidgetWithChildrenShortcut,
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown], context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.onSlideSelectedNextAction)
self.toolbar.addAction(self.nextItem)
self.toolbar.addSeparator()
@ -195,24 +179,19 @@ class SlideController(DisplayController):
self.hideMenu.setObjectName(u'hideMenu')
self.hideMenu.setText(translate('OpenLP.SlideController', 'Hide'))
self.hideMenu.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
self.hideMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Hide'), self.toolbar))
self.hideMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Hide'), self.toolbar))
self.toolbar.addToolbarWidget(self.hideMenu)
self.blankScreen = create_action(self, u'blankScreen',
text=translate('OpenLP.SlideController', 'Blank Screen'),
icon=u':/slides/slide_blank.png', checked=False,
shortcuts=[QtCore.Qt.Key_Period],
category=self.category, triggers=self.onBlankDisplay)
text=translate('OpenLP.SlideController', 'Blank Screen'), icon=u':/slides/slide_blank.png',
checked=False, shortcuts=[QtCore.Qt.Key_Period], category=self.category, triggers=self.onBlankDisplay)
self.themeScreen = create_action(self, u'themeScreen',
text=translate('OpenLP.SlideController', 'Blank to Theme'),
icon=u':/slides/slide_theme.png', checked=False,
shortcuts=[QtGui.QKeySequence(u'T')],
category=self.category, triggers=self.onThemeDisplay)
text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=u':/slides/slide_theme.png',
checked=False, shortcuts=[QtGui.QKeySequence(u'T')], category=self.category,
triggers=self.onThemeDisplay)
self.desktopScreen = create_action(self, u'desktopScreen',
text=translate('OpenLP.SlideController', 'Show Desktop'),
icon=u':/slides/slide_desktop.png', checked=False,
shortcuts=[QtGui.QKeySequence(u'D')],
category=self.category, triggers=self.onHideDisplay)
text=translate('OpenLP.SlideController', 'Show Desktop'), icon=u':/slides/slide_desktop.png',
checked=False, shortcuts=[QtGui.QKeySequence(u'D')], category=self.category,
triggers=self.onHideDisplay)
self.hideMenu.setDefaultAction(self.blankScreen)
self.hideMenu.menu().addAction(self.blankScreen)
self.hideMenu.menu().addAction(self.themeScreen)
@ -221,23 +200,18 @@ class SlideController(DisplayController):
# Play Slides Menu
self.playSlidesMenu = QtGui.QToolButton(self.toolbar)
self.playSlidesMenu.setObjectName(u'playSlidesMenu')
self.playSlidesMenu.setText(translate('OpenLP.SlideController',
'Play Slides'))
self.playSlidesMenu.setText(translate('OpenLP.SlideController', 'Play Slides'))
self.playSlidesMenu.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
self.playSlidesMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Play Slides'),
self.toolbar))
self.playSlidesMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Play Slides'), self.toolbar))
self.toolbar.addToolbarWidget(self.playSlidesMenu)
self.playSlidesLoop = create_action(self, u'playSlidesLoop',
text=UiStrings().PlaySlidesInLoop,
icon=u':/media/media_time.png', checked=False, shortcuts=[],
category=self.category, triggers=self.onPlaySlidesLoop)
self.playSlidesOnce = create_action(self, u'playSlidesOnce',
text=UiStrings().PlaySlidesToEnd,
icon=u':/media/media_time.png', checked=False, shortcuts=[],
category=self.category, triggers=self.onPlaySlidesOnce)
if Settings().value(self.parent().generalSettingsSection +
u'/enable slide loop', QtCore.QVariant(True)).toBool():
self.playSlidesLoop = create_action(self, u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop,
icon=u':/media/media_time.png', checked=False, shortcuts=[], category=self.category,
triggers=self.onPlaySlidesLoop)
self.playSlidesOnce = create_action(self, u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd,
icon=u':/media/media_time.png', checked=False, shortcuts=[], category=self.category,
triggers=self.onPlaySlidesOnce)
if Settings().value(self.parent().generalSettingsSection + u'/enable slide loop',
QtCore.QVariant(True)).toBool():
self.playSlidesMenu.setDefaultAction(self.playSlidesLoop)
else:
self.playSlidesMenu.setDefaultAction(self.playSlidesOnce)
@ -248,23 +222,16 @@ class SlideController(DisplayController):
self.delaySpinBox.setObjectName(u'delaySpinBox')
self.delaySpinBox.setRange(1, 180)
self.delaySpinBox.setSuffix(UiStrings().Seconds)
self.delaySpinBox.setToolTip(translate('OpenLP.SlideController',
'Delay between slides in seconds.'))
self.delaySpinBox.setToolTip(translate('OpenLP.SlideController', 'Delay between slides in seconds.'))
self.toolbar.addToolbarWidget(self.delaySpinBox)
else:
self.toolbar.addToolbarAction(u'goLive',
icon=u':/general/general_live.png',
tooltip=translate('OpenLP.SlideController', 'Move to live.'),
triggers=self.onGoLive)
self.toolbar.addToolbarAction(u'addToService',
icon=u':/general/general_add.png',
tooltip=translate('OpenLP.SlideController', 'Add to Service.'),
triggers=self.onPreviewAddToService)
self.toolbar.addToolbarAction(u'goLive', icon=u':/general/general_live.png',
tooltip=translate('OpenLP.SlideController', 'Move to live.'), triggers=self.onGoLive)
self.toolbar.addToolbarAction(u'addToService', icon=u':/general/general_add.png',
tooltip=translate('OpenLP.SlideController', 'Add to Service.'), triggers=self.onPreviewAddToService)
self.toolbar.addSeparator()
self.toolbar.addToolbarAction(u'editSong',
icon=u':/general/general_edit.png',
tooltip=translate('OpenLP.SlideController',
'Edit and reload song preview.'), triggers=self.onEditSong)
self.toolbar.addToolbarAction(u'editSong', icon=u':/general/general_edit.png',
tooltip=translate('OpenLP.SlideController', 'Edit and reload song preview.'), triggers=self.onEditSong)
self.controllerLayout.addWidget(self.toolbar)
# Build the Media Toolbar
self.mediaController.register_controller(self)
@ -274,35 +241,27 @@ class SlideController(DisplayController):
self.songMenu.setObjectName(u'songMenu')
self.songMenu.setText(translate('OpenLP.SlideController', 'Go To'))
self.songMenu.setPopupMode(QtGui.QToolButton.InstantPopup)
self.songMenu.setMenu(QtGui.QMenu(
translate('OpenLP.SlideController', 'Go To'), self.toolbar))
self.songMenu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Go To'), self.toolbar))
self.toolbar.addToolbarWidget(self.songMenu)
# Stuff for items with background audio.
self.audioPauseItem = self.toolbar.addToolbarAction(
u'audioPauseItem', icon=u':/slides/media_playback_pause.png',
text=translate('OpenLP.SlideController', 'Pause Audio'),
self.audioPauseItem = self.toolbar.addToolbarAction(u'audioPauseItem',
icon=u':/slides/media_playback_pause.png', text=translate('OpenLP.SlideController', 'Pause Audio'),
tooltip=translate('OpenLP.SlideController', 'Pause audio.'),
checked=False, visible=False, category=self.category,
context=QtCore.Qt.WindowShortcut,
checked=False, visible=False, category=self.category, context=QtCore.Qt.WindowShortcut,
shortcuts=[], triggers=self.onAudioPauseClicked)
self.audioMenu = QtGui.QMenu(
translate('OpenLP.SlideController', 'Background Audio'), self.toolbar)
self.audioMenu = QtGui.QMenu(translate('OpenLP.SlideController', 'Background Audio'), self.toolbar)
self.audioPauseItem.setMenu(self.audioMenu)
self.audioPauseItem.setParent(self.toolbar)
self.toolbar.widgetForAction(self.audioPauseItem).setPopupMode(
QtGui.QToolButton.MenuButtonPopup)
self.nextTrackItem = create_action(self, u'nextTrackItem',
text=UiStrings().NextTrack,
icon=u':/slides/media_playback_next.png', tooltip=translate(
'OpenLP.SlideController', 'Go to next audio track.'),
category=self.category,
shortcuts=[], triggers=self.onNextTrackClicked)
self.nextTrackItem = create_action(self, u'nextTrackItem', text=UiStrings().NextTrack,
icon=u':/slides/media_playback_next.png',
tooltip=translate('OpenLP.SlideController', 'Go to next audio track.'),
category=self.category, shortcuts=[], triggers=self.onNextTrackClicked)
self.audioMenu.addAction(self.nextTrackItem)
self.trackMenu = self.audioMenu.addMenu(
translate('OpenLP.SlideController', 'Tracks'))
self.trackMenu = self.audioMenu.addMenu(translate('OpenLP.SlideController', 'Tracks'))
self.audioTimeLabel = QtGui.QLabel(u' 00:00 ', self.toolbar)
self.audioTimeLabel.setAlignment(
QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter)
self.audioTimeLabel.setAlignment(QtCore.Qt.AlignCenter|QtCore.Qt.AlignHCenter)
self.audioTimeLabel.setStyleSheet(
u'background-color: palette(background); '
u'border-top-color: palette(shadow); '
@ -319,8 +278,7 @@ class SlideController(DisplayController):
self.previewFrame = QtGui.QFrame(self.splitter)
self.previewFrame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio))
self.previewFrame.setMinimumHeight(100)
self.previewFrame.setSizePolicy(QtGui.QSizePolicy(
QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored,
self.previewFrame.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored,
QtGui.QSizePolicy.Label))
self.previewFrame.setFrameShape(QtGui.QFrame.StyledPanel)
self.previewFrame.setFrameShadow(QtGui.QFrame.Sunken)
@ -340,8 +298,7 @@ class SlideController(DisplayController):
self.previewDisplay.hide()
# Actual preview screen
self.slidePreview = QtGui.QLabel(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
QtGui.QSizePolicy.Fixed)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
@ -385,20 +342,16 @@ class SlideController(DisplayController):
self.shortcutTimer, QtCore.SIGNAL(u'timeout()'),
self._slideShortcutActivated)
# Signals
QtCore.QObject.connect(self.previewListWidget,
QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
QtCore.QObject.connect(self.previewListWidget, QtCore.SIGNAL(u'clicked(QModelIndex)'), self.onSlideSelected)
if self.isLive:
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_live_spin_delay'),
self.receiveSpinDelay)
QtCore.SIGNAL(u'slidecontroller_live_spin_delay'), self.receiveSpinDelay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_toggle_display'),
self.toggleDisplay)
QtCore.SIGNAL(u'slidecontroller_toggle_display'), self.toggleDisplay)
self.toolbar.setWidgetVisible(self.loopList, False)
else:
QtCore.QObject.connect(self.previewListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onGoLiveClick)
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onGoLiveClick)
self.toolbar.setWidgetVisible([u'editSong'], False)
if self.isLive:
self.setLiveHotkeys(self)
@ -407,29 +360,21 @@ class SlideController(DisplayController):
self.previewListWidget.addActions(
[self.nextItem, self.previousItem])
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix),
self.onStopLoop)
QtCore.SIGNAL(u'slidecontroller_%s_stop_loop' % self.typePrefix), self.onStopLoop)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_next' % self.typePrefix),
self.onSlideSelectedNext)
QtCore.SIGNAL(u'slidecontroller_%s_next' % self.typePrefix), self.onSlideSelectedNext)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.typePrefix),
self.onSlideSelectedPrevious)
QtCore.SIGNAL(u'slidecontroller_%s_previous' % self.typePrefix), self.onSlideSelectedPrevious)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.typePrefix),
self.onSlideChange)
QtCore.SIGNAL(u'slidecontroller_%s_change' % self.typePrefix), self.onSlideChange)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_set' % self.typePrefix),
self.onSlideSelectedIndex)
QtCore.SIGNAL(u'slidecontroller_%s_set' % self.typePrefix), self.onSlideSelectedIndex)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_blank' % self.typePrefix),
self.onSlideBlank)
QtCore.SIGNAL(u'slidecontroller_%s_blank' % self.typePrefix), self.onSlideBlank)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix),
self.onSlideUnblank)
QtCore.SIGNAL(u'slidecontroller_%s_unblank' % self.typePrefix), self.onSlideUnblank)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_update_slide_limits'),
self.updateSlideLimits)
QtCore.SIGNAL(u'slidecontroller_update_slide_limits'), self.updateSlideLimits)
def _slideShortcutActivated(self):
"""
@ -448,30 +393,22 @@ class SlideController(DisplayController):
except ImportError:
SONGS_PLUGIN_AVAILABLE = False
sender_name = unicode(self.sender().objectName())
verse_type = sender_name[15:] \
if sender_name[:15] == u'shortcutAction_' else u''
verse_type = sender_name[15:] if sender_name[:15] == u'shortcutAction_' else u''
if SONGS_PLUGIN_AVAILABLE:
if verse_type == u'V':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Verse]
self.current_shortcut = VerseType.TranslatedTags[VerseType.Verse]
elif verse_type == u'C':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Chorus]
self.current_shortcut = VerseType.TranslatedTags[VerseType.Chorus]
elif verse_type == u'B':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Bridge]
self.current_shortcut = VerseType.TranslatedTags[VerseType.Bridge]
elif verse_type == u'P':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.PreChorus]
self.current_shortcut = VerseType.TranslatedTags[VerseType.PreChorus]
elif verse_type == u'I':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Intro]
self.current_shortcut = VerseType.TranslatedTags[VerseType.Intro]
elif verse_type == u'E':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Ending]
self.current_shortcut = VerseType.TranslatedTags[VerseType.Ending]
elif verse_type == u'O':
self.current_shortcut = \
VerseType.TranslatedTags[VerseType.Other]
self.current_shortcut = VerseType.TranslatedTags[VerseType.Other]
elif verse_type.isnumeric():
self.current_shortcut += verse_type
self.current_shortcut = self.current_shortcut.upper()
@ -495,8 +432,7 @@ class SlideController(DisplayController):
if self.current_shortcut in keys:
# We had more than one match for example "V1" and "V10", but
# "V1" was the slide we wanted to go.
self.__checkUpdateSelectedSlide(
self.slideList[self.current_shortcut])
self.__checkUpdateSelectedSlide(self.slideList[self.current_shortcut])
self.slideSelected()
# Reset the shortcut.
self.current_shortcut = u''
@ -504,19 +440,16 @@ class SlideController(DisplayController):
def setLiveHotkeys(self, parent=None):
self.previousService = create_action(parent, u'previousService',
text=translate('OpenLP.SlideController', 'Previous Service'),
shortcuts=[QtCore.Qt.Key_Left],
context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.servicePrevious)
shortcuts=[QtCore.Qt.Key_Left], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.servicePrevious)
self.nextService = create_action(parent, 'nextService',
text=translate('OpenLP.SlideController', 'Next Service'),
shortcuts=[QtCore.Qt.Key_Right],
context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.serviceNext)
shortcuts=[QtCore.Qt.Key_Right], context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.serviceNext)
self.escapeItem = create_action(parent, 'escapeItem',
text=translate('OpenLP.SlideController', 'Escape Item'),
shortcuts=[QtCore.Qt.Key_Escape],
context=QtCore.Qt.WidgetWithChildrenShortcut,
category=self.category, triggers=self.liveEscape)
shortcuts=[QtCore.Qt.Key_Escape],context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category,
triggers=self.liveEscape)
def liveEscape(self):
self.display.setVisible(False)
@ -564,8 +497,7 @@ class SlideController(DisplayController):
Receiver.send_message('servicemanager_previous_item')
elif keypressCommand == ServiceItemAction.PreviousLastSlide:
# Go to the last slide of the previous item
Receiver.send_message('servicemanager_previous_item',
u'last slide')
Receiver.send_message('servicemanager_previous_item', u'last slide')
else:
Receiver.send_message('servicemanager_next_item')
self.keypress_loop = False
@ -582,20 +514,17 @@ class SlideController(DisplayController):
self.display.setup()
if self.isLive:
self.__addActionsToWidget(self.display)
self.display.audioPlayer.connectSlot(
QtCore.SIGNAL(u'tick(qint64)'), self.onAudioTimeRemaining)
self.display.audioPlayer.connectSlot(QtCore.SIGNAL(u'tick(qint64)'), self.onAudioTimeRemaining)
# The SlidePreview's ratio.
try:
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())
self.ratio = float(self.screens.current[u'size'].width()) / float(self.screens.current[u'size'].height())
except ZeroDivisionError:
self.ratio = 1
self.mediaController.setup_display(self.display, False)
self.previewSizeChanged()
self.previewDisplay.setup()
serviceItem = ServiceItem()
self.previewDisplay.webView.setHtml(build_html(serviceItem,
self.previewDisplay.screen, None, self.isLive,
self.previewDisplay.webView.setHtml(build_html(serviceItem, self.previewDisplay.screen, None, self.isLive,
plugins=PluginManager.get_instance().plugins))
self.mediaController.setup_display(self.previewDisplay,True)
if self.serviceItem:
@ -613,23 +542,18 @@ class SlideController(DisplayController):
splitters is moved or when the screen size is changed. Note, that this
method is (also) called frequently from the mainwindow *paintEvent*.
"""
if self.ratio < float(self.previewFrame.width()) / float(
self.previewFrame.height()):
if self.ratio < float(self.previewFrame.width()) / float(self.previewFrame.height()):
# We have to take the height as limit.
max_height = self.previewFrame.height() - self.grid.margin() * 2
self.slidePreview.setFixedSize(QtCore.QSize(
max_height * self.ratio, max_height))
self.previewDisplay.setFixedSize(QtCore.QSize(
max_height * self.ratio, max_height))
self.slidePreview.setFixedSize(QtCore.QSize(max_height * self.ratio, max_height))
self.previewDisplay.setFixedSize(QtCore.QSize(max_height * self.ratio, max_height))
self.previewDisplay.screen = {
u'size': self.previewDisplay.geometry()}
else:
# We have to take the width as limit.
max_width = self.previewFrame.width() - self.grid.margin() * 2
self.slidePreview.setFixedSize(QtCore.QSize(max_width,
max_width / self.ratio))
self.previewDisplay.setFixedSize(QtCore.QSize(max_width,
max_width / self.ratio))
self.slidePreview.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio))
self.previewDisplay.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio))
self.previewDisplay.screen = {
u'size': self.previewDisplay.geometry()}
# Make sure that the frames have the correct size.
@ -643,8 +567,7 @@ class SlideController(DisplayController):
# Sort out image heights.
width = self.parent().controlSplitter.sizes()[self.split]
for framenumber in range(len(self.serviceItem.get_frames())):
self.previewListWidget.setRowHeight(
framenumber, width / self.ratio)
self.previewListWidget.setRowHeight(framenumber, width / self.ratio)
def onSongBarHandler(self):
request = unicode(self.sender().text())
@ -662,8 +585,7 @@ class SlideController(DisplayController):
"""
Updates the Slide Limits variable from the settings.
"""
self.slide_limits = Settings().value(
self.parent().advancedSettingsSection + u'/slide limits',
self.slide_limits = Settings().value(self.parent().advancedSettingsSection + u'/slide limits',
QtCore.QVariant(SlideLimits.End)).toInt()[0]
def enableToolBar(self, item):
@ -692,12 +614,10 @@ class SlideController(DisplayController):
self.playSlidesLoop.setChecked(False)
self.playSlidesLoop.setIcon(build_icon(u':/media/media_time.png'))
if item.is_text():
if Settings().value(
self.parent().songsSettingsSection + u'/display songbar',
QtCore.QVariant(True)).toBool() and self.slideList:
if Settings().value(self.parent().songsSettingsSection + u'/display songbar',
QtCore.QVariant(True)).toBool() and self.slideList:
self.songMenu.show()
if item.is_capable(ItemCapabilities.CanLoop) and \
len(item.get_frames()) > 1:
if item.is_capable(ItemCapabilities.CanLoop) and len(item.get_frames()) > 1:
self.toolbar.setWidgetVisible(self.loopList)
if item.is_media():
self.mediabar.show()
@ -785,8 +705,7 @@ class SlideController(DisplayController):
old_item = self.serviceItem
# take a copy not a link to the servicemanager copy.
self.serviceItem = copy.copy(serviceItem)
if old_item and self.isLive and old_item.is_capable(
ItemCapabilities.ProvidesOwnDisplay):
if old_item and self.isLive and old_item.is_capable(ItemCapabilities.ProvidesOwnDisplay):
self._resetBlank()
Receiver.send_message(u'%s_start' % serviceItem.name.lower(),
[serviceItem, self.isLive, self.hideMode(), slideno])
@ -803,24 +722,16 @@ class SlideController(DisplayController):
# If the current item has background audio
if self.serviceItem.is_capable(ItemCapabilities.HasBackgroundAudio):
log.debug(u'Starting to play...')
self.display.audioPlayer.addToPlaylist(
self.serviceItem.background_audio)
self.display.audioPlayer.addToPlaylist(self.serviceItem.background_audio)
self.trackMenu.clear()
for counter in range(len(self.serviceItem.background_audio)):
action = self.trackMenu.addAction(os.path.basename(
self.serviceItem.background_audio[counter]))
action = self.trackMenu.addAction(os.path.basename(self.serviceItem.background_audio[counter]))
action.setData(counter)
QtCore.QObject.connect(action,
QtCore.SIGNAL(u'triggered(bool)'),
self.onTrackTriggered)
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered(bool)'), self.onTrackTriggered)
self.display.audioPlayer.repeat = Settings().value(
self.parent().generalSettingsSection + \
u'/audio repeat list',
QtCore.QVariant(False)).toBool()
self.parent().generalSettingsSection + u'/audio repeat list', QtCore.QVariant(False)).toBool()
if Settings().value(
self.parent().generalSettingsSection + \
u'/audio start paused',
QtCore.QVariant(True)).toBool():
self.parent().generalSettingsSection + u'/audio start paused', QtCore.QVariant(True)).toBool():
self.audioPauseItem.setChecked(True)
self.display.audioPlayer.pause()
else:
@ -829,8 +740,7 @@ class SlideController(DisplayController):
row = 0
text = []
for framenumber, frame in enumerate(self.serviceItem.get_frames()):
self.previewListWidget.setRowCount(
self.previewListWidget.rowCount() + 1)
self.previewListWidget.setRowCount(self.previewListWidget.rowCount() + 1)
item = QtGui.QTableWidgetItem()
slideHeight = 0
if self.serviceItem.is_text():
@ -853,8 +763,7 @@ class SlideController(DisplayController):
label = QtGui.QLabel()
label.setMargin(4)
if serviceItem.is_media():
label.setAlignment(QtCore.Qt.AlignHCenter |
QtCore.Qt.AlignVCenter)
label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
else:
label.setScaledContents(True)
if self.serviceItem.is_command():
@ -862,11 +771,9 @@ class SlideController(DisplayController):
else:
# If current slide set background to image
if framenumber == slideno:
self.serviceItem.bg_image_bytes = \
self.imageManager.getImageBytes(frame[u'path'],
self.serviceItem.bg_image_bytes = self.imageManager.getImageBytes(frame[u'path'],
ImageSource.ImagePlugin)
image = self.imageManager.getImage(frame[u'path'],
ImageSource.ImagePlugin)
image = self.imageManager.getImage(frame[u'path'], ImageSource.ImagePlugin)
label.setPixmap(QtGui.QPixmap.fromImage(image))
self.previewListWidget.setCellWidget(framenumber, 0, label)
slideHeight = width * (1 / self.ratio)
@ -898,12 +805,10 @@ class SlideController(DisplayController):
# However opening a new item of the same type will automatically
# close the previous, so make sure we don't close the new one.
if old_item.is_command() and not serviceItem.is_command():
Receiver.send_message(u'%s_stop' %
old_item.name.lower(), [old_item, self.isLive])
Receiver.send_message(u'%s_stop' % old_item.name.lower(), [old_item, self.isLive])
if old_item.is_media() and not serviceItem.is_media():
self.onMediaClose()
Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix,
[serviceItem])
Receiver.send_message(u'slidecontroller_%s_started' % self.typePrefix, [serviceItem])
def __updatePreviewSelection(self, slideno):
"""
@ -924,8 +829,7 @@ class SlideController(DisplayController):
if not self.serviceItem:
return
if self.serviceItem.is_command():
Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive, index])
Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive, index])
self.updatePreview()
else:
self.__checkUpdateSelectedSlide(index)
@ -936,11 +840,9 @@ class SlideController(DisplayController):
Allow the main display to blank the main display at startup time
"""
log.debug(u'mainDisplaySetBackground live = %s' % self.isLive)
display_type = Settings().value(
self.parent().generalSettingsSection + u'/screen blank',
display_type = Settings().value(self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'')).toString()
if self.screens.which_screen(self.window()) != \
self.screens.which_screen(self.display):
if self.screens.which_screen(self.window()) != self.screens.which_screen(self.display):
# Order done to handle initial conversion
if display_type == u'themed':
self.onThemeDisplay(True)
@ -977,12 +879,9 @@ class SlideController(DisplayController):
self.themeScreen.setChecked(False)
self.desktopScreen.setChecked(False)
if checked:
Settings().setValue(
self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'blanked'))
Settings().setValue(self.parent().generalSettingsSection + u'/screen blank', QtCore.QVariant(u'blanked'))
else:
Settings().remove(
self.parent().generalSettingsSection + u'/screen blank')
Settings().remove(self.parent().generalSettingsSection + u'/screen blank')
self.blankPlugin()
self.updatePreview()
@ -998,12 +897,9 @@ class SlideController(DisplayController):
self.themeScreen.setChecked(checked)
self.desktopScreen.setChecked(False)
if checked:
Settings().setValue(
self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'themed'))
Settings().setValue(self.parent().generalSettingsSection + u'/screen blank', QtCore.QVariant(u'themed'))
else:
Settings().remove(
self.parent().generalSettingsSection + u'/screen blank')
Settings().remove(self.parent().generalSettingsSection + u'/screen blank')
self.blankPlugin()
self.updatePreview()
@ -1019,12 +915,9 @@ class SlideController(DisplayController):
self.themeScreen.setChecked(False)
self.desktopScreen.setChecked(checked)
if checked:
Settings().setValue(
self.parent().generalSettingsSection + u'/screen blank',
QtCore.QVariant(u'hidden'))
Settings().setValue(self.parent().generalSettingsSection + u'/screen blank', QtCore.QVariant(u'hidden'))
else:
Settings().remove(
self.parent().generalSettingsSection + u'/screen blank')
Settings().remove(self.parent().generalSettingsSection + u'/screen blank')
self.hidePlugin(checked)
self.updatePreview()
@ -1038,14 +931,12 @@ class SlideController(DisplayController):
if hide_mode:
if not self.serviceItem.is_command():
Receiver.send_message(u'live_display_hide', hide_mode)
Receiver.send_message(u'%s_blank'
% self.serviceItem.name.lower(),
Receiver.send_message(u'%s_blank' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive, hide_mode])
else:
if not self.serviceItem.is_command():
Receiver.send_message(u'live_display_show')
Receiver.send_message(u'%s_unblank'
% self.serviceItem.name.lower(),
Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
else:
if hide_mode:
@ -1061,14 +952,12 @@ class SlideController(DisplayController):
if self.serviceItem is not None:
if hide:
Receiver.send_message(u'live_display_hide', HideMode.Screen)
Receiver.send_message(u'%s_hide'
% self.serviceItem.name.lower(),
Receiver.send_message(u'%s_hide' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
else:
if not self.serviceItem.is_command():
Receiver.send_message(u'live_display_show')
Receiver.send_message(u'%s_unblank'
% self.serviceItem.name.lower(),
Receiver.send_message(u'%s_unblank' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
else:
if hide:
@ -1092,8 +981,7 @@ class SlideController(DisplayController):
if -1 < row < self.previewListWidget.rowCount():
if self.serviceItem.is_command():
if self.isLive and not start:
Receiver.send_message(
u'%s_slide' % self.serviceItem.name.lower(),
Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive, row])
else:
to_display = self.serviceItem.get_rendered_frame(row)
@ -1109,8 +997,7 @@ class SlideController(DisplayController):
self.updatePreview()
self.selectedRow = row
self.__checkUpdateSelectedSlide(row)
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix,
row)
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row)
def onSlideChange(self, row):
"""
@ -1118,8 +1005,7 @@ class SlideController(DisplayController):
"""
self.__checkUpdateSelectedSlide(row)
self.updatePreview()
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix,
row)
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, row)
def updatePreview(self):
"""
@ -1128,7 +1014,7 @@ class SlideController(DisplayController):
"""
log.debug(u'updatePreview %s ' % self.screens.current[u'primary'])
if not self.screens.current[u'primary'] and self.serviceItem and \
self.serviceItem.is_capable(ItemCapabilities.ProvidesOwnDisplay):
self.serviceItem.is_capable(ItemCapabilities.ProvidesOwnDisplay):
# Grab now, but try again in a couple of seconds if slide change
# is slow
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
@ -1142,8 +1028,7 @@ class SlideController(DisplayController):
"""
winid = QtGui.QApplication.desktop().winId()
rect = self.screens.current[u'size']
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(),
rect.y(), rect.width(), rect.height())
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height())
self.slidePreview.setPixmap(winimg)
def onSlideSelectedNextAction(self, checked):
@ -1159,8 +1044,7 @@ class SlideController(DisplayController):
"""
if not self.serviceItem:
return
Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
Receiver.send_message(u'%s_next' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
if self.serviceItem.is_command() and self.isLive:
self.updatePreview()
else:
@ -1187,8 +1071,7 @@ class SlideController(DisplayController):
"""
if not self.serviceItem:
return
Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
Receiver.send_message(u'%s_previous' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
if self.serviceItem.is_command() and self.isLive:
self.updatePreview()
else:
@ -1197,8 +1080,7 @@ class SlideController(DisplayController):
if self.slide_limits == SlideLimits.Wrap:
row = self.previewListWidget.rowCount() - 1
elif self.isLive and self.slide_limits == SlideLimits.Next:
self.keypress_queue.append(
ServiceItemAction.PreviousLastSlide)
self.keypress_queue.append(ServiceItemAction.PreviousLastSlide)
self._process_queue()
return
else:
@ -1208,8 +1090,7 @@ class SlideController(DisplayController):
def __checkUpdateSelectedSlide(self, row):
if row + 1 < self.previewListWidget.rowCount():
self.previewListWidget.scrollToItem(
self.previewListWidget.item(row + 1, 0))
self.previewListWidget.scrollToItem(self.previewListWidget.item(row + 1, 0))
self.previewListWidget.selectRow(row)
def onToggleLoop(self):
@ -1226,8 +1107,7 @@ class SlideController(DisplayController):
Start the timer loop running and store the timer id
"""
if self.previewListWidget.rowCount() > 1:
self.timer_id = self.startTimer(
int(self.delaySpinBox.value()) * 1000)
self.timer_id = self.startTimer(int(self.delaySpinBox.value()) * 1000)
def onStopLoop(self):
"""
@ -1302,29 +1182,24 @@ class SlideController(DisplayController):
From the preview display requires the service Item to be editied
"""
self.songEdit = True
Receiver.send_message(u'%s_edit' % self.serviceItem.name.lower(),
u'P:%s' % self.serviceItem.edit_id)
Receiver.send_message(u'%s_edit' % self.serviceItem.name.lower(), u'P:%s' % self.serviceItem.edit_id)
def onPreviewAddToService(self):
"""
From the preview display request the Item to be added to service
"""
if self.serviceItem:
self.parent().serviceManagerContents.addServiceItem(
self.serviceItem)
self.parent().serviceManagerContents.addServiceItem(self.serviceItem)
def onGoLiveClick(self):
"""
triggered by clicking the Preview slide items
"""
if Settings().value(u'advanced/double click live',
QtCore.QVariant(False)).toBool():
if Settings().value(u'advanced/double click live', QtCore.QVariant(False)).toBool():
# Live and Preview have issues if we have video or presentations
# playing in both at the same time.
if self.serviceItem.is_command():
Receiver.send_message(u'%s_stop' %
self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
Receiver.send_message(u'%s_stop' % self.serviceItem.name.lower(), [self.serviceItem, self.isLive])
if self.serviceItem.is_media():
self.onMediaClose()
self.onGoLive()
@ -1336,11 +1211,9 @@ class SlideController(DisplayController):
row = self.previewListWidget.currentRow()
if -1 < row < self.previewListWidget.rowCount():
if self.serviceItem.from_service:
Receiver.send_message('servicemanager_preview_live',
u'%s:%s' % (self.serviceItem._uuid, row))
Receiver.send_message('servicemanager_preview_live', u'%s:%s' % (self.serviceItem._uuid, row))
else:
self.parent().liveController.addServiceManagerItem(
self.serviceItem, row)
self.parent().liveController.addServiceManagerItem(self.serviceItem, row)
def onMediaStart(self, item):
"""