mirror of https://gitlab.com/openlp/openlp.git
adapted latest merge
This commit is contained in:
parent
9c39f57d5a
commit
dfc2eed1f4
|
@ -186,8 +186,9 @@ def context_menu_action(base, icon, text, slot, shortcuts=None):
|
|||
if icon:
|
||||
action.setIcon(build_icon(icon))
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
if shortcuts:
|
||||
if shortcuts is not None:
|
||||
action.setShortcuts(shortcuts)
|
||||
ActionList.add_action(action)
|
||||
return action
|
||||
|
||||
def context_menu(base, icon, text):
|
||||
|
@ -343,3 +344,4 @@ from dockwidget import OpenLPDockWidget
|
|||
from renderer import Renderer
|
||||
from rendermanager import RenderManager
|
||||
from mediamanageritem import MediaManagerItem
|
||||
from openlp.core.utils.actions import ActionList
|
||||
|
|
|
@ -202,7 +202,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
'Moves the selection down the window.'),
|
||||
self.onMoveSelectionDown, shortcuts=[QtCore.Qt.Key_Down])
|
||||
self.serviceManagerList.down.setObjectName(u'down')
|
||||
ActionList.add_action(self.serviceManagerList.down, UiStrings.Service)
|
||||
ActionList.add_action(self.serviceManagerList.down)
|
||||
self.serviceManagerList.down.setVisible(False)
|
||||
self.serviceManagerList.up = self.orderToolbar.addToolbarButton(
|
||||
translate('OpenLP.ServiceManager', 'Move up'),
|
||||
|
@ -211,7 +211,7 @@ class ServiceManager(QtGui.QWidget):
|
|||
'Moves the selection up the window.'),
|
||||
self.onMoveSelectionUp, shortcuts=[QtCore.Qt.Key_Up])
|
||||
self.serviceManagerList.up.setObjectName(u'up')
|
||||
ActionList.add_action(self.serviceManagerList.up, UiStrings.Service)
|
||||
ActionList.add_action(self.serviceManagerList.up)
|
||||
self.serviceManagerList.up.setVisible(False)
|
||||
self.orderToolbar.addSeparator()
|
||||
self.serviceManagerList.delete = self.orderToolbar.addToolbarButton(
|
||||
|
|
|
@ -134,6 +134,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||
"""
|
||||
self.treeWidget.clear()
|
||||
for category in ActionList.categories:
|
||||
# Check if the category is for internal use only.
|
||||
if category.name is None:
|
||||
continue
|
||||
item = QtGui.QTreeWidgetItem([category.name])
|
||||
for action in category.actions:
|
||||
actionText = REMOVE_AMPERSAND.sub('', unicode(action.text()))
|
||||
|
@ -218,7 +221,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||
self.column = column
|
||||
action = item.data(0, QtCore.Qt.UserRole).toPyObject()
|
||||
text = u''
|
||||
if action is None:# or column not in [1, 2]:
|
||||
if action is None:
|
||||
self.shortcutButton.setChecked(False)
|
||||
self.shortcutButton.setEnabled(False)
|
||||
else:
|
||||
|
@ -273,6 +276,9 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog):
|
|||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(u'shortcuts')
|
||||
for category in ActionList.categories:
|
||||
# Check if the category is for internal use only.
|
||||
if category.name is None:
|
||||
continue
|
||||
for action in category.actions:
|
||||
if self.changedActions .has_key(action):
|
||||
action.setShortcuts(self.changedActions[action])
|
||||
|
|
|
@ -189,8 +189,26 @@ class ActionList(object):
|
|||
categories = CategoryList()
|
||||
|
||||
@staticmethod
|
||||
def add_action(action, category, weight=None):
|
||||
category = unicode(category)
|
||||
def add_action(action, category=None, weight=None):
|
||||
"""
|
||||
Add an action to the list of actions.
|
||||
|
||||
``action``
|
||||
The action to add (QAction).
|
||||
|
||||
``category``
|
||||
The category this action belongs to. The category can be a QString
|
||||
or python unicode string. **Note**, if the category is ``None``, the
|
||||
category and its actions are being hidden in the shortcut dialog.
|
||||
However, if they are added, it is possible to avoid assigning
|
||||
shortcuts twice, which is important.
|
||||
|
||||
``weight``
|
||||
The weight specifies how important a category is. However, this only
|
||||
has an impact on the order the categories are displayed.
|
||||
"""
|
||||
if category is not None:
|
||||
category = unicode(category)
|
||||
if category not in ActionList.categories:
|
||||
ActionList.categories.append(category)
|
||||
action.defaultShortcuts = action.shortcuts()
|
||||
|
@ -198,6 +216,9 @@ class ActionList(object):
|
|||
ActionList.categories[category].actions.append(action)
|
||||
else:
|
||||
ActionList.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')
|
||||
|
@ -208,8 +229,9 @@ class ActionList(object):
|
|||
settings.endGroup()
|
||||
|
||||
@staticmethod
|
||||
def remove_action(action, category):
|
||||
category = unicode(category)
|
||||
def remove_action(action, category=None):
|
||||
if category is not None:
|
||||
category = unicode(category)
|
||||
if category not in ActionList.categories:
|
||||
return
|
||||
ActionList.categories[category].actions.remove(action)
|
||||
|
|
Loading…
Reference in New Issue