Index: /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 81207)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp	(revision 81208)
@@ -107,6 +107,26 @@
 };
 
-struct KeyCaptions
-{
+struct UIKeyCaptions
+{
+    UIKeyCaptions(const QString &strBase, const QString &strShift,
+                const QString &strAltGr, const QString &strShiftAltGr)
+        : m_strBase(strBase)
+        , m_strShift(strShift)
+        , m_strAltGr(strAltGr)
+        , m_strShiftAltGr(strShiftAltGr)
+    {
+        m_strBase.replace("\\n", "\n");
+        m_strShift.replace("\\n", "\n");
+        m_strAltGr.replace("\\n", "\n");
+        m_strShiftAltGr.replace("\\n", "\n");
+    }
+    UIKeyCaptions(){}
+    bool operator==(const UIKeyCaptions &other) const
+    {
+        return (m_strBase == other.m_strBase &&
+                m_strShift == other.m_strShift &&
+                m_strAltGr == other.m_strAltGr &&
+                m_strShiftAltGr == other.m_strShiftAltGr);
+    }
     QString m_strBase;
     QString m_strShift;
@@ -175,5 +195,5 @@
 
     void sigLayoutEdited();
-    void sigKeyCaptionsEdited(UISoftKeyboardKey* pKey);
+    void sigUIKeyCaptionsEdited(UISoftKeyboardKey* pKey);
     void sigGoBackButton();
 
@@ -192,8 +212,5 @@
 private slots:
 
-    void sltKeyBaseCaptionChange(const QString &strCaption);
-    void sltKeyShiftCaptionChange(const QString &strCaption);
-    void sltKeyAltGrCaptionChange(const QString &strCaption);
-    void sltKeyShiftAltGrCaptionChange(const QString &strCaption);
+    void sltCaptionsUpdate();
     void sltPhysicalLayoutChanged();
     void sltLayoutNameChanged(const QString &strCaption);
@@ -327,5 +344,6 @@
 /** UISoftKeyboardKey is a place holder for a keyboard key. Graphical key represantations are drawn according to this class.
   * The position of a key within the physical layout is read from the layout file. Note that UISoftKeyboardKey does not have
-  * caption field(s). */
+  * caption field(s). Captions are kept by UISoftKeyboardLayout since same keys may (and usually do) have different captions in
+  * different layouts. */
 class UISoftKeyboardKey
 {
@@ -450,5 +468,5 @@
     bool isFromResources() const;
 
-    void updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions);
+    void updateUIKeyCaptions(int iKeyPosition, UIKeyCaptions &newCaptions);
 
     void setEditable(bool fEditable);
@@ -458,22 +476,14 @@
     const QUuid &physicalLayoutUuid() const;
 
-    void setKeyCapMap(const QMap<int, KeyCaptions> &keyCapMap);
-    QMap<int, KeyCaptions> &keyCapMap();
-    const QMap<int, KeyCaptions> &keyCapMap() const;
+    void setKeyCapMap(const QMap<int, UIKeyCaptions> &keyCaptionsMap);
+    void addOrUpdateUIKeyCaptions(int iKeyPosition, const UIKeyCaptions &keyCaptions);
+    UIKeyCaptions keyCaptions(int iKeyPosition);
+
     bool operator==(const UISoftKeyboardLayout &otherLayout);
 
-    const QString baseCaption(int iKeyPosition) const;
-    void setBaseCaption(int iKeyPosition, const QString &strBaseCaption);
-
-    const QString shiftCaption(int iKeyPosition) const;
-    void setShiftCaption(int iKeyPosition, const QString &strShiftCaption);
-
-    const QString altGrCaption(int iKeyPosition) const;
-    void  setAltGrCaption(int iKeyPosition, const QString &strAltGrCaption);
-
-    const QString shiftAltGrCaption(int iKeyPosition) const;
-    void  setShiftAltGrCaption(int iKeyPosition, const QString &strAltGrCaption);
-
-    const KeyCaptions keyCaptions(int iKeyPosition) const;
+    QString baseCaption(int iKeyPosition) const;
+    QString shiftCaption(int iKeyPosition) const;
+    QString altGrCaption(int iKeyPosition) const;
+    QString shiftAltGrCaption(int iKeyPosition) const;
 
     void setUid(const QUuid &uid);
@@ -485,7 +495,7 @@
 private:
 
-    QMap<int, KeyCaptions> m_keyCapMap;
-    QMap<int, QPicture>    m_pictureMap;
-
+    QMap<int, UIKeyCaptions> m_keyCaptionsMap;
+    /** Caching the font sizes we used for font rendering since it is not a very cheap process to compute these. */
+    QMap<int, int>         m_keyCaptionsFontSizeMap;
     /** The UUID of the physical layout used by this layout. */
     QUuid   m_physicalLayoutUuid;
@@ -693,5 +703,5 @@
 private:
 
-    void  parseKey(QMap<int, KeyCaptions> &keyCapMap);
+    void  parseKey(UISoftKeyboardLayout &layout);
     QXmlStreamReader m_xmlReader;
     /** Map key is the key position and the value is the captions of the key. */
@@ -897,13 +907,14 @@
     if (m_pKey)
     {
-        KeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position());
-        if (captions.m_strBase != m_pBaseCaptionEdit->text())
-            m_pLayout->setBaseCaption(m_pKey->position(), m_pBaseCaptionEdit->text());
-        if (captions.m_strShift != m_pShiftCaptionEdit->text())
-            m_pLayout->setShiftCaption(m_pKey->position(), m_pShiftCaptionEdit->text());
-        if (captions.m_strAltGr != m_pAltGrCaptionEdit->text())
-            m_pLayout->setAltGrCaption(m_pKey->position(), m_pAltGrCaptionEdit->text());
-        if (captions.m_strShiftAltGr != m_pShiftAltGrCaptionEdit->text())
-            m_pLayout->setShiftAltGrCaption(m_pKey->position(), m_pShiftAltGrCaptionEdit->text());
+        UIKeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position());
+        if (captions.m_strBase != m_pBaseCaptionEdit->text() ||
+            captions.m_strShift != m_pShiftCaptionEdit->text() ||
+            captions.m_strAltGr != m_pAltGrCaptionEdit->text() ||
+            captions.m_strShiftAltGr != m_pShiftAltGrCaptionEdit->text())
+            m_pLayout->addOrUpdateUIKeyCaptions(m_pKey->position(),
+                                              UIKeyCaptions(m_pBaseCaptionEdit->text(),
+                                                          m_pShiftCaptionEdit->text(),
+                                                          m_pAltGrCaptionEdit->text(),
+                                                          m_pShiftAltGrCaptionEdit->text()));
     }
     m_pKey = pKey;
@@ -919,5 +930,5 @@
     if (m_pPositionEdit)
         m_pPositionEdit->setText(QString::number(m_pKey->position()));
-    KeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position());
+    UIKeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position());
     if (m_pBaseCaptionEdit)
         m_pBaseCaptionEdit->setText(captions.m_strBase);
@@ -1005,42 +1016,14 @@
 }
 
-void UIKeyboardLayoutEditor::sltKeyBaseCaptionChange(const QString &strCaption)
+void UIKeyboardLayoutEditor::sltCaptionsUpdate()
 {
     if (!m_pKey || !m_pLayout)
         return;
-    if (m_pLayout->baseCaption(m_pKey->position()) == strCaption)
-        return;
-    m_pLayout->setBaseCaption(m_pKey->position(), strCaption);
-    emit sigKeyCaptionsEdited(m_pKey);
-}
-
-void UIKeyboardLayoutEditor::sltKeyShiftCaptionChange(const QString &strCaption)
-{
-    if (!m_pKey || !m_pLayout)
-        return;
-    if (m_pLayout->shiftCaption(m_pKey->position()) == strCaption)
-        return;
-    m_pLayout->setShiftCaption(m_pKey->position(), strCaption);
-    emit sigKeyCaptionsEdited(m_pKey);
-}
-
-void UIKeyboardLayoutEditor::sltKeyAltGrCaptionChange(const QString &strCaption)
-{
-    if (!m_pKey || !m_pLayout)
-        return;
-    if (m_pLayout->altGrCaption(m_pKey->position()) == strCaption)
-        return;
-    m_pLayout->setAltGrCaption(m_pKey->position(), strCaption);
-    emit sigKeyCaptionsEdited(m_pKey);
-}
-
-void UIKeyboardLayoutEditor::sltKeyShiftAltGrCaptionChange(const QString &strCaption)
-{
-    if (!m_pKey || !m_pLayout)
-        return;
-    if (m_pLayout->shiftAltGrCaption(m_pKey->position()) == strCaption)
-        return;
-    m_pLayout->setShiftAltGrCaption(m_pKey->position(), strCaption);
-    emit sigKeyCaptionsEdited(m_pKey);
+    m_pLayout->addOrUpdateUIKeyCaptions(m_pKey->position(),
+                                      UIKeyCaptions(m_pBaseCaptionEdit->text(),
+                                                  m_pShiftCaptionEdit->text(),
+                                                  m_pAltGrCaptionEdit->text(),
+                                                  m_pShiftAltGrCaptionEdit->text()));
+    emit sigUIKeyCaptionsEdited(m_pKey);
 }
 
@@ -1166,5 +1149,5 @@
     pCaptionEditorLayout->addWidget(m_pBaseCaptionLabel, 0, 0);
     pCaptionEditorLayout->addWidget(m_pBaseCaptionEdit, 0, 1);
-    connect(m_pBaseCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltKeyBaseCaptionChange);
+    connect(m_pBaseCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate);
 
     m_pShiftCaptionLabel = new QLabel;
@@ -1173,5 +1156,5 @@
     pCaptionEditorLayout->addWidget(m_pShiftCaptionLabel, 1, 0);
     pCaptionEditorLayout->addWidget(m_pShiftCaptionEdit, 1, 1);
-    connect(m_pShiftCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltKeyShiftCaptionChange);
+    connect(m_pShiftCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate);
 
     m_pAltGrCaptionLabel = new QLabel;
@@ -1180,5 +1163,5 @@
     pCaptionEditorLayout->addWidget(m_pAltGrCaptionLabel, 2, 0);
     pCaptionEditorLayout->addWidget(m_pAltGrCaptionEdit, 2, 1);
-    connect(m_pAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltKeyAltGrCaptionChange);
+    connect(m_pAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate);
 
     m_pShiftAltGrCaptionLabel = new QLabel;
@@ -1187,5 +1170,5 @@
     pCaptionEditorLayout->addWidget(m_pShiftAltGrCaptionLabel, 3, 0);
     pCaptionEditorLayout->addWidget(m_pShiftAltGrCaptionEdit, 3, 1);
-    connect(m_pShiftAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltKeyShiftAltGrCaptionChange);
+    connect(m_pShiftAltGrCaptionEdit, &QLineEdit::textChanged, this, &UIKeyboardLayoutEditor::sltCaptionsUpdate);
 
 
@@ -1685,9 +1668,9 @@
 }
 
-void UISoftKeyboardLayout::updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions)
-{
-    if (!m_keyCapMap.contains(iKeyPosition))
-        return;
-    m_keyCapMap[iKeyPosition] = newCaptions;
+void UISoftKeyboardLayout::updateUIKeyCaptions(int iKeyPosition, UIKeyCaptions &newCaptions)
+{
+    if (!m_keyCaptionsMap.contains(iKeyPosition))
+        return;
+    m_keyCaptionsMap[iKeyPosition] = newCaptions;
 }
 
@@ -1764,17 +1747,21 @@
 }
 
-void UISoftKeyboardLayout::setKeyCapMap(const QMap<int, KeyCaptions> &keyCapMap)
-{
-    m_keyCapMap = keyCapMap;
-}
-
-QMap<int, KeyCaptions> &UISoftKeyboardLayout::keyCapMap()
-{
-    return m_keyCapMap;
-}
-
-const QMap<int, KeyCaptions> &UISoftKeyboardLayout::keyCapMap() const
-{
-    return m_keyCapMap;
+void UISoftKeyboardLayout::setKeyCapMap(const QMap<int, UIKeyCaptions> &keyCaptionsMap)
+{
+    m_keyCaptionsMap = keyCaptionsMap;
+}
+
+void UISoftKeyboardLayout::addOrUpdateUIKeyCaptions(int iKeyPosition, const UIKeyCaptions &keyCaptions)
+{
+    if (m_keyCaptionsMap[iKeyPosition] == keyCaptions)
+        return;
+    m_keyCaptionsMap[iKeyPosition] = keyCaptions;
+    /* Updating the captions invalidates the cached font size. We set it to 0, thereby forcing its recomputaion: */
+    m_keyCaptionsFontSizeMap[iKeyPosition] = 0;
+}
+
+UIKeyCaptions UISoftKeyboardLayout::keyCaptions(int iKeyPosition)
+{
+    return m_keyCaptionsMap[iKeyPosition];
 }
 
@@ -1796,59 +1783,28 @@
 }
 
-const QString UISoftKeyboardLayout::baseCaption(int iKeyPosition) const
-{
-    return m_keyCapMap.value(iKeyPosition, KeyCaptions()).m_strBase;
-}
-
-void UISoftKeyboardLayout::setBaseCaption(int iKeyPosition, const QString &strBaseCaption)
-{
-    m_keyCapMap[iKeyPosition].m_strBase = strBaseCaption;
-    m_keyCapMap[iKeyPosition].m_strBase.replace("\\n", "\n");
-}
-
-const QString UISoftKeyboardLayout::shiftCaption(int iKeyPosition) const
-{
-    if (!m_keyCapMap.contains(iKeyPosition))
+QString UISoftKeyboardLayout::baseCaption(int iKeyPosition) const
+{
+    return m_keyCaptionsMap.value(iKeyPosition, UIKeyCaptions()).m_strBase;
+}
+
+QString UISoftKeyboardLayout::shiftCaption(int iKeyPosition) const
+{
+    if (!m_keyCaptionsMap.contains(iKeyPosition))
         return QString();
-    return m_keyCapMap[iKeyPosition].m_strShift;
-}
-
-void UISoftKeyboardLayout::setShiftCaption(int iKeyPosition, const QString &strShiftCaption)
-{
-    m_keyCapMap[iKeyPosition].m_strShift = strShiftCaption;
-    m_keyCapMap[iKeyPosition].m_strShift.replace("\\n", "\n");
-}
-
-const QString UISoftKeyboardLayout::altGrCaption(int iKeyPosition) const
-{
-    if (!m_keyCapMap.contains(iKeyPosition))
+    return m_keyCaptionsMap[iKeyPosition].m_strShift;
+}
+
+QString UISoftKeyboardLayout::altGrCaption(int iKeyPosition) const
+{
+    if (!m_keyCaptionsMap.contains(iKeyPosition))
         return QString();
-    return m_keyCapMap[iKeyPosition].m_strAltGr;
-}
-
-void UISoftKeyboardLayout::setAltGrCaption(int iKeyPosition, const QString &strAltGrCaption)
-{
-    m_keyCapMap[iKeyPosition].m_strAltGr = strAltGrCaption;
-    m_keyCapMap[iKeyPosition].m_strAltGr.replace("\\n", "\n");
-}
-
-const QString UISoftKeyboardLayout::shiftAltGrCaption(int iKeyPosition) const
-{
-    if (!m_keyCapMap.contains(iKeyPosition))
+    return m_keyCaptionsMap[iKeyPosition].m_strAltGr;
+}
+
+QString UISoftKeyboardLayout::shiftAltGrCaption(int iKeyPosition) const
+{
+    if (!m_keyCaptionsMap.contains(iKeyPosition))
         return QString();
-    return m_keyCapMap[iKeyPosition].m_strShiftAltGr;
-}
-
-void UISoftKeyboardLayout::setShiftAltGrCaption(int iKeyPosition, const QString &strShiftAltGrCaption)
-{
-    m_keyCapMap[iKeyPosition].m_strShiftAltGr = strShiftAltGrCaption;
-    m_keyCapMap[iKeyPosition].m_strShiftAltGr.replace("\\n", "\n");
-}
-
-const KeyCaptions UISoftKeyboardLayout::keyCaptions(int iKeyPosition) const
-{
-    if (!m_keyCapMap.contains(iKeyPosition))
-        return KeyCaptions();
-    return m_keyCapMap[iKeyPosition];
+    return m_keyCaptionsMap[iKeyPosition].m_strShiftAltGr;
 }
 
@@ -1865,77 +1821,82 @@
 void UISoftKeyboardLayout::drawTextInRect(const UISoftKeyboardKey &key, QPainter &painter)
 {
-    int iKeyPosition = key.position();
-    const QRect &keyGeometry = key.keyGeometry();
-    QFont painterFont(painter.font());
-    int iFontSize = 30;
-
-    const QString &strBaseCaption = baseCaption(iKeyPosition);
-    const QString &strShiftCaption = shiftCaption(iKeyPosition);
-
-    const QString &strShiftAltGrCaption = shiftAltGrCaption(iKeyPosition);
-    const QString &strAltGrCaption = altGrCaption(iKeyPosition);
-
-    const QString &strTopleftString = !strShiftCaption.isEmpty() ? strShiftCaption : strBaseCaption;
-    const QString &strBottomleftString = !strShiftCaption.isEmpty() ? strBaseCaption : QString();
-
-    do
-    {
-        painterFont.setPixelSize(iFontSize);
-        painterFont.setBold(true);
-        painter.setFont(painterFont);
-        QFontMetrics fontMetrics = painter.fontMetrics();
-        int iMargin = 0.25 * fontMetrics.width('X');
-
-        int iTopWidth = 0;
-
-        QStringList strList;
-        strList << strTopleftString.split("\n", QString::SkipEmptyParts)
-                << strShiftAltGrCaption.split("\n", QString::SkipEmptyParts);
-        foreach (const QString &strPart, strList)
-            iTopWidth = qMax(iTopWidth, fontMetrics.width(strPart));
-        strList.clear();
-        strList << strBottomleftString.split("\n", QString::SkipEmptyParts)
-                << strAltGrCaption.split("\n", QString::SkipEmptyParts);
-
-        int iBottomWidth = 0;
-        foreach (const QString &strPart, strList)
-            iBottomWidth = qMax(iBottomWidth, fontMetrics.width(strPart));
-        int iTextWidth =  2 * iMargin + qMax(iTopWidth, iBottomWidth);
-        int iTextHeight = 0;
-
-        if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys)
-            iTextHeight = 2 * iMargin + fontMetrics.height();
-        else
-            iTextHeight = 2 * iMargin + 2 * fontMetrics.height();
-
-        if (iTextWidth >= keyGeometry.width() || iTextHeight >= keyGeometry.height())
-            --iFontSize;
-        else
-            break;
-
-    }while(iFontSize > 1);
-
-
-    QFontMetrics fontMetrics = painter.fontMetrics();
-    int iMargin = 0.25 * fontMetrics.width('X');
-#if 0
-    painter.drawText(iMargin, iMargin + fontMetrics.height(), QString::number(iKeyPosition));
-#else
-    QRect textRect;
-    if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys)
-        textRect = QRect(2 * iMargin, iMargin,
-                         keyGeometry.width() - 2 * iMargin,
-                         keyGeometry.height() - 2 * iMargin);
-    else
-        textRect = QRect(iMargin, iMargin,
-                         keyGeometry.width() - 2 * iMargin,
-                         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
+     int iKeyPosition = key.position();
+     const QRect &keyGeometry = key.keyGeometry();
+     QFont painterFont(painter.font());
+
+     const QString &strBaseCaption = baseCaption(iKeyPosition);
+     const QString &strShiftCaption = shiftCaption(iKeyPosition);
+
+     const QString &strShiftAltGrCaption = shiftAltGrCaption(iKeyPosition);
+     const QString &strAltGrCaption = altGrCaption(iKeyPosition);
+
+     const QString &strTopleftString = !strShiftCaption.isEmpty() ? strShiftCaption : strBaseCaption;
+     const QString &strBottomleftString = !strShiftCaption.isEmpty() ? strBaseCaption : QString();
+
+     int iFontSize = 30;
+     if (!m_keyCaptionsFontSizeMap.contains(iKeyPosition) || m_keyCaptionsFontSizeMap.value(iKeyPosition) == 0)
+     {
+         do
+         {
+             painterFont.setPixelSize(iFontSize);
+             painterFont.setBold(true);
+             painter.setFont(painterFont);
+             QFontMetrics fontMetrics = painter.fontMetrics();
+             int iMargin = 0.25 * fontMetrics.width('X');
+
+             int iTopWidth = 0;
+             /* Some captions are multi line using \n as separator: */
+             QStringList strList;
+             strList << strTopleftString.split("\n", QString::SkipEmptyParts)
+                     << strShiftAltGrCaption.split("\n", QString::SkipEmptyParts);
+             foreach (const QString &strPart, strList)
+                 iTopWidth = qMax(iTopWidth, fontMetrics.width(strPart));
+             strList.clear();
+             strList << strBottomleftString.split("\n", QString::SkipEmptyParts)
+                     << strAltGrCaption.split("\n", QString::SkipEmptyParts);
+
+             int iBottomWidth = 0;
+             foreach (const QString &strPart, strList)
+                 iBottomWidth = qMax(iBottomWidth, fontMetrics.width(strPart));
+             int iTextWidth =  2 * iMargin + qMax(iTopWidth, iBottomWidth);
+             int iTextHeight = 0;
+
+             if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys)
+                 iTextHeight = 2 * iMargin + fontMetrics.height();
+             else
+                 iTextHeight = 2 * iMargin + 2 * fontMetrics.height();
+
+             if (iTextWidth >= keyGeometry.width() || iTextHeight >= keyGeometry.height())
+                 --iFontSize;
+             else
+                 break;
+
+         }while(iFontSize > 1);
+         m_keyCaptionsFontSizeMap[iKeyPosition] = iFontSize;
+     }
+     else
+     {
+         iFontSize = m_keyCaptionsFontSizeMap[iKeyPosition];
+         painterFont.setPixelSize(iFontSize);
+         painterFont.setBold(true);
+         painter.setFont(painterFont);
+     }
+
+     QFontMetrics fontMetrics = painter.fontMetrics();
+     int iMargin = 0.25 * fontMetrics.width('X');
+     QRect textRect;
+     if (key.keyboardRegion() == KeyboardRegion_MultimediaKeys)
+         textRect = QRect(2 * iMargin, iMargin,
+                          keyGeometry.width() - 2 * iMargin,
+                          keyGeometry.height() - 2 * iMargin);
+     else
+         textRect = QRect(iMargin, iMargin,
+                          keyGeometry.width() - 2 * iMargin,
+                          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);
 }
 
@@ -3213,5 +3174,5 @@
     {
         if (m_xmlReader.name() == "key")
-            parseKey(layout.keyCapMap());
+            parseKey(layout);
         else if (m_xmlReader.name() == "name")
             layout.setName(m_xmlReader.readElementText());
@@ -3228,7 +3189,7 @@
 }
 
-void  UIKeyboardLayoutReader::parseKey(QMap<int, KeyCaptions> &keyCapMap)
-{
-    KeyCaptions keyCaptions;
+void  UIKeyboardLayoutReader::parseKey(UISoftKeyboardLayout &layout)
+{
+    UIKeyCaptions keyCaptions;
     int iKeyPosition = 0;
     while (m_xmlReader.readNextStartElement())
@@ -3259,5 +3220,5 @@
             m_xmlReader.skipCurrentElement();
     }
-    keyCapMap.insert(iKeyPosition, keyCaptions);
+    layout.addOrUpdateUIKeyCaptions(iKeyPosition, keyCaptions);
 }
 
@@ -3787,5 +3748,5 @@
     connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector);
     connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigLayoutEdited, this, &UISoftKeyboard::sltLayoutEdited);
-    connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigKeyCaptionsEdited, this, &UISoftKeyboard::sltKeyCaptionsEdited);
+    connect(m_pLayoutEditor, &UIKeyboardLayoutEditor::sigUIKeyCaptionsEdited, this, &UISoftKeyboard::sltKeyCaptionsEdited);
 
     connect(m_pStatusBarWidget, &UISoftKeyboardStatusBarWidget::sigShowHideSidePanel, this, &UISoftKeyboard::sltShowHideSidePanel);
