VirtualBox

Changeset 79130 in vbox


Ignore:
Timestamp:
Jun 13, 2019 1:32:10 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6143. Fixing some missing things in save/load keyboard load stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r79126 r79130  
    6767    UIKeyType_Modifier,
    6868    UIKeyType_Max
     69};
     70
     71struct KeyCaptions
     72{
     73    QString m_strBase;
     74    QString m_strShift;
     75    QString m_strAltGr;
    6976};
    7077
     
    285292
    286293public:
     294
    287295    UISoftKeyboardLayout()
    288296        :m_pPhysicalLayout(0){}
     
    290298    UISoftKeyboardPhysicalLayout *m_pPhysicalLayout;
    291299    QString m_strName;
     300    /** We cache the key caps here instead of reading the layout files each time layout changes.
     301      * Map key is the key position and the value is the captions of the key. */
     302    QMap<int, KeyCaptions> m_keyCapMap;
    292303};
    293304
     
    427438public:
    428439
    429     struct KeyCaptions
    430     {
    431         QString m_strBase;
    432         QString m_strShift;
    433         QString m_strAltGr;
    434     };
    435 
    436440    bool  parseFile(const QString &strFileName);
     441    const QUuid &physicalLayoutUUID() const;
     442    const QString &name() const;
     443    const QMap<int, KeyCaptions> &keyCapMap() const;
    437444
    438445private:
     
    14231430void UISoftKeyboardWidget::loadDefaultLayout()
    14241431{
    1425     /* Choose the first layout action's data as the default layout: */
    1426     // if (m_defaultLayouts.isEmpty())
    1427     //     return;
    1428     // const QString &strLayout = m_defaultLayouts.at(0);
    1429     // if (loadPhysicalLayout(strLayout))
    1430     //     emit sigLayoutChange(strLayout);
     1432    if (m_layouts.isEmpty())
     1433        return;
     1434    setCurrentLayout(&(m_layouts[0]));
    14311435}
    14321436
     
    15241528        return false;
    15251529
    1526     // m_layouts.append(UISoftKeyboardLayout());
    1527     // UISoftKeyboardLayout &newLayout = m_layouts.back();
    1528 
    1529 
     1530
     1531    UISoftKeyboardPhysicalLayout *pPhysicalLayout = 0;
    15301532    /* Search for the physical layout among the one stored in m_pPhysicalLayout: */
    1531     // for (int i = 0; i < m_physicalLayouts.size(); ++i)
    1532     // {
    1533     //     if (physicalLayoutUid == m_physicalLayouts[i].m_uId)
    1534     //         newLayout.m_pPhysicalLayout = &(m_physicalLayouts[i]);
    1535     // }
    1536 
    1537     // /* If no pyhsical layout with the UUID the keyboard layout refers is found then cancel loading the keyboard layout: */
    1538     // if (!newLayout.m_pPhysicalLayout)
    1539     // {
    1540     //     m_layouts.removeLast();
    1541     //     return false;
    1542     // }
     1533    for (int i = 0; i < m_physicalLayouts.size(); ++i)
     1534    {
     1535        if (keyboardLayoutReader.physicalLayoutUUID() == m_physicalLayouts[i].m_uId)
     1536            pPhysicalLayout = &(m_physicalLayouts[i]);
     1537    }
     1538
     1539    /* If no pyhsical layout with the UUID the keyboard layout refers is found then cancel loading the keyboard layout: */
     1540    if (!pPhysicalLayout)
     1541        return false;
     1542
     1543    m_layouts.append(UISoftKeyboardLayout());
     1544    UISoftKeyboardLayout &newLayout = m_layouts.back();
     1545    newLayout.m_pPhysicalLayout = pPhysicalLayout;
     1546    newLayout.m_strName = keyboardLayoutReader.name();
     1547    newLayout.m_keyCapMap = keyboardLayoutReader.keyCapMap();
    15431548    return true;
    1544 
    15451549}
    15461550
     
    16321636
    16331637    if (m_pLayoutEditor)
    1634     {
    16351638        m_pLayoutEditor->setLayoutName(m_pCurrentKeyboardLayout->m_strName);
     1639    const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->m_keyCapMap;
     1640
     1641    /* Update the key captions: */
     1642    QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows;
     1643    for (int i = 0; i < rows.size(); ++i)
     1644    {
     1645        QVector<UISoftKeyboardKey> &keys = rows[i].keys();
     1646        for (int j = 0; j < keys.size(); ++j)
     1647        {
     1648            UISoftKeyboardKey &key = keys[j];
     1649            if (!keyCapMap.contains(key.position()))
     1650                continue;
     1651            const KeyCaptions &captions = keyCapMap.value(key.position());
     1652            key.setBaseCaption(captions.m_strBase);
     1653            key.setShiftCaption(captions.m_strShift);
     1654            key.setAltGrCaption(captions.m_strAltGr);
     1655        }
    16361656    }
    16371657}
     
    18861906}
    18871907
     1908const QUuid &UIKeyboardLayoutReader::physicalLayoutUUID() const
     1909{
     1910    return m_physicalLayoutUid;
     1911}
     1912
     1913const QString &UIKeyboardLayoutReader::name() const
     1914{
     1915    return m_strName;
     1916}
     1917
     1918const QMap<int, KeyCaptions> &UIKeyboardLayoutReader::keyCapMap() const
     1919{
     1920    return m_keyCapMap;
     1921}
     1922
    18881923void  UIKeyboardLayoutReader::parseKey()
    18891924{
  • trunk/src/VBox/Frontends/VirtualBox/xml/us_international.xml

    r79121 r79130  
    125125    <key>
    126126        <position>5</position>
    127         <basecaption></basecaption>
    128         <shiftcaption></shiftcaption>
     127        <basecaption>4</basecaption>
     128        <shiftcaption>$</shiftcaption>
    129129        <altgrcaption></altgrcaption>
    130130    </key>
     
    203203    <key>
    204204        <position>16</position>
    205         <basecaption></basecaption>
     205        <basecaption>Tab</basecaption>
    206206        <shiftcaption></shiftcaption>
    207207        <altgrcaption></altgrcaption>
     
    305305    <key>
    306306        <position>30</position>
    307         <basecaption></basecaption>
     307        <basecaption>CapsLock</basecaption>
    308308        <shiftcaption></shiftcaption>
    309309        <altgrcaption></altgrcaption>
     
    461461    <key>
    462462        <position>58</position>
    463         <basecaption></basecaption>
     463        <basecaption>Ctrl</basecaption>
    464464        <shiftcaption></shiftcaption>
    465465        <altgrcaption></altgrcaption>
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette