forked from openlp/openlp
Move icon creation inside setup_item to avoid generating the icon multiple times
This commit is contained in:
parent
6688d45108
commit
85d2cfda6a
@ -43,10 +43,6 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
CLAPPERBOARD = ':/media/slidecontroller_multimedia.png'
|
||||
OPTICAL = ':/media/media_optical.png'
|
||||
VIDEO = ':/media/media_video.png'
|
||||
AUDIO = ':/media/media_audio.png'
|
||||
ERROR = ':/general/general_delete.png'
|
||||
|
||||
|
||||
class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
@ -68,6 +64,10 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
self.single_service_item = False
|
||||
self.has_search = True
|
||||
self.media_object = None
|
||||
self.optical_icon = build_icon(':/media/media_optical.png')
|
||||
self.video_icon = build_icon(':/media/media_video.png')
|
||||
self.audio_icon = build_icon(':/media/media_audio.png')
|
||||
self.error_icon = build_icon(':/general/general_delete.png')
|
||||
self.display_controller = DisplayController(self.parent())
|
||||
self.display_controller.controller_layout = QtGui.QVBoxLayout()
|
||||
self.media_controller.register_controller(self.display_controller)
|
||||
@ -129,7 +129,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
optical_button_text = translate('MediaPlugin.MediaItem', 'Load CD/DVD')
|
||||
optical_button_tooltip = translate('MediaPlugin.MediaItem',
|
||||
'Load CD/DVD - only supported when VLC is installed and enabled')
|
||||
self.load_optical = self.toolbar.add_toolbar_action('load_optical', icon=build_icon(OPTICAL),
|
||||
self.load_optical = self.toolbar.add_toolbar_action('load_optical', icon=self.optical_icon,
|
||||
text=optical_button_text,
|
||||
tooltip=optical_button_tooltip,
|
||||
triggers=self.on_load_optical)
|
||||
@ -351,14 +351,14 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
# Handle optical based item
|
||||
(file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track)
|
||||
item_name = QtGui.QListWidgetItem(clip_name)
|
||||
item_name.setIcon(build_icon(OPTICAL))
|
||||
item_name.setIcon(self.optical_icon)
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
item_name.setToolTip('%s@%s-%s' % (file_name, format_milliseconds(start), format_milliseconds(end)))
|
||||
elif not os.path.exists(track):
|
||||
# File doesn't exist, mark as error.
|
||||
file_name = os.path.split(str(track))[1]
|
||||
item_name = QtGui.QListWidgetItem(file_name)
|
||||
item_name.setIcon(build_icon(ERROR))
|
||||
item_name.setIcon(self.error_icon)
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
item_name.setToolTip(track)
|
||||
elif track_info.isFile():
|
||||
@ -366,9 +366,9 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||
file_name = os.path.split(str(track))[1]
|
||||
item_name = QtGui.QListWidgetItem(file_name)
|
||||
if '*.%s' % (file_name.split('.')[-1].lower()) in self.media_controller.audio_extensions_list:
|
||||
item_name.setIcon(build_icon(AUDIO))
|
||||
item_name.setIcon(self.audio_icon)
|
||||
else:
|
||||
item_name.setIcon(build_icon(VIDEO))
|
||||
item_name.setIcon(self.video_icon)
|
||||
item_name.setData(QtCore.Qt.UserRole, track)
|
||||
item_name.setToolTip(track)
|
||||
if item_name:
|
||||
|
Loading…
Reference in New Issue
Block a user