~openlp-core/openlp/trunk

« back to all changes in this revision

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

  • Committer: Tomas Groth
  • Author(s): tim.bentley at gmail
  • Date: 2018-08-04 21:11:51 UTC
  • mfrom: (2820.3.10 fonts)
  • Revision ID: tomasgroth@yahoo.dk-20180804211151-k681l5vd76zdq5gk
Replaced png icons with fonts
Added ability to have custom fonts

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
from openlp.core.common.registry import Registry
33
33
from openlp.core.common.settings import Settings
34
34
from openlp.core.lib import ItemCapabilities, MediaManagerItem, MediaType, ServiceItem, ServiceItemContext, \
35
 
    build_icon, check_item_selected
 
35
    check_item_selected
36
36
from openlp.core.lib.ui import create_widget_action, critical_error_message_box, create_horizontal_adjusting_combo_box
37
37
from openlp.core.ui import DisplayControllerType
 
38
from openlp.core.ui.icons import UiIcons
38
39
from openlp.core.ui.media import get_media_players, set_media_players, parse_optical_path, format_milliseconds
39
40
from openlp.core.ui.media.vlcplayer import get_vlc
40
41
 
45
46
log = logging.getLogger(__name__)
46
47
 
47
48
 
48
 
CLAPPERBOARD = ':/media/slidecontroller_multimedia.png'
 
49
CLAPPERBOARD = UiIcons().clapperboard
49
50
 
50
51
 
51
52
class MediaMediaItem(MediaManagerItem, RegistryProperties):
67
68
        self.icon_path = 'images/image'
68
69
        self.background = False
69
70
        self.automatic = ''
70
 
        self.optical_icon = build_icon(':/media/media_optical.png')
71
 
        self.video_icon = build_icon(':/media/media_video.png')
72
 
        self.audio_icon = build_icon(':/media/media_audio.png')
73
 
        self.error_icon = build_icon(':/general/general_delete.png')
 
71
        self.error_icon = UiIcons().delete
74
72
 
75
73
    def setup_item(self):
76
74
        """
137
135
            optical_button_text = translate('MediaPlugin.MediaItem', 'Load CD/DVD')
138
136
            optical_button_tooltip = translate('MediaPlugin.MediaItem',
139
137
                                               'CD/DVD playback is only supported if VLC is installed and enabled.')
140
 
        self.load_optical = self.toolbar.add_toolbar_action('load_optical', icon=self.optical_icon,
 
138
        self.load_optical = self.toolbar.add_toolbar_action('load_optical', icon=UiIcons().optical,
141
139
                                                            text=optical_button_text,
142
140
                                                            tooltip=optical_button_tooltip,
143
141
                                                            triggers=self.on_load_optical)
149
147
        Adds buttons to the end of the header bar.
150
148
        """
151
149
        # Replace backgrounds do not work at present so remove functionality.
152
 
        self.replace_action = self.toolbar.add_toolbar_action('replace_action', icon=':/slides/slide_theme.png',
 
150
        self.replace_action = self.toolbar.add_toolbar_action('replace_action', icon=UiIcons().theme,
153
151
                                                              triggers=self.on_replace_click)
154
152
        if 'webkit' not in get_media_players()[0]:
155
153
            self.replace_action.setDisabled(True)
156
154
            if hasattr(self, 'replace_action_context'):
157
155
                self.replace_action_context.setDisabled(True)
158
 
        self.reset_action = self.toolbar.add_toolbar_action('reset_action', icon=':/system/system_close.png',
 
156
        self.reset_action = self.toolbar.add_toolbar_action('reset_action', icon=UiIcons().close,
159
157
                                                            visible=False, triggers=self.on_reset_click)
160
158
        self.media_widget = QtWidgets.QWidget(self)
161
159
        self.media_widget.setObjectName('media_widget')
179
177
            self.list_view, text=UiStrings().ReplaceBG, icon=':/slides/slide_theme.png',
180
178
            triggers=self.on_replace_click)
181
179
        self.reset_action_context = create_widget_action(
182
 
            self.list_view, text=UiStrings().ReplaceLiveBG, icon=':/system/system_close.png',
 
180
            self.list_view, text=UiStrings().ReplaceLiveBG, icon=UiIcons().close,
183
181
            visible=False, triggers=self.on_reset_click)
184
182
 
185
183
    @staticmethod
205
203
 
206
204
    def video_background_replaced(self):
207
205
        """
208
 
        Triggered by main display on change of serviceitem.
 
206
        Triggered by main display on change of service item.
209
207
        """
210
208
        self.reset_action.setVisible(False)
211
209
        self.reset_action_context.setVisible(False)
369
367
                # Handle optical based item
370
368
                (file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track)
371
369
                item_name = QtWidgets.QListWidgetItem(clip_name)
372
 
                item_name.setIcon(self.optical_icon)
 
370
                item_name.setIcon(UiIcons().optical)
373
371
                item_name.setData(QtCore.Qt.UserRole, track)
374
372
                item_name.setToolTip('{name}@{start}-{end}'.format(name=file_name,
375
373
                                                                   start=format_milliseconds(start),
378
376
                # File doesn't exist, mark as error.
379
377
                file_name = os.path.split(str(track))[1]
380
378
                item_name = QtWidgets.QListWidgetItem(file_name)
381
 
                item_name.setIcon(self.error_icon)
 
379
                item_name.setIcon(UiIcons().error)
382
380
                item_name.setData(QtCore.Qt.UserRole, track)
383
381
                item_name.setToolTip(track)
384
382
            elif track_info.isFile():
387
385
                item_name = QtWidgets.QListWidgetItem(file_name)
388
386
                search = file_name.split('.')[-1].lower()
389
387
                if '*.{text}'.format(text=search) in self.media_controller.audio_extensions_list:
390
 
                    item_name.setIcon(self.audio_icon)
 
388
                    item_name.setIcon(UiIcons().audio)
391
389
                else:
392
 
                    item_name.setIcon(self.video_icon)
 
390
                    item_name.setIcon(UiIcons().video)
393
391
                item_name.setData(QtCore.Qt.UserRole, track)
394
392
                item_name.setToolTip(track)
395
393
            if item_name: