Changeset 79248 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 19, 2019 4:05:53 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox_xml.qrc
r79172 r79248 5 5 <file alias="us_international.xml">xml/us_international.xml</file> 6 6 <file alias="german.xml">xml/german.xml</file> 7 <file alias="us.xml">xml/us.xml</file> 7 8 </qresource> 8 9 </RCC> -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79212 r79248 41 41 #include "UIExtraDataManager.h" 42 42 #include "UIIconPool.h" 43 #include "UIMessageCenter.h" 43 44 #include "UIModalWindowManager.h" 44 45 #include "UISession.h" … … 143 144 private slots: 144 145 145 void sltKeyBaseCaptionChange( );146 void sltKeyShiftCaptionChange( );147 void sltKeyAltGrCaptionChange( );146 void sltKeyBaseCaptionChange(const QString &strCaption); 147 void sltKeyShiftCaptionChange(const QString &strCaption); 148 void sltKeyAltGrCaptionChange(const QString &strCaption); 148 149 void sltPhysicalLayoutChanged(); 150 void sltLayoutNameChanged(const QString &strCaption); 149 151 150 152 private: … … 195 197 void sigSaveLayout(); 196 198 void sigCopyLayout(); 199 void sigDeleteLayout(); 197 200 void sigLayoutSelectionChanged(const QString &strSelectedLayoutName); 198 201 void sigShowLayoutEditor(); … … 204 207 void setLayoutList(const QStringList &layoutNames); 205 208 void setCurrentLayout(const QString &strLayoutName); 209 void setCurrentLayoutIsEditable(bool fEditable); 206 210 207 211 protected: … … 221 225 QToolButton *m_pCopyLayoutButton; 222 226 QToolButton *m_pSaveLayoutButton; 227 QToolButton *m_pDeleteLayoutButton; 223 228 QLabel *m_pTitleLabel; 224 229 QToolButton *m_pCloseButton; … … 364 369 public: 365 370 366 UISoftKeyboardLayout(){} 367 368 void setName(const QString &strName) 369 { 370 m_strName = strName; 371 } 372 373 void updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions) 374 { 375 if (!m_keyCapMap.contains(iKeyPosition)) 376 return; 377 m_keyCapMap[iKeyPosition] = newCaptions; 378 } 379 380 const QString &name() const 381 { 382 return m_strName; 383 } 371 UISoftKeyboardLayout(); 372 373 void setName(const QString &strName); 374 const QString &name() const; 375 376 void setSourceFilePath(const QString& strSourceFilePath); 377 const QString& sourceFilePath() const; 378 379 void setIsFromResources(bool fIsFromResources); 380 bool isFromResources() const; 381 382 void updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions); 383 384 void setEditable(bool fEditable); 385 bool editable() const; 386 387 void setPhysicalLayoutUuid(const QUuid &uuid); 388 const QUuid &physicalLayoutUuid() const; 389 390 void setKeyCapMap(const QMap<int, KeyCaptions> &keyCapMap); 391 QMap<int, KeyCaptions> &keyCapMap(); 392 const QMap<int, KeyCaptions> &keyCapMap() const; 393 bool operator==(const UISoftKeyboardLayout &otherLayout); 394 395 private: 384 396 385 397 /** The UUID of the physical layout used by this layout. */ … … 390 402 QMap<int, KeyCaptions> m_keyCapMap; 391 403 392 private:393 394 404 QString m_strName; 405 QString m_strSourceFilePath; 406 bool m_fEditable; 407 bool m_fIsFromResources; 395 408 }; 396 409 … … 432 445 QStringList layoutNameList() const; 433 446 const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts() const; 434 447 void deleteCurrentLayout(); 435 448 void toggleEditMode(bool fIsEditMode); 436 449 /** Is called when the captions in UISoftKeyboardKey is changed and forward this changes to 437 450 * corresponding UISoftKeyboardLayout */ 438 451 void updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey); 439 void addLayout(const UISoftKeyboardLayout &newLayout);440 452 void saveCurentLayoutToFile(); 453 void copyCurentLayout(); 441 454 442 455 protected: … … 455 468 private: 456 469 457 void setNewMinimumSize(const QSize &size); 458 void setInitialSize(int iWidth, int iHeight); 470 void addLayout(const UISoftKeyboardLayout &newLayout); 471 void setNewMinimumSize(const QSize &size); 472 void setInitialSize(int iWidth, int iHeight); 459 473 /** Searches for the key which contains the position of the @p pEvent and returns it if found. */ 460 474 UISoftKeyboardKey *keyUnderMouse(QMouseEvent *pEvent); … … 620 634 if (m_pKey == pKey) 621 635 return; 636 /* First apply the pending changes to the key that has been edited: */ 637 if (m_pKey) 638 { 639 if (m_pKey->shiftCaption() != m_pShiftCaptionEdit->text()) 640 m_pKey->setShiftCaption(m_pShiftCaptionEdit->text()); 641 if (m_pKey->baseCaption() != m_pBaseCaptionEdit->text()) 642 m_pKey->setBaseCaption(m_pBaseCaptionEdit->text()); 643 if (m_pKey->altGrCaption() != m_pAltGrCaptionEdit->text()) 644 m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text()); 645 } 646 622 647 m_pKey = pKey; 623 648 if (m_pSelectedKeyGroupBox) … … 651 676 if (m_pPhysicalLayoutCombo && m_pLayout) 652 677 { 653 int iIndex = m_pPhysicalLayoutCombo->findData(m_pLayout-> m_physicalLayoutUuid);678 int iIndex = m_pPhysicalLayoutCombo->findData(m_pLayout->physicalLayoutUuid()); 654 679 if (iIndex != -1) 655 680 m_pPhysicalLayoutCombo->setCurrentIndex(iIndex); … … 693 718 } 694 719 695 void UILayoutEditor::sltKeyBaseCaptionChange( )696 { 697 if (!m_pKey || !m_pBaseCaptionEdit)698 return; 699 m_pKey->setBaseCaption( m_pBaseCaptionEdit->text());720 void UILayoutEditor::sltKeyBaseCaptionChange(const QString &strCaption) 721 { 722 if (!m_pKey || m_pKey->baseCaption() == strCaption) 723 return; 724 m_pKey->setBaseCaption(strCaption); 700 725 emit sigKeyCaptionsEdited(m_pKey); 701 726 } 702 727 703 void UILayoutEditor::sltKeyShiftCaptionChange( )704 { 705 if (!m_pKey || !m_pShiftCaptionEdit)706 return; 707 m_pKey->setShiftCaption( m_pShiftCaptionEdit->text());728 void UILayoutEditor::sltKeyShiftCaptionChange(const QString &strCaption) 729 { 730 if (!m_pKey || m_pKey->shiftCaption() == strCaption) 731 return; 732 m_pKey->setShiftCaption(strCaption); 708 733 emit sigKeyCaptionsEdited(m_pKey); 709 734 } 710 735 711 void UILayoutEditor::sltKeyAltGrCaptionChange( )712 { 713 if (!m_pKey || !m_pAltGrCaptionEdit)714 return; 715 m_pKey->setAltGrCaption( m_pAltGrCaptionEdit->text());736 void UILayoutEditor::sltKeyAltGrCaptionChange(const QString &strCaption) 737 { 738 if (!m_pKey || m_pKey->altGrCaption() == strCaption) 739 return; 740 m_pKey->setAltGrCaption(strCaption); 716 741 emit sigKeyCaptionsEdited(m_pKey); 717 742 } … … 723 748 QUuid currentData = m_pPhysicalLayoutCombo->currentData().toUuid(); 724 749 if (!currentData.isNull()) 725 m_pLayout->m_physicalLayoutUuid = currentData; 750 m_pLayout->setPhysicalLayoutUuid(currentData); 751 emit sigLayoutEdited(); 752 } 753 754 void UILayoutEditor::sltLayoutNameChanged(const QString &strName) 755 { 756 if (!m_pLayout || m_pLayout->name() == strName) 757 return; 758 m_pLayout->setName(strName); 726 759 emit sigLayoutEdited(); 727 760 } … … 739 772 m_pGoBackButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}"); 740 773 m_pEditorLayout->addWidget(m_pGoBackButton, 0, 0, 1, 1); 741 connect(m_pGoBackButton, &QToolButton:: pressed, this, &UILayoutEditor::sigGoBackButton);774 connect(m_pGoBackButton, &QToolButton::clicked, this, &UILayoutEditor::sigGoBackButton); 742 775 pTitleLayout->addWidget(m_pGoBackButton); 743 776 pTitleLayout->addStretch(2); … … 752 785 m_pEditorLayout->addWidget(m_pLayoutNameLabel, 2, 0, 1, 1); 753 786 m_pEditorLayout->addWidget(m_pLayoutNameEdit, 2, 1, 1, 1); 754 connect(m_pLayoutNameEdit, &QLineEdit:: editingFinished, this, &UILayoutEditor::sigLayoutEdited);787 connect(m_pLayoutNameEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltLayoutNameChanged); 755 788 756 789 … … 814 847 pCaptionEditorLayout->addWidget(m_pBaseCaptionLabel, 0, 0); 815 848 pCaptionEditorLayout->addWidget(m_pBaseCaptionEdit, 0, 1); 816 connect(m_pBaseCaptionEdit, &QLineEdit:: editingFinished, this, &UILayoutEditor::sltKeyBaseCaptionChange);849 connect(m_pBaseCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyBaseCaptionChange); 817 850 818 851 m_pShiftCaptionLabel = new QLabel; … … 821 854 pCaptionEditorLayout->addWidget(m_pShiftCaptionLabel, 1, 0); 822 855 pCaptionEditorLayout->addWidget(m_pShiftCaptionEdit, 1, 1); 823 connect(m_pShiftCaptionEdit, &QLineEdit:: editingFinished, this, &UILayoutEditor::sltKeyShiftCaptionChange);856 connect(m_pShiftCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyShiftCaptionChange); 824 857 825 858 m_pAltGrCaptionLabel = new QLabel; … … 828 861 pCaptionEditorLayout->addWidget(m_pAltGrCaptionLabel, 2, 0); 829 862 pCaptionEditorLayout->addWidget(m_pAltGrCaptionEdit, 2, 1); 830 connect(m_pAltGrCaptionEdit, &QLineEdit:: editingFinished, this, &UILayoutEditor::sltKeyAltGrCaptionChange);863 connect(m_pAltGrCaptionEdit, &QLineEdit::textChanged, this, &UILayoutEditor::sltKeyAltGrCaptionChange); 831 864 832 865 QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); … … 863 896 , m_pCopyLayoutButton(0) 864 897 , m_pSaveLayoutButton(0) 898 , m_pDeleteLayoutButton(0) 865 899 , m_pTitleLabel(0) 866 900 , m_pCloseButton(0) … … 885 919 return; 886 920 m_pLayoutListWidget->setCurrentItem(pItem); 921 } 922 923 void UILayoutSelector::setCurrentLayoutIsEditable(bool fEditable) 924 { 925 if (m_pEditLayoutButton) 926 m_pEditLayoutButton->setEnabled(fEditable); 927 if (m_pSaveLayoutButton) 928 m_pSaveLayoutButton->setEnabled(fEditable); 929 if (m_pDeleteLayoutButton) 930 m_pDeleteLayoutButton->setEnabled(fEditable); 887 931 } 888 932 … … 902 946 if (m_pEditLayoutButton) 903 947 m_pEditLayoutButton->setToolTip(UISoftKeyboard::tr("Edit the selected layout")); 948 if (m_pDeleteLayoutButton) 949 m_pDeleteLayoutButton->setToolTip(UISoftKeyboard::tr("Delete the selected layout")); 904 950 if (m_pCopyLayoutButton) 905 951 m_pCopyLayoutButton->setToolTip(UISoftKeyboard::tr("Copy the selected layout")); … … 924 970 m_pCloseButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_DialogCancel)); 925 971 m_pCloseButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}"); 926 connect(m_pCloseButton, &QToolButton:: pressed, this, &UILayoutSelector::sigCloseLayoutList);972 connect(m_pCloseButton, &QToolButton::clicked, this, &UILayoutSelector::sigCloseLayoutList); 927 973 pTitleLayout->addWidget(m_pCloseButton); 928 974 pTitleLayout->addStretch(2); … … 941 987 m_pEditLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_settings_16px.png")); 942 988 pButtonsLayout->addWidget(m_pEditLayoutButton); 943 connect(m_pEditLayoutButton, &QToolButton:: pressed, this, &UILayoutSelector::sigShowLayoutEditor);989 connect(m_pEditLayoutButton, &QToolButton::clicked, this, &UILayoutSelector::sigShowLayoutEditor); 944 990 945 991 m_pCopyLayoutButton = new QToolButton; 946 992 m_pCopyLayoutButton->setIcon(UIIconPool::iconSet(":/vm_clone_16px.png")); 947 993 pButtonsLayout->addWidget(m_pCopyLayoutButton); 948 connect(m_pCopyLayoutButton, &QToolButton:: pressed, this, &UILayoutSelector::sigCopyLayout);994 connect(m_pCopyLayoutButton, &QToolButton::clicked, this, &UILayoutSelector::sigCopyLayout); 949 995 950 996 m_pSaveLayoutButton = new QToolButton; 951 997 m_pSaveLayoutButton->setIcon(UIIconPool::iconSet(":/vm_save_state_16px.png")); 952 998 pButtonsLayout->addWidget(m_pSaveLayoutButton); 953 connect(m_pSaveLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigSaveLayout); 954 999 connect(m_pSaveLayoutButton, &QToolButton::clicked, this, &UILayoutSelector::sigSaveLayout); 1000 1001 m_pDeleteLayoutButton = new QToolButton; 1002 m_pDeleteLayoutButton->setIcon(UIIconPool::iconSet(":/file_manager_delete_16px.png")); 1003 pButtonsLayout->addWidget(m_pDeleteLayoutButton); 1004 connect(m_pDeleteLayoutButton, &QToolButton::clicked, this, &UILayoutSelector::sigDeleteLayout); 955 1005 956 1006 pButtonsLayout->addStretch(2); … … 1258 1308 m_strText += QString("%1\n").arg(m_strAltGrCaption); 1259 1309 } 1310 1311 /********************************************************************************************************************************* 1312 * UISoftKeyboardLayout implementation. * 1313 *********************************************************************************************************************************/ 1314 1315 UISoftKeyboardLayout::UISoftKeyboardLayout() 1316 : m_fEditable(true) 1317 , m_fIsFromResources(false) 1318 { 1319 } 1320 1321 void UISoftKeyboardLayout::updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions) 1322 { 1323 if (!m_keyCapMap.contains(iKeyPosition)) 1324 return; 1325 m_keyCapMap[iKeyPosition] = newCaptions; 1326 } 1327 1328 void UISoftKeyboardLayout::setSourceFilePath(const QString& strSourceFilePath) 1329 { 1330 m_strSourceFilePath = strSourceFilePath; 1331 } 1332 1333 const QString& UISoftKeyboardLayout::sourceFilePath() const 1334 { 1335 return m_strSourceFilePath; 1336 } 1337 1338 void UISoftKeyboardLayout::setIsFromResources(bool fIsFromResources) 1339 { 1340 m_fIsFromResources = fIsFromResources; 1341 } 1342 1343 bool UISoftKeyboardLayout::isFromResources() const 1344 { 1345 return m_fIsFromResources; 1346 } 1347 1348 void UISoftKeyboardLayout::setName(const QString &strName) 1349 { 1350 m_strName = strName; 1351 } 1352 1353 const QString &UISoftKeyboardLayout::name() const 1354 { 1355 return m_strName; 1356 } 1357 1358 void UISoftKeyboardLayout::setEditable(bool fEditable) 1359 { 1360 m_fEditable = fEditable; 1361 } 1362 1363 bool UISoftKeyboardLayout::editable() const 1364 { 1365 return m_fEditable; 1366 } 1367 1368 void UISoftKeyboardLayout::setPhysicalLayoutUuid(const QUuid &uuid) 1369 { 1370 m_physicalLayoutUuid = uuid; 1371 } 1372 1373 const QUuid &UISoftKeyboardLayout::physicalLayoutUuid() const 1374 { 1375 return m_physicalLayoutUuid; 1376 } 1377 1378 void UISoftKeyboardLayout::setKeyCapMap(const QMap<int, KeyCaptions> &keyCapMap) 1379 { 1380 m_keyCapMap = keyCapMap; 1381 } 1382 1383 QMap<int, KeyCaptions> &UISoftKeyboardLayout::keyCapMap() 1384 { 1385 return m_keyCapMap; 1386 } 1387 1388 const QMap<int, KeyCaptions> &UISoftKeyboardLayout::keyCapMap() const 1389 { 1390 return m_keyCapMap; 1391 } 1392 1393 bool UISoftKeyboardLayout::operator==(const UISoftKeyboardLayout &otherLayout) 1394 { 1395 if (m_strName != otherLayout.m_strName) 1396 return false; 1397 if (m_physicalLayoutUuid != otherLayout.m_physicalLayoutUuid) 1398 return false; 1399 if (m_fEditable != otherLayout.m_fEditable) 1400 return false; 1401 if (m_strSourceFilePath != otherLayout.m_strSourceFilePath) 1402 return false; 1403 if (m_fIsFromResources != otherLayout.m_fIsFromResources) 1404 return false; 1405 return true; 1406 } 1407 1260 1408 1261 1409 /********************************************************************************************************************************* … … 1320 1468 return; 1321 1469 1322 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout-> m_physicalLayoutUuid);1470 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid()); 1323 1471 if (!pPhysicalLayout) 1324 1472 return; … … 1385 1533 handleKeyPress(m_pKeyPressed); 1386 1534 else if (m_enmMode == Mode_LayoutEdit) 1387 {1388 /* If the editor is shown already for another key clicking away accepts the entered text: */1389 if (m_pKeyBeingEdited && m_pKeyBeingEdited != m_pKeyUnderMouse)1390 {1391 //printf("farkli %p\n", m_pKeyBeingEdited);1392 }1393 1535 setKeyBeingEdited(m_pKeyUnderMouse); 1394 // if (m_pKeyBeingEdited && m_pLayoutEditor)1395 // m_pLayoutEditor->setText(m_pKeyBeingEdited->keyCap());1396 }1397 1536 update(); 1398 1537 } … … 1430 1569 void UISoftKeyboardWidget::saveCurentLayoutToFile() 1431 1570 { 1571 if (!m_pCurrentKeyboardLayout) 1572 return; 1573 1432 1574 QString strHomeFolder = vboxGlobal().homeFolder(); 1433 1575 QDir dir(strHomeFolder); … … 1446 1588 dialog.setWindowModality(Qt::WindowModal); 1447 1589 dialog.setWindowTitle(UISoftKeyboard::tr("Provide a file name")); 1448 dialog.setLabelText(QString("%1 %2").arg(UISoftKeyboard::tr("The File will be saved under:\n")).arg(strHomeFolder)); 1590 dialog.setTextValue(m_pCurrentKeyboardLayout->name()); 1591 dialog.setLabelText(QString("%1 %2").arg(UISoftKeyboard::tr("The file will be saved under:\n")).arg(strHomeFolder)); 1449 1592 if (dialog.exec() == QDialog::Rejected) 1450 1593 return; … … 1456 1599 } 1457 1600 1458 if (!m_pCurrentKeyboardLayout) 1459 return; 1460 1461 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid); 1601 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid()); 1462 1602 if (!pPhysicalLayout) 1463 1603 { … … 1471 1611 strFileName = strHomeFolder + QString(QDir::separator()) + strFileName; 1472 1612 QFile xmlFile(strFileName); 1473 if (!xmlFile.open(QIODevice::WriteOnly ))1613 if (!xmlFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) 1474 1614 { 1475 1615 sigStatusBarMessage("The layout file could not be saved"); … … 1507 1647 1508 1648 xmlFile.close(); 1509 1649 m_pCurrentKeyboardLayout->setSourceFilePath(strFileName); 1510 1650 sigStatusBarMessage(QString("%1 %2").arg(strFileName).arg(UISoftKeyboard::tr(" is saved"))); 1651 } 1652 1653 void UISoftKeyboardWidget::copyCurentLayout() 1654 { 1655 UISoftKeyboardLayout newLayout(*(m_pCurrentKeyboardLayout)); 1656 QString strNewName = QString("%1-%2").arg(newLayout.name()).arg(tr("Copy")); 1657 newLayout.setName(strNewName); 1658 newLayout.setEditable(true); 1659 newLayout.setIsFromResources(false); 1660 newLayout.setSourceFilePath(QString()); 1661 addLayout(newLayout); 1662 } 1663 1664 void UISoftKeyboardWidget::deleteCurrentLayout() 1665 { 1666 if (!m_pCurrentKeyboardLayout || !m_pCurrentKeyboardLayout->editable() || m_pCurrentKeyboardLayout->isFromResources()) 1667 return; 1668 /* Make sure we have at least one layout. */ 1669 if (m_layouts.size() <= 1) 1670 return; 1671 1672 int iIndex = m_layouts.indexOf(*(m_pCurrentKeyboardLayout)); 1673 if (iIndex == -1) 1674 return; 1675 1676 QDir fileToDelete; 1677 QString strFilePath(m_pCurrentKeyboardLayout->sourceFilePath()); 1678 bool fFileExists = fileToDelete.exists(strFilePath); 1679 1680 if (fFileExists) 1681 { 1682 if (!msgCenter().questionBinary(this, MessageType_Question, 1683 QString(UISoftKeyboard::tr("This will delete the keyboard layout file as well, Proceed?")), 1684 0 /* auto-confirm id */, 1685 QString("Delete") /* ok button text */, 1686 QString() /* cancel button text */, 1687 false /* ok button by default? */)) 1688 return; 1689 } 1690 1691 m_layouts.removeAt(iIndex); 1692 setCurrentLayout(&(m_layouts[0])); 1693 /* It might be that the layout copied but not yet saved into a file: */ 1694 if (fFileExists) 1695 { 1696 if (fileToDelete.remove(strFilePath)) 1697 sigStatusBarMessage(QString("%1 %2 %3").arg(UISoftKeyboard::tr("The file ")).arg(strFilePath).arg(UISoftKeyboard::tr(" has been deleted"))); 1698 else 1699 sigStatusBarMessage(QString("%1 %2 %3").arg(UISoftKeyboard::tr("Deleting the file ")).arg(strFilePath).arg(UISoftKeyboard::tr(" has failed"))); 1700 } 1511 1701 } 1512 1702 … … 1547 1737 return; 1548 1738 1549 if (m_pCurrentKeyboardLayout-> m_physicalLayoutUuid== m_physicalLayouts[iIndex].m_uId)1550 return; 1551 m_pCurrentKeyboardLayout-> m_physicalLayoutUuid = m_physicalLayouts[iIndex].m_uId;1739 if (m_pCurrentKeyboardLayout->physicalLayoutUuid() == m_physicalLayouts[iIndex].m_uId) 1740 return; 1741 m_pCurrentKeyboardLayout->setPhysicalLayoutUuid(m_physicalLayouts[iIndex].m_uId); 1552 1742 update(); 1553 1743 } … … 1575 1765 if (!m_pCurrentKeyboardLayout) 1576 1766 return 0; 1577 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout-> m_physicalLayoutUuid);1767 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid()); 1578 1768 if (!pPhysicalLayout) 1579 1769 return 0; … … 1737 1927 } 1738 1928 1739 bool UISoftKeyboardWidget::loadKeyboardLayout(const QString &strLayout Name)1740 { 1741 if (strLayout Name.isEmpty())1929 bool UISoftKeyboardWidget::loadKeyboardLayout(const QString &strLayoutFileName) 1930 { 1931 if (strLayoutFileName.isEmpty()) 1742 1932 return false; 1743 1933 1744 1934 UIKeyboardLayoutReader keyboardLayoutReader; 1745 1935 1746 if (!keyboardLayoutReader.parseFile(strLayout Name))1936 if (!keyboardLayoutReader.parseFile(strLayoutFileName)) 1747 1937 return false; 1748 1938 … … 1754 1944 m_layouts.append(UISoftKeyboardLayout()); 1755 1945 UISoftKeyboardLayout &newLayout = m_layouts.back(); 1756 newLayout. m_physicalLayoutUuid = pPhysicalLayout->m_uId;1946 newLayout.setPhysicalLayoutUuid(pPhysicalLayout->m_uId); 1757 1947 newLayout.setName(keyboardLayoutReader.name()); 1758 newLayout.m_keyCapMap = keyboardLayoutReader.keyCapMap(); 1948 newLayout.setSourceFilePath(strLayoutFileName); 1949 newLayout.setKeyCapMap(keyboardLayoutReader.keyCapMap()); 1759 1950 return true; 1760 1951 } … … 1786 1977 QStringList keyboardLayoutNames; 1787 1978 keyboardLayoutNames << ":/us_international.xml" 1788 <<":/german.xml"; 1979 <<":/german.xml" 1980 << ":/us.xml"; 1981 1982 foreach (const QString &strName, keyboardLayoutNames) 1983 loadKeyboardLayout(strName); 1984 /* Mark the layouts we load from the resources as non-editable: */ 1985 for (int i = 0; i < m_layouts.size(); ++i) 1986 { 1987 m_layouts[i].setEditable(false); 1988 m_layouts[i].setIsFromResources(true); 1989 } 1990 keyboardLayoutNames.clear(); 1789 1991 /* Add keyboard layouts from the defalt keyboard layout folder: */ 1790 1992 lookAtDefaultLayoutFolder(keyboardLayoutNames); … … 1833 2035 emit sigCurrentLayoutChange(); 1834 2036 1835 const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout-> m_keyCapMap;1836 1837 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid);2037 const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->keyCapMap(); 2038 2039 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->physicalLayoutUuid()); 1838 2040 if (!pPhysicalLayout) 1839 2041 return; … … 2214 2416 m_pLayoutListButton->resize(QSize(iIconMetric, iIconMetric)); 2215 2417 m_pLayoutListButton->setStyleSheet("QToolButton { border: 0px none black; margin: 0px 0px 0px 0px; } QToolButton::menu-indicator {image: none;}"); 2216 connect(m_pLayoutListButton, &QToolButton:: pressed, this, &UISoftKeyboardStatusBarWidget::sigShowHideSidePanel);2418 connect(m_pLayoutListButton, &QToolButton::clicked, this, &UISoftKeyboardStatusBarWidget::sigShowHideSidePanel); 2217 2419 pLayout->addWidget(m_pLayoutListButton); 2218 2420 } … … 2293 2495 void UISoftKeyboard::sltLayoutSelectionChanged(const QString &strLayoutName) 2294 2496 { 2295 if (m_pKeyboardWidget) 2296 m_pKeyboardWidget->setCurrentLayout(strLayoutName); 2497 if (!m_pKeyboardWidget) 2498 return; 2499 m_pKeyboardWidget->setCurrentLayout(strLayoutName); 2500 if (m_pLayoutSelector && m_pKeyboardWidget->currentLayout()) 2501 m_pLayoutSelector->setCurrentLayoutIsEditable(m_pKeyboardWidget->currentLayout()->editable()); 2297 2502 } 2298 2503 … … 2306 2511 QString strLayoutName = pCurrentLayout ? pCurrentLayout->name() : QString(); 2307 2512 updateStatusBarMessage(strLayoutName); 2513 updateLayoutSelector(); 2308 2514 } 2309 2515 … … 2339 2545 m_pKeyboardWidget->update(); 2340 2546 updateLayoutSelector(); 2547 UISoftKeyboardLayout *pCurrentLayout = m_pKeyboardWidget->currentLayout(); 2548 2549 /* Update the status bar string: */ 2550 QString strLayoutName = pCurrentLayout ? pCurrentLayout->name() : QString(); 2551 updateStatusBarMessage(strLayoutName); 2341 2552 } 2342 2553 … … 2359 2570 void UISoftKeyboard::sltCopyLayout() 2360 2571 { 2361 if (!m_pKeyboardWidget || !m_pKeyboardWidget->currentLayout()) 2362 return; 2363 UISoftKeyboardLayout newLayout(*(m_pKeyboardWidget->currentLayout())); 2364 QString strNewName = QString("%1-%2").arg(newLayout.name()).arg(tr("Copy")); 2365 newLayout.setName(strNewName); 2366 m_pKeyboardWidget->addLayout(newLayout); 2572 if (!m_pKeyboardWidget) 2573 return; 2574 m_pKeyboardWidget->copyCurentLayout(); 2367 2575 updateLayoutSelector(); 2368 2576 } … … 2372 2580 if (m_pKeyboardWidget) 2373 2581 m_pKeyboardWidget->saveCurentLayoutToFile(); 2582 } 2583 2584 void UISoftKeyboard::sltDeleteLayout() 2585 { 2586 if (m_pKeyboardWidget) 2587 m_pKeyboardWidget->deleteCurrentLayout(); 2374 2588 } 2375 2589 … … 2429 2643 connect(m_pLayoutSelector, &UILayoutSelector::sigCloseLayoutList, this, &UISoftKeyboard::sltShowHideSidePanel); 2430 2644 connect(m_pLayoutSelector, &UILayoutSelector::sigSaveLayout, this, &UISoftKeyboard::sltSaveLayout); 2645 connect(m_pLayoutSelector, &UILayoutSelector::sigDeleteLayout, this, &UISoftKeyboard::sltDeleteLayout); 2431 2646 connect(m_pLayoutSelector, &UILayoutSelector::sigCopyLayout, this, &UISoftKeyboard::sltCopyLayout); 2432 2647 connect(m_pLayoutEditor, &UILayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector); -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r79212 r79248 81 81 void sltCopyLayout(); 82 82 void sltSaveLayout(); 83 void sltDeleteLayout(); 83 84 void sltStatusBarMessage(const QString &strMessage); 84 85 -
trunk/src/VBox/Frontends/VirtualBox/xml/us.xml
r79184 r79248 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <layout> 3 <name> German</name>3 <name>US</name> 4 4 <physicallayoutid>{368efa94-3744-48c5-9d5a-59c2f15fe5ec}</physicallayoutid> 5 5 <key> 6 6 <position>110</position> 7 <basecaption>Esc xx</basecaption>7 <basecaption>Esc</basecaption> 8 8 <shiftcaption></shiftcaption> 9 9 <altgrcaption></altgrcaption> … … 83 83 <key> 84 84 <position>124</position> 85 <basecaption> </basecaption>86 <shiftcaption> </shiftcaption>85 <basecaption>Prt Scrn</basecaption> 86 <shiftcaption>Sys Rq</shiftcaption> 87 87 <altgrcaption></altgrcaption> 88 88 </key> 89 89 <key> 90 90 <position>125</position> 91 <basecaption> </basecaption>91 <basecaption>Scroll Lock</basecaption> 92 92 <shiftcaption></shiftcaption> 93 93 <altgrcaption></altgrcaption> … … 95 95 <key> 96 96 <position>126</position> 97 <basecaption> </basecaption>97 <basecaption>Pause Break</basecaption> 98 98 <shiftcaption></shiftcaption> 99 99 <altgrcaption></altgrcaption> … … 131 131 <key> 132 132 <position>6</position> 133 <basecaption> </basecaption>134 <shiftcaption> </shiftcaption>133 <basecaption>5</basecaption> 134 <shiftcaption>%</shiftcaption> 135 135 <altgrcaption></altgrcaption> 136 136 </key> … … 143 143 <key> 144 144 <position>8</position> 145 <basecaption> </basecaption>146 <shiftcaption> </shiftcaption>145 <basecaption>6</basecaption> 146 <shiftcaption>^</shiftcaption> 147 147 <altgrcaption></altgrcaption> 148 148 </key> 149 149 <key> 150 150 <position>9</position> 151 <basecaption> </basecaption>152 <shiftcaption> </shiftcaption>151 <basecaption>7</basecaption> 152 <shiftcaption>&</shiftcaption> 153 153 <altgrcaption></altgrcaption> 154 154 </key> 155 155 <key> 156 156 <position>10</position> 157 <basecaption> </basecaption>158 <shiftcaption> </shiftcaption>157 <basecaption>8</basecaption> 158 <shiftcaption>*</shiftcaption> 159 159 <altgrcaption></altgrcaption> 160 160 </key> 161 161 <key> 162 162 <position>11</position> 163 <basecaption> </basecaption>164 <shiftcaption> </shiftcaption>163 <basecaption>9</basecaption> 164 <shiftcaption>(</shiftcaption> 165 165 <altgrcaption></altgrcaption> 166 166 </key> 167 167 <key> 168 168 <position>12</position> 169 <basecaption> </basecaption>170 <shiftcaption> </shiftcaption>169 <basecaption>0</basecaption> 170 <shiftcaption>)</shiftcaption> 171 171 <altgrcaption></altgrcaption> 172 172 </key> 173 173 <key> 174 174 <position>13</position> 175 <basecaption> </basecaption>176 <shiftcaption> </shiftcaption>175 <basecaption>-</basecaption> 176 <shiftcaption>_</shiftcaption> 177 177 <altgrcaption></altgrcaption> 178 178 </key> 179 179 <key> 180 180 <position>15</position> 181 <basecaption> </basecaption>181 <basecaption>Backspace</basecaption> 182 182 <shiftcaption></shiftcaption> 183 183 <altgrcaption></altgrcaption> … … 185 185 <key> 186 186 <position>75</position> 187 <basecaption> </basecaption>187 <basecaption>Insert</basecaption> 188 188 <shiftcaption></shiftcaption> 189 189 <altgrcaption></altgrcaption> … … 191 191 <key> 192 192 <position>80</position> 193 <basecaption> </basecaption>193 <basecaption>Home</basecaption> 194 194 <shiftcaption></shiftcaption> 195 195 <altgrcaption></altgrcaption> … … 197 197 <key> 198 198 <position>85</position> 199 <basecaption> </basecaption>199 <basecaption>Page Up</basecaption> 200 200 <shiftcaption></shiftcaption> 201 201 <altgrcaption></altgrcaption> … … 209 209 <key> 210 210 <position>17</position> 211 <basecaption> </basecaption>211 <basecaption>Q</basecaption> 212 212 <shiftcaption></shiftcaption> 213 213 <altgrcaption></altgrcaption> … … 215 215 <key> 216 216 <position>18</position> 217 <basecaption> </basecaption>217 <basecaption>W</basecaption> 218 218 <shiftcaption></shiftcaption> 219 219 <altgrcaption></altgrcaption> … … 221 221 <key> 222 222 <position>19</position> 223 <basecaption> </basecaption>223 <basecaption>E</basecaption> 224 224 <shiftcaption></shiftcaption> 225 225 <altgrcaption></altgrcaption> … … 227 227 <key> 228 228 <position>20</position> 229 <basecaption> </basecaption>229 <basecaption>R</basecaption> 230 230 <shiftcaption></shiftcaption> 231 231 <altgrcaption></altgrcaption> … … 233 233 <key> 234 234 <position>21</position> 235 <basecaption> </basecaption>235 <basecaption>T</basecaption> 236 236 <shiftcaption></shiftcaption> 237 237 <altgrcaption></altgrcaption> … … 239 239 <key> 240 240 <position>22</position> 241 <basecaption> </basecaption>241 <basecaption>Y</basecaption> 242 242 <shiftcaption></shiftcaption> 243 243 <altgrcaption></altgrcaption> … … 245 245 <key> 246 246 <position>23</position> 247 <basecaption> </basecaption>247 <basecaption>U</basecaption> 248 248 <shiftcaption></shiftcaption> 249 249 <altgrcaption></altgrcaption> … … 251 251 <key> 252 252 <position>24</position> 253 <basecaption> </basecaption>253 <basecaption>I</basecaption> 254 254 <shiftcaption></shiftcaption> 255 255 <altgrcaption></altgrcaption> … … 257 257 <key> 258 258 <position>25</position> 259 <basecaption> </basecaption>259 <basecaption>O</basecaption> 260 260 <shiftcaption></shiftcaption> 261 261 <altgrcaption></altgrcaption> … … 263 263 <key> 264 264 <position>26</position> 265 <basecaption> </basecaption>265 <basecaption>P</basecaption> 266 266 <shiftcaption></shiftcaption> 267 267 <altgrcaption></altgrcaption> … … 269 269 <key> 270 270 <position>27</position> 271 <basecaption> </basecaption>272 <shiftcaption> </shiftcaption>271 <basecaption>[</basecaption> 272 <shiftcaption>{</shiftcaption> 273 273 <altgrcaption></altgrcaption> 274 274 </key> 275 275 <key> 276 276 <position>28</position> 277 <basecaption> </basecaption>278 <shiftcaption> </shiftcaption>277 <basecaption>]</basecaption> 278 <shiftcaption>}</shiftcaption> 279 279 <altgrcaption></altgrcaption> 280 280 </key> 281 281 <key> 282 282 <position>29</position> 283 <basecaption> </basecaption>284 <shiftcaption> </shiftcaption>283 <basecaption>\</basecaption> 284 <shiftcaption>|</shiftcaption> 285 285 <altgrcaption></altgrcaption> 286 286 </key> 287 287 <key> 288 288 <position>76</position> 289 <basecaption> </basecaption>289 <basecaption>Delete</basecaption> 290 290 <shiftcaption></shiftcaption> 291 291 <altgrcaption></altgrcaption> … … 293 293 <key> 294 294 <position>81</position> 295 <basecaption> </basecaption>295 <basecaption>End</basecaption> 296 296 <shiftcaption></shiftcaption> 297 297 <altgrcaption></altgrcaption> … … 299 299 <key> 300 300 <position>86</position> 301 <basecaption> </basecaption>301 <basecaption>Page Down</basecaption> 302 302 <shiftcaption></shiftcaption> 303 303 <altgrcaption></altgrcaption> … … 311 311 <key> 312 312 <position>31</position> 313 <basecaption> </basecaption>313 <basecaption>A</basecaption> 314 314 <shiftcaption></shiftcaption> 315 315 <altgrcaption></altgrcaption> … … 317 317 <key> 318 318 <position>32</position> 319 <basecaption> </basecaption>319 <basecaption>S</basecaption> 320 320 <shiftcaption></shiftcaption> 321 321 <altgrcaption></altgrcaption> … … 323 323 <key> 324 324 <position>33</position> 325 <basecaption> </basecaption>325 <basecaption>D</basecaption> 326 326 <shiftcaption></shiftcaption> 327 327 <altgrcaption></altgrcaption> … … 329 329 <key> 330 330 <position>34</position> 331 <basecaption> </basecaption>331 <basecaption>F</basecaption> 332 332 <shiftcaption></shiftcaption> 333 333 <altgrcaption></altgrcaption> … … 335 335 <key> 336 336 <position>35</position> 337 <basecaption> </basecaption>337 <basecaption>G</basecaption> 338 338 <shiftcaption></shiftcaption> 339 339 <altgrcaption></altgrcaption> … … 341 341 <key> 342 342 <position>36</position> 343 <basecaption> </basecaption>343 <basecaption>H</basecaption> 344 344 <shiftcaption></shiftcaption> 345 345 <altgrcaption></altgrcaption> … … 347 347 <key> 348 348 <position>37</position> 349 <basecaption> </basecaption>349 <basecaption>J</basecaption> 350 350 <shiftcaption></shiftcaption> 351 351 <altgrcaption></altgrcaption> … … 353 353 <key> 354 354 <position>38</position> 355 <basecaption> </basecaption>355 <basecaption>K</basecaption> 356 356 <shiftcaption></shiftcaption> 357 357 <altgrcaption></altgrcaption> … … 359 359 <key> 360 360 <position>39</position> 361 <basecaption> </basecaption>361 <basecaption>L</basecaption> 362 362 <shiftcaption></shiftcaption> 363 363 <altgrcaption></altgrcaption> … … 365 365 <key> 366 366 <position>40</position> 367 <basecaption> </basecaption>368 <shiftcaption> </shiftcaption>367 <basecaption>;</basecaption> 368 <shiftcaption>:</shiftcaption> 369 369 <altgrcaption></altgrcaption> 370 370 </key> 371 371 <key> 372 372 <position>41</position> 373 <basecaption> </basecaption>374 <shiftcaption> </shiftcaption>373 <basecaption>'</basecaption> 374 <shiftcaption>"</shiftcaption> 375 375 <altgrcaption></altgrcaption> 376 376 </key> 377 377 <key> 378 378 <position>43</position> 379 <basecaption> </basecaption>379 <basecaption>Enter</basecaption> 380 380 <shiftcaption></shiftcaption> 381 381 <altgrcaption></altgrcaption> … … 449 449 <key> 450 450 <position>57</position> 451 <basecaption> </basecaption>451 <basecaption>Shift</basecaption> 452 452 <shiftcaption></shiftcaption> 453 453 <altgrcaption></altgrcaption> … … 455 455 <key> 456 456 <position>83</position> 457 <basecaption> </basecaption>457 <basecaption>↑</basecaption> 458 458 <shiftcaption></shiftcaption> 459 459 <altgrcaption></altgrcaption> … … 467 467 <key> 468 468 <position>227</position> 469 <basecaption> </basecaption>469 <basecaption>OS</basecaption> 470 470 <shiftcaption></shiftcaption> 471 471 <altgrcaption></altgrcaption> … … 473 473 <key> 474 474 <position>60</position> 475 <basecaption> </basecaption>475 <basecaption>Alt</basecaption> 476 476 <shiftcaption></shiftcaption> 477 477 <altgrcaption></altgrcaption> … … 485 485 <key> 486 486 <position>62</position> 487 <basecaption> </basecaption>487 <basecaption>Alt</basecaption> 488 488 <shiftcaption></shiftcaption> 489 489 <altgrcaption></altgrcaption> … … 491 491 <key> 492 492 <position>231</position> 493 <basecaption> </basecaption>493 <basecaption>OS</basecaption> 494 494 <shiftcaption></shiftcaption> 495 495 <altgrcaption></altgrcaption> … … 497 497 <key> 498 498 <position>0</position> 499 <basecaption> </basecaption>499 <basecaption>Menu</basecaption> 500 500 <shiftcaption></shiftcaption> 501 501 <altgrcaption></altgrcaption> … … 503 503 <key> 504 504 <position>64</position> 505 <basecaption> </basecaption>505 <basecaption>Ctrl</basecaption> 506 506 <shiftcaption></shiftcaption> 507 507 <altgrcaption></altgrcaption> … … 509 509 <key> 510 510 <position>79</position> 511 <basecaption> </basecaption>511 <basecaption>←</basecaption> 512 512 <shiftcaption></shiftcaption> 513 513 <altgrcaption></altgrcaption> … … 515 515 <key> 516 516 <position>84</position> 517 <basecaption> </basecaption>517 <basecaption>↓</basecaption> 518 518 <shiftcaption></shiftcaption> 519 519 <altgrcaption></altgrcaption> … … 521 521 <key> 522 522 <position>89</position> 523 <basecaption> </basecaption>523 <basecaption>→</basecaption> 524 524 <shiftcaption></shiftcaption> 525 525 <altgrcaption></altgrcaption>
Note:
See TracChangeset
for help on using the changeset viewer.