Author: johannes
Date: 2007-04-26 09:27:47 -0500 (Thu, 26 Apr 2007)
New Revision: 9534
Modified:
trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py
Log:
Use proper hotkeys
Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py 2007-04-26 14:13:11 UTC (rev 9533)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/menuitem.py 2007-04-26 14:27:47 UTC (rev 9534)
@@ -60,9 +60,19 @@
else:
self.__widget = self.parent.insertItem(label, self.__on_menu)
- if hotkey:
- self.parent.setAccel(qt.QKeySequence(hotkey), self.__widget)
+ if hotkey is not None:
+ parts = hotkey.split("+")
+ if len(parts[-1]) == 1:
+ base = ord(parts[-1])
+ else:
+ base = self.__keymap[parts[-1]]
+ mod = 0
+ if "SHIFT" in parts: mod = mod | qt.Qt.SHIFT
+ if "CTRL" in parts: mod = mod | qt.Qt.CTRL
+ if "ALT" in parts: mod = mod | qt.Qt.ALT
+ self.parent.setAccel(qt.QKeySequence(base | mod), self.__widget)
+
self.parent.setWhatsThis(self.__widget, description or '')
else:
self.__widget = None
@@ -115,6 +125,38 @@
self.parent.setItemEnabled(self.__widget, False)
+ # -------------------------------------------------------------------------
+ # The keymap for hotkeys
+ # -------------------------------------------------------------------------
+
+ __keymap = {
+ "F1" : qt.Qt.Key_F1,
+ "F2" : qt.Qt.Key_F2,
+ "F3" : qt.Qt.Key_F3,
+ "F4" : qt.Qt.Key_F4,
+ "F5" : qt.Qt.Key_F5,
+ "F6" : qt.Qt.Key_F6,
+ "F7" : qt.Qt.Key_F7,
+ "F8" : qt.Qt.Key_F8,
+ "F9" : qt.Qt.Key_F9,
+ "F10" : qt.Qt.Key_F10,
+ "F11" : qt.Qt.Key_F11,
+ "F12" : qt.Qt.Key_F12,
+ "INS" : qt.Qt.Key_Insert,
+ "DEL" : qt.Qt.Key_Delete,
+ "HOME" : qt.Qt.Key_Home,
+ "END" : qt.Qt.Key_End,
+ "PGUP" : qt.Qt.Key_Prior,
+ "PGDN" : qt.Qt.Key_Next,
+ "UP" : qt.Qt.Key_Up,
+ "DOWN" : qt.Qt.Key_Down,
+ "LEFT" : qt.Qt.Key_Left,
+ "RIGHT" : qt.Qt.Key_Right,
+ "TAB" : qt.Qt.Key_Tab,
+ "ENTER" : qt.Qt.Key_Return,
+ "BACK" : qt.Qt.Key_BackSpace}
+
+
# =============================================================================
# Configuration data
# =============================================================================
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.