Index: /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 79587)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 79588)
@@ -67,28 +67,35 @@
 
 const int iMessageTimeout = 3000;
-/** Lock key position are used to identify respective keys. */
+/** Key position are used to identify respective keys. */
 const int iCapsLockPosition = 30;
 const int iNumLockPosition = 90;
 const int iScrollLockPosition = 125;
+const int iLeftShiftPosition = 44;
+const int iRightShiftPosition = 57;
+const int iLeftCtrlPosition = 58;
+const int iRightCtrlPosition = 64;
+const int iAltPosition = 60;
+const int iAltGrPosition = 62;
+
 
 const QString strSubDirectorName("keyboardLayouts");
 
-enum UIKeyState
-{
-    UIKeyState_NotPressed,
-    UIKeyState_Pressed,
-    UIKeyState_Locked,
-    UIKeyState_Max
+enum KeyState
+{
+    KeyState_NotPressed,
+    KeyState_Pressed,
+    KeyState_Locked,
+    KeyState_Max
 };
 
-enum UIKeyType
-{
-    /** Can be in UIKeyState_NotPressed and UIKeyState_Pressed states. */
-    UIKeyType_Ordinary,
-    /** e.g. CapsLock, NumLock. Can be only in UIKeyState_NotPressed, UIKeyState_Locked */
-    UIKeyType_Lock,
+enum KeyType
+{
+    /** Can be in KeyState_NotPressed and KeyState_Pressed states. */
+    KeyType_Ordinary,
+    /** e.g. CapsLock, NumLock. Can be only in KeyState_NotPressed, KeyState_Locked */
+    KeyType_Lock,
     /** e.g. Shift Can be in all 3 states*/
-    UIKeyType_Modifier,
-    UIKeyType_Max
+    KeyType_Modifier,
+    KeyType_Max
 };
 
@@ -331,6 +338,6 @@
     int position() const;
 
-    void setType(UIKeyType enmType);
-    UIKeyType type() const;
+    void setType(KeyType enmType);
+    KeyType type() const;
 
     void setIsNumPadKey(bool fIsNumPadKey);
@@ -343,5 +350,5 @@
 
     void setParentWidget(UISoftKeyboardWidget* pParent);
-    UIKeyState state() const;
+    KeyState state() const;
     QVector<LONG> scanCodeWithPrefix() const;
 
@@ -367,6 +374,6 @@
     /** Stores the key polygon in local coordinates. */
     QPolygon   m_polygon;
-    UIKeyType  m_enmType;
-    UIKeyState m_enmState;
+    KeyType  m_enmType;
+    KeyState m_enmState;
     /** Key width as it is read from the xml file. */
     int        m_iWidth;
@@ -535,8 +542,8 @@
     float layoutAspectRatio();
 
-    bool showOSMenuKeys();
+    bool showOSMenuKeys() const;
     void setShowOSMenuKeys(bool fShow);
 
-    bool showNumPad();
+    bool showNumPad() const;
     void setShowNumPad(bool fShow);
 
@@ -1387,6 +1394,6 @@
 
 UISoftKeyboardKey::UISoftKeyboardKey()
-    : m_enmType(UIKeyType_Ordinary)
-    , m_enmState(UIKeyState_NotPressed)
+    : m_enmType(KeyType_Ordinary)
+    , m_enmState(KeyState_NotPressed)
     , m_iWidth(0)
     , m_iHeight(0)
@@ -1476,10 +1483,10 @@
 }
 
-void UISoftKeyboardKey::setType(UIKeyType enmType)
+void UISoftKeyboardKey::setType(KeyType enmType)
 {
     m_enmType = enmType;
 }
 
-UIKeyType UISoftKeyboardKey::type() const
+KeyType UISoftKeyboardKey::type() const
 {
     return m_enmType;
@@ -1513,5 +1520,5 @@
 }
 
-UIKeyState UISoftKeyboardKey::state() const
+KeyState UISoftKeyboardKey::state() const
 {
     return m_enmState;
@@ -1526,5 +1533,5 @@
 {
     /* Lock key states are controlled by the event signals we get from the guest OS. See updateLockKeyState function: */
-    if (m_enmType != UIKeyType_Lock)
+    if (m_enmType != KeyType_Lock)
         updateState(false);
 }
@@ -1533,5 +1540,5 @@
 {
     /* Lock key states are controlled by the event signals we get from the guest OS. See updateLockKeyState function: */
-    if (m_enmType != UIKeyType_Lock)
+    if (m_enmType != KeyType_Lock)
         updateState(true);
 }
@@ -1571,39 +1578,32 @@
 void UISoftKeyboardKey::updateState(bool fPressed)
 {
-    UIKeyState enmPreviousState = state();
-    if (m_enmType == UIKeyType_Modifier)
+    KeyState enmPreviousState = state();
+    if (m_enmType == KeyType_Modifier)
     {
         if (fPressed)
         {
-            if (m_enmState == UIKeyState_NotPressed)
-                m_enmState = UIKeyState_Pressed;
-            else if(m_enmState == UIKeyState_Pressed)
-                m_enmState = UIKeyState_Locked;
+            if (m_enmState == KeyState_NotPressed)
+                m_enmState = KeyState_Pressed;
+            else if(m_enmState == KeyState_Pressed)
+                m_enmState = KeyState_Locked;
             else
-                m_enmState = UIKeyState_NotPressed;
+                m_enmState = KeyState_NotPressed;
         }
         else
         {
-            if(m_enmState == UIKeyState_Pressed)
-                m_enmState = UIKeyState_NotPressed;
+            if(m_enmState == KeyState_Pressed)
+                m_enmState = KeyState_NotPressed;
         }
     }
-    else if (m_enmType == UIKeyType_Lock)
-    {
-        m_enmState = fPressed ? UIKeyState_Locked : UIKeyState_NotPressed;
-        // if (fPressed)
-        // {
-        //     if (m_enmState == UIKeyState_NotPressed)
-        //          m_enmState = UIKeyState_Locked;
-        //     else
-        //         m_enmState = UIKeyState_NotPressed;
-        // }
-    }
-    else if (m_enmType == UIKeyType_Ordinary)
-    {
-        if (m_enmState == UIKeyState_NotPressed)
-            m_enmState = UIKeyState_Pressed;
+    else if (m_enmType == KeyType_Lock)
+    {
+        m_enmState = fPressed ? KeyState_Locked : KeyState_NotPressed;
+    }
+    else if (m_enmType == KeyType_Ordinary)
+    {
+        if (m_enmState == KeyState_NotPressed)
+            m_enmState = KeyState_Pressed;
         else
-            m_enmState = UIKeyState_NotPressed;
+            m_enmState = KeyState_NotPressed;
     }
     if (enmPreviousState != state() && m_pParentWidget)
@@ -1613,9 +1613,9 @@
 void UISoftKeyboardKey::updateLockState(bool fLocked)
 {
-    if (m_enmType != UIKeyType_Lock)
-        return;
-    if (fLocked && m_enmState == UIKeyState_Locked)
-        return;
-    if (!fLocked && m_enmState == UIKeyState_NotPressed)
+    if (m_enmType != KeyType_Lock)
+        return;
+    if (fLocked && m_enmState == KeyState_Locked)
+        return;
+    if (!fLocked && m_enmState == KeyState_NotPressed)
         return;
     updateState(fLocked);
@@ -1868,10 +1868,9 @@
                    keyGeometry.height() - 2 * iMargin);
 
-
     painter.drawText(textRect, Qt::AlignLeft | Qt::AlignTop, strTopleftString);
     painter.drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, strBottomleftString);
-
     painter.drawText(textRect, Qt::AlignRight | Qt::AlignTop, strShiftAltGrCaption);
     painter.drawText(textRect, Qt::AlignRight | Qt::AlignBottom, strAltGrCaption);
+
 #endif
 }
@@ -2071,10 +2070,10 @@
             m_pCurrentKeyboardLayout->drawTextInRect(key.position(), key.keyGeometry(), painter);
 
-            if (key.type() != UIKeyType_Ordinary)
+            if (key.type() != KeyType_Ordinary)
             {
                 QColor ledColor;
-                if (key.state() == UIKeyState_NotPressed)
+                if (key.state() == KeyState_NotPressed)
                     ledColor = color(KeyboardColorType_Font);
-                else if (key.state() == UIKeyState_Pressed)
+                else if (key.state() == KeyState_Pressed)
                     ledColor = QColor(0, 191, 204);
                 else
@@ -2249,5 +2248,5 @@
 }
 
-bool UISoftKeyboardWidget::showOSMenuKeys()
+bool UISoftKeyboardWidget::showOSMenuKeys() const
 {
     return m_fShowOSMenuKeys;
@@ -2262,5 +2261,5 @@
 }
 
-bool UISoftKeyboardWidget::showNumPad()
+bool UISoftKeyboardWidget::showNumPad() const
 {
     return m_fShowNumPad;
@@ -2297,8 +2296,6 @@
 void UISoftKeyboardWidget::updateLockKeyStates(bool fCapsLockState, bool fNumLockState, bool fScrollLockState)
 {
-    UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid());
-    if (!pPhysicalLayout)
-        return;
-    pPhysicalLayout->updateLockKeyStates(fCapsLockState, fNumLockState, fScrollLockState);
+    for (int i = 0; i < m_physicalLayouts.size(); ++i)
+        m_physicalLayouts[i].updateLockKeyStates(fCapsLockState, fNumLockState, fScrollLockState);
     update();
 }
@@ -2428,8 +2425,8 @@
     if (!pKey)
         return;
-    if (pKey->type() == UIKeyType_Ordinary)
+    if (pKey->type() == KeyType_Ordinary)
         pKey->release();
     /* We only send the scan codes of Ordinary keys: */
-    if (pKey->type() == UIKeyType_Modifier)
+    if (pKey->type() == KeyType_Modifier)
         return;
 
@@ -2458,5 +2455,5 @@
     pKey->press();
 
-    if (pKey->type() == UIKeyType_Modifier)
+    if (pKey->type() == KeyType_Modifier)
         return;
 
@@ -2481,7 +2478,7 @@
     if (!pKey)
         return;
-    if (pKey->type() == UIKeyType_Modifier)
-    {
-        if (pKey->state() == UIKeyState_NotPressed)
+    if (pKey->type() == KeyType_Modifier)
+    {
+        if (pKey->state() == KeyState_NotPressed)
             m_pressedModifiers.removeOne(pKey);
         else
@@ -2916,7 +2913,7 @@
             QString strType = m_xmlReader.readElementText();
             if (strType == "modifier")
-                key.setType(UIKeyType_Modifier);
+                key.setType(KeyType_Modifier);
             else if (strType == "lock")
-                key.setType(UIKeyType_Lock);
+                key.setType(KeyType_Lock);
         }
         else if (m_xmlReader.name() == "osmenukey")
@@ -3298,5 +3295,5 @@
     QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding);
     if (pSpacer)
-        pSettingsLayout->addItem(pSpacer, 5, 0);
+        pSettingsLayout->addItem(pSpacer, 6, 0);
 
     setLayout(pSettingsLayout);
@@ -3646,5 +3643,5 @@
 void UISoftKeyboard::configure()
 {
-    setWindowIcon(UIIconPool::iconSetFull(":/vm_show_logs_32px.png", ":/vm_show_logs_16px.png"));
+    setWindowIcon(UIIconPool::iconSet(":/keyboard_24px.png"));
     if (m_pKeyboardWidget && m_pSettingsWidget)
     {
@@ -3661,5 +3658,8 @@
     updateLayoutSelectorList();
     if (m_pKeyboardWidget && m_pKeyboardWidget->currentLayout() && m_pLayoutSelector)
+    {
         m_pLayoutSelector->setCurrentLayout(m_pKeyboardWidget->currentLayout()->uid());
+        m_pLayoutSelector->setCurrentLayoutIsEditable(m_pKeyboardWidget->currentLayout()->editable());
+    }
 }
 
