log a warning, when a shortcut cannot be used

This commit is contained in:
Andreas Preikschat 2013-03-07 11:07:02 +01:00
parent 580baf76f4
commit b0f7e34271
1 changed files with 9 additions and 1 deletions

View File

@ -30,11 +30,16 @@
The :mod:`~openlp.core.utils.actions` module provides action list classes used The :mod:`~openlp.core.utils.actions` module provides action list classes used
by the shortcuts system. by the shortcuts system.
""" """
import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Settings from openlp.core.lib import Settings
log = logging.getLogger(__name__)
class ActionCategory(object): class ActionCategory(object):
""" """
The :class:`~openlp.core.utils.ActionCategory` class encapsulates a category for the The :class:`~openlp.core.utils.ActionCategory` class encapsulates a category for the
@ -312,6 +317,8 @@ class ActionList(object):
actions.append(action) actions.append(action)
ActionList.shortcut_map[shortcuts[1]] = actions ActionList.shortcut_map[shortcuts[1]] = actions
else: else:
log.warn(u'Shortcut %s is removed from %s because another action already uses this shortcut.' %
(shortcuts[1], action.objectName()))
shortcuts.remove(shortcuts[1]) shortcuts.remove(shortcuts[1])
# Check the primary shortcut. # Check the primary shortcut.
existing_actions = ActionList.shortcut_map.get(shortcuts[0], []) existing_actions = ActionList.shortcut_map.get(shortcuts[0], [])
@ -321,7 +328,8 @@ class ActionList(object):
actions.append(action) actions.append(action)
ActionList.shortcut_map[shortcuts[0]] = actions ActionList.shortcut_map[shortcuts[0]] = actions
else: else:
shortcuts.remove(shortcuts[0]) log.warn(u'Shortcut %s is removed from %s because another action already uses this shortcut.' %
(shortcuts[0], action.objectName()))
action.setShortcuts([QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) action.setShortcuts([QtGui.QKeySequence(shortcut) for shortcut in shortcuts])
def remove_action(self, action, category=None): def remove_action(self, action, category=None):