Index: /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIHotKeyEdit.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIHotKeyEdit.cpp	(revision 35579)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIHotKeyEdit.cpp	(revision 35580)
@@ -7,5 +7,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -18,9 +18,10 @@
  */
 
+/* Local includes */
 #include "QIHotKeyEdit.h"
 #include "VBoxDefs.h"
 #include "VBoxGlobal.h"
 
-/* Qt includes */
+/* Global includes */
 #include <QApplication>
 #include <QStyleOption>
@@ -29,14 +30,10 @@
 #ifdef Q_WS_WIN
 /* VBox/cdefs.h defines these: */
-#undef LOWORD
-#undef HIWORD
-#undef LOBYTE
-#undef HIBYTE
-#include <windows.h>
-#endif
-
-#if defined (Q_WS_PM)
-QMap<int, QString> QIHotKeyEdit::sKeyNames;
-#endif
+# undef LOWORD
+# undef HIWORD
+# undef LOBYTE
+# undef HIBYTE
+# include <windows.h>
+#endif /* Q_WS_WIN */
 
 #ifdef Q_WS_X11
@@ -46,23 +43,23 @@
  * conflicts with Qt. Therefore we use the following hack
  * to redefine those conflicting identifiers. */
-#define XK_XKB_KEYS
-#define XK_MISCELLANY
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/keysymdef.h>
-#ifdef KeyPress
+# define XK_XKB_KEYS
+# define XK_MISCELLANY
+# include <X11/Xlib.h>
+# include <X11/Xutil.h>
+# include <X11/keysymdef.h>
+# ifdef KeyPress
 const int XFocusOut = FocusOut;
 const int XFocusIn = FocusIn;
 const int XKeyPress = KeyPress;
 const int XKeyRelease = KeyRelease;
-#undef KeyRelease
-#undef KeyPress
-#undef FocusOut
-#undef FocusIn
-#endif
-#include "XKeyboard.h"
-QMap<QString, QString> QIHotKeyEdit::sKeyNames;
-#include <QX11Info>
-#endif
+#  undef KeyRelease
+#  undef KeyPress
+#  undef FocusOut
+#  undef FocusIn
+# endif /* KeyPress */
+# include "XKeyboard.h"
+QMap<QString, QString> QIHotKeyEdit::s_keyNames;
+# include <QX11Info>
+#endif /* Q_WS_X11 */
 
 #ifdef Q_WS_MAC
@@ -74,12 +71,10 @@
 
 
-#if defined (Q_WS_WIN32)
-/**
- *  Returns the correct modifier vkey for the *last* keyboard message,
- *  distinguishing between left and right keys. If both are pressed
- *  the left key wins. If the pressed key not a modifier, wParam is returned
- *  unchanged.
- */
-int qi_distinguish_modifier_vkey (WPARAM wParam)
+#ifdef Q_WS_WIN
+/* Returns the correct modifier vkey for the *last* keyboard message,
+ * distinguishing between left and right keys. If both are pressed
+ * the left key wins. If the pressed key not a modifier, wParam is returned
+ * unchanged. */
+int qi_distinguish_modifier_vkey(WPARAM wParam)
 {
     int keyval = wParam;
@@ -87,61 +82,53 @@
     {
         case VK_SHIFT:
-            if (::GetKeyState (VK_LSHIFT) & 0x8000) keyval = VK_LSHIFT;
-            else if (::GetKeyState (VK_RSHIFT) & 0x8000) keyval = VK_RSHIFT;
+            if (::GetKeyState(VK_LSHIFT) & 0x8000) keyval = VK_LSHIFT;
+            else if (::GetKeyState(VK_RSHIFT) & 0x8000) keyval = VK_RSHIFT;
             break;
         case VK_CONTROL:
-            if (::GetKeyState (VK_LCONTROL) & 0x8000) keyval = VK_LCONTROL;
-            else if (::GetKeyState (VK_RCONTROL) & 0x8000) keyval = VK_RCONTROL;
+            if (::GetKeyState(VK_LCONTROL) & 0x8000) keyval = VK_LCONTROL;
+            else if (::GetKeyState(VK_RCONTROL) & 0x8000) keyval = VK_RCONTROL;
             break;
         case VK_MENU:
-            if (::GetKeyState (VK_LMENU) & 0x8000) keyval = VK_LMENU;
-            else if (::GetKeyState (VK_RMENU) & 0x8000) keyval = VK_RMENU;
+            if (::GetKeyState(VK_LMENU) & 0x8000) keyval = VK_LMENU;
+            else if (::GetKeyState(VK_RMENU) & 0x8000) keyval = VK_RMENU;
             break;
     }
     return keyval;
 }
-#endif
-
-/** @class QIHotKeyEdit
- *
- *  The QIHotKeyEdit widget is a hot key editor.
- */
-
-const char *QIHotKeyEdit::kNoneSymbName = "None";
-
-QIHotKeyEdit::QIHotKeyEdit (QWidget *aParent) :
-    QLabel (aParent)
+#endif /* Q_WS_WIN */
+
+
+const char *QIHotKeyEdit::m_spNoneSymbName = "None";
+
+QIHotKeyEdit::QIHotKeyEdit(QWidget *pParent)
+    : QLabel(pParent)
 {
 #ifdef Q_WS_X11
-    /* Initialize the X keyboard subsystem */
-    initMappedX11Keyboard(QX11Info::display(),
-            vboxGlobal().settings().publicProperty ("GUI/RemapScancodes"));
-#endif
+    /* Initialize the X keyboard subsystem: */
+    initMappedX11Keyboard(QX11Info::display(), vboxGlobal().settings().publicProperty("GUI/RemapScancodes"));
+#endif /* Q_WS_X11 */
 
     clear();
 
-#if defined (Q_WS_WIN32)
-    /* Qt documentation hasn't mentioned this is
-     * windows-only flag, but looks like that is so,
-     * anyway it is required for winEvent() handler only */
-    setAttribute (Qt::WA_NativeWindow);
-#endif
-    setFrameStyle (QFrame::StyledPanel | Sunken);
-    setAlignment (Qt::AlignCenter);
-    setFocusPolicy (Qt::StrongFocus);
-    setAutoFillBackground (true);
+#ifdef Q_WS_WIN
+    /* Qt documentation hasn't mentioned this is windows-only flag,
+     * but looks like that is so, anyway it is required for winEvent() handler only: */
+    setAttribute(Qt::WA_NativeWindow);
+#endif /* Q_WS_WIN */
+    setFrameStyle(QFrame::StyledPanel | Sunken);
+    setAlignment(Qt::AlignCenter);
+    setFocusPolicy(Qt::StrongFocus);
+    setAutoFillBackground(true);
 
     QPalette p = palette();
-    p.setColor (QPalette::Active, QPalette::Foreground,
-                p.color (QPalette::Active, QPalette::Text));
-    p.setColor (QPalette::Active, QPalette::Background,
-                p.color (QPalette::Active, QPalette::Base));
-    setPalette (p);
+    p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::Text));
+    p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Base));
+    setPalette(p);
 
 #ifdef Q_WS_MAC
-    mDarwinKeyModifiers = GetCurrentEventKeyModifiers();
+    m_uDarwinKeyModifiers = GetCurrentEventKeyModifiers();
     UICocoaApplication::instance()->registerForNativeEvents(RT_BIT_32(10) | RT_BIT_32(11) | RT_BIT_32(12) /* NSKeyDown  | NSKeyUp | | NSFlagsChanged */, QIHotKeyEdit::darwinEventHandlerProc, this);
-    ::DarwinGrabKeyboard (false /* just modifiers */);
-#endif
+    ::DarwinGrabKeyboard(false /* just modifiers */);
+#endif /* Q_WS_MAC */
 }
 
@@ -153,7 +140,4 @@
 #endif
 }
-
-// Public members
-/////////////////////////////////////////////////////////////////////////////
 
 /**
@@ -165,8 +149,8 @@
  *      to the keycode.
  */
-void QIHotKeyEdit::setKey (int aKeyVal)
-{
-    mKeyVal = aKeyVal;
-    mSymbName = QIHotKeyEdit::keyName (aKeyVal);
+void QIHotKeyEdit::setKey(int iKeyVal)
+{
+    m_iKeyVal = iKeyVal;
+    m_strSymbName = QIHotKeyEdit::keyName(iKeyVal);
     updateText();
 }
@@ -183,164 +167,28 @@
  */
 
-/**
- *  Stolen from QLineEdit.
- */
 QSize QIHotKeyEdit::sizeHint() const
 {
     ensurePolished();
-    QFontMetrics fm (font());
-    int h = qMax (fm.lineSpacing(), 14) + 2;
-    int w = fm.width ('x') * 17; // "some"
+    QFontMetrics fm(font());
+    int h = qMax(fm.lineSpacing(), 14) + 2;
+    int w = fm.width('x') * 17;
     int m = frameWidth() * 2;
     QStyleOption option;
-    option.initFrom (this);
-    return (style()->sizeFromContents (QStyle::CT_LineEdit, &option,
-                                       QSize (w + m, h + m)
-                                       .expandedTo (QApplication::globalStrut()),
-                                       this));
-}
-
-/**
- *  Stolen from QLineEdit.
- */
+    option.initFrom(this);
+    return (style()->sizeFromContents(QStyle::CT_LineEdit, &option,
+                                      QSize(w + m, h + m)
+                                      .expandedTo(QApplication::globalStrut()),
+                                      this));
+}
+
 QSize QIHotKeyEdit::minimumSizeHint() const
 {
     ensurePolished();
     QFontMetrics fm = fontMetrics();
-    int h = fm.height() + qMax (2, fm.leading());
+    int h = fm.height() + qMax(2, fm.leading());
     int w = fm.maxWidth();
     int m = frameWidth() * 2;
-    return QSize (w + m, h + m);
-}
-
-#if defined (Q_WS_PM)
-/**
- *  Returns the virtual key extracted from the QMSG structure.
- *
- *  This function tries to detect some extra virtual keys definitions missing
- *  in PM (like Left Shift, Left Ctrl, Win keys). In all other cases it simply
- *  returns SHORT2FROMMP (aMsg->mp2).
- *
- *  @param aMsg  Pointer to the QMSG structure to extract the virtual key from.
- *  @return The extracted virtual key code or zero if there is no virtual key.
- */
-/* static */
-int QIHotKeyEdit::virtualKey (QMSG *aMsg)
-{
-    USHORT f = SHORT1FROMMP (aMsg->mp1);
-    CHAR scan = CHAR4FROMMP (aMsg->mp1);
-    USHORT ch = SHORT1FROMMP (aMsg->mp2);
-    int vkey = (unsigned int) SHORT2FROMMP (aMsg->mp2);
-
-    if (f & KC_VIRTUALKEY)
-    {
-        /* distinguish Left Shift from Right Shift) */
-        if (vkey == VK_SHIFT && scan == 0x2A)
-            vkey = VK_LSHIFT;
-        /* distinguish Left Ctrl from Right Ctrl */
-        else if (vkey == VK_CTRL && scan == 0x1D)
-            vkey = VK_LCTRL;
-        /* distinguish Ctrl+ScrLock from Ctrl+Break */
-        else if (vkey == VK_BREAK && scan == 0x46 && f & KC_CTRL)
-            vkey = VK_SCRLLOCK;
-    }
-    else if (!(f & KC_CHAR))
-    {
-        /* detect some special keys that have a pseudo char code in the high
-         * byte of ch (probably this is less device-dependent than
-         * scancode) */
-        switch (ch)
-        {
-            case 0xEC00: vkey = VK_LWIN; break;
-            case 0xED00: vkey = VK_RWIN; break;
-            case 0xEE00: vkey = VK_WINMENU; break;
-            case 0xF900: vkey = VK_FORWARD; break;
-            case 0xFA00: vkey = VK_BACKWARD; break;
-            default: vkey = 0;
-        }
-    }
-
-    return vkey;
-}
-#endif
-
-#if defined (Q_WS_PM)
-/**
- *  Updates the associative array containing the translations of PM virtual
- *  keys to human readable key names.
- */
-void QIHotKeyEdit::retranslateUi()
-{
-    /* Note: strings for the same key must match strings in retranslateUi()
-     * versions for all platforms, to keep translators happy. */
-
-    sKeyNames [VK_LSHIFT]        = tr ("Left Shift");
-    sKeyNames [VK_SHIFT]         = tr ("Right Shift");
-    sKeyNames [VK_LCTRL]         = tr ("Left Ctrl");
-    sKeyNames [VK_CTRL]          = tr ("Right Ctrl");
-    sKeyNames [VK_ALT]           = tr ("Left Alt");
-    sKeyNames [VK_ALTGRAF]       = tr ("Right Alt");
-    sKeyNames [VK_LWIN]          = tr ("Left WinKey");
-    sKeyNames [VK_RWIN]          = tr ("Right WinKey");
-    sKeyNames [VK_WINMENU]       = tr ("Menu key");
-    sKeyNames [VK_CAPSLOCK]      = tr ("Caps Lock");
-    sKeyNames [VK_SCRLLOCK]      = tr ("Scroll Lock");
-
-    sKeyNames [VK_PAUSE]         = tr ("Pause");
-    sKeyNames [VK_PRINTSCRN]     = tr ("Print Screen");
-
-    sKeyNames [VK_F1]            = tr ("F1");
-    sKeyNames [VK_F2]            = tr ("F2");
-    sKeyNames [VK_F3]            = tr ("F3");
-    sKeyNames [VK_F4]            = tr ("F4");
-    sKeyNames [VK_F5]            = tr ("F5");
-    sKeyNames [VK_F6]            = tr ("F6");
-    sKeyNames [VK_F7]            = tr ("F7");
-    sKeyNames [VK_F8]            = tr ("F8");
-    sKeyNames [VK_F9]            = tr ("F9");
-    sKeyNames [VK_F10]           = tr ("F10");
-    sKeyNames [VK_F11]           = tr ("F11");
-    sKeyNames [VK_F12]           = tr ("F12");
-    sKeyNames [VK_F13]           = tr ("F13");
-    sKeyNames [VK_F14]           = tr ("F14");
-    sKeyNames [VK_F15]           = tr ("F15");
-    sKeyNames [VK_F16]           = tr ("F16");
-    sKeyNames [VK_F17]           = tr ("F17");
-    sKeyNames [VK_F18]           = tr ("F18");
-    sKeyNames [VK_F19]           = tr ("F19");
-    sKeyNames [VK_F20]           = tr ("F20");
-    sKeyNames [VK_F21]           = tr ("F21");
-    sKeyNames [VK_F22]           = tr ("F22");
-    sKeyNames [VK_F23]           = tr ("F23");
-    sKeyNames [VK_F24]           = tr ("F24");
-
-    sKeyNames [VK_NUMLOCK]       = tr ("Num Lock");
-    sKeyNames [VK_FORWARD]       = tr ("Forward");
-    sKeyNames [VK_BACKWARD]      = tr ("Back");
-}
-#elif defined (Q_WS_X11)
-/**
- *  Updates the associative array containing the translations of X11 key strings to human
- *  readable key names.
- */
-void QIHotKeyEdit::retranslateUi()
-{
-    /* Note: strings for the same key must match strings in retranslateUi()
-     * versions for all platforms, to keep translators happy. */
-
-    sKeyNames ["Shift_L"]          = tr ("Left Shift");
-    sKeyNames ["Shift_R"]          = tr ("Right Shift");
-    sKeyNames ["Control_L"]        = tr ("Left Ctrl");
-    sKeyNames ["Control_R"]        = tr ("Right Ctrl");
-    sKeyNames ["Alt_L"]            = tr ("Left Alt");
-    sKeyNames ["Alt_R"]            = tr ("Right Alt");
-    sKeyNames ["Super_L"]          = tr ("Left WinKey");
-    sKeyNames ["Super_R"]          = tr ("Right WinKey");
-    sKeyNames ["Menu"]             = tr ("Menu key");
-    sKeyNames ["ISO_Level3_Shift"] = tr ("Alt Gr");
-    sKeyNames ["Caps_Lock"]        = tr ("Caps Lock");
-    sKeyNames ["Scroll_Lock"]      = tr ("Scroll Lock");
-}
-#endif
+    return QSize(w + m, h + m);
+}
 
 /**
@@ -353,15 +201,15 @@
  */
 /* static */
-QString QIHotKeyEdit::keyName (int aKeyVal)
-{
-    QString name;
-
-    if (!aKeyVal)
-    {
-        name = tr (kNoneSymbName);
+QString QIHotKeyEdit::keyName(int iKeyVal)
+{
+    QString strName;
+
+    if (!iKeyVal)
+    {
+        strName = tr(m_spNoneSymbName);
     }
     else
     {
-#if defined (Q_WS_WIN32)
+#if defined (Q_WS_WIN)
         /* Stupid MapVirtualKey doesn't distinguish between right and left
          * vkeys, even under XP, despite that it stated in msdn. Do it by
@@ -369,5 +217,5 @@
          * VK_DIVIDE & VK_PAUSE, this is also known bug. */
         int scan;
-        switch (aKeyVal)
+        switch (iKeyVal)
         {
             /* Processing special keys... */
@@ -380,40 +228,33 @@
             case VK_LWIN:
             case VK_RWIN:
-            case VK_NUMLOCK: scan = (::MapVirtualKey (aKeyVal, 0) | 256) << 16; break;
-            default: scan = ::MapVirtualKey (aKeyVal, 0) << 16;
-        }
-        TCHAR *str = new TCHAR [256];
-        if (::GetKeyNameText (scan, str, 256))
-        {
-            name = QString::fromUtf16 (str);
+            case VK_NUMLOCK: scan = (::MapVirtualKey(iKeyVal, 0) | 256) << 16; break;
+            default: scan = ::MapVirtualKey(iKeyVal, 0) << 16;
+        }
+        TCHAR *str = new TCHAR[256];
+        if (::GetKeyNameText(scan, str, 256))
+        {
+            strName = QString::fromUtf16(str);
         }
         else
         {
             AssertFailed();
-            name = QString (tr ("<key_%1>")).arg (aKeyVal);
+            strName = QString(tr("<key_%1>")).arg(iKeyVal);
         }
         delete[] str;
-#elif defined (Q_WS_PM)
-        name = sKeyNames [aKeyVal];
-        if (name.isNull())
+#elif defined (Q_WS_X11)
+        char *sn = ::XKeysymToString((KeySym)iKeyVal);
+        if (sn)
+        {
+            strName = s_keyNames[sn];
+            if (strName.isEmpty())
+                strName = sn;
+        }
+        else
         {
             AssertFailed();
-            name = QString (tr ("<key_%1>")).arg (aKeyVal);
-        }
-#elif defined (Q_WS_X11)
-        char *sn = ::XKeysymToString ((KeySym) aKeyVal);
-        if (sn)
-        {
-            name = sKeyNames [sn];
-            if (name.isEmpty())
-                name = sn;
-        }
-        else
-        {
-            AssertFailed();
-            name = QString (tr ("<key_%1>")).arg (aKeyVal);
+            strName = QString(tr("<key_%1>")).arg(iKeyVal);
         }
 #elif defined(Q_WS_MAC)
-        UInt32 modMask = DarwinKeyCodeToDarwinModifierMask (aKeyVal);
+        UInt32 modMask = DarwinKeyCodeToDarwinModifierMask(iKeyVal);
         switch (modMask)
         {
@@ -422,5 +263,5 @@
             case controlKey:
             case cmdKey:
-                name = tr ("Left ");
+                strName = tr("Left ");
                 break;
             case rightShiftKey:
@@ -428,8 +269,8 @@
             case rightControlKey:
             case kEventKeyModifierRightCmdKeyMask:
-                name = tr ("Right ");
+                strName = tr("Right ");
                 break;
             default:
-                AssertMsgFailedReturn (("modMask=%#x\n", modMask), QString());
+                AssertMsgFailedReturn(("modMask=%#x\n", modMask), QString());
         }
         switch (modMask)
@@ -437,64 +278,48 @@
             case shiftKey:
             case rightShiftKey:
-                name += QChar (kShiftUnicode);
+                strName += QChar(kShiftUnicode);
                 break;
             case optionKey:
             case rightOptionKey:
-                name += QChar (kOptionUnicode);
+                strName += QChar(kOptionUnicode);
                 break;
             case controlKey:
             case rightControlKey:
-                name += QChar (kControlUnicode);
+                strName += QChar(kControlUnicode);
                 break;
             case cmdKey:
             case kEventKeyModifierRightCmdKeyMask:
-                name += QChar (kCommandUnicode);
+                strName += QChar(kCommandUnicode);
                 break;
         }
 #else
         AssertFailed();
-        name = QString (tr ("<key_%1>")).arg (aKeyVal);
-#endif
-    }
-
-    return name;
+        strName = QString(tr("<key_%1>")).arg(iKeyVal);
+#endif
+    }
+
+    return strName;
 }
 
 /* static */
-bool QIHotKeyEdit::isValidKey (int aKeyVal)
+bool QIHotKeyEdit::isValidKey(int iKeyVal)
 {
     /* Empty value is correct: */
-    if (aKeyVal == 0)
+    if (iKeyVal == 0)
         return true;
-#if defined(Q_WS_WIN32)
-    return (
-        (aKeyVal >= VK_SHIFT && aKeyVal <= VK_CAPITAL) ||
-        aKeyVal == VK_PRINT ||
-        aKeyVal == VK_LWIN || aKeyVal == VK_RWIN ||
-        aKeyVal == VK_APPS ||
-        (aKeyVal >= VK_F1 && aKeyVal <= VK_F24) ||
-        aKeyVal == VK_NUMLOCK || aKeyVal == VK_SCROLL ||
-        (aKeyVal >= VK_LSHIFT && aKeyVal <= VK_RMENU));
-#elif defined(Q_WS_PM)
-    return (
-        (aKeyVal >= VK_SHIFT && aKeyVal <= VK_CAPSLOCK) ||
-        aKeyVal == VK_PRINTSCRN ||
-        (aKeyVal >= VK_F1 && aKeyVal <= VK_F24) ||
-        aKeyVal == VK_NUMLOCK || aKeyVal == VK_SCRLLOCK ||
-        (aKeyVal >= VK_LSHIFT && aKeyVal <= VK_BACKWARD));
+#if defined(Q_WS_WIN)
+    return ((iKeyVal >= VK_SHIFT && iKeyVal <= VK_CAPITAL) ||
+            iKeyVal == VK_PRINT ||
+            iKeyVal == VK_LWIN || iKeyVal == VK_RWIN ||
+            iKeyVal == VK_APPS ||
+            (iKeyVal >= VK_F1 && iKeyVal <= VK_F24) ||
+            iKeyVal == VK_NUMLOCK || iKeyVal == VK_SCROLL ||
+            (iKeyVal >= VK_LSHIFT && iKeyVal <= VK_RMENU));
 #elif defined(Q_WS_X11)
-    KeySym ks = (KeySym) aKeyVal;
-    return
-        (
-            ks != NoSymbol &&
-            ks != XK_Insert
-        ) && (
-            ks == XK_Scroll_Lock ||
-            IsModifierKey (ks) ||
-            IsFunctionKey (ks) ||
-            IsMiscFunctionKey (ks)
-        );
+    KeySym ks = (KeySym)iKeyVal;
+    return (ks != NoSymbol && ks != XK_Insert) &&
+           (ks == XK_Scroll_Lock || IsModifierKey(ks) || IsFunctionKey(ks) || IsMiscFunctionKey(ks));
 #elif defined(Q_WS_MAC)
-    UInt32 modMask = ::DarwinKeyCodeToDarwinModifierMask (aKeyVal);
+    UInt32 modMask = ::DarwinKeyCodeToDarwinModifierMask(iKeyVal);
     switch (modMask)
     {
@@ -512,70 +337,84 @@
     }
 #else
-    Q_UNUSED (aKeyVal);
+    Q_UNUSED(iKeyVal);
     return true;
 #endif
 }
 
-// Public slots
-/////////////////////////////////////////////////////////////////////////////
+#ifdef Q_WS_X11
+/* Updates the associative array containing the translations
+ * of X11 key strings to human readable key names. */
+void QIHotKeyEdit::retranslateUi()
+{
+    /* Note: strings for the same key must match strings in retranslateUi()
+     * versions for all platforms, to keep translators happy. */
+
+    s_keyNames["Shift_L"]          = tr("Left Shift");
+    s_keyNames["Shift_R"]          = tr("Right Shift");
+    s_keyNames["Control_L"]        = tr("Left Ctrl");
+    s_keyNames["Control_R"]        = tr("Right Ctrl");
+    s_keyNames["Alt_L"]            = tr("Left Alt");
+    s_keyNames["Alt_R"]            = tr("Right Alt");
+    s_keyNames["Super_L"]          = tr("Left WinKey");
+    s_keyNames["Super_R"]          = tr("Right WinKey");
+    s_keyNames["Menu"]             = tr("Menu key");
+    s_keyNames["ISO_Level3_Shift"] = tr("Alt Gr");
+    s_keyNames["Caps_Lock"]        = tr("Caps Lock");
+    s_keyNames["Scroll_Lock"]      = tr("Scroll Lock");
+}
+#endif /* Q_WS_X11 */
 
 void QIHotKeyEdit::clear()
 {
-    mKeyVal = 0;
-    mSymbName = tr (kNoneSymbName);
+    m_iKeyVal = 0;
+    m_strSymbName = tr(m_spNoneSymbName);
     updateText();
 }
 
-// Protected members
-/////////////////////////////////////////////////////////////////////////////
-
-// Protected events
-/////////////////////////////////////////////////////////////////////////////
-
-#if defined (Q_WS_WIN32)
-
-bool QIHotKeyEdit::winEvent (MSG *aMsg, long* /* aResult */)
-{
-    if (!(aMsg->message == WM_KEYDOWN || aMsg->message == WM_SYSKEYDOWN ||
-          aMsg->message == WM_KEYUP || aMsg->message == WM_SYSKEYUP ||
-          aMsg->message == WM_CHAR || aMsg->message == WM_SYSCHAR ||
-          aMsg->message == WM_DEADCHAR || aMsg->message == WM_SYSDEADCHAR ||
-          aMsg->message == WM_CONTEXTMENU))
+#if defined (Q_WS_WIN)
+
+bool QIHotKeyEdit::winEvent(MSG *pMsg, long* /* pResult */)
+{
+    if (!(pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN ||
+          pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYUP ||
+          pMsg->message == WM_CHAR || pMsg->message == WM_SYSCHAR ||
+          pMsg->message == WM_DEADCHAR || pMsg->message == WM_SYSDEADCHAR ||
+          pMsg->message == WM_CONTEXTMENU))
         return false;
 
-    /* ignore if not a valid hot key */
-    if (!isValidKey (aMsg->wParam))
+    /* Ignore if not a valid hot key: */
+    if (!isValidKey(pMsg->wParam))
         return false;
 
 #if 0
-    LogFlow (("%WM_%04X: vk=%04X rep=%05d scan=%02X ext=%01d"
-              "rzv=%01X ctx=%01d prev=%01d tran=%01d\n",
-              aMsg->message, aMsg->wParam,
-              (aMsg->lParam & 0xFFFF),
-              ((aMsg->lParam >> 16) & 0xFF),
-              ((aMsg->lParam >> 24) & 0x1),
-              ((aMsg->lParam >> 25) & 0xF),
-              ((aMsg->lParam >> 29) & 0x1),
-              ((aMsg->lParam >> 30) & 0x1),
-              ((aMsg->lParam >> 31) & 0x1)));
-#endif
-
-    if (aMsg->message == WM_KEYDOWN || aMsg->message == WM_SYSKEYDOWN)
-    {
-        /* determine platform-dependent key */
-        mKeyVal = qi_distinguish_modifier_vkey (aMsg->wParam);
-        /* determine symbolic name */
-        TCHAR *str = new TCHAR [256];
-        if (::GetKeyNameText (aMsg->lParam, str, 256))
-        {
-            mSymbName = QString::fromUtf16 (str);
+    LogFlow(("%WM_%04X: vk=%04X rep=%05d scan=%02X ext=%01d"
+             "rzv=%01X ctx=%01d prev=%01d tran=%01d\n",
+             pMsg->message, pMsg->wParam,
+             (pMsg->lParam & 0xFFFF),
+             ((pMsg->lParam >> 16) & 0xFF),
+             ((pMsg->lParam >> 24) & 0x1),
+             ((pMsg->lParam >> 25) & 0xF),
+             ((pMsg->lParam >> 29) & 0x1),
+             ((pMsg->lParam >> 30) & 0x1),
+             ((pMsg->lParam >> 31) & 0x1)));
+#endif
+
+    if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN)
+    {
+        /* Determine platform-dependent key: */
+        m_iKeyVal = qi_distinguish_modifier_vkey(pMsg->wParam);
+        /* Determine symbolic name: */
+        TCHAR *pStr = new TCHAR[256];
+        if (::GetKeyNameText(pMsg->lParam, pStr, 256))
+        {
+            m_strSymbName = QString::fromUtf16(pStr);
         }
         else
         {
             AssertFailed();
-            mSymbName = QString (tr ("<key_%1>")).arg (mKeyVal);
-        }
-        delete[] str;
-        /* update the display */
+            m_strSymbName = QString(tr("<key_%1>")).arg(m_iKeyVal);
+        }
+        delete[] pStr;
+        /* Update the display: */
         updateText();
     }
@@ -584,62 +423,34 @@
 }
 
-#elif defined (Q_WS_PM)
-
-bool QIHotKeyEdit::pmEvent (QMSG *aMsg)
-{
-    if (aMsg->msg != WM_CHAR)
-        return false;
-
-    USHORT f = SHORT1FROMMP (aMsg->mp1);
-
-    int vkey = QIHotKeyEdit::virtualKey (aMsg);
-
-    /* ignore if not a valid hot key */
-    if (!isValidKey (vkey))
-        return false;
-
-    if (!(f & KC_KEYUP))
-    {
-        /* determine platform-dependent key */
-        mKeyVal = vkey;
-        /* determine symbolic name */
-        mSymbName = QIHotKeyEdit::keyName (mKeyVal);
-        /* update the display */
-        updateText();
-    }
-
-    return true;
-}
-
 #elif defined (Q_WS_X11)
 
-bool QIHotKeyEdit::x11Event (XEvent *event)
-{
-    switch (event->type)
+bool QIHotKeyEdit::x11Event(XEvent *pEvent)
+{
+    switch (pEvent->type)
     {
         case XKeyPress:
         case XKeyRelease:
         {
-            XKeyEvent *ke = (XKeyEvent *) event;
-            KeySym ks = ::XKeycodeToKeysym (ke->display, ke->keycode, 0);
-            /* ignore if not a valid hot key */
-            if (!isValidKey ((int) ks))
+            XKeyEvent *pKeyEvent = (XKeyEvent*)pEvent;
+            KeySym ks = ::XKeycodeToKeysym(pKeyEvent->display, pKeyEvent->keycode, 0);
+            /* Ignore if not a valid hot key: */
+            if (!isValidKey((int)ks))
                 return false;
 
-            /* skip key releases */
-            if (event->type == XKeyRelease)
+            /* Skip key releases: */
+            if (pEvent->type == XKeyRelease)
                 return true;
 
-            /* determine platform-dependent key */
-            mKeyVal = (int) ks;
-            /* determine symbolic name */
-            mSymbName = QIHotKeyEdit::keyName (mKeyVal);
-            /* update the display */
+            /* Determine platform-dependent key: */
+            m_iKeyVal = (int)ks;
+            /* Determine symbolic name: */
+            m_strSymbName = QIHotKeyEdit::keyName(m_iKeyVal);
+            /* Update the display: */
             updateText();
 #if 0
-            LogFlow (("%s: state=%08X keycode=%08X keysym=%08X symb=%s\n",
-                      event->type == XKeyPress ? "XKeyPress" : "XKeyRelease",
-                      ke->state, ke->keycode, ks,
-                      symbname.latin1()));
+            LogFlow(("%s: state=%08X keycode=%08X keysym=%08X symb=%s\n",
+                     pEvent->type == XKeyPress ? "XKeyPress" : "XKeyRelease",
+                     pKeyEvent->state, pKeyEvent->keycode, ks,
+                     symbname.latin1()));
 #endif
             return true;
@@ -651,17 +462,17 @@
 
 #elif defined (Q_WS_MAC)
+
 /* static */
-bool QIHotKeyEdit::darwinEventHandlerProc (const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser)
-{
-    QIHotKeyEdit *edit = (QIHotKeyEdit *) pvUser;
+bool QIHotKeyEdit::darwinEventHandlerProc(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser)
+{
+    QIHotKeyEdit *edit = (QIHotKeyEdit*)pvUser;
     EventRef inEvent = (EventRef)pvCarbonEvent;
-    UInt32 EventClass = ::GetEventClass (inEvent);
+    UInt32 EventClass = ::GetEventClass(inEvent);
     if (EventClass == kEventClassKeyboard)
-        return edit->darwinKeyboardEvent (pvCocoaEvent, inEvent);
+        return edit->darwinKeyboardEvent(pvCocoaEvent, inEvent);
     return false;
 }
 
-
-bool QIHotKeyEdit::darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent)
+bool QIHotKeyEdit::darwinKeyboardEvent(const void *pvCocoaEvent, EventRef inEvent)
 {
 #if 0 /* for debugging */
@@ -669,9 +480,9 @@
 #endif
 
-    /* ignore key changes unless we're the focus widget */
+    /* Ignore key changes unless we're the focus widget: */
     if (!hasFocus())
         return false;
 
-    UInt32 eventKind = ::GetEventKind (inEvent);
+    UInt32 eventKind = ::GetEventKind(inEvent);
     switch (eventKind)
     {
@@ -682,23 +493,23 @@
         {
             UInt32 modifierMask = 0;
-            ::GetEventParameter (inEvent, kEventParamKeyModifiers, typeUInt32, NULL,
-                                 sizeof (modifierMask), NULL, &modifierMask);
-
-            modifierMask = ::DarwinAdjustModifierMask (modifierMask, pvCocoaEvent);
-            UInt32 changed = mDarwinKeyModifiers ^ modifierMask;
-            mDarwinKeyModifiers = modifierMask;
-
-            /* skip key releases */
+            ::GetEventParameter(inEvent, kEventParamKeyModifiers, typeUInt32, NULL,
+                                sizeof(modifierMask), NULL, &modifierMask);
+
+            modifierMask = ::DarwinAdjustModifierMask(modifierMask, pvCocoaEvent);
+            UInt32 changed = m_uDarwinKeyModifiers ^ modifierMask;
+            m_uDarwinKeyModifiers = modifierMask;
+
+            /* Skip key releases: */
             if (changed && (changed & modifierMask))
                 break;
 
-            /* convert to keycode and skip keycodes we don't care about. */
-            unsigned keyCode = ::DarwinModifierMaskToDarwinKeycode (changed);
-            if (!keyCode || keyCode == ~0U || !isValidKey (keyCode))
-                break;
-
-            /* update key current key. */
-            mKeyVal = keyCode;
-            mSymbName = QIHotKeyEdit::keyName (keyCode);
+            /* Convert to keycode and skip keycodes we don't care about. */
+            unsigned keyCode = ::DarwinModifierMaskToDarwinKeycode(changed);
+            if (!keyCode || keyCode == ~0U || !isValidKey(keyCode))
+                break;
+
+            /* Update key current key: */
+            m_iKeyVal = keyCode;
+            m_strSymbName = QIHotKeyEdit::keyName(keyCode);
             updateText();
             break; //return true;
@@ -713,48 +524,41 @@
 #endif
 
-void QIHotKeyEdit::focusInEvent (QFocusEvent *aEvent)
-{
-    QLabel::focusInEvent (aEvent);
+void QIHotKeyEdit::focusInEvent(QFocusEvent *pEvent)
+{
+    QLabel::focusInEvent(pEvent);
 
     QPalette p = palette();
-    p.setColor (QPalette::Active, QPalette::Foreground,
-                p.color (QPalette::Active, QPalette::HighlightedText));
-    p.setColor (QPalette::Active, QPalette::Background,
-                p.color (QPalette::Active, QPalette::Highlight));
-    setPalette (p);
-}
-
-void QIHotKeyEdit::focusOutEvent (QFocusEvent *aEvent)
-{
-    QLabel::focusOutEvent (aEvent);
+    p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::HighlightedText));
+    p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Highlight));
+    setPalette(p);
+}
+
+void QIHotKeyEdit::focusOutEvent(QFocusEvent *pEvent)
+{
+    QLabel::focusOutEvent(pEvent);
 
     QPalette p = palette();
-    p.setColor (QPalette::Active, QPalette::Foreground,
-                p.color (QPalette::Active, QPalette::Text));
-    p.setColor (QPalette::Active, QPalette::Background,
-                p.color (QPalette::Active, QPalette::Base));
-    setPalette (p);
-}
-
-void QIHotKeyEdit::paintEvent (QPaintEvent *aEvent)
+    p.setColor(QPalette::Active, QPalette::Foreground, p.color(QPalette::Active, QPalette::Text));
+    p.setColor(QPalette::Active, QPalette::Background, p.color(QPalette::Active, QPalette::Base));
+    setPalette(p);
+}
+
+void QIHotKeyEdit::paintEvent(QPaintEvent *pEvent)
 {
     if (hasFocus())
     {
-        QStylePainter painter (this);
+        QStylePainter painter(this);
         QStyleOptionFocusRect option;
-        option.initFrom (this);
-        option.backgroundColor = palette().color (QPalette::Background);
+        option.initFrom(this);
+        option.backgroundColor = palette().color(QPalette::Background);
         option.rect = contentsRect();
-        painter.drawPrimitive (QStyle::PE_FrameFocusRect, option);
-    }
-    QLabel::paintEvent (aEvent);
-}
-
-// Private members
-/////////////////////////////////////////////////////////////////////////////
+        painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
+    }
+    QLabel::paintEvent(pEvent);
+}
 
 void QIHotKeyEdit::updateText()
 {
-    setText (QString (" %1 ").arg (mSymbName));
-}
-
+    setText(QString(" %1 ").arg(m_strSymbName));
+}
+
Index: /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIHotKeyEdit.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIHotKeyEdit.h	(revision 35579)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIHotKeyEdit.h	(revision 35580)
@@ -6,5 +6,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -20,20 +20,10 @@
 #define ___QIHotKeyEdit_h___
 
+/* Global includes */
 #include <QLabel>
 
 #ifdef Q_WS_X11
 # include <QMap>
-#endif
-
-#ifdef Q_WS_PM
-/* Extra virtual keys returned by QIHotKeyEdit::virtualKey() */
-# define VK_LSHIFT   VK_USERFIRST + 0
-# define VK_LCTRL    VK_USERFIRST + 1
-# define VK_LWIN     VK_USERFIRST + 2
-# define VK_RWIN     VK_USERFIRST + 3
-# define VK_WINMENU  VK_USERFIRST + 4
-# define VK_FORWARD  VK_USERFIRST + 5
-# define VK_BACKWARD VK_USERFIRST + 6
-#endif
+#endif /* Q_WS_X11 */
 
 class QIHotKeyEdit : public QLabel
@@ -43,24 +33,20 @@
 public:
 
-    QIHotKeyEdit (QWidget *aParent);
+    QIHotKeyEdit(QWidget *pParent);
     virtual ~QIHotKeyEdit();
 
-    void setKey (int aKeyVal);
-    int key() const { return mKeyVal; }
+    void setKey(int iKeyVal);
+    int key() const { return m_iKeyVal; }
 
-    QString symbolicName() const { return mSymbName; }
+    QString symbolicName() const { return m_strSymbName; }
 
     QSize sizeHint() const;
     QSize minimumSizeHint() const;
 
-#ifdef Q_WS_PM
-    static int virtualKey (QMSG *aMsg);
-#endif
-
-#if defined (Q_WS_PM) || defined (Q_WS_X11)
+    static QString keyName(int iKeyVal);
+    static bool isValidKey(int iKeyVal);
+#ifdef Q_WS_X11
     static void retranslateUi();
-#endif
-    static QString keyName (int aKeyVal);
-    static bool isValidKey (int aKeyVal);
+#endif /* Q_WS_X11 */
 
 public slots:
@@ -71,18 +57,15 @@
 
 #if defined (Q_WS_WIN32)
-    bool winEvent (MSG *aMsg, long *aResult);
-#elif defined (Q_WS_PM)
-    bool pmEvent (QMSG *aMsg);
+    bool winEvent(MSG *pMsg, long *pResult);
 #elif defined (Q_WS_X11)
-    bool x11Event (XEvent *event);
+    bool x11Event(XEvent *pEvent);
 #elif defined (Q_WS_MAC)
-    static bool darwinEventHandlerProc (const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
-    bool darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent);
+    static bool darwinEventHandlerProc(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
+    bool darwinKeyboardEvent(const void *pvCocoaEvent, EventRef inEvent);
 #endif
 
-    void focusInEvent (QFocusEvent *);
-    void focusOutEvent (QFocusEvent *);
-
-    void paintEvent (QPaintEvent *);
+    void focusInEvent(QFocusEvent *pEvent);
+    void focusOutEvent(QFocusEvent *pEvent);
+    void paintEvent(QPaintEvent *pEvent);
 
 private:
@@ -90,20 +73,18 @@
     void updateText();
 
-    int mKeyVal;
-    QString mSymbName;
+    int m_iKeyVal;
+    QString m_strSymbName;
 
-#if defined (Q_WS_PM)
-    static QMap <int, QString> sKeyNames;
-#elif defined (Q_WS_X11)
-    static QMap <QString, QString> sKeyNames;
-#endif
+#ifdef Q_WS_X11
+    static QMap<QString, QString> s_keyNames;
+#endif /* Q_WS_X11 */
 
 #ifdef Q_WS_MAC
-    /** The current modifier key mask. Used to figure out which modifier
-     *  key was pressed when we get a kEventRawKeyModifiersChanged event. */
-    uint32_t mDarwinKeyModifiers;
-#endif
+    /* The current modifier key mask. Used to figure out which modifier
+     * key was pressed when we get a kEventRawKeyModifiersChanged event. */
+    uint32_t m_uDarwinKeyModifiers;
+#endif /* Q_WS_MAC */
 
-    static const char *kNoneSymbName;
+    static const char *m_spNoneSymbName;
 };
 
