mediamanageritem

Provides the generic functions for interfacing plugins with the Media Manager.

class openlp.core.lib.mediamanageritem.MediaManagerItem(parent=None, plugin=None)[source]

Bases: PyQt5.QtWidgets.QWidget, openlp.core.common.registryproperties.RegistryProperties

MediaManagerItem is a helper widget for plugins.

None of the following need to be used, feel free to override them completely in your plugin’s implementation. Alternatively, call them from your plugin before or after you’ve done extra things that you need to.

Constructor Parameters

parent
The parent widget. Usually this will be the Media Manager itself. This needs to be a class descended from QWidget.
plugin
The plugin widget. Usually this will be the Plugin itself. This needs to be a class descended from Plugin.

Member Variables

When creating a descendant class from this class for your plugin, the following member variables should be set.

self.on_new_prompt

Defaults to ‘Select Image(s)’.
self.on_new_file_masks
Defaults to ‘Images (.jpg jpeg *.gif *.png *.bmp)’. This assumes that the new action is to load a file. If not, you need to override the OnNew method.
self.PreviewFunction
This must be a method which returns a QImage to represent the item (usually a preview). No scaling is required, that is performed automatically by OpenLP when necessary. If this method is not defined, a default will be used (treat the filename as an image).
add_custom_context_actions()[source]

Implement this method in your descendant media manager item to add any context menu items. This method is called automatically.

add_end_header_bar()[source]

Slot at end of toolbar for plugin to add widgets

add_list_view_to_toolbar()[source]

Creates the main widget for listing items the media item is tracking

add_middle_header_bar()[source]

Create buttons for the media item toolbar

add_search_to_toolbar()[source]

Creates a search field with button and related signal handling.

add_start_header_bar()[source]

Slot at start of toolbar for plugin to add widgets

add_to_service(item=None, replace=None, remote=False, position=-1)[source]

Add this item to the current service.

Parameters:
  • item – Item to be processed
  • replace – Replace the existing item
  • remote – Triggered from remote
  • position – Position to place item
add_to_service_remote(message)[source]

Remote Call wrapper

Parameters:message – The passed data item:Remote.
add_toolbar()[source]

A method to help developers easily add a toolbar to the media manager item.

build_service_item(item=None, xml_version=False, remote=False, context=1)[source]

Common method for generating a service item :param item: Service Item to be built. :param xml_version: version of XML (False) :param remote: Remote triggered (False) :param context: The context on which this is called

context_menu(point)[source]

Display a context menu

Parameters:point – The point the cursor was at
create_item_from_id(item_id)[source]

Create a media item from an item id.

Parameters:item_id – Id to make live
dnd_move_internal(target)[source]

Handle internal moving of media manager items

Parameters:target – The target of the DnD action
generate_slide_data(service_item, item=None, xml_version=False, remote=False, context=1)[source]

Generate the slide data. Needs to be implemented by the plugin. :param service_item: The service Item to be processed :param item: The database item to be used to build the service item :param xml_version: :param remote: Was this remote triggered (False) :param context: The service context

get_file_list()[source]

Return the current list of files

go_live(item_id=None, remote=False)[source]

Make the currently selected item go live.

Parameters:
  • item_id – item to make live
  • remote – From Remote
go_live_remote(message)[source]

Remote Call wrapper

Parameters:message – The passed data item_id:Remote.
initialise()[source]

Implement this method in your descendant media manager item to do any UI or other initialisation. This method is called automatically.

load_file(data)[source]

Turn file from Drag and Drop into an array so the Validate code can run it.

Parameters:data – A dictionary containing the list of files to be loaded and the target
load_list(load_list, target_group)[source]

Load a list. Needs to be implemented by the plugin.

Parameters:
  • load_list – List object to load
  • target_group – Group to load
on_add_click()[source]

Add a selected item to the current service

on_add_edit_click()[source]

Add a selected item to an existing item in the current service.

on_delete_click()[source]

Delete an item. Needs to be implemented by the plugin.

on_double_clicked()[source]

Allows the list click action to be determined dynamically

on_edit_click()[source]

Hook for plugins to define behaviour for editing items.

on_file_click()[source]

Add a file to the list widget to make it available for showing

on_focus()[source]

Run when a tab in the media manager gains focus. This gives the media item a chance to focus any elements it wants to.

on_live_click()[source]

Send an item live by building a service item then adding that service item to the live slide controller.

on_new_click()[source]

Hook for plugins to define behaviour for adding new items.

on_preview_click(keep_focus=False)[source]

Preview an item by building a service item then adding that service item to the preview slide controller.

Parameters:keep_focus – Do we keep focus (False)
on_selection_change()[source]

Allows the change of current item in the list to be actioned

required_icons()[source]

This method is called to define the icons for the plugin. It provides a default set and the plugin is able to override the if required.

retranslateUi()[source]

This method is called automatically to provide OpenLP with the opportunity to translate the MediaManagerItem to another language.

save_auto_select_id()[source]

Sorts out, what item to select after loading a list.

search(string, show_error=True)[source]

Performs a plugin specific search for items containing string

Parameters:
  • string – String to be displayed
  • show_error – Should the error be shown (True)
service_load(item)[source]

Method to add processing when a service has been loaded and individual service items need to be processed by the plugins.

Parameters:item – The item to be processed and returned.
setupUi()[source]

This method sets up the interface on the button. Plugin developers use this to add and create toolbars, and the rest of the interface of the media manager item.

setup_item()[source]

Override this for additional Plugin setup

validate_and_load(files, target_group=None)[source]

Process a list for files either from the File Dialog or from Drag and Drop

Parameters:
  • files – The files to be loaded.
  • target_group – The QTreeWidgetItem of the group that will be the parent of the added files