Save any service text item as a custom slide

This commit is contained in:
Jonathan Corwin 2012-12-23 00:00:24 +00:00
parent 9f5c5f7133
commit 0092fc6960
2 changed files with 30 additions and 3 deletions

View File

@ -40,7 +40,7 @@ log = logging.getLogger(__name__)
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \ from openlp.core.lib import OpenLPToolbar, ServiceItem, Receiver, build_icon, ItemCapabilities, SettingsManager, \
translate, str_to_bool, check_directory_exists translate, str_to_bool, check_directory_exists, PluginStatus
from openlp.core.lib.theme import ThemeLevel from openlp.core.lib.theme import ThemeLevel
from openlp.core.lib.settings import Settings from openlp.core.lib.settings import Settings
from openlp.core.lib.ui import UiStrings, critical_error_message_box, create_widget_action, find_and_set_in_combo_box from openlp.core.lib.ui import UiStrings, critical_error_message_box, create_widget_action, find_and_set_in_combo_box
@ -258,6 +258,8 @@ class ServiceManager(QtGui.QWidget):
icon=u':/media/auto-start_active.png', triggers=self.onAutoStart) icon=u':/media/auto-start_active.png', triggers=self.onAutoStart)
# Add already existing delete action to the menu. # Add already existing delete action to the menu.
self.menu.addAction(self.serviceManagerList.delete) self.menu.addAction(self.serviceManagerList.delete)
self.create_custom_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager',
'Create New &Custom Slide'), icon=u':/general/general_edit.png', triggers=self.create_custom)
self.menu.addSeparator() 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) icon=u':/general/general_preview.png', triggers=self.makePreview)
@ -759,6 +761,7 @@ class ServiceManager(QtGui.QWidget):
pos = item.parent().data(0, QtCore.Qt.UserRole).toInt()[0] pos = item.parent().data(0, QtCore.Qt.UserRole).toInt()[0]
serviceItem = self.serviceItems[pos - 1] serviceItem = self.serviceItems[pos - 1]
self.editAction.setVisible(False) self.editAction.setVisible(False)
self.create_custom_action.setVisible(False)
self.maintainAction.setVisible(False) self.maintainAction.setVisible(False)
self.notesAction.setVisible(False) self.notesAction.setVisible(False)
self.timeAction.setVisible(False) self.timeAction.setVisible(False)
@ -778,6 +781,11 @@ class ServiceManager(QtGui.QWidget):
if serviceItem[u'service_item'].will_auto_start: if serviceItem[u'service_item'].will_auto_start:
self.autoStartAction.setText(translate('OpenLP.ServiceManager', '&Auto Start - active')) self.autoStartAction.setText(translate('OpenLP.ServiceManager', '&Auto Start - active'))
self.autoStartAction.setIcon(self.active) self.autoStartAction.setIcon(self.active)
if serviceItem[u'service_item'].is_text():
for plugin in self.mainwindow.pluginManager.plugins:
if plugin.name == u'custom' and plugin.status == PluginStatus.Active:
self.create_custom_action.setVisible(True)
break
self.themeMenu.menuAction().setVisible(False) self.themeMenu.menuAction().setVisible(False)
# Set up the theme menu. # 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:
@ -1317,6 +1325,13 @@ class ServiceManager(QtGui.QWidget):
Receiver.send_message(u'%s_edit' % self.serviceItems[item][u'service_item'].name.lower(), 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) u'L:%s' % self.serviceItems[item][u'service_item'].edit_id)
def create_custom(self):
"""
Saves the current text item as a custom slide
"""
item = self.findServiceItem()[0]
Receiver.send_message(u'custom_create_from_service', self.serviceItems[item][u'service_item'])
def findServiceItem(self): def findServiceItem(self):
""" """
Finds the first selected ServiceItem in the list and returns the Finds the first selected ServiceItem in the list and returns the

View File

@ -87,6 +87,8 @@ class CustomMediaItem(MediaManagerItem):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_updated'), self.config_updated)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'custom_create_from_service'), self.create_from_service_item)
def config_updated(self): def config_updated(self):
self.add_custom_from_service = Settings().value( self.add_custom_from_service = Settings().value(
@ -275,9 +277,18 @@ class CustomMediaItem(MediaManagerItem):
custom = self.plugin.manager.get_object_filtered(CustomSlide, CustomSlide.title == item.title) custom = self.plugin.manager.get_object_filtered(CustomSlide, CustomSlide.title == item.title)
if custom: if custom:
return return
self.create_from_service_item(item)
def create_from_service_item(self, item):
"""
Create a custom slide from a text service item
"""
custom = CustomSlide() custom = CustomSlide()
custom.title = item.title custom.title = item.title
custom.theme_name = item.theme if item.theme:
custom.theme_name = item.theme
else:
custom.theme_name = u''
footer = u' '.join(item.raw_footer) footer = u' '.join(item.raw_footer)
if footer: if footer:
if footer.startswith(item.title): if footer.startswith(item.title):
@ -292,7 +303,8 @@ class CustomMediaItem(MediaManagerItem):
custom.text = unicode(custom_xml.extract_xml(), u'utf-8') custom.text = unicode(custom_xml.extract_xml(), u'utf-8')
self.plugin.manager.save_object(custom) self.plugin.manager.save_object(custom)
self.onSearchTextButtonClicked() self.onSearchTextButtonClicked()
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item._uuid, False)) if item.name.lower() == u'custom':
Receiver.send_message(u'service_item_update', u'%s:%s:%s' % (custom.id, item._uuid, False))
def onClearTextButtonClick(self): def onClearTextButtonClick(self):
""" """