forked from openlp/openlp
correct parenting of shortcut actions in slide controller
This commit is contained in:
parent
b952b2cdbc
commit
970e6c5564
@ -98,10 +98,6 @@ class SlideController(Controller):
|
|||||||
self.songEditList = [
|
self.songEditList = [
|
||||||
u'editSong',
|
u'editSong',
|
||||||
]
|
]
|
||||||
self.nextPreviousList = [
|
|
||||||
u'previousItem',
|
|
||||||
u'nextItem'
|
|
||||||
]
|
|
||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
self.songEdit = False
|
self.songEdit = False
|
||||||
self.selectedRow = 0
|
self.selectedRow = 0
|
||||||
@ -172,22 +168,23 @@ class SlideController(Controller):
|
|||||||
sizeToolbarPolicy.setHeightForWidth(
|
sizeToolbarPolicy.setHeightForWidth(
|
||||||
self.toolbar.sizePolicy().hasHeightForWidth())
|
self.toolbar.sizePolicy().hasHeightForWidth())
|
||||||
self.toolbar.setSizePolicy(sizeToolbarPolicy)
|
self.toolbar.setSizePolicy(sizeToolbarPolicy)
|
||||||
self.previousItem = self.toolbar.addToolbarAction(
|
self.previousItem = create_action(self,
|
||||||
u'previousItem_' + self.typePrefix,
|
u'previousItem_' + self.typePrefix,
|
||||||
text=translate('OpenLP.SlideController', 'Previous Item'),
|
text=translate('OpenLP.SlideController', 'Previous Slide'),
|
||||||
icon=u':/slides/slide_previous.png',
|
icon=u':/slides/slide_previous.png',
|
||||||
tooltip=translate('OpenLP.SlideController', 'Move to previous.'),
|
tooltip=translate('OpenLP.SlideController', 'Move to previous.'),
|
||||||
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp],
|
shortcuts=[QtCore.Qt.Key_Up, QtCore.Qt.Key_PageUp],
|
||||||
context=QtCore.Qt.WidgetWithChildrenShortcut,
|
context=QtCore.Qt.WidgetWithChildrenShortcut,
|
||||||
category=self.category, triggers=self.onSlideSelectedPrevious)
|
category=self.category, triggers=self.onSlideSelectedPrevious)
|
||||||
self.nextItem = self.toolbar.addToolbarAction(
|
self.toolbar.addAction(self.previousItem)
|
||||||
u'nextItem_' + self.typePrefix,
|
self.nextItem = create_action(self, u'nextItem_' + self.typePrefix,
|
||||||
text=translate('OpenLP.SlideController', 'Next Item'),
|
text=translate('OpenLP.SlideController', 'Next Slide'),
|
||||||
icon=u':/slides/slide_next.png',
|
icon=u':/slides/slide_next.png',
|
||||||
tooltip=translate('OpenLP.SlideController', 'Move to next.'),
|
tooltip=translate('OpenLP.SlideController', 'Move to next.'),
|
||||||
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown],
|
shortcuts=[QtCore.Qt.Key_Down, QtCore.Qt.Key_PageDown],
|
||||||
context=QtCore.Qt.WidgetWithChildrenShortcut,
|
context=QtCore.Qt.WidgetWithChildrenShortcut,
|
||||||
category=self.category, triggers=self.onSlideSelectedNext)
|
category=self.category, triggers=self.onSlideSelectedNext)
|
||||||
|
self.toolbar.addAction(self.nextItem)
|
||||||
self.toolbar.addSeparator()
|
self.toolbar.addSeparator()
|
||||||
if self.isLive:
|
if self.isLive:
|
||||||
# Hide Menu
|
# Hide Menu
|
||||||
@ -198,17 +195,17 @@ class SlideController(Controller):
|
|||||||
self.hideMenu.setMenu(QtGui.QMenu(
|
self.hideMenu.setMenu(QtGui.QMenu(
|
||||||
translate('OpenLP.SlideController', 'Hide'), self.toolbar))
|
translate('OpenLP.SlideController', 'Hide'), self.toolbar))
|
||||||
self.toolbar.addToolbarWidget(self.hideMenu)
|
self.toolbar.addToolbarWidget(self.hideMenu)
|
||||||
self.blankScreen = create_action(self.hideMenu, u'blankScreen',
|
self.blankScreen = create_action(self, u'blankScreen',
|
||||||
text=translate('OpenLP.SlideController', 'Blank Screen'),
|
text=translate('OpenLP.SlideController', 'Blank Screen'),
|
||||||
icon=u':/slides/slide_blank.png', checked=False,
|
icon=u':/slides/slide_blank.png', checked=False,
|
||||||
shortcuts=[QtCore.Qt.Key_Period],
|
shortcuts=[QtCore.Qt.Key_Period],
|
||||||
category=self.category, triggers=self.onBlankDisplay)
|
category=self.category, triggers=self.onBlankDisplay)
|
||||||
self.themeScreen = create_action(self.hideMenu, u'themeScreen',
|
self.themeScreen = create_action(self, u'themeScreen',
|
||||||
text=translate('OpenLP.SlideController', 'Blank to Theme'),
|
text=translate('OpenLP.SlideController', 'Blank to Theme'),
|
||||||
icon=u':/slides/slide_theme.png', checked=False,
|
icon=u':/slides/slide_theme.png', checked=False,
|
||||||
shortcuts=[QtGui.QKeySequence(u'T')],
|
shortcuts=[QtGui.QKeySequence(u'T')],
|
||||||
category=self.category, triggers=self.onThemeDisplay)
|
category=self.category, triggers=self.onThemeDisplay)
|
||||||
self.desktopScreen = create_action(self.hideMenu, u'desktopScreen',
|
self.desktopScreen = create_action(self, u'desktopScreen',
|
||||||
text=translate('OpenLP.SlideController', 'Show Desktop'),
|
text=translate('OpenLP.SlideController', 'Show Desktop'),
|
||||||
icon=u':/slides/slide_desktop.png', checked=False,
|
icon=u':/slides/slide_desktop.png', checked=False,
|
||||||
shortcuts=[QtGui.QKeySequence(u'D')],
|
shortcuts=[QtGui.QKeySequence(u'D')],
|
||||||
@ -228,12 +225,12 @@ class SlideController(Controller):
|
|||||||
translate('OpenLP.SlideController', 'Play Slides'),
|
translate('OpenLP.SlideController', 'Play Slides'),
|
||||||
self.toolbar))
|
self.toolbar))
|
||||||
self.toolbar.addToolbarWidget(self.playSlidesMenu)
|
self.toolbar.addToolbarWidget(self.playSlidesMenu)
|
||||||
self.playSlidesLoop = create_action(self.playSlidesMenu,
|
self.playSlidesLoop = create_action(self, u'playSlidesLoop',
|
||||||
u'playSlidesLoop', text=UiStrings().PlaySlidesInLoop,
|
text=UiStrings().PlaySlidesInLoop,
|
||||||
icon=u':/media/media_time.png', checked=False, shortcuts=[],
|
icon=u':/media/media_time.png', checked=False, shortcuts=[],
|
||||||
category=self.category, triggers=self.onPlaySlidesLoop)
|
category=self.category, triggers=self.onPlaySlidesLoop)
|
||||||
self.playSlidesOnce = create_action(self.playSlidesMenu,
|
self.playSlidesOnce = create_action(self, u'playSlidesOnce',
|
||||||
u'playSlidesOnce', text=UiStrings().PlaySlidesToEnd,
|
text=UiStrings().PlaySlidesToEnd,
|
||||||
icon=u':/media/media_time.png', checked=False, shortcuts=[],
|
icon=u':/media/media_time.png', checked=False, shortcuts=[],
|
||||||
category=self.category, triggers=self.onPlaySlidesOnce)
|
category=self.category, triggers=self.onPlaySlidesOnce)
|
||||||
if QtCore.QSettings().value(self.parent().generalSettingsSection +
|
if QtCore.QSettings().value(self.parent().generalSettingsSection +
|
||||||
@ -667,12 +664,11 @@ class SlideController(Controller):
|
|||||||
len(item.get_frames()) > 1:
|
len(item.get_frames()) > 1:
|
||||||
self.toolbar.setWidgetVisible(self.loopList)
|
self.toolbar.setWidgetVisible(self.loopList)
|
||||||
if item.is_media():
|
if item.is_media():
|
||||||
self.mediabar.setVisible(True)
|
self.mediabar.show()
|
||||||
self.toolbar.setWidgetVisible(self.nextPreviousList, False)
|
self.previousItem.setVisible(not item.is_media())
|
||||||
else:
|
self.nextItem.setVisible(not item.is_media())
|
||||||
# Work-around for OS X, hide and then show the toolbar
|
# Work-around for OS X, hide and then show the toolbar
|
||||||
# See bug #791050
|
# See bug #791050
|
||||||
self.toolbar.setWidgetVisible(self.nextPreviousList)
|
|
||||||
self.toolbar.show()
|
self.toolbar.show()
|
||||||
|
|
||||||
def enablePreviewToolBar(self, item):
|
def enablePreviewToolBar(self, item):
|
||||||
@ -682,17 +678,16 @@ class SlideController(Controller):
|
|||||||
# Work-around for OS X, hide and then show the toolbar
|
# Work-around for OS X, hide and then show the toolbar
|
||||||
# See bug #791050
|
# See bug #791050
|
||||||
self.toolbar.hide()
|
self.toolbar.hide()
|
||||||
self.mediabar.setVisible(False)
|
self.mediabar.hide()
|
||||||
self.toolbar.setWidgetVisible(self.songEditList, False)
|
self.toolbar.setWidgetVisible(self.songEditList, False)
|
||||||
if item.is_capable(ItemCapabilities.CanEdit) and item.from_plugin:
|
if item.is_capable(ItemCapabilities.CanEdit) and item.from_plugin:
|
||||||
self.toolbar.setWidgetVisible(self.songEditList)
|
self.toolbar.setWidgetVisible(self.songEditList)
|
||||||
elif item.is_media():
|
elif item.is_media():
|
||||||
self.mediabar.setVisible(True)
|
self.mediabar.show()
|
||||||
self.toolbar.setWidgetVisible(self.nextPreviousList, False)
|
self.previousItem.setVisible(not item.is_media())
|
||||||
if not item.is_media():
|
self.nextItem.setVisible(not item.is_media())
|
||||||
# Work-around for OS X, hide and then show the toolbar
|
# Work-around for OS X, hide and then show the toolbar
|
||||||
# See bug #791050
|
# See bug #791050
|
||||||
self.toolbar.setWidgetVisible(self.nextPreviousList)
|
|
||||||
self.toolbar.show()
|
self.toolbar.show()
|
||||||
|
|
||||||
def refreshServiceItem(self):
|
def refreshServiceItem(self):
|
||||||
@ -824,7 +819,7 @@ class SlideController(Controller):
|
|||||||
self.slideList[unicode(row)] = row - 1
|
self.slideList[unicode(row)] = row - 1
|
||||||
text.append(unicode(row))
|
text.append(unicode(row))
|
||||||
self.previewListWidget.setItem(framenumber, 0, item)
|
self.previewListWidget.setItem(framenumber, 0, item)
|
||||||
if slideHeight != 0:
|
if slideHeight:
|
||||||
self.previewListWidget.setRowHeight(framenumber, slideHeight)
|
self.previewListWidget.setRowHeight(framenumber, slideHeight)
|
||||||
self.previewListWidget.setVerticalHeaderLabels(text)
|
self.previewListWidget.setVerticalHeaderLabels(text)
|
||||||
if self.serviceItem.is_text():
|
if self.serviceItem.is_text():
|
||||||
@ -1039,7 +1034,7 @@ class SlideController(Controller):
|
|||||||
"""
|
"""
|
||||||
row = self.previewListWidget.currentRow()
|
row = self.previewListWidget.currentRow()
|
||||||
self.selectedRow = 0
|
self.selectedRow = 0
|
||||||
if row > -1 and row < self.previewListWidget.rowCount():
|
if -1 < row < self.previewListWidget.rowCount():
|
||||||
if self.serviceItem.is_command():
|
if self.serviceItem.is_command():
|
||||||
if self.isLive and not start:
|
if self.isLive and not start:
|
||||||
Receiver.send_message(
|
Receiver.send_message(
|
||||||
@ -1175,7 +1170,7 @@ class SlideController(Controller):
|
|||||||
"""
|
"""
|
||||||
Stop the timer loop running
|
Stop the timer loop running
|
||||||
"""
|
"""
|
||||||
if self.timer_id != 0:
|
if self.timer_id:
|
||||||
self.killTimer(self.timer_id)
|
self.killTimer(self.timer_id)
|
||||||
self.timer_id = 0
|
self.timer_id = 0
|
||||||
|
|
||||||
@ -1276,7 +1271,7 @@ class SlideController(Controller):
|
|||||||
If preview copy slide item to live
|
If preview copy slide item to live
|
||||||
"""
|
"""
|
||||||
row = self.previewListWidget.currentRow()
|
row = self.previewListWidget.currentRow()
|
||||||
if row > -1 and row < self.previewListWidget.rowCount():
|
if -1 < row < self.previewListWidget.rowCount():
|
||||||
if self.serviceItem.from_service:
|
if self.serviceItem.from_service:
|
||||||
Receiver.send_message('servicemanager_preview_live',
|
Receiver.send_message('servicemanager_preview_live',
|
||||||
u'%s:%s' % (self.serviceItem._uuid, row))
|
u'%s:%s' % (self.serviceItem._uuid, row))
|
||||||
|
@ -281,7 +281,7 @@ class ActionList(object):
|
|||||||
return
|
return
|
||||||
self.categories[category].actions.remove(action)
|
self.categories[category].actions.remove(action)
|
||||||
# Remove empty categories.
|
# Remove empty categories.
|
||||||
if len(self.categories[category].actions) == 0:
|
if not self.categories[category].actions:
|
||||||
self.categories.remove(category)
|
self.categories.remove(category)
|
||||||
shortcuts = map(unicode,
|
shortcuts = map(unicode,
|
||||||
map(QtGui.QKeySequence.toString, action.shortcuts()))
|
map(QtGui.QKeySequence.toString, action.shortcuts()))
|
||||||
@ -354,19 +354,32 @@ class ActionList(object):
|
|||||||
``action``
|
``action``
|
||||||
The action which wants to use a particular shortcut.
|
The action which wants to use a particular shortcut.
|
||||||
"""
|
"""
|
||||||
|
local = action.shortcutContext() in \
|
||||||
|
[QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]
|
||||||
|
affected_actions = filter(lambda a: isinstance(a, QtGui.QAction),
|
||||||
|
self.getAllChildObjects(action.parent())) if local else []
|
||||||
for existing_action in existing_actions:
|
for existing_action in existing_actions:
|
||||||
if action is existing_action:
|
if action is existing_action:
|
||||||
continue
|
continue
|
||||||
if existing_action.parent() is action.parent():
|
if not local or existing_action in affected_actions:
|
||||||
return False
|
return False
|
||||||
if existing_action.shortcutContext() in [QtCore.Qt.WindowShortcut,
|
if existing_action.shortcutContext() \
|
||||||
QtCore.Qt.ApplicationShortcut]:
|
in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut]:
|
||||||
return False
|
return False
|
||||||
if action.shortcutContext() in [QtCore.Qt.WindowShortcut,
|
elif action in self.getAllChildObjects(existing_action.parent()):
|
||||||
QtCore.Qt.ApplicationShortcut]:
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def getAllChildObjects(self, qobject):
|
||||||
|
"""
|
||||||
|
Goes recursively through the children of ``qobject`` and returns a list
|
||||||
|
of all child objects.
|
||||||
|
"""
|
||||||
|
children = [child for child in qobject.children()]
|
||||||
|
for child in qobject.children():
|
||||||
|
children.append(self.getAllChildObjects(child))
|
||||||
|
return children
|
||||||
|
|
||||||
|
|
||||||
class CategoryOrder(object):
|
class CategoryOrder(object):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user