forked from openlp/openlp
Save any service text item as a custom slide
This commit is contained in:
parent
9f5c5f7133
commit
0092fc6960
@ -40,7 +40,7 @@ log = logging.getLogger(__name__)
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
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.settings import Settings
|
||||
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)
|
||||
# Add already existing delete action to the menu.
|
||||
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.previewAction = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', 'Show &Preview'),
|
||||
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]
|
||||
serviceItem = self.serviceItems[pos - 1]
|
||||
self.editAction.setVisible(False)
|
||||
self.create_custom_action.setVisible(False)
|
||||
self.maintainAction.setVisible(False)
|
||||
self.notesAction.setVisible(False)
|
||||
self.timeAction.setVisible(False)
|
||||
@ -778,6 +781,11 @@ class ServiceManager(QtGui.QWidget):
|
||||
if serviceItem[u'service_item'].will_auto_start:
|
||||
self.autoStartAction.setText(translate('OpenLP.ServiceManager', '&Auto Start - 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)
|
||||
# Set up the theme menu.
|
||||
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(),
|
||||
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):
|
||||
"""
|
||||
Finds the first selected ServiceItem in the list and returns the
|
||||
|
@ -87,6 +87,8 @@ class CustomMediaItem(MediaManagerItem):
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
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'custom_create_from_service'), self.create_from_service_item)
|
||||
|
||||
def config_updated(self):
|
||||
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)
|
||||
if custom:
|
||||
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.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)
|
||||
if footer:
|
||||
if footer.startswith(item.title):
|
||||
@ -292,7 +303,8 @@ class CustomMediaItem(MediaManagerItem):
|
||||
custom.text = unicode(custom_xml.extract_xml(), u'utf-8')
|
||||
self.plugin.manager.save_object(custom)
|
||||
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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user