This commit is contained in:
Raoul Snyman 2011-12-04 22:50:39 +02:00
commit 11f5dfcfcd
2 changed files with 63 additions and 14 deletions

View File

@ -206,15 +206,15 @@ class MediaController(object):
controller.mediabar = OpenLPToolbar(controller)
controller.mediabar.addToolbarButton(
u'media_playback_play', u':/slides/media_playback_start.png',
translate('OpenLP.SlideController', 'Start playing media'),
translate('OpenLP.SlideController', 'Start playing media.'),
controller.sendToPlugins)
controller.mediabar.addToolbarButton(
u'media_playback_pause', u':/slides/media_playback_pause.png',
translate('OpenLP.SlideController', 'Pause playing media'),
translate('OpenLP.SlideController', 'Pause playing media.'),
controller.sendToPlugins)
controller.mediabar.addToolbarButton(
u'media_playback_stop', u':/slides/media_playback_stop.png',
translate('OpenLP.SlideController', 'Stop playing media'),
translate('OpenLP.SlideController', 'Stop playing media.'),
controller.sendToPlugins)
# Build the seekSlider.
controller.seekSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
@ -223,7 +223,7 @@ class MediaController(object):
'OpenLP.SlideController', 'Video position.'))
controller.seekSlider.setGeometry(QtCore.QRect(90, 260, 221, 24))
controller.seekSlider.setObjectName(u'seek_slider')
controller.mediabar.addToolbarWidget(u'Seek Slider',
controller.mediabar.addToolbarWidget(u'Seek Slider',
controller.seekSlider)
# Build the volumeSlider.
controller.volumeSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
@ -236,7 +236,7 @@ class MediaController(object):
controller.volumeSlider.setValue(controller.media_info.volume)
controller.volumeSlider.setGeometry(QtCore.QRect(90, 160, 221, 24))
controller.volumeSlider.setObjectName(u'volume_slider')
controller.mediabar.addToolbarWidget(u'Audio Volume',
controller.mediabar.addToolbarWidget(u'Audio Volume',
controller.volumeSlider)
control_panel.addWidget(controller.mediabar)
controller.mediabar.setVisible(False)
@ -255,7 +255,7 @@ class MediaController(object):
def setup_display(self, display):
"""
After a new display is configured, all media related widget will be
After a new display is configured, all media related widget will be
created too
"""
# clean up possible running old media files
@ -276,13 +276,13 @@ class MediaController(object):
def set_controls_visible(self, controller, value):
# Generic controls
controller.mediabar.setVisible(value)
# Special controls: Here media type specific Controls will be enabled
# Special controls: Here media type specific Controls will be enabled
# (e.g. for DVD control, ...)
# TODO
def resize(self, controller, display, player):
"""
After Mainwindow changes or Splitter moved all related media widgets
After Mainwindow changes or Splitter moved all related media widgets
have to be resized
"""
player.resize(display)
@ -389,7 +389,7 @@ class MediaController(object):
def video_play(self, msg, status=True):
"""
Responds to the request to play a loaded video
``msg``
First element is the controller which should be used
"""

View File

@ -188,6 +188,7 @@ class ActionList(object):
actions or categories.
"""
instance = None
shortcut_map = {}
def __init__(self):
self.categories = CategoryList()
@ -226,17 +227,41 @@ class ActionList(object):
self.categories[category].actions.append(action)
else:
self.categories[category].actions.add(action, weight)
if category is None:
# Stop here, as this action is not configurable.
return
# Load the shortcut from the config.
settings = QtCore.QSettings()
settings.beginGroup(u'shortcuts')
shortcuts = settings.value(action.objectName(),
QtCore.QVariant(action.shortcuts())).toStringList()
settings.endGroup()
if not shortcuts:
action.setShortcuts([])
return
shortcuts = map(unicode, shortcuts)
# Check the alternate shortcut first, to avoid problems when the
# alternate shortcut becomes the primary shortcut after removing the
# (initial) primary shortcut due to confllicts.
if len(shortcuts) == 2:
existing_actions = ActionList.shortcut_map.get(shortcuts[1], [])
# Check for conflicts with other actions considering the shortcut
# context.
if self._shortcut_available(existing_actions, action):
actions = ActionList.shortcut_map.get(shortcuts[1], [])
actions.append(action)
ActionList.shortcut_map[shortcuts[1]] = actions
else:
shortcuts.remove(shortcuts[1])
# Check the primary shortcut.
existing_actions = ActionList.shortcut_map.get(shortcuts[0], [])
# Check for conflicts with other actions considering the shortcut
# context.
if self._shortcut_available(existing_actions, action):
actions = ActionList.shortcut_map.get(shortcuts[0], [])
actions.append(action)
ActionList.shortcut_map[shortcuts[0]] = actions
else:
shortcuts.remove(shortcuts[0])
action.setShortcuts(
[QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
settings.endGroup()
def remove_action(self, action, category=None):
"""
@ -244,7 +269,7 @@ class ActionList(object):
automatically removed.
``action``
The QAction object to be removed.
The ``QAction`` object to be removed.
``category``
The name (unicode string) of the category, which contains the
@ -279,6 +304,30 @@ class ActionList(object):
return
self.categories.add(name, weight)
def _shortcut_available(self, existing_actions, action):
"""
Checks if the given ``action`` may use its assigned shortcut(s) or not.
Returns ``True`` or ``False.
``existing_actions``
A list of actions which already use a particular shortcut.
``action``
The action which wants to use a particular shortcut.
"""
for existing_action in existing_actions:
if action is existing_action:
continue
if existing_action.parent() is action.parent():
return False
if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut,
QtCore.Qt.ApplicationShortcut]:
return False
if action.shortcutContext() in [QtCore.Qt.WindowShortcut,
QtCore.Qt.ApplicationShortcut]:
return False
return True
class CategoryOrder(object):
"""