Changeset 79385 in vbox
- Timestamp:
- Jun 27, 2019 11:43:39 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79365 r79385 150 150 UILayoutEditor(QWidget *pParent = 0); 151 151 void setKey(UISoftKeyboardKey *pKey); 152 153 152 void setLayoutToEdit(UISoftKeyboardLayout *pLayout); 154 153 void setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts); … … 220 219 void sigCopyLayout(); 221 220 void sigDeleteLayout(); 222 void sigLayoutSelectionChanged(const Q String &strSelectedLayoutName);221 void sigLayoutSelectionChanged(const QUuid &strSelectedLayoutUid); 223 222 void sigShowLayoutEditor(); 224 223 void sigCloseLayoutList(); … … 227 226 228 227 UILayoutSelector(QWidget *pParent = 0); 229 void setLayoutList(const QStringList &layoutNames );228 void setLayoutList(const QStringList &layoutNames, QList<QUuid> layoutIdList); 230 229 void setCurrentLayout(const QString &strLayoutName); 231 230 void setCurrentLayoutIsEditable(bool fEditable); … … 237 236 private slots: 238 237 238 void sltCurrentItemChanged(QListWidgetItem *pCurrent, QListWidgetItem *pPrevious); 239 239 240 240 private: … … 298 298 void setKeyGeometry(const QRect &rect); 299 299 300 const QString baseCaption() const;301 void setBaseCaption(const QString &strBaseCaption);302 303 const QString shiftCaption() const;304 void setShiftCaption(const QString &strShiftCaption);305 306 const QString altGrCaption() const;307 void setAltGrCaption(const QString &strAltGrCaption);308 309 const QString shiftAltGrCaption() const;310 void setShiftAltGrCaption(const QString &strAltGrCaption);311 312 void resetCaptions();313 const QString text() const;314 315 300 void setWidth(int iWidth); 316 301 int width() const; … … 357 342 int cutoutWidth() const; 358 343 int cutoutHeight() const; 359 QPicture m_textPixmap;360 344 361 345 private: 362 346 363 347 void updateState(bool fPressed); 364 void updateText();365 348 366 349 QRect m_keyGeometry; 367 QString m_strBaseCaption;368 QString m_strShiftCaption;369 QString m_strAltGrCaption;370 QString m_strShiftAltGrCaption;371 /** m_strText is concatenation of base, shift, and altgr captions. */372 QString m_strText;373 350 /** Stores the key polygon in local coordinates. */ 374 351 QPolygon m_polygon; … … 435 412 bool operator==(const UISoftKeyboardLayout &otherLayout); 436 413 414 const QString baseCaption(int iKeyPosition) const; 415 void setBaseCaption(int iKeyPosition, const QString &strBaseCaption); 416 417 const QString shiftCaption(int iKeyPosition) const; 418 void setShiftCaption(int iKeyPosition, const QString &strShiftCaption); 419 420 const QString altGrCaption(int iKeyPosition) const; 421 void setAltGrCaption(int iKeyPosition, const QString &strAltGrCaption); 422 423 const QString shiftAltGrCaption(int iKeyPosition) const; 424 void setShiftAltGrCaption(int iKeyPosition, const QString &strAltGrCaption); 425 426 const KeyCaptions keyCaptions(int iKeyPosition) const; 427 428 void setUid(const QUuid &uid); 429 QUuid uid() const; 430 431 void drawText(int iKeyPosition, const QRect &keyGeometry, QPainter &painter); 432 437 433 private: 438 434 … … 440 436 QUuid m_physicalLayoutUuid; 441 437 442 /** We cache the key caps here instead of reading the layout files each time layout changes.443 * Map key is the key position and the value is the captions of the key. */444 438 QMap<int, KeyCaptions> m_keyCapMap; 439 QMap<int, QPicture> m_pictureMap; 440 445 441 /** This is the English name of the layout. */ 446 442 QString m_strName; … … 449 445 bool m_fEditable; 450 446 bool m_fIsFromResources; 447 QUuid m_uid; 451 448 }; 452 449 … … 484 481 485 482 void setCurrentLayout(const QString &strLayoutName); 483 void setCurrentLayout(const QUuid &layoutUid); 486 484 UISoftKeyboardLayout *currentLayout(); 487 485 488 486 QStringList layoutNameList() const; 487 QList<QUuid> layoutUidList() const; 489 488 const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts() const; 490 489 void deleteCurrentLayout(); … … 535 534 void setCurrentLayout(UISoftKeyboardLayout *pLayout); 536 535 UISoftKeyboardLayout *findLayoutByName(const QString &strName); 536 UISoftKeyboardLayout *findLayoutByUid(const QUuid &uid); 537 537 /** Looks under the default keyboard layout folder and add the file names to the fileList. */ 538 538 void lookAtDefaultLayoutFolder(QStringList &fileList); … … 731 731 void UILayoutEditor::setKey(UISoftKeyboardKey *pKey) 732 732 { 733 if (m_pKey == pKey )733 if (m_pKey == pKey || !m_pLayout) 734 734 return; 735 735 /* First apply the pending changes to the key that has been edited: */ 736 736 if (m_pKey) 737 737 { 738 if (m_pKey->shiftCaption() != m_pShiftCaptionEdit->text()) 739 m_pKey->setShiftCaption(m_pShiftCaptionEdit->text()); 740 if (m_pKey->baseCaption() != m_pBaseCaptionEdit->text()) 741 m_pKey->setBaseCaption(m_pBaseCaptionEdit->text()); 742 if (m_pKey->altGrCaption() != m_pAltGrCaptionEdit->text()) 743 m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text()); 744 if (m_pKey->shiftAltGrCaption() != m_pShiftAltGrCaptionEdit->text()) 745 m_pKey->setShiftAltGrCaption(m_pShiftAltGrCaptionEdit->text()); 738 KeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position()); 739 if (captions.m_strShift != m_pShiftCaptionEdit->text()) 740 m_pLayout->setShiftCaption(m_pKey->position(), m_pShiftCaptionEdit->text()); 741 if (captions.m_strBase != m_pBaseCaptionEdit->text()) 742 m_pLayout->setShiftCaption(m_pKey->position(), m_pBaseCaptionEdit->text()); 743 if (captions.m_strAltGr != m_pAltGrCaptionEdit->text()) 744 m_pLayout->setAltGrCaption(m_pKey->position(), m_pAltGrCaptionEdit->text()); 745 if (captions.m_strShiftAltGr != m_pShiftAltGrCaptionEdit->text()) 746 m_pLayout->setShiftAltGrCaption(m_pKey->position(), m_pShiftAltGrCaptionEdit->text()); 746 747 } 747 748 … … 758 759 if (m_pPositionEdit) 759 760 m_pPositionEdit->setText(QString::number(m_pKey->position())); 761 KeyCaptions captions = m_pLayout->keyCaptions(m_pKey->position()); 760 762 if (m_pBaseCaptionEdit) 761 m_pBaseCaptionEdit->setText( m_pKey->baseCaption());763 m_pBaseCaptionEdit->setText(captions.m_strBase); 762 764 if (m_pShiftCaptionEdit) 763 m_pShiftCaptionEdit->setText( m_pKey->shiftCaption());765 m_pShiftCaptionEdit->setText(captions.m_strShift); 764 766 if (m_pAltGrCaptionEdit) 765 m_pAltGrCaptionEdit->setText( m_pKey->altGrCaption());767 m_pAltGrCaptionEdit->setText(captions.m_strAltGr); 766 768 if (m_pShiftAltGrCaptionEdit) 767 m_pShiftAltGrCaptionEdit->setText( m_pKey->shiftAltGrCaption());769 m_pShiftAltGrCaptionEdit->setText(captions.m_strShiftAltGr); 768 770 } 769 771 … … 844 846 void UILayoutEditor::sltKeyBaseCaptionChange(const QString &strCaption) 845 847 { 846 if (!m_pKey || m_pKey->baseCaption() == strCaption) 847 return; 848 m_pKey->setBaseCaption(strCaption); 848 if (!m_pKey || !m_pLayout) 849 return; 850 if (m_pLayout->baseCaption(m_pKey->position()) == strCaption) 851 return; 852 m_pLayout->setBaseCaption(m_pKey->position(), strCaption); 849 853 emit sigKeyCaptionsEdited(m_pKey); 850 854 } … … 852 856 void UILayoutEditor::sltKeyShiftCaptionChange(const QString &strCaption) 853 857 { 854 if (!m_pKey || m_pKey->shiftCaption() == strCaption) 855 return; 856 m_pKey->setShiftCaption(strCaption); 858 if (!m_pKey || !m_pLayout) 859 return; 860 if (m_pLayout->shiftCaption(m_pKey->position()) == strCaption) 861 return; 862 m_pLayout->setShiftCaption(m_pKey->position(), strCaption); 857 863 emit sigKeyCaptionsEdited(m_pKey); 858 864 } … … 860 866 void UILayoutEditor::sltKeyAltGrCaptionChange(const QString &strCaption) 861 867 { 862 if (!m_pKey || m_pKey->altGrCaption() == strCaption) 863 return; 864 m_pKey->setAltGrCaption(strCaption); 868 if (!m_pKey || !m_pLayout) 869 return; 870 if (m_pLayout->altGrCaption(m_pKey->position()) == strCaption) 871 return; 872 m_pLayout->setAltGrCaption(m_pKey->position(), strCaption); 865 873 emit sigKeyCaptionsEdited(m_pKey); 866 874 } … … 868 876 void UILayoutEditor::sltKeyShiftAltGrCaptionChange(const QString &strCaption) 869 877 { 870 if (!m_pKey || m_pKey->shiftAltGrCaption() == strCaption) 871 return; 872 m_pKey->setShiftAltGrCaption(strCaption); 878 if (!m_pKey || !m_pLayout) 879 return; 880 if (m_pLayout->shiftAltGrCaption(m_pKey->position()) == strCaption) 881 return; 882 m_pLayout->setShiftAltGrCaption(m_pKey->position(), strCaption); 873 883 emit sigKeyCaptionsEdited(m_pKey); 874 884 } … … 1095 1105 } 1096 1106 1097 void UILayoutSelector::setLayoutList(const QStringList &layoutNames )1098 { 1099 if (!m_pLayoutListWidget )1107 void UILayoutSelector::setLayoutList(const QStringList &layoutNames, QList<QUuid> layoutUidList) 1108 { 1109 if (!m_pLayoutListWidget || layoutNames.size() != layoutUidList.size()) 1100 1110 return; 1101 1111 m_pLayoutListWidget->clear(); 1102 foreach (const QString &strLayoutName, layoutNames) 1103 m_pLayoutListWidget->addItem(strLayoutName); 1112 for (int i = 0; i < layoutNames.size(); ++i) 1113 { 1114 QListWidgetItem *pItem = new QListWidgetItem(layoutNames[i], m_pLayoutListWidget); 1115 pItem->setData(Qt::UserRole, layoutUidList[i]); 1116 m_pLayoutListWidget->addItem(pItem); 1117 } 1104 1118 } 1105 1119 … … 1148 1162 m_pLayoutListWidget = new QListWidget; 1149 1163 pLayout->addWidget(m_pLayoutListWidget); 1150 connect(m_pLayoutListWidget, &QListWidget::current TextChanged, this, &UILayoutSelector::sigLayoutSelectionChanged);1164 connect(m_pLayoutListWidget, &QListWidget::currentItemChanged, this, &UILayoutSelector::sltCurrentItemChanged); 1151 1165 1152 1166 QHBoxLayout *pButtonsLayout = new QHBoxLayout; … … 1176 1190 1177 1191 retranslateUi(); 1192 } 1193 1194 void UILayoutSelector::sltCurrentItemChanged(QListWidgetItem *pCurrent, QListWidgetItem *pPrevious) 1195 { 1196 Q_UNUSED(pPrevious); 1197 if (!pCurrent) 1198 return; 1199 emit sigLayoutSelectionChanged(pCurrent->data(Qt::UserRole).toUuid()); 1178 1200 } 1179 1201 … … 1262 1284 } 1263 1285 1264 const QString UISoftKeyboardKey::baseCaption() const1265 {1266 return m_strBaseCaption;1267 }1268 1269 void UISoftKeyboardKey::setBaseCaption(const QString &strBaseCaption)1270 {1271 m_strBaseCaption = strBaseCaption;1272 updateText();1273 }1274 1275 const QString UISoftKeyboardKey::shiftCaption() const1276 {1277 return m_strShiftCaption;1278 }1279 1280 void UISoftKeyboardKey::setShiftCaption(const QString &strShiftCaption)1281 {1282 m_strShiftCaption = strShiftCaption;1283 updateText();1284 }1285 1286 const QString UISoftKeyboardKey::altGrCaption() const1287 {1288 return m_strAltGrCaption;1289 }1290 1291 void UISoftKeyboardKey::setAltGrCaption(const QString &strAltGrCaption)1292 {1293 m_strAltGrCaption = strAltGrCaption;1294 updateText();1295 }1296 1297 const QString UISoftKeyboardKey::shiftAltGrCaption() const1298 {1299 return m_strShiftAltGrCaption;1300 }1301 1302 void UISoftKeyboardKey::setShiftAltGrCaption(const QString &strShiftAltGrCaption)1303 {1304 m_strShiftAltGrCaption = strShiftAltGrCaption;1305 updateText();1306 }1307 1308 void UISoftKeyboardKey::resetCaptions()1309 {1310 m_strBaseCaption.clear();1311 m_strShiftCaption.clear();1312 m_strAltGrCaption.clear();1313 m_strShiftAltGrCaption.clear();1314 updateText();1315 }1316 1317 const QString UISoftKeyboardKey::text() const1318 {1319 return m_strText;1320 }1321 1286 1322 1287 void UISoftKeyboardKey::setWidth(int iWidth) … … 1510 1475 } 1511 1476 1512 void UISoftKeyboardKey::updateText()1513 {1514 QPainter painter(&m_textPixmap);1515 painter.setPen(QColor(0,0,0));1516 painter.setRenderHint(QPainter::Antialiasing);1517 QFont painterFont(painter.font());1518 1519 painterFont.setPixelSize(15);1520 painterFont.setBold(true);1521 painter.setFont(painterFont);1522 QFontMetrics fontMetric = painter.fontMetrics();1523 int iSideMargin = 0.5 * fontMetric.width('X');1524 1525 int iX = 0;1526 int iY = fontMetric.height();1527 #if 01528 painter.drawText(iX + iSideMargin, iY, QString::number(m_iPosition));1529 #else1530 if (!m_strShiftCaption.isEmpty())1531 {1532 painter.drawText(iX + iSideMargin, iY, m_strShiftCaption);1533 painter.drawText(iX + iSideMargin, 2 * iY, m_strBaseCaption);1534 }1535 else1536 {1537 int iSpaceIndex = m_strBaseCaption.indexOf(" " );1538 if (iSpaceIndex == -1)1539 painter.drawText(iX + iSideMargin, iY, m_strBaseCaption);1540 else1541 {1542 painter.drawText(iX + iSideMargin, iY, m_strBaseCaption.left(iSpaceIndex));1543 painter.drawText(iX + iSideMargin, 2 * iY, m_strBaseCaption.right(m_strBaseCaption.length() - iSpaceIndex - 1));1544 }1545 }1546 1547 if (!m_strShiftAltGrCaption.isEmpty())1548 {1549 painter.drawText(keyGeometry().width() - fontMetric.width('X') - iSideMargin, iY, m_strShiftAltGrCaption);1550 painter.drawText(keyGeometry().width() - fontMetric.width('X') - iSideMargin, 2 * iY, m_strAltGrCaption);1551 }1552 else1553 painter.drawText(keyGeometry().width() - fontMetric.width('X') - iSideMargin, 2 * iY, m_strAltGrCaption);1554 #endif1555 painter.end();1556 }1557 1477 1558 1478 /********************************************************************************************************************************* … … 1563 1483 : m_fEditable(true) 1564 1484 , m_fIsFromResources(false) 1485 , m_uid(QUuid::createUuid()) 1565 1486 { 1566 1487 } … … 1663 1584 return false; 1664 1585 return true; 1586 } 1587 1588 const QString UISoftKeyboardLayout::baseCaption(int iKeyPosition) const 1589 { 1590 if (!m_keyCapMap.contains(iKeyPosition)) 1591 return QString(); 1592 return m_keyCapMap[iKeyPosition].m_strBase; 1593 } 1594 1595 void UISoftKeyboardLayout::setBaseCaption(int iKeyPosition, const QString &strBaseCaption) 1596 { 1597 m_keyCapMap[iKeyPosition].m_strBase = strBaseCaption; 1598 } 1599 1600 const QString UISoftKeyboardLayout::shiftCaption(int iKeyPosition) const 1601 { 1602 if (!m_keyCapMap.contains(iKeyPosition)) 1603 return QString(); 1604 return m_keyCapMap[iKeyPosition].m_strShift; 1605 } 1606 1607 void UISoftKeyboardLayout::setShiftCaption(int iKeyPosition, const QString &strShiftCaption) 1608 { 1609 m_keyCapMap[iKeyPosition].m_strShift = strShiftCaption; 1610 } 1611 1612 const QString UISoftKeyboardLayout::altGrCaption(int iKeyPosition) const 1613 { 1614 if (!m_keyCapMap.contains(iKeyPosition)) 1615 return QString(); 1616 return m_keyCapMap[iKeyPosition].m_strAltGr; 1617 } 1618 1619 void UISoftKeyboardLayout::setAltGrCaption(int iKeyPosition, const QString &strAltGrCaption) 1620 { 1621 m_keyCapMap[iKeyPosition].m_strAltGr = strAltGrCaption; 1622 } 1623 1624 const QString UISoftKeyboardLayout::shiftAltGrCaption(int iKeyPosition) const 1625 { 1626 if (!m_keyCapMap.contains(iKeyPosition)) 1627 return QString(); 1628 return m_keyCapMap[iKeyPosition].m_strShiftAltGr; 1629 } 1630 1631 void UISoftKeyboardLayout::setShiftAltGrCaption(int iKeyPosition, const QString &strShiftAltGrCaption) 1632 { 1633 m_keyCapMap[iKeyPosition].m_strShiftAltGr = strShiftAltGrCaption; 1634 } 1635 1636 const KeyCaptions UISoftKeyboardLayout::keyCaptions(int iKeyPosition) const 1637 { 1638 if (!m_keyCapMap.contains(iKeyPosition)) 1639 return KeyCaptions(); 1640 return m_keyCapMap[iKeyPosition]; 1641 } 1642 1643 void UISoftKeyboardLayout::setUid(const QUuid &uid) 1644 { 1645 m_uid = uid; 1646 } 1647 1648 QUuid UISoftKeyboardLayout::uid() const 1649 { 1650 return m_uid; 1651 } 1652 1653 void UISoftKeyboardLayout::drawText(int iKeyPosition, const QRect &keyGeometry, QPainter &painter) 1654 { 1655 painter.setPen(QColor(0,0,0)); 1656 painter.setRenderHint(QPainter::Antialiasing); 1657 QFont painterFont(painter.font()); 1658 1659 painterFont.setPixelSize(15); 1660 painterFont.setBold(true); 1661 painter.setFont(painterFont); 1662 QFontMetrics fontMetric = painter.fontMetrics(); 1663 int iSideMargin = 0.5 * fontMetric.width('X'); 1664 1665 int iX = 0; 1666 int iY = fontMetric.height(); 1667 #if 0 1668 Q_UNUSED(keyGeometry); 1669 painter.drawText(iX + iSideMargin, iY, QString::number(iKeyPosition)); 1670 #else 1671 const QString &strBaseCaption = baseCaption(iKeyPosition); 1672 const QString &strShiftCaption = shiftCaption(iKeyPosition); 1673 const QString &strShiftAltGrCaption = shiftAltGrCaption(iKeyPosition); 1674 const QString &strAltGrCaption = altGrCaption(iKeyPosition); 1675 1676 if (!strShiftCaption.isEmpty()) 1677 { 1678 painter.drawText(iX + iSideMargin, iY, strShiftCaption); 1679 painter.drawText(iX + iSideMargin, 2 * iY, strBaseCaption); 1680 } 1681 else 1682 { 1683 int iSpaceIndex = strBaseCaption.indexOf(" " ); 1684 if (iSpaceIndex == -1) 1685 painter.drawText(iX + iSideMargin, iY, strBaseCaption); 1686 else 1687 { 1688 painter.drawText(iX + iSideMargin, iY, strBaseCaption.left(iSpaceIndex)); 1689 painter.drawText(iX + iSideMargin, 2 * iY, strBaseCaption.right(strBaseCaption.length() - iSpaceIndex - 1)); 1690 } 1691 } 1692 1693 if (!strShiftAltGrCaption.isEmpty()) 1694 { 1695 painter.drawText(keyGeometry.width() - fontMetric.width('X') - iSideMargin, iY, strShiftAltGrCaption); 1696 painter.drawText(keyGeometry.width() - fontMetric.width('X') - iSideMargin, 2 * iY, strAltGrCaption); 1697 } 1698 else 1699 painter.drawText(keyGeometry.width() - fontMetric.width('X') - iSideMargin, 2 * iY, strAltGrCaption); 1700 #endif 1665 1701 } 1666 1702 … … 1767 1803 painter.drawPolygon(key.polygon()); 1768 1804 1769 key.m_textPixmap.play(&painter);1805 m_pCurrentKeyboardLayout->drawText(key.position(), key.keyGeometry(), painter); 1770 1806 1771 1807 if (key.type() != UIKeyType_Ordinary) … … 1904 1940 UISoftKeyboardKey &key = keys[j]; 1905 1941 xmlWriter.writeTextElement("position", QString::number(key.position())); 1906 xmlWriter.writeTextElement("basecaption", key.baseCaption());1907 xmlWriter.writeTextElement("shiftcaption", key.shiftCaption());1908 xmlWriter.writeTextElement("altgrcaption", key.altGrCaption());1909 xmlWriter.writeTextElement("shiftaltgrcaption", key.shiftAltGrCaption());1942 xmlWriter.writeTextElement("basecaption", m_pCurrentKeyboardLayout->baseCaption(key.position())); 1943 xmlWriter.writeTextElement("shiftcaption", m_pCurrentKeyboardLayout->shiftCaption(key.position())); 1944 xmlWriter.writeTextElement("altgrcaption", m_pCurrentKeyboardLayout->altGrCaption(key.position())); 1945 xmlWriter.writeTextElement("shiftaltgrcaption", m_pCurrentKeyboardLayout->shiftAltGrCaption(key.position())); 1910 1946 xmlWriter.writeEndElement(); 1911 1947 } … … 1933 1969 newLayout.setIsFromResources(false); 1934 1970 newLayout.setSourceFilePath(QString()); 1971 newLayout.setUid(QUuid::createUuid()); 1935 1972 addLayout(newLayout); 1936 1973 } … … 2029 2066 /* Assuming the key captions are changed for the current layout: */ 2030 2067 KeyCaptions newCaptions; 2031 newCaptions.m_strBase = pKey->baseCaption();2032 newCaptions.m_strShift = pKey->shiftCaption();2033 newCaptions.m_strAltGr = pKey->altGrCaption();2034 newCaptions.m_strShiftAltGr = pKey->shiftAltGrCaption();2068 // newCaptions.m_strBase = pKey->baseCaption(); 2069 // newCaptions.m_strShift = pKey->shiftCaption(); 2070 // newCaptions.m_strAltGr = pKey->altGrCaption(); 2071 // newCaptions.m_strShiftAltGr = pKey->shiftAltGrCaption(); 2035 2072 m_pCurrentKeyboardLayout->updateKeyCaptions(pKey->position(), newCaptions); 2036 2073 } … … 2151 2188 { 2152 2189 UISoftKeyboardLayout *pLayout = findLayoutByName(strLayoutName); 2190 if (!pLayout) 2191 return; 2192 setCurrentLayout(pLayout); 2193 } 2194 2195 void UISoftKeyboardWidget::setCurrentLayout(const QUuid &layoutUid) 2196 { 2197 UISoftKeyboardLayout *pLayout = findLayoutByUid(layoutUid); 2153 2198 if (!pLayout) 2154 2199 return; … … 2396 2441 emit sigCurrentLayoutChange(); 2397 2442 2398 const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->keyCapMap();2399 2400 2443 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid()); 2401 2444 if (!pPhysicalLayout) 2402 2445 return; 2403 2446 2404 /* Update the key captions: */2405 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->rows();2406 for (int i = 0; i < rows.size(); ++i)2407 {2408 QVector<UISoftKeyboardKey> &keys = rows[i].keys();2409 for (int j = 0; j < keys.size(); ++j)2410 {2411 UISoftKeyboardKey &key = keys[j];2412 if (!keyCapMap.contains(key.position()))2413 {2414 key.resetCaptions();2415 continue;2416 }2417 const KeyCaptions &captions = keyCapMap.value(key.position());2418 key.setBaseCaption(captions.m_strBase);2419 key.setShiftCaption(captions.m_strShift);2420 key.setAltGrCaption(captions.m_strAltGr);2421 key.setShiftAltGrCaption(captions.m_strShiftAltGr);2422 }2423 }2424 2447 update(); 2425 2448 } … … 2430 2453 { 2431 2454 if (m_layouts[i].name() == strName) 2455 return &(m_layouts[i]); 2456 } 2457 return 0; 2458 } 2459 2460 UISoftKeyboardLayout *UISoftKeyboardWidget::findLayoutByUid(const QUuid &uid) 2461 { 2462 for (int i = 0; i < m_layouts.size(); ++i) 2463 { 2464 if (m_layouts[i].uid() == uid) 2432 2465 return &(m_layouts[i]); 2433 2466 } … … 2462 2495 } 2463 2496 return layoutNames; 2497 } 2498 2499 QList<QUuid> UISoftKeyboardWidget::layoutUidList() const 2500 { 2501 QList<QUuid> layoutUids; 2502 foreach (const UISoftKeyboardLayout &layout, m_layouts) 2503 layoutUids << layout.uid(); 2504 return layoutUids; 2464 2505 } 2465 2506 … … 2956 2997 } 2957 2998 2958 void UISoftKeyboard::sltLayoutSelectionChanged(const Q String &strLayoutName)2999 void UISoftKeyboard::sltLayoutSelectionChanged(const QUuid &layoutUid) 2959 3000 { 2960 3001 if (!m_pKeyboardWidget) 2961 3002 return; 2962 m_pKeyboardWidget->setCurrentLayout( strLayoutName);3003 m_pKeyboardWidget->setCurrentLayout(layoutUid); 2963 3004 if (m_pLayoutSelector && m_pKeyboardWidget->currentLayout()) 2964 3005 m_pLayoutSelector->setCurrentLayoutIsEditable(m_pKeyboardWidget->currentLayout()->editable()); … … 3218 3259 if (!m_pKeyboardWidget || !m_pLayoutSelector) 3219 3260 return; 3220 m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList() );3261 m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList(), m_pKeyboardWidget->layoutUidList()); 3221 3262 m_pLayoutSelector->setCurrentLayout(m_pKeyboardWidget->currentLayout() ? m_pKeyboardWidget->currentLayout()->name() : QString()); 3222 3263 } -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r79356 r79385 70 70 /** Handles the signal we get from the layout selector widget. 71 71 * Selection changed is forwarded to the keyboard widget. */ 72 void sltLayoutSelectionChanged(const Q String &strLayoutName);72 void sltLayoutSelectionChanged(const QUuid &layoutUid); 73 73 /** Handles the signal we get from the keyboard widget. */ 74 74 void sltCurentLayoutChanged(); -
trunk/src/VBox/Frontends/VirtualBox/xml/german.xml
r79357 r79385 3 3 <name>German</name> 4 4 <nativename>Deutsch</nativename> 5 <id>e45b1a6f-8b87-424f-a437-c9cec6715311</id> 5 6 <physicallayoutid>{d41a0398-92a0-4ba4-beba-3d91a5dd0e50}</physicallayoutid> 6 7 <key> 7 8 <position>110</position> 8 <basecaption>Esc </basecaption>9 <basecaption>Escx</basecaption> 9 10 <shiftcaption></shiftcaption> 10 11 <altgrcaption></altgrcaption> -
trunk/src/VBox/Frontends/VirtualBox/xml/greek.xml
r79325 r79385 2 2 <layout> 3 3 <name>Greek</name> 4 <id>878fcc44-59bf-4fd9-a73e-fc95b7652281</id> 4 5 <physicallayoutid>{368efa94-3744-48c5-9d5a-59c2f15fe5ec}</physicallayoutid> 5 6 <key> … … 159 160 <key> 160 161 <position>7</position> 161 <basecaption></basecaption>162 <shiftcaption></shiftcaption>163 <altgrcaption></altgrcaption>164 <shiftaltgrcaption></shiftaltgrcaption>165 </key>166 <key>167 <position>8</position>168 162 <basecaption>6</basecaption> 169 163 <shiftcaption>^</shiftcaption> … … 172 166 </key> 173 167 <key> 174 <position> 9</position>168 <position>8</position> 175 169 <basecaption>7</basecaption> 176 170 <shiftcaption>&</shiftcaption> … … 179 173 </key> 180 174 <key> 181 <position> 10</position>175 <position>9</position> 182 176 <basecaption>8</basecaption> 183 177 <shiftcaption>*</shiftcaption> … … 186 180 </key> 187 181 <key> 188 <position>1 1</position>182 <position>10</position> 189 183 <basecaption>9</basecaption> 190 184 <shiftcaption>(</shiftcaption> … … 193 187 </key> 194 188 <key> 195 <position>1 2</position>189 <position>11</position> 196 190 <basecaption>0</basecaption> 197 191 <shiftcaption>)</shiftcaption> … … 200 194 </key> 201 195 <key> 202 <position>1 3</position>196 <position>12</position> 203 197 <basecaption>-</basecaption> 204 198 <shiftcaption>_</shiftcaption> 199 <altgrcaption></altgrcaption> 200 <shiftaltgrcaption></shiftaltgrcaption> 201 </key> 202 <key> 203 <position>13</position> 204 <basecaption>=</basecaption> 205 <shiftcaption>+</shiftcaption> 205 206 <altgrcaption></altgrcaption> 206 207 <shiftaltgrcaption></shiftaltgrcaption> -
trunk/src/VBox/Frontends/VirtualBox/xml/us.xml
r79317 r79385 2 2 <layout> 3 3 <name>US</name> 4 <id>25867c1e-0455-4303-bf76-1c3ae4cca042</id> 4 5 <physicallayoutid>{368efa94-3744-48c5-9d5a-59c2f15fe5ec}</physicallayoutid> 5 6 <key> … … 159 160 <key> 160 161 <position>7</position> 161 <basecaption></basecaption>162 <shiftcaption></shiftcaption>163 <altgrcaption></altgrcaption>164 <shiftaltgrcaption></shiftaltgrcaption>165 </key>166 <key>167 <position>8</position>168 162 <basecaption>6</basecaption> 169 163 <shiftcaption>^</shiftcaption> … … 172 166 </key> 173 167 <key> 174 <position> 9</position>168 <position>8</position> 175 169 <basecaption>7</basecaption> 176 170 <shiftcaption>&</shiftcaption> … … 179 173 </key> 180 174 <key> 181 <position> 10</position>175 <position>9</position> 182 176 <basecaption>8</basecaption> 183 177 <shiftcaption>*</shiftcaption> … … 186 180 </key> 187 181 <key> 188 <position>1 1</position>182 <position>10</position> 189 183 <basecaption>9</basecaption> 190 184 <shiftcaption>(</shiftcaption> … … 193 187 </key> 194 188 <key> 195 <position>1 2</position>189 <position>11</position> 196 190 <basecaption>0</basecaption> 197 191 <shiftcaption>)</shiftcaption> … … 200 194 </key> 201 195 <key> 202 <position>1 3</position>196 <position>12</position> 203 197 <basecaption>-</basecaption> 204 198 <shiftcaption>_</shiftcaption> 199 <altgrcaption></altgrcaption> 200 <shiftaltgrcaption></shiftaltgrcaption> 201 </key> 202 <key> 203 <position>13</position> 204 <basecaption>=</basecaption> 205 <shiftcaption>+</shiftcaption> 205 206 <altgrcaption></altgrcaption> 206 207 <shiftaltgrcaption></shiftaltgrcaption> -
trunk/src/VBox/Frontends/VirtualBox/xml/us_international.xml
r79317 r79385 2 2 <layout> 3 3 <name>US International</name> 4 <id>3c7b7be7-4d2a-4f65-a21e-208ba2e4ecaf</id> 4 5 <physicallayoutid>{368efa94-3744-48c5-9d5a-59c2f15fe5ec}</physicallayoutid> 5 6 <key>
Note:
See TracChangeset
for help on using the changeset viewer.