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'
|
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):
|
class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
||||||
@ -68,6 +64,10 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
|||||||
self.single_service_item = False
|
self.single_service_item = False
|
||||||
self.has_search = True
|
self.has_search = True
|
||||||
self.media_object = None
|
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 = DisplayController(self.parent())
|
||||||
self.display_controller.controller_layout = QtGui.QVBoxLayout()
|
self.display_controller.controller_layout = QtGui.QVBoxLayout()
|
||||||
self.media_controller.register_controller(self.display_controller)
|
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_text = translate('MediaPlugin.MediaItem', 'Load CD/DVD')
|
||||||
optical_button_tooltip = translate('MediaPlugin.MediaItem',
|
optical_button_tooltip = translate('MediaPlugin.MediaItem',
|
||||||
'Load CD/DVD - only supported when VLC is installed and enabled')
|
'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,
|
text=optical_button_text,
|
||||||
tooltip=optical_button_tooltip,
|
tooltip=optical_button_tooltip,
|
||||||
triggers=self.on_load_optical)
|
triggers=self.on_load_optical)
|
||||||
@ -351,14 +351,14 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
|||||||
# Handle optical based item
|
# Handle optical based item
|
||||||
(file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track)
|
(file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track)
|
||||||
item_name = QtGui.QListWidgetItem(clip_name)
|
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.setData(QtCore.Qt.UserRole, track)
|
||||||
item_name.setToolTip('%s@%s-%s' % (file_name, format_milliseconds(start), format_milliseconds(end)))
|
item_name.setToolTip('%s@%s-%s' % (file_name, format_milliseconds(start), format_milliseconds(end)))
|
||||||
elif not os.path.exists(track):
|
elif not os.path.exists(track):
|
||||||
# File doesn't exist, mark as error.
|
# File doesn't exist, mark as error.
|
||||||
file_name = os.path.split(str(track))[1]
|
file_name = os.path.split(str(track))[1]
|
||||||
item_name = QtGui.QListWidgetItem(file_name)
|
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.setData(QtCore.Qt.UserRole, track)
|
||||||
item_name.setToolTip(track)
|
item_name.setToolTip(track)
|
||||||
elif track_info.isFile():
|
elif track_info.isFile():
|
||||||
@ -366,9 +366,9 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties):
|
|||||||
file_name = os.path.split(str(track))[1]
|
file_name = os.path.split(str(track))[1]
|
||||||
item_name = QtGui.QListWidgetItem(file_name)
|
item_name = QtGui.QListWidgetItem(file_name)
|
||||||
if '*.%s' % (file_name.split('.')[-1].lower()) in self.media_controller.audio_extensions_list:
|
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:
|
else:
|
||||||
item_name.setIcon(build_icon(VIDEO))
|
item_name.setIcon(self.video_icon)
|
||||||
item_name.setData(QtCore.Qt.UserRole, track)
|
item_name.setData(QtCore.Qt.UserRole, track)
|
||||||
item_name.setToolTip(track)
|
item_name.setToolTip(track)
|
||||||
if item_name:
|
if item_name:
|
||||||
|
Loading…
Reference in New Issue
Block a user