forked from openlp/openlp
media code standards
This commit is contained in:
parent
582f1aa003
commit
7682698cf1
@ -70,10 +70,10 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.on_new_file_masks = u'%s;;%s (*.*) (*)' % (file_formats, UiStrings().AllFiles)
|
||||
self.addGroupAction.setText(UiStrings().AddGroup)
|
||||
self.addGroupAction.setToolTip(UiStrings().AddGroup)
|
||||
self.replaceAction.setText(UiStrings().ReplaceBG)
|
||||
self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG)
|
||||
self.resetAction.setText(UiStrings().ResetBG)
|
||||
self.resetAction.setToolTip(UiStrings().ResetLiveBG)
|
||||
self.replace_action.setText(UiStrings().ReplaceBG)
|
||||
self.replace_action.setToolTip(UiStrings().ReplaceLiveBG)
|
||||
self.reset_action.setText(UiStrings().ResetBG)
|
||||
self.reset_action.setToolTip(UiStrings().ResetLiveBG)
|
||||
|
||||
def required_icons(self):
|
||||
"""
|
||||
@ -155,7 +155,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.list_view.doubleClicked.connect(self.on_double_clicked)
|
||||
self.list_view.itemSelectionChanged.connect(self.on_selection_change)
|
||||
self.list_view.customContextMenuRequested.connect(self.context_menu)
|
||||
self.list_view.addAction(self.replaceAction)
|
||||
self.list_view.addAction(self.replace_action)
|
||||
|
||||
def add_custom_context_actions(self):
|
||||
"""
|
||||
@ -179,9 +179,9 @@ class ImageMediaItem(MediaManagerItem):
|
||||
"""
|
||||
Add custom buttons to the end of the toolbar
|
||||
"""
|
||||
self.replaceAction = self.toolbar.add_toolbar_action(u'replaceAction',
|
||||
self.replace_action = self.toolbar.add_toolbar_action(u'replace_action',
|
||||
icon=u':/slides/slide_blank.png', triggers=self.on_replace_click)
|
||||
self.resetAction = self.toolbar.add_toolbar_action(u'resetAction',
|
||||
self.reset_action = self.toolbar.add_toolbar_action(u'reset_action',
|
||||
icon=u':/system/system_close.png', visible=False, triggers=self.on_reset_click)
|
||||
|
||||
def recursively_delete_group(self, image_group):
|
||||
@ -641,14 +641,14 @@ class ImageMediaItem(MediaManagerItem):
|
||||
"""
|
||||
Called to reset the Live background with the image selected.
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
self.reset_action.setVisible(False)
|
||||
self.live_controller.display.reset_image()
|
||||
|
||||
def live_theme_changed(self):
|
||||
"""
|
||||
Triggered by the change of theme in the slide controller.
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
self.reset_action.setVisible(False)
|
||||
|
||||
def on_replace_click(self):
|
||||
"""
|
||||
@ -664,7 +664,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
filename = bitem.data(0, QtCore.Qt.UserRole).filename
|
||||
if os.path.exists(filename):
|
||||
if self.live_controller.display.direct_image(filename, background):
|
||||
self.resetAction.setVisible(True)
|
||||
self.reset_action.setVisible(True)
|
||||
else:
|
||||
critical_error_message_box(UiStrings().LiveBGError,
|
||||
translate('ImagePlugin.MediaItem', 'There was no display item to amend.'))
|
||||
|
@ -27,8 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`media` module provides the Media plugin which allows OpenLP to
|
||||
display videos. The media supported depends not only on the Python support
|
||||
but also extensively on the codecs installed on the underlying operating system
|
||||
being picked up and usable by Python.
|
||||
The :mod:`media` module provides the Media plugin which allows OpenLP to display videos. The media supported depends not
|
||||
only on the Python support but also extensively on the codecs installed on the underlying operating system being picked
|
||||
up and usable by Python.
|
||||
"""
|
||||
|
@ -44,10 +44,10 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
CLAPPERBOARD = u':/media/slidecontroller_multimedia.png'
|
||||
VIDEO = build_icon(QtGui.QImage(u':/media/media_video.png'))
|
||||
AUDIO = build_icon(QtGui.QImage(u':/media/media_audio.png'))
|
||||
DVDICON = build_icon(QtGui.QImage(u':/media/media_video.png'))
|
||||
ERROR = build_icon(QtGui.QImage(u':/general/general_delete.png'))
|
||||
VIDEO_ICON = build_icon(QtGui.QImage(u':/media/media_video.png'))
|
||||
AUDIO_ICON = build_icon(QtGui.QImage(u':/media/media_audio.png'))
|
||||
DVD_ICON = build_icon(QtGui.QImage(u':/media/media_video.png'))
|
||||
ERROR_ICON = build_icon(QtGui.QImage(u':/general/general_delete.png'))
|
||||
|
||||
|
||||
class MediaMediaItem(MediaManagerItem):
|
||||
@ -82,12 +82,12 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def retranslateUi(self):
|
||||
self.on_new_prompt = translate('MediaPlugin.MediaItem', 'Select Media')
|
||||
self.replaceAction.setText(UiStrings().ReplaceBG)
|
||||
self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG)
|
||||
self.resetAction.setText(UiStrings().ResetBG)
|
||||
self.resetAction.setToolTip(UiStrings().ResetLiveBG)
|
||||
self.replace_action.setText(UiStrings().ReplaceBG)
|
||||
self.replace_action.setToolTip(UiStrings().ReplaceLiveBG)
|
||||
self.reset_action.setText(UiStrings().ResetBG)
|
||||
self.reset_action.setToolTip(UiStrings().ResetLiveBG)
|
||||
self.automatic = UiStrings().Automatic
|
||||
self.displayTypeLabel.setText(translate('MediaPlugin.MediaItem', 'Use Player:'))
|
||||
self.display_type_label.setText(translate('MediaPlugin.MediaItem', 'Use Player:'))
|
||||
self.rebuild_players()
|
||||
|
||||
def required_icons(self):
|
||||
@ -101,27 +101,28 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def add_list_view_to_toolbar(self):
|
||||
MediaManagerItem.add_list_view_to_toolbar(self)
|
||||
self.list_view.addAction(self.replaceAction)
|
||||
self.list_view.addAction(self.replace_action)
|
||||
|
||||
def add_end_header_bar(self):
|
||||
# Replace backgrounds do not work at present so remove functionality.
|
||||
self.replaceAction = self.toolbar.add_toolbar_action(u'replaceAction', icon=u':/slides/slide_blank.png',
|
||||
self.replace_action = self.toolbar.add_toolbar_action(u'replace_action', icon=u':/slides/slide_blank.png',
|
||||
triggers=self.onReplaceClick)
|
||||
self.resetAction = self.toolbar.add_toolbar_action(u'resetAction', icon=u':/system/system_close.png',
|
||||
self.reset_action = self.toolbar.add_toolbar_action(u'reset_action', icon=u':/system/system_close.png',
|
||||
visible=False, triggers=self.onResetClick)
|
||||
self.mediaWidget = QtGui.QWidget(self)
|
||||
self.mediaWidget.setObjectName(u'mediaWidget')
|
||||
self.displayLayout = QtGui.QFormLayout(self.mediaWidget)
|
||||
self.displayLayout.setMargin(self.displayLayout.spacing())
|
||||
self.displayLayout.setObjectName(u'displayLayout')
|
||||
self.displayTypeLabel = QtGui.QLabel(self.mediaWidget)
|
||||
self.displayTypeLabel.setObjectName(u'displayTypeLabel')
|
||||
self.displayTypeComboBox = create_horizontal_adjusting_combo_box(self.mediaWidget, u'displayTypeComboBox')
|
||||
self.displayTypeLabel.setBuddy(self.displayTypeComboBox)
|
||||
self.displayLayout.addRow(self.displayTypeLabel, self.displayTypeComboBox)
|
||||
# Add the Media widget to the page layout
|
||||
self.page_layout.addWidget(self.mediaWidget)
|
||||
self.displayTypeComboBox.currentIndexChanged.connect(self.overridePlayerChanged)
|
||||
self.media_widget = QtGui.QWidget(self)
|
||||
self.media_widget.setObjectName(u'media_widget')
|
||||
self.display_layout = QtGui.QFormLayout(self.media_widget)
|
||||
self.display_layout.setMargin(self.display_layout.spacing())
|
||||
self.display_layout.setObjectName(u'display_layout')
|
||||
self.display_type_label = QtGui.QLabel(self.media_widget)
|
||||
self.display_type_label.setObjectName(u'display_type_label')
|
||||
self.display_type_combo_box = create_horizontal_adjusting_combo_box(
|
||||
self.media_widget, u'display_type_combo_box')
|
||||
self.display_type_label.setBuddy(self.display_type_combo_box)
|
||||
self.display_layout.addRow(self.display_type_label, self.display_type_combo_box)
|
||||
# Add the Media widget to the page layout.
|
||||
self.page_layout.addWidget(self.media_widget)
|
||||
self.display_type_combo_box.currentIndexChanged.connect(self.overridePlayerChanged)
|
||||
|
||||
def overridePlayerChanged(self, index):
|
||||
player = get_media_players()[0]
|
||||
@ -135,13 +136,13 @@ class MediaMediaItem(MediaManagerItem):
|
||||
Called to reset the Live background with the media selected,
|
||||
"""
|
||||
self.media_controller.media_reset(self.live_controller)
|
||||
self.resetAction.setVisible(False)
|
||||
self.reset_action.setVisible(False)
|
||||
|
||||
def video_background_replaced(self):
|
||||
"""
|
||||
Triggered by main display on change of serviceitem.
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
self.reset_action.setVisible(False)
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
@ -158,7 +159,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
(path, name) = os.path.split(filename)
|
||||
service_item.add_from_command(path, name,CLAPPERBOARD)
|
||||
if self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True):
|
||||
self.resetAction.setVisible(True)
|
||||
self.reset_action.setVisible(True)
|
||||
else:
|
||||
critical_error_message_box(UiStrings().LiveBGError,
|
||||
translate('MediaPlugin.MediaItem', 'There was no display item to amend.'))
|
||||
@ -167,7 +168,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
translate('MediaPlugin.MediaItem',
|
||||
'There was a problem replacing your background, the media file "%s" no longer exists.') % filename)
|
||||
|
||||
def generate_slide_data(self, service_item, item=None, xmlVersion=False, remote=False,
|
||||
def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False,
|
||||
context=ServiceItemContext.Live):
|
||||
"""
|
||||
Generate the slide data. Needs to be implemented by the plugin.
|
||||
@ -184,7 +185,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
translate('MediaPlugin.MediaItem', 'Missing Media File'),
|
||||
translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename)
|
||||
return False
|
||||
service_item.title = self.displayTypeComboBox.currentText()
|
||||
service_item.title = self.display_type_combo_box.currentText()
|
||||
service_item.shortname = service_item.title
|
||||
(path, name) = os.path.split(filename)
|
||||
service_item.add_from_command(path, name, CLAPPERBOARD)
|
||||
@ -212,8 +213,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def rebuild_players(self):
|
||||
"""
|
||||
Rebuild the tab in the media manager when changes are made in
|
||||
the settings
|
||||
Rebuild the tab in the media manager when changes are made in the settings.
|
||||
"""
|
||||
self.populateDisplayTypes()
|
||||
self.on_new_file_masks = translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)') % (
|
||||
@ -225,29 +225,27 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def populateDisplayTypes(self):
|
||||
"""
|
||||
Load the combobox with the enabled media players,
|
||||
allowing user to select a specific player if settings allow
|
||||
Load the combobox with the enabled media players, allowing user to select a specific player if settings allow.
|
||||
"""
|
||||
# block signals to avoid unnecessary overridePlayerChanged Signals
|
||||
# while combo box creation
|
||||
self.displayTypeComboBox.blockSignals(True)
|
||||
self.displayTypeComboBox.clear()
|
||||
# block signals to avoid unnecessary overridePlayerChanged Signals while combo box creation
|
||||
self.display_type_combo_box.blockSignals(True)
|
||||
self.display_type_combo_box.clear()
|
||||
usedPlayers, overridePlayer = get_media_players()
|
||||
media_players = self.media_controller.media_players
|
||||
currentIndex = 0
|
||||
for player in usedPlayers:
|
||||
# load the drop down selection
|
||||
self.displayTypeComboBox.addItem(media_players[player].original_name)
|
||||
self.display_type_combo_box.addItem(media_players[player].original_name)
|
||||
if overridePlayer == player:
|
||||
currentIndex = len(self.displayTypeComboBox)
|
||||
if self.displayTypeComboBox.count() > 1:
|
||||
self.displayTypeComboBox.insertItem(0, self.automatic)
|
||||
self.displayTypeComboBox.setCurrentIndex(currentIndex)
|
||||
currentIndex = len(self.display_type_combo_box)
|
||||
if self.display_type_combo_box.count() > 1:
|
||||
self.display_type_combo_box.insertItem(0, self.automatic)
|
||||
self.display_type_combo_box.setCurrentIndex(currentIndex)
|
||||
if overridePlayer:
|
||||
self.mediaWidget.show()
|
||||
self.media_widget.show()
|
||||
else:
|
||||
self.mediaWidget.hide()
|
||||
self.displayTypeComboBox.blockSignals(False)
|
||||
self.media_widget.hide()
|
||||
self.display_type_combo_box.blockSignals(False)
|
||||
|
||||
def on_delete_click(self):
|
||||
"""
|
||||
@ -270,34 +268,34 @@ class MediaMediaItem(MediaManagerItem):
|
||||
if not os.path.exists(track):
|
||||
filename = os.path.split(unicode(track))[1]
|
||||
item_name = QtGui.QListWidgetItem(filename)
|
||||
item_name.setIcon(ERROR)
|
||||
item_name.setIcon(ERROR_ICON)
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
elif track_info.isFile():
|
||||
filename = os.path.split(unicode(track))[1]
|
||||
item_name = QtGui.QListWidgetItem(filename)
|
||||
if u'*.%s' % (filename.split(u'.')[-1].lower()) in self.media_controller.audio_extensions_list:
|
||||
item_name.setIcon(AUDIO)
|
||||
item_name.setIcon(AUDIO_ICON)
|
||||
else:
|
||||
item_name.setIcon(VIDEO)
|
||||
item_name.setIcon(VIDEO_ICON)
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
else:
|
||||
filename = os.path.split(unicode(track))[1]
|
||||
item_name = QtGui.QListWidgetItem(filename)
|
||||
item_name.setIcon(build_icon(DVDICON))
|
||||
item_name.setIcon(build_icon(DVD_ICON))
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
item_name.setToolTip(track)
|
||||
self.list_view.addItem(item_name)
|
||||
|
||||
def getList(self, type=MediaType.Audio):
|
||||
def get_list(self, type=MediaType.Audio):
|
||||
media = Settings().value(self.settings_section + u'/media files')
|
||||
media.sort(key=lambda filename: get_locale_key(os.path.split(unicode(filename))[1]))
|
||||
ext = []
|
||||
extension = []
|
||||
if type == MediaType.Audio:
|
||||
ext = self.media_controller.audio_extensions_list
|
||||
extension = self.media_controller.audio_extensions_list
|
||||
else:
|
||||
ext = self.media_controller.video_extensions_list
|
||||
ext = map(lambda x: x[1:], ext)
|
||||
media = filter(lambda x: os.path.splitext(x)[1] in ext, media)
|
||||
extension = self.media_controller.video_extensions_list
|
||||
extension = map(lambda x: x[1:], extension)
|
||||
media = filter(lambda x: os.path.splitext(x)[1] in extension, media)
|
||||
return media
|
||||
|
||||
def search(self, string, showError):
|
||||
|
@ -34,12 +34,14 @@ from PyQt4 import QtCore
|
||||
from openlp.core.lib import Plugin, Registry, StringContent, Settings, build_icon, translate
|
||||
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Some settings starting with "media" are in core, because they are needed for core functionality.
|
||||
__default_settings__ = {
|
||||
u'media/media auto start': QtCore.Qt.Unchecked,
|
||||
u'media/media files': []
|
||||
u'media/media auto start': QtCore.Qt.Unchecked,
|
||||
u'media/media files': []
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +96,7 @@ class MediaPlugin(Plugin):
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
Time to tidy up on exit
|
||||
Time to tidy up on exit.
|
||||
"""
|
||||
log.info(u'Media Finalising')
|
||||
self.media_controller.finalise()
|
||||
@ -102,19 +104,19 @@ class MediaPlugin(Plugin):
|
||||
|
||||
def get_display_css(self):
|
||||
"""
|
||||
Add css style sheets to htmlbuilder
|
||||
Add css style sheets to htmlbuilder.
|
||||
"""
|
||||
return self.media_controller.get_media_display_css()
|
||||
|
||||
def get_display_javascript(self):
|
||||
"""
|
||||
Add javascript functions to htmlbuilder
|
||||
Add javascript functions to htmlbuilder.
|
||||
"""
|
||||
return self.media_controller.get_media_display_javascript()
|
||||
|
||||
def get_display_html(self):
|
||||
"""
|
||||
Add html code to htmlbuilder
|
||||
Add html code to htmlbuilder.
|
||||
"""
|
||||
return self.media_controller.get_media_display_html()
|
||||
|
||||
|
@ -110,11 +110,11 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
self.display_layout.setObjectName(u'display_layout')
|
||||
self.display_type_label = QtGui.QLabel(self.presentation_widget)
|
||||
self.display_type_label.setObjectName(u'display_type_label')
|
||||
self.displayTypeComboBox = create_horizontal_adjusting_combo_box(self.presentation_widget,
|
||||
u'displayTypeComboBox')
|
||||
self.display_type_label.setBuddy(self.displayTypeComboBox)
|
||||
self.display_layout.addRow(self.display_type_label, self.displayTypeComboBox)
|
||||
# Add the Presentation widget to the page layout
|
||||
self.display_type_combo_box = create_horizontal_adjusting_combo_box(self.presentation_widget,
|
||||
u'display_type_combo_box')
|
||||
self.display_type_label.setBuddy(self.display_type_combo_box)
|
||||
self.display_layout.addRow(self.display_type_label, self.display_type_combo_box)
|
||||
# Add the Presentation widget to the page layout.
|
||||
self.page_layout.addWidget(self.presentation_widget)
|
||||
|
||||
def initialise(self):
|
||||
@ -131,14 +131,14 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
Load the combobox with the enabled presentation controllers, allowing user to select a specific app if settings
|
||||
allow.
|
||||
"""
|
||||
self.displayTypeComboBox.clear()
|
||||
self.display_type_combo_box.clear()
|
||||
for item in self.controllers:
|
||||
# load the drop down selection
|
||||
if self.controllers[item].enabled():
|
||||
self.displayTypeComboBox.addItem(item)
|
||||
if self.displayTypeComboBox.count() > 1:
|
||||
self.displayTypeComboBox.insertItem(0, self.Automatic)
|
||||
self.displayTypeComboBox.setCurrentIndex(0)
|
||||
self.display_type_combo_box.addItem(item)
|
||||
if self.display_type_combo_box.count() > 1:
|
||||
self.display_type_combo_box.insertItem(0, self.Automatic)
|
||||
self.display_type_combo_box.setCurrentIndex(0)
|
||||
if Settings().value(self.settings_section + u'/override app') == QtCore.Qt.Checked:
|
||||
self.presentation_widget.show()
|
||||
else:
|
||||
@ -244,8 +244,8 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
items = self.list_view.selectedItems()
|
||||
if len(items) > 1:
|
||||
return False
|
||||
service_item.title = self.displayTypeComboBox.currentText()
|
||||
service_item.shortname = self.displayTypeComboBox.currentText()
|
||||
service_item.title = self.display_type_combo_box.currentText()
|
||||
service_item.shortname = self.display_type_combo_box.currentText()
|
||||
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
|
||||
service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay)
|
||||
shortname = service_item.shortname
|
||||
|
@ -320,7 +320,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
for plugin in self.plugin_manager.plugins:
|
||||
if plugin.name == u'media' and plugin.status == PluginStatus.Active:
|
||||
self.from_media_button.setVisible(True)
|
||||
self.media_form.populateFiles(plugin.media_item.getList(MediaType.Audio))
|
||||
self.media_form.populateFiles(plugin.media_item.get_list(MediaType.Audio))
|
||||
break
|
||||
|
||||
def new_song(self):
|
||||
|
Loading…
Reference in New Issue
Block a user