Changeset 79172 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 17, 2019 9:09:03 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131343
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/VirtualBox_xml.qrc
r79121 r79172 4 4 <file alias="102_iso.xml">xml/102_iso.xml</file> 5 5 <file alias="us_international.xml">xml/us_international.xml</file> 6 <file alias="german.xml">xml/german.xml</file> 6 7 </qresource> 7 8 </RCC> -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79130 r79172 23 23 #include <QLabel> 24 24 #include <QLineEdit> 25 #include <QListWidget> 25 26 #include <QMenu> 26 27 #include <QPainter> 27 28 #include <QPushButton> 29 #include <QSplitter> 28 30 #include <QStatusBar> 29 31 #include <QStyle> 32 #include <QStackedWidget> 30 33 #include <QToolButton> 31 34 #include <QXmlStreamReader> … … 49 52 /* Forward declarations: */ 50 53 class UISoftKeyboardWidget; 54 class UISoftKeyboardLayout; 55 class UISoftKeyboardRow; 51 56 52 57 enum UIKeyState … … 76 81 }; 77 82 83 84 /********************************************************************************************************************************* 85 * UISoftKeyboardPhysicalLayout definition. * 86 *********************************************************************************************************************************/ 87 88 class UISoftKeyboardPhysicalLayout 89 { 90 91 public: 92 93 void setName(const QString &strName) 94 { 95 m_strName = strName; 96 } 97 98 const QString &name() const 99 { 100 return m_strName; 101 } 102 103 QString m_strFileName; 104 QUuid m_uId; 105 106 QVector<UISoftKeyboardRow> m_rows; 107 108 private: 109 110 QString m_strName; 111 }; 112 78 113 /********************************************************************************************************************************* 79 114 * UILayoutEditor definition. * … … 86 121 signals: 87 122 88 void sigKeyCaptionEdited(); 89 void sigPhysicalLayoutChanged(int iIndex); 90 void sigLayoutNameChanged(const QString &strName); 123 void sigLayoutEdited(); 124 void sigGoBackButton(); 91 125 92 126 public: … … 94 128 UILayoutEditor(QWidget *pParent = 0); 95 129 void setKey(UISoftKeyboardKey *pKey); 96 void setLayoutName(const QString &strName); 97 void setPhysicalLayoutNames(const QStringList &strPhysicalLayoutNames); 130 131 void setLayoutToEdit(UISoftKeyboardLayout *pLayout); 132 void setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts); 98 133 99 134 protected: … … 107 142 void sltKeyAltGrCaptionChange(); 108 143 void sltLayoutNameChange(); 144 void sltHandlePhysicalLayoutChanged(); 109 145 110 146 private: … … 115 151 116 152 QGridLayout *m_pEditorLayout; 153 QToolButton *m_pGoBackButton; 117 154 QGroupBox *m_pSelectedKeyGroupBox; 118 155 QGroupBox *m_pCaptionEditGroupBox; … … 136 173 /** The key which is being currently edited. Might be Null. */ 137 174 UISoftKeyboardKey *m_pKey; 175 /** The layout which is being currently edited. */ 176 UISoftKeyboardLayout *m_pLayout; 177 QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts; 178 }; 179 180 /********************************************************************************************************************************* 181 * UILayoutSelector definition. * 182 *********************************************************************************************************************************/ 183 184 class UILayoutSelector : public QIWithRetranslateUI<QWidget> 185 { 186 Q_OBJECT; 187 188 signals: 189 190 void sigApplySelectedLayout(const QString &strSelectedLayoutName); 191 void sigEditSelectedLayout(); 192 193 public: 194 195 UILayoutSelector(QWidget *pParent = 0); 196 void setLayoutList(const QStringList &layoutNames); 197 QString selectedLayoutName() const; 198 void selectLayoutByName(const QString &strLayoutName); 199 200 protected: 201 202 virtual void retranslateUi() /* override */; 203 204 private slots: 205 206 207 private: 208 void prepareObjects(); 209 210 QListWidget *m_pLayoutListWidget; 211 QToolButton *m_pApplyLayoutButton; 212 QToolButton *m_pEditLayoutButton; 138 213 }; 139 214 … … 269 344 270 345 /********************************************************************************************************************************* 271 * UISoftKeyboardPhysicalLayout definition. *272 *********************************************************************************************************************************/273 274 class UISoftKeyboardPhysicalLayout275 {276 277 public:278 279 QString m_strName;280 QString m_strFileName;281 QUuid m_uId;282 283 QVector<UISoftKeyboardRow> m_rows;284 };285 286 /*********************************************************************************************************************************287 346 * UISoftKeyboardLayout definition. * 288 347 *********************************************************************************************************************************/ … … 295 354 UISoftKeyboardLayout() 296 355 :m_pPhysicalLayout(0){} 356 357 void setName(const QString &strName) 358 { 359 m_strName = strName; 360 } 361 362 const QString &name() const 363 { 364 return m_strName; 365 } 366 297 367 /** The physical layout used by this layout. */ 298 368 UISoftKeyboardPhysicalLayout *m_pPhysicalLayout; 299 QString m_strName; 369 300 370 /** We cache the key caps here instead of reading the layout files each time layout changes. 301 371 * Map key is the key position and the value is the captions of the key. */ 302 372 QMap<int, KeyCaptions> m_keyCapMap; 373 374 private: 375 376 QString m_strName; 303 377 }; 304 378 … … 322 396 void sigPutKeyboardSequence(QVector<LONG> sequence); 323 397 void sigLayoutChange(const QString &strLayoutName); 324 void sig KeyCapChange(const QString &strKepCapFileName);398 void sigLayoutListChanged(QStringList layoutNames); 325 399 326 400 public: … … 328 402 UISoftKeyboardWidget(QWidget *pParent = 0); 329 403 330 virtual QSize minimumSizeHint() const ;331 virtual QSize sizeHint() const ;404 virtual QSize minimumSizeHint() const /* override */; 405 virtual QSize sizeHint() const /* override */; 332 406 void keyStateChange(UISoftKeyboardKey* pKey); 333 void load DefaultLayout();407 void loadLayouts(); 334 408 void showContextMenu(const QPoint &globalPoint); 409 void applyLayoutByName(const QString &strLayoutName); 410 QStringList layoutNameList() const; 411 const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts() const; 335 412 336 413 protected: 337 414 338 void paintEvent(QPaintEvent *pEvent) /* override */; 339 void mousePressEvent(QMouseEvent *pEvent) /* override */; 340 void mouseReleaseEvent(QMouseEvent *pEvent) /* override */; 341 void mouseMoveEvent(QMouseEvent *pEvent) /* override */; 342 bool eventFilter(QObject *pWatched, QEvent *pEvent)/* override */; 343 415 virtual void paintEvent(QPaintEvent *pEvent) /* override */; 416 virtual void mousePressEvent(QMouseEvent *pEvent) /* override */; 417 virtual void mouseReleaseEvent(QMouseEvent *pEvent) /* override */; 418 virtual void mouseMoveEvent(QMouseEvent *pEvent) /* override */; 344 419 virtual void retranslateUi() /* override */; 345 420 … … 350 425 void sltHandleLayoutEditModeToggle(bool fToggle); 351 426 void sltHandleNewLayout(); 352 void sltHandleKeyCaptionEdited();353 427 void sltPhysicalLayoutForLayoutChanged(int iIndex); 354 void sltLayoutNameChange(const QString &strName);355 428 356 429 private: … … 366 439 bool loadKeyboardLayout(const QString &strLayoutName); 367 440 void reset(); 368 void configure();369 441 void prepareObjects(); 370 442 /** Sets m_pKeyBeingEdited. */ 371 443 void setKeyBeingEdited(UISoftKeyboardKey *pKey); 372 444 void setCurrentLayout(UISoftKeyboardLayout *pLayout); 445 void emitLayoutNames(); 446 UISoftKeyboardLayout *findLayoutByName(const QString &strName); 447 373 448 UISoftKeyboardKey *m_pKeyUnderMouse; 374 449 UISoftKeyboardKey *m_pKeyBeingEdited; … … 401 476 QAction *m_pShowPositionsAction; 402 477 QAction *m_pLayoutEditModeToggleAction; 403 UILayoutEditor *m_pLayoutEditor;404 478 Mode m_enmMode; 405 479 }; … … 460 534 :QIWithRetranslateUI<QWidget>(pParent) 461 535 , m_pEditorLayout(0) 536 , m_pGoBackButton(0) 462 537 , m_pSelectedKeyGroupBox(0) 463 538 , m_pCaptionEditGroupBox(0) … … 503 578 } 504 579 505 void UILayoutEditor::setLayoutName(const QString &strName) 506 { 580 void UILayoutEditor::setLayoutToEdit(UISoftKeyboardLayout *pLayout) 581 { 582 if (m_pLayout != pLayout) 583 return; 507 584 if (m_pLayoutNameEdit) 508 m_pLayoutNameEdit->setText(strName); 509 } 510 511 void UILayoutEditor::setPhysicalLayoutNames(const QStringList &strPhysicalLayoutNames) 512 { 585 m_pLayoutNameEdit->setText(m_pLayout->name()); 586 update(); 587 } 588 589 void UILayoutEditor::setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts) 590 { 591 m_physicalLayouts = physicalLayouts; 592 513 593 if (!m_pPhysicalLayoutCombo) 514 594 return; 515 foreach (const QString &strName, strPhysicalLayoutNames) 516 m_pPhysicalLayoutCombo->addItem(strName); 595 m_pPhysicalLayoutCombo->clear(); 596 foreach (const UISoftKeyboardPhysicalLayout &physicalLayout, physicalLayouts) 597 m_pPhysicalLayoutCombo->addItem(physicalLayout.name(), physicalLayout.m_uId); 517 598 } 518 599 519 600 void UILayoutEditor::retranslateUi() 520 601 { 602 if (m_pGoBackButton) 603 m_pGoBackButton->setToolTip(UISoftKeyboard::tr("Return Back to Layout List")); 521 604 if (m_pPhysicalLayoutLabel) 522 605 m_pPhysicalLayoutLabel->setText(UISoftKeyboard::tr("Physical Layout")); … … 544 627 return; 545 628 m_pKey->setBaseCaption(m_pBaseCaptionEdit->text()); 546 emit sig KeyCaptionEdited();629 emit sigLayoutEdited(); 547 630 } 548 631 … … 552 635 return; 553 636 m_pKey->setShiftCaption(m_pShiftCaptionEdit->text()); 554 emit sig KeyCaptionEdited();637 emit sigLayoutEdited(); 555 638 } 556 639 … … 560 643 return; 561 644 m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text()); 562 emit sig KeyCaptionEdited();645 emit sigLayoutEdited(); 563 646 } 564 647 … … 567 650 if (!m_pLayoutNameEdit) 568 651 return; 569 emit sigLayoutNameChanged(m_pLayoutNameEdit->text()); 652 emit sigLayoutEdited(); 653 } 654 655 void UILayoutEditor::sltHandlePhysicalLayoutChanged() 656 { 657 if (!m_pPhysicalLayoutCombo) 658 return; 659 660 570 661 } 571 662 … … 576 667 return; 577 668 setLayout(m_pEditorLayout); 669 670 m_pGoBackButton = new QToolButton; 671 m_pGoBackButton->setIcon(UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_ArrowBack)); 672 m_pEditorLayout->addWidget(m_pGoBackButton, 0, 0, 1, 1); 673 connect(m_pGoBackButton, &QToolButton::pressed, this, &UILayoutEditor::sigGoBackButton); 578 674 579 675 m_pLayoutNameLabel = new QLabel; 580 676 m_pLayoutNameEdit = new QLineEdit; 581 677 m_pLayoutNameLabel->setBuddy(m_pLayoutNameEdit); 582 m_pEditorLayout->addWidget(m_pLayoutNameLabel, 0, 0, 1, 1);583 m_pEditorLayout->addWidget(m_pLayoutNameEdit, 0, 1, 1, 1);678 m_pEditorLayout->addWidget(m_pLayoutNameLabel, 1, 0, 1, 1); 679 m_pEditorLayout->addWidget(m_pLayoutNameEdit, 1, 1, 1, 1); 584 680 connect(m_pLayoutNameEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sltLayoutNameChange); 585 681 … … 588 684 m_pPhysicalLayoutCombo = new QComboBox; 589 685 m_pPhysicalLayoutLabel->setBuddy(m_pPhysicalLayoutCombo); 590 m_pEditorLayout->addWidget(m_pPhysicalLayoutLabel, 1, 0, 1, 1);591 m_pEditorLayout->addWidget(m_pPhysicalLayoutCombo, 1, 1, 1, 1);686 m_pEditorLayout->addWidget(m_pPhysicalLayoutLabel, 2, 0, 1, 1); 687 m_pEditorLayout->addWidget(m_pPhysicalLayoutCombo, 2, 1, 1, 1); 592 688 connect(m_pPhysicalLayoutCombo, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 593 this, &UILayoutEditor::s igPhysicalLayoutChanged);689 this, &UILayoutEditor::sltHandlePhysicalLayoutChanged); 594 690 595 691 m_pSelectedKeyGroupBox = new QGroupBox; 596 692 m_pSelectedKeyGroupBox->setEnabled(false); 597 693 598 m_pEditorLayout->addWidget(m_pSelectedKeyGroupBox, 2, 0, 1, 2);694 m_pEditorLayout->addWidget(m_pSelectedKeyGroupBox, 3, 0, 1, 2); 599 695 QGridLayout *pSelectedKeyLayout = new QGridLayout(m_pSelectedKeyGroupBox); 600 696 pSelectedKeyLayout->setSpacing(0); … … 665 761 pCaptionEditorLayout->addItem(pSpacer, 4, 1); 666 762 return m_pCaptionEditGroupBox; 763 } 764 765 /********************************************************************************************************************************* 766 * UILayoutSelector implementation. * 767 *********************************************************************************************************************************/ 768 769 UILayoutSelector::UILayoutSelector(QWidget *pParent /* = 0 */) 770 :QIWithRetranslateUI<QWidget>(pParent) 771 , m_pLayoutListWidget(0) 772 , m_pApplyLayoutButton(0) 773 , m_pEditLayoutButton(0) 774 { 775 prepareObjects(); 776 } 777 778 QString UILayoutSelector::selectedLayoutName() const 779 { 780 if (!m_pLayoutListWidget || !m_pLayoutListWidget->currentItem()) 781 return QString(); 782 return m_pLayoutListWidget->currentItem()->text(); 783 } 784 785 void UILayoutSelector::selectLayoutByName(const QString &strLayoutName) 786 { 787 if (!m_pLayoutListWidget) 788 return; 789 QList<QListWidgetItem *> items = m_pLayoutListWidget->findItems(strLayoutName, Qt::MatchFixedString |Qt::MatchCaseSensitive); 790 if (items.isEmpty()) 791 return; 792 QListWidgetItem *pItem = items[0]; 793 if (!pItem || pItem == m_pLayoutListWidget->currentItem()) 794 return; 795 m_pLayoutListWidget->setCurrentItem(pItem); 796 } 797 798 void UILayoutSelector::setLayoutList(const QStringList &layoutNames) 799 { 800 if (!m_pLayoutListWidget) 801 return; 802 m_pLayoutListWidget->clear(); 803 foreach (const QString &strLayoutName, layoutNames) 804 m_pLayoutListWidget->addItem(strLayoutName); 805 } 806 807 void UILayoutSelector::retranslateUi() 808 { 809 if (m_pApplyLayoutButton) 810 m_pApplyLayoutButton->setToolTip(UISoftKeyboard::tr("Use the selected layout")); 811 if (m_pEditLayoutButton) 812 m_pEditLayoutButton->setToolTip(UISoftKeyboard::tr("Edit the selected layout")); 813 } 814 815 void UILayoutSelector::prepareObjects() 816 { 817 QVBoxLayout *pLayout = new QVBoxLayout; 818 if (!pLayout) 819 return; 820 pLayout->setSpacing(0); 821 setLayout(pLayout); 822 823 m_pLayoutListWidget = new QListWidget; 824 pLayout->addWidget(m_pLayoutListWidget); 825 connect(m_pLayoutListWidget, &QListWidget::currentTextChanged, this, &UILayoutSelector::sigApplySelectedLayout); 826 827 QHBoxLayout *pButtonsLayout = new QHBoxLayout; 828 pLayout->addLayout(pButtonsLayout); 829 830 // m_pApplyLayoutButton = new QToolButton; 831 // m_pApplyLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_16px.png")); 832 // pButtonsLayout->addWidget(m_pApplyLayoutButton); 833 834 835 m_pEditLayoutButton = new QToolButton; 836 m_pEditLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_settings_16px.png")); 837 pButtonsLayout->addWidget(m_pEditLayoutButton); 838 connect(m_pEditLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigEditSelectedLayout); 839 840 pButtonsLayout->addStretch(2); 841 842 retranslateUi(); 667 843 } 668 844 … … 995 1171 , m_enmMode(Mode_Keyboard) 996 1172 { 997 998 configure();999 1173 prepareObjects(); 1000 1174 } … … 1002 1176 QSize UISoftKeyboardWidget::minimumSizeHint() const 1003 1177 { 1004 return m_minimumSize;1178 return QSize(0.5 * m_minimumSize.width(), 0.5 * m_minimumSize.height()); 1005 1179 } 1006 1180 1007 1181 QSize UISoftKeyboardWidget::sizeHint() const 1008 1182 { 1009 return m_minimumSize; 1183 return QSize(0.5 * m_minimumSize.width(), 0.5 * m_minimumSize.height()); 1184 //return m_minimumSize; 1010 1185 } 1011 1186 … … 1030 1205 float fLedRadius = 0.8 * unitSize; 1031 1206 float fLedMargin = 0.6 * unitSize; 1032 1033 if (m_enmMode == Mode_LayoutEdit)1034 {1035 m_pLayoutEditor->setGeometry(width() - iEditDialogWidth, 0,1036 iEditDialogWidth, height());1037 m_pLayoutEditor->show();1038 m_pLayoutEditor->setFocus();1039 }1040 else1041 m_pLayoutEditor->hide();1042 1207 1043 1208 if (!m_pCurrentKeyboardLayout || m_iInitialWidth == 0 || m_iInitialHeight == 0) … … 1141 1306 } 1142 1307 1143 bool UISoftKeyboardWidget::eventFilter(QObject *pWatched, QEvent *pEvent)1144 {1145 if (pWatched != m_pLayoutEditor)1146 return QIWithRetranslateUI<QWidget>::eventFilter(pWatched, pEvent);1147 1148 switch (pEvent->type())1149 {1150 case QEvent::KeyPress:1151 {1152 QKeyEvent *pKeyEvent = dynamic_cast<QKeyEvent*>(pEvent);1153 if (pKeyEvent && pKeyEvent->key() == Qt::Key_Escape)1154 {1155 setKeyBeingEdited(0);1156 update();1157 return true;1158 }1159 else if (pKeyEvent && (pKeyEvent->key() == Qt::Key_Enter || pKeyEvent->key() == Qt::Key_Return))1160 {1161 // if (m_pKeyBeingEdited)1162 // m_pKeyBeingEdited->setStaticKeyCap(m_pLayoutEditor->text());1163 setKeyBeingEdited(0);1164 update();1165 return true;1166 }1167 break;1168 }1169 default:1170 break;1171 }1172 1173 return QIWithRetranslateUI<QWidget>::eventFilter(pWatched, pEvent);1174 }1308 // bool UISoftKeyboardWidget::eventFilter(QObject *pWatched, QEvent *pEvent) 1309 // { 1310 // if (pWatched != m_pLayoutEditor) 1311 // return QIWithRetranslateUI<QWidget>::eventFilter(pWatched, pEvent); 1312 1313 // switch (pEvent->type()) 1314 // { 1315 // case QEvent::KeyPress: 1316 // { 1317 // QKeyEvent *pKeyEvent = dynamic_cast<QKeyEvent*>(pEvent); 1318 // if (pKeyEvent && pKeyEvent->key() == Qt::Key_Escape) 1319 // { 1320 // setKeyBeingEdited(0); 1321 // update(); 1322 // return true; 1323 // } 1324 // else if (pKeyEvent && (pKeyEvent->key() == Qt::Key_Enter || pKeyEvent->key() == Qt::Key_Return)) 1325 // { 1326 // // if (m_pKeyBeingEdited) 1327 // // m_pKeyBeingEdited->setStaticKeyCap(m_pLayoutEditor->text()); 1328 // setKeyBeingEdited(0); 1329 // update(); 1330 // return true; 1331 // } 1332 // break; 1333 // } 1334 // default: 1335 // break; 1336 // } 1337 1338 // return QIWithRetranslateUI<QWidget>::eventFilter(pWatched, pEvent); 1339 // } 1175 1340 1176 1341 … … 1242 1407 xmlWriter.writeStartDocument("1.0"); 1243 1408 xmlWriter.writeStartElement("layout"); 1244 xmlWriter.writeTextElement("name", m_pCurrentKeyboardLayout-> m_strName);1409 xmlWriter.writeTextElement("name", m_pCurrentKeyboardLayout->name()); 1245 1410 xmlWriter.writeTextElement("physicallayoutid", m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_uId.toString()); 1246 1411 … … 1314 1479 UISoftKeyboardLayout &newLayout = m_layouts.back(); 1315 1480 newLayout.m_pPhysicalLayout = &(m_physicalLayouts[0]); 1316 newLayout. m_strName = QString(UISoftKeyboard::tr("Unnamed"));1481 newLayout.setName(QString(UISoftKeyboard::tr("Unnamed"))); 1317 1482 setCurrentLayout(&newLayout); 1318 }1319 1320 void UISoftKeyboardWidget::sltHandleKeyCaptionEdited()1321 {1322 update();1323 1483 } 1324 1484 … … 1334 1494 m_pCurrentKeyboardLayout->m_pPhysicalLayout = &(m_physicalLayouts[iIndex]); 1335 1495 update(); 1336 }1337 1338 void UISoftKeyboardWidget::sltLayoutNameChange(const QString &strName)1339 {1340 if (!m_pCurrentKeyboardLayout)1341 return;1342 m_pCurrentKeyboardLayout->m_strName = strName;1343 emit sigLayoutChange(m_pCurrentKeyboardLayout->m_strName);1344 1496 } 1345 1497 … … 1428 1580 } 1429 1581 1430 void UISoftKeyboardWidget::loadDefaultLayout()1431 {1432 if (m_layouts.isEmpty())1433 return;1434 setCurrentLayout(&(m_layouts[0]));1435 }1436 1437 1582 void UISoftKeyboardWidget::showContextMenu(const QPoint &globalPoint) 1438 1583 { 1439 1584 m_pContextMenu->exec(globalPoint); 1440 1585 update(); 1586 } 1587 1588 void UISoftKeyboardWidget::applyLayoutByName(const QString &strLayoutName) 1589 { 1590 UISoftKeyboardLayout *pLayout = findLayoutByName(strLayoutName); 1591 if (!pLayout) 1592 return; 1593 setCurrentLayout(pLayout); 1441 1594 } 1442 1595 … … 1512 1665 int iInitialWidth = iMaxWidth + m_iRightMargin; 1513 1666 int iInitialHeight = iY + m_iBottomMargin; 1514 float fScale = 1.0f; 1515 setNewMinimumSize(QSize( fScale * iInitialWidth, fScale *iInitialHeight));1516 setInitialSize( fScale * iInitialWidth, fScale *iInitialHeight);1667 1668 setNewMinimumSize(QSize(iInitialWidth, iInitialHeight)); 1669 setInitialSize(iInitialWidth, iInitialHeight); 1517 1670 return true; 1518 1671 } … … 1544 1697 UISoftKeyboardLayout &newLayout = m_layouts.back(); 1545 1698 newLayout.m_pPhysicalLayout = pPhysicalLayout; 1546 newLayout. m_strName = keyboardLayoutReader.name();1699 newLayout.setName(keyboardLayoutReader.name()); 1547 1700 newLayout.m_keyCapMap = keyboardLayoutReader.keyCapMap(); 1548 1701 return true; … … 1555 1708 } 1556 1709 1557 void UISoftKeyboardWidget:: configure()1710 void UISoftKeyboardWidget::loadLayouts() 1558 1711 { 1559 1712 /* Load physical layouts from resources: */ … … 1565 1718 /* Load keyboard layouts from resources: */ 1566 1719 QStringList keyboardLayoutNames; 1567 keyboardLayoutNames << ":/us_international.xml"; 1720 keyboardLayoutNames << ":/us_international.xml" 1721 <<":/german.xml"; 1568 1722 foreach (const QString &strName, keyboardLayoutNames) 1569 {1570 1723 loadKeyboardLayout(strName); 1571 } 1572 1573 setMouseTracking(true); 1574 setContextMenuPolicy(Qt::CustomContextMenu); 1575 connect(this, &UISoftKeyboardWidget::customContextMenuRequested, 1576 this, &UISoftKeyboardWidget::sltHandleContextMenuRequest); 1724 emitLayoutNames(); 1725 if (m_layouts.isEmpty()) 1726 return; 1727 setCurrentLayout(&(m_layouts[0])); 1577 1728 } 1578 1729 1579 1730 void UISoftKeyboardWidget::prepareObjects() 1580 1731 { 1581 m_pLayoutEditor = new UILayoutEditor(this);1582 if (m_pLayoutEditor)1583 {1584 m_pLayoutEditor->hide();1585 m_pLayoutEditor->installEventFilter(this);1586 1587 QStringList physicalLayoutNames;1588 for (int i = 0; i < m_physicalLayouts.size(); ++i)1589 physicalLayoutNames << m_physicalLayouts[i].m_strName;1590 m_pLayoutEditor->setPhysicalLayoutNames(physicalLayoutNames);1591 1592 connect(m_pLayoutEditor, &UILayoutEditor::sigKeyCaptionEdited, this, &UISoftKeyboardWidget::sltHandleKeyCaptionEdited);1593 connect(m_pLayoutEditor, &UILayoutEditor::sigPhysicalLayoutChanged, this, &UISoftKeyboardWidget::sltPhysicalLayoutForLayoutChanged);1594 connect(m_pLayoutEditor, &UILayoutEditor::sigLayoutNameChanged, this, &UISoftKeyboardWidget::sltLayoutNameChange);1595 }1596 1732 m_pContextMenu = new QMenu(this); 1597 1733 … … 1612 1748 m_pShowPositionsAction->setChecked(false); 1613 1749 #endif 1750 1751 setMouseTracking(true); 1752 setContextMenuPolicy(Qt::CustomContextMenu); 1753 connect(this, &UISoftKeyboardWidget::customContextMenuRequested, 1754 this, &UISoftKeyboardWidget::sltHandleContextMenuRequest); 1614 1755 } 1615 1756 … … 1619 1760 return; 1620 1761 m_pKeyBeingEdited = pKey; 1621 if (m_pLayoutEditor)1622 m_pLayoutEditor->setKey(pKey);1762 // if (m_pLayoutEditor) 1763 // m_pLayoutEditor->setKey(pKey); 1623 1764 } 1624 1765 … … 1633 1774 return; 1634 1775 } 1635 emit sigLayoutChange(m_pCurrentKeyboardLayout->m_strName); 1636 1637 if (m_pLayoutEditor) 1638 m_pLayoutEditor->setLayoutName(m_pCurrentKeyboardLayout->m_strName); 1776 emit sigLayoutChange(m_pCurrentKeyboardLayout->name()); 1777 1639 1778 const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->m_keyCapMap; 1640 1779 … … 1657 1796 } 1658 1797 1798 void UISoftKeyboardWidget::emitLayoutNames() 1799 { 1800 emit sigLayoutListChanged(layoutNameList()); 1801 } 1802 1803 UISoftKeyboardLayout *UISoftKeyboardWidget::findLayoutByName(const QString &strName) 1804 { 1805 for (int i = 0; i < m_layouts.size(); ++i) 1806 { 1807 if (m_layouts[i].name() == strName) 1808 return &(m_layouts[i]); 1809 } 1810 return 0; 1811 } 1812 1813 QStringList UISoftKeyboardWidget::layoutNameList() const 1814 { 1815 QStringList layoutNames; 1816 foreach (const UISoftKeyboardLayout &layout, m_layouts) 1817 layoutNames << layout.name(); 1818 return layoutNames; 1819 } 1820 1821 const QVector<UISoftKeyboardPhysicalLayout> &UISoftKeyboardWidget::physicalLayouts() const 1822 { 1823 return m_physicalLayouts; 1824 } 1825 1659 1826 /********************************************************************************************************************************* 1660 1827 * UIPhysicalLayoutReader implementation. * … … 1687 1854 parseRowSpace(rows); 1688 1855 else if (m_xmlReader.name() == "name") 1689 physicalLayout. m_strName = m_xmlReader.readElementText();1856 physicalLayout.setName(m_xmlReader.readElementText()); 1690 1857 else if (m_xmlReader.name() == "id") 1691 1858 physicalLayout.m_uId = m_xmlReader.readElementText(); … … 1952 2119 , m_pContainerWidget(0) 1953 2120 , m_strMachineName(strMachineName) 2121 , m_pSplitter(0) 1954 2122 , m_pSettingsButton(0) 2123 , m_pSidePanelContainerWidget(0) 2124 , m_pLayoutEditor(0) 1955 2125 { 1956 2126 setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Soft Keyboard"))); … … 1960 2130 1961 2131 if (m_pContainerWidget) 1962 m_pContainerWidget->load DefaultLayout();2132 m_pContainerWidget->loadLayouts(); 1963 2133 1964 2134 loadSettings(); … … 2009 2179 } 2010 2180 2011 void UISoftKeyboard::sltHandleLayoutChange(const QString &strLayoutName)2012 {2013 if (m_strLayoutName == strLayoutName)2014 return;2015 m_strLayoutName = strLayoutName;2016 updateStatusBarMessage();2017 }2018 2019 void UISoftKeyboard::sltHandleKeyCapFileChange(const QString &strKeyCapFileName)2020 {2021 if (strKeyCapFileName == m_strKeyCapFileName)2022 return;2023 m_strKeyCapFileName = strKeyCapFileName;2024 updateStatusBarMessage();2025 }2026 2027 2181 void UISoftKeyboard::sltHandleStatusBarContextMenuRequest(const QPoint &point) 2028 2182 { … … 2033 2187 void UISoftKeyboard::prepareObjects() 2034 2188 { 2189 m_pSplitter = new QSplitter; 2190 if (!m_pSplitter) 2191 return; 2192 setCentralWidget(m_pSplitter); 2193 2194 m_pSidePanelContainerWidget = new QStackedWidget; 2195 m_pSplitter->addWidget(m_pSidePanelContainerWidget); 2196 2197 m_pLayoutSelector = new UILayoutSelector; 2198 if (m_pLayoutSelector) 2199 m_pSidePanelContainerWidget->addWidget(m_pLayoutSelector); 2200 2201 m_pLayoutEditor = new UILayoutEditor; 2202 if (m_pLayoutEditor) 2203 m_pSidePanelContainerWidget->addWidget(m_pLayoutEditor); 2204 2035 2205 m_pContainerWidget = new UISoftKeyboardWidget; 2036 2206 if (!m_pContainerWidget) 2037 2207 return; 2038 2208 m_pContainerWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); 2039 setCentralWidget(m_pContainerWidget);2040 2209 m_pContainerWidget->updateGeometry(); 2041 2210 m_pSplitter->addWidget(m_pContainerWidget); 2042 2211 2043 2212 statusBar()->setContextMenuPolicy(Qt::CustomContextMenu); … … 2062 2231 connect(m_pSession, &UISession::sigKeyboardLedsChange, this, &UISoftKeyboard::sltHandleKeyboardLedsChange); 2063 2232 connect(m_pContainerWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltHandlePutKeyboardSequence); 2064 connect(m_pContainerWidget, &UISoftKeyboardWidget::sigLayoutChange, this, &UISoftKeyboard::sltHandleLayoutChange);2065 connect(m_pContainerWidget, &UISoftKeyboardWidget::sigKeyCapChange, this, &UISoftKeyboard::sltHandleKeyCapFileChange);2066 2233 } 2067 2234 -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r79089 r79172 37 37 class QHBoxLayout; 38 38 class QVBoxLayout; 39 class UISoftKeyboardWidget;40 39 class QToolButton; 40 class UILayoutEditor; 41 class UILayoutSelector; 41 42 class UISession; 42 43 class UISoftKeyboardKey; 44 class UISoftKeyboardLayout; 45 class UISoftKeyboardWidget; 46 class QSplitter; 47 class QStackedWidget; 43 48 44 49 class UISoftKeyboard : public QIWithRetranslateUI<QMainWindow> … … 61 66 void sltHandleKeyboardLedsChange(); 62 67 void sltHandlePutKeyboardSequence(QVector<LONG> sequence); 63 void sltHandleLayoutChange(const QString &strLayoutName);64 void sltHandleKeyCapFileChange(const QString &strKeyCapFileName);65 68 void sltHandleStatusBarContextMenuRequest(const QPoint &point); 66 69 … … 80 83 QString m_strLayoutName; 81 84 QString m_strKeyCapFileName; 82 QToolButton *m_pSettingsButton; 85 QSplitter *m_pSplitter; 86 QToolButton *m_pSettingsButton; 87 QStackedWidget *m_pSidePanelContainerWidget; 88 UILayoutEditor *m_pLayoutEditor; 89 UILayoutSelector *m_pLayoutSelector; 83 90 }; 84 91 -
trunk/src/VBox/Frontends/VirtualBox/xml/german.xml
r79130 r79172 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <layout> 3 <name> US International</name>3 <name>German</name> 4 4 <physicallayoutid>{368efa94-3744-48c5-9d5a-59c2f15fe5ec}</physicallayoutid> 5 5 <key>
Note:
See TracChangeset
for help on using the changeset viewer.