~tomasgroth/openlp/portable-path

« back to all changes in this revision

Viewing changes to openlp/plugins/custom/lib/mediaitem.py

  • Committer: Tomas Groth
  • Date: 2019-04-30 19:02:42 UTC
  • mfrom: (2829.2.32 openlp)
  • Revision ID: tomasgroth@yahoo.dk-20190430190242-6zwjk8724tyux70m
trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
###############################################################################
5
5
# OpenLP - Open Source Lyrics Projection                                      #
6
6
# --------------------------------------------------------------------------- #
7
 
# Copyright (c) 2008-2018 OpenLP Developers                                   #
 
7
# Copyright (c) 2008-2019 OpenLP Developers                                   #
8
8
# --------------------------------------------------------------------------- #
9
9
# This program is free software; you can redistribute it and/or modify it     #
10
10
# under the terms of the GNU General Public License as published by the Free  #
23
23
import logging
24
24
 
25
25
from PyQt5 import QtCore, QtWidgets
26
 
from sqlalchemy.sql import or_, func, and_
 
26
from sqlalchemy.sql import and_, func, or_
27
27
 
28
28
from openlp.core.common.i18n import UiStrings, translate
29
29
from openlp.core.common.registry import Registry
30
30
from openlp.core.common.settings import Settings
31
 
from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext, PluginStatus, \
32
 
    check_item_selected
 
31
from openlp.core.lib import check_item_selected
 
32
from openlp.core.lib.mediamanageritem import MediaManagerItem
 
33
from openlp.core.lib.plugin import PluginStatus
 
34
from openlp.core.lib.serviceitem import ItemCapabilities
33
35
from openlp.core.lib.ui import create_widget_action
34
36
from openlp.core.ui.icons import UiIcons
35
37
from openlp.plugins.custom.forms.editcustomform import EditCustomForm
36
 
from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder
 
38
from openlp.plugins.custom.lib.customxmlhandler import CustomXMLBuilder, CustomXMLParser
37
39
from openlp.plugins.custom.lib.db import CustomSlide
38
40
 
 
41
 
39
42
log = logging.getLogger(__name__)
40
43
 
41
44
 
100
103
        self.add_custom_from_service = Settings().value(self.settings_section + '/add custom from service')
101
104
        self.is_search_as_you_type_enabled = Settings().value('advanced/search as type')
102
105
 
103
 
    def retranslateUi(self):
 
106
    def retranslate_ui(self):
104
107
        """
105
108
 
106
109
        """
216
219
        self.search_text_edit.setFocus()
217
220
        self.search_text_edit.selectAll()
218
221
 
219
 
    def generate_slide_data(self, service_item, item=None, xml_version=False,
220
 
                            remote=False, context=ServiceItemContext.Service):
 
222
    def generate_slide_data(self, service_item, *, item=None, **kwargs):
221
223
        """
222
224
        Generate the slide data. Needs to be implemented by the plugin.
223
225
        :param service_item: To be updated
224
226
        :param item: The custom database item to be used
225
 
        :param xml_version: No used
226
 
        :param remote: Is this triggered by the Preview Controller or Service Manager.
227
 
        :param context: Why is this item required to be build (Default Service).
 
227
        :param kwargs: Consume other unused args specified by the base implementation, but not use by this one.
228
228
        """
229
229
        item_id = self._get_id_of_item_to_generate(item, self.remote_custom)
230
230
        service_item.add_capability(ItemCapabilities.CanEdit)
348
348
        else:
349
349
            custom.credits = ''
350
350
        custom_xml = CustomXMLBuilder()
351
 
        for (idx, slide) in enumerate(item._raw_frames):
 
351
        for (idx, slide) in enumerate(item.slides):
352
352
            custom_xml.add_verse_to_lyrics('custom', str(idx + 1), slide['raw_slide'])
353
353
        custom.text = str(custom_xml.extract_xml(), 'utf-8')
354
354
        self.plugin.db_manager.save_object(custom)