Changeset 79130 in vbox
- Timestamp:
- Jun 13, 2019 1:32:10 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79126 r79130 67 67 UIKeyType_Modifier, 68 68 UIKeyType_Max 69 }; 70 71 struct KeyCaptions 72 { 73 QString m_strBase; 74 QString m_strShift; 75 QString m_strAltGr; 69 76 }; 70 77 … … 285 292 286 293 public: 294 287 295 UISoftKeyboardLayout() 288 296 :m_pPhysicalLayout(0){} … … 290 298 UISoftKeyboardPhysicalLayout *m_pPhysicalLayout; 291 299 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; 292 303 }; 293 304 … … 427 438 public: 428 439 429 struct KeyCaptions430 {431 QString m_strBase;432 QString m_strShift;433 QString m_strAltGr;434 };435 436 440 bool parseFile(const QString &strFileName); 441 const QUuid &physicalLayoutUUID() const; 442 const QString &name() const; 443 const QMap<int, KeyCaptions> &keyCapMap() const; 437 444 438 445 private: … … 1423 1430 void UISoftKeyboardWidget::loadDefaultLayout() 1424 1431 { 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])); 1431 1435 } 1432 1436 … … 1524 1528 return false; 1525 1529 1526 // m_layouts.append(UISoftKeyboardLayout()); 1527 // UISoftKeyboardLayout &newLayout = m_layouts.back(); 1528 1529 1530 1531 UISoftKeyboardPhysicalLayout *pPhysicalLayout = 0; 1530 1532 /* 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(); 1543 1548 return true; 1544 1545 1549 } 1546 1550 … … 1632 1636 1633 1637 if (m_pLayoutEditor) 1634 {1635 1638 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 } 1636 1656 } 1637 1657 } … … 1886 1906 } 1887 1907 1908 const QUuid &UIKeyboardLayoutReader::physicalLayoutUUID() const 1909 { 1910 return m_physicalLayoutUid; 1911 } 1912 1913 const QString &UIKeyboardLayoutReader::name() const 1914 { 1915 return m_strName; 1916 } 1917 1918 const QMap<int, KeyCaptions> &UIKeyboardLayoutReader::keyCapMap() const 1919 { 1920 return m_keyCapMap; 1921 } 1922 1888 1923 void UIKeyboardLayoutReader::parseKey() 1889 1924 { -
trunk/src/VBox/Frontends/VirtualBox/xml/us_international.xml
r79121 r79130 125 125 <key> 126 126 <position>5</position> 127 <basecaption> </basecaption>128 <shiftcaption> </shiftcaption>127 <basecaption>4</basecaption> 128 <shiftcaption>$</shiftcaption> 129 129 <altgrcaption></altgrcaption> 130 130 </key> … … 203 203 <key> 204 204 <position>16</position> 205 <basecaption> </basecaption>205 <basecaption>Tab</basecaption> 206 206 <shiftcaption></shiftcaption> 207 207 <altgrcaption></altgrcaption> … … 305 305 <key> 306 306 <position>30</position> 307 <basecaption> </basecaption>307 <basecaption>CapsLock</basecaption> 308 308 <shiftcaption></shiftcaption> 309 309 <altgrcaption></altgrcaption> … … 461 461 <key> 462 462 <position>58</position> 463 <basecaption> </basecaption>463 <basecaption>Ctrl</basecaption> 464 464 <shiftcaption></shiftcaption> 465 465 <altgrcaption></altgrcaption>
Note:
See TracChangeset
for help on using the changeset viewer.