E5Gui/E5Action.py

branch
Py2 comp.
changeset 2525
8b507a9a2d40
parent 2302
f29e9405c851
child 3057
10516539f238
equal deleted inserted replaced
2523:139f182b72f6 2525:8b507a9a2d40
7 Module implementing an Action class extending QAction. 7 Module implementing an Action class extending QAction.
8 8
9 This extension is necessary in order to support alternate keyboard 9 This extension is necessary in order to support alternate keyboard
10 shortcuts. 10 shortcuts.
11 """ 11 """
12
13 from __future__ import unicode_literals # __IGNORE_WARNING__
12 14
13 from PyQt4.QtGui import QAction, QActionGroup, QIcon, QKeySequence, qApp 15 from PyQt4.QtGui import QAction, QActionGroup, QIcon, QKeySequence, qApp
14 16
15 17
16 class ArgumentsError(RuntimeError): 18 class ArgumentsError(RuntimeError):
79 raise ArgumentsError( 81 raise ArgumentsError(
80 "Too many arguments, max. {0:d} expected, got {1:d}".format( 82 "Too many arguments, max. {0:d} expected, got {1:d}".format(
81 7 + incr, len(args))) 83 7 + incr, len(args)))
82 84
83 parent = args[4 + incr] 85 parent = args[4 + incr]
84 super().__init__(parent) 86 super(E5Action, self).__init__(parent)
85 name = args[5 + incr] 87 name = args[5 + incr]
86 if name: 88 if name:
87 self.setObjectName(name) 89 self.setObjectName(name)
88 90
89 if args[1 + incr]: 91 if args[1 + incr]:
143 """ 145 """
144 Public slot to set the keyboard shortcut. 146 Public slot to set the keyboard shortcut.
145 147
146 @param shortcut the accelerator (QKeySequence) 148 @param shortcut the accelerator (QKeySequence)
147 """ 149 """
148 super().setShortcut(shortcut) 150 super(E5Action, self).setShortcut(shortcut)
149 self.__ammendToolTip() 151 self.__ammendToolTip()
150 152
151 def setShortcuts(self, shortcuts): 153 def setShortcuts(self, shortcuts):
152 """ 154 """
153 Public slot to set the list of keyboard shortcuts. 155 Public slot to set the list of keyboard shortcuts.
154 156
155 @param shortcuts list of keyboard accelerators (list of QKeySequence) 157 @param shortcuts list of keyboard accelerators (list of QKeySequence)
156 or key for a platform dependent list of accelerators 158 or key for a platform dependent list of accelerators
157 (QKeySequence.StandardKey) 159 (QKeySequence.StandardKey)
158 """ 160 """
159 super().setShortcuts(shortcuts) 161 super(E5Action, self).setShortcuts(shortcuts)
160 self.__ammendToolTip() 162 self.__ammendToolTip()
161 163
162 def setIconText(self, text): 164 def setIconText(self, text):
163 """ 165 """
164 Public slot to set the icon text of the action. 166 Public slot to set the icon text of the action.
165 167
166 @param text new icon text (string) 168 @param text new icon text (string)
167 """ 169 """
168 super().setIconText(text) 170 super(E5Action, self).setIconText(text)
169 self.__ammendToolTip() 171 self.__ammendToolTip()
170 172
171 def __ammendToolTip(self): 173 def __ammendToolTip(self):
172 """ 174 """
173 Private slot to add the primary keyboard accelerator to the tooltip. 175 Private slot to add the primary keyboard accelerator to the tooltip.

eric ide

mercurial