Changeset 79184 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jun 17, 2019 1:23:13 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79172 r79184 35 35 #include <QVBoxLayout> 36 36 37 38 37 /* GUI includes: */ 39 38 #include "QIDialogButtonBox.h" … … 122 121 123 122 void sigLayoutEdited(); 123 void sigKeyCaptionsEdited(UISoftKeyboardKey* pKey); 124 124 void sigGoBackButton(); 125 125 … … 141 141 void sltKeyShiftCaptionChange(); 142 142 void sltKeyAltGrCaptionChange(); 143 void sltLayoutNameChange();144 143 void sltHandlePhysicalLayoutChanged(); 145 144 … … 149 148 void prepareConnections(); 150 149 QWidget *prepareKeyCaptionEditWidgets(); 150 void reset(); 151 151 152 152 QGridLayout *m_pEditorLayout; … … 175 175 /** The layout which is being currently edited. */ 176 176 UISoftKeyboardLayout *m_pLayout; 177 QVector<UISoftKeyboardPhysicalLayout> m_physicalLayouts;178 177 }; 179 178 … … 188 187 signals: 189 188 190 void sig ApplySelectedLayout(const QString &strSelectedLayoutName);191 void sig EditSelectedLayout();189 void sigLayoutSelectionChanged(const QString &strSelectedLayoutName); 190 void sigShowLayoutEditor(); 192 191 193 192 public: … … 195 194 UILayoutSelector(QWidget *pParent = 0); 196 195 void setLayoutList(const QStringList &layoutNames); 197 QString selectedLayoutName() const; 198 void selectLayoutByName(const QString &strLayoutName); 196 void setCurrentLayout(const QString &strLayoutName); 199 197 200 198 protected: … … 352 350 public: 353 351 354 UISoftKeyboardLayout() 355 :m_pPhysicalLayout(0){} 352 UISoftKeyboardLayout(){} 356 353 357 354 void setName(const QString &strName) … … 360 357 } 361 358 359 void updateKeyCaptions(int iKeyPosition, KeyCaptions &newCaptions) 360 { 361 if (!m_keyCapMap.contains(iKeyPosition)) 362 return; 363 m_keyCapMap[iKeyPosition] = newCaptions; 364 } 365 362 366 const QString &name() const 363 367 { … … 365 369 } 366 370 367 /** The physical layout used by this layout. */368 UISoftKeyboardPhysicalLayout *m_pPhysicalLayout;371 /** The UUID of the physical layout used by this layout. */ 372 QUuid m_physicalLayoutUuid; 369 373 370 374 /** We cache the key caps here instead of reading the layout files each time layout changes. … … 395 399 396 400 void sigPutKeyboardSequence(QVector<LONG> sequence); 397 void sig LayoutChange(const QString &strLayoutName);398 void sig LayoutListChanged(QStringList layoutNames);401 void sigCurrentLayoutChange(); 402 void sigKeyToEdit(UISoftKeyboardKey* pKey); 399 403 400 404 public: … … 407 411 void loadLayouts(); 408 412 void showContextMenu(const QPoint &globalPoint); 409 void applyLayoutByName(const QString &strLayoutName); 413 414 void setCurrentLayout(const QString &strLayoutName); 415 UISoftKeyboardLayout *currentLayout(); 416 410 417 QStringList layoutNameList() const; 411 418 const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts() const; 419 420 void toggleEditMode(bool fIsEditMode); 421 /** Is called when the captions in UISoftKeyboardKey is changed and forward this changes to 422 * corresponding UISoftKeyboardLayout */ 423 void updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey); 412 424 413 425 protected: … … 423 435 void sltHandleContextMenuRequest(const QPoint &point); 424 436 void sltHandleSaveLayout(); 425 void sltHandleLayoutEditModeToggle(bool fToggle);426 437 void sltHandleNewLayout(); 427 438 void sltPhysicalLayoutForLayoutChanged(int iIndex); … … 440 451 void reset(); 441 452 void prepareObjects(); 453 UISoftKeyboardPhysicalLayout *findPhysicalLayout(const QUuid &uuid); 442 454 /** Sets m_pKeyBeingEdited. */ 443 455 void setKeyBeingEdited(UISoftKeyboardKey *pKey); 444 456 void setCurrentLayout(UISoftKeyboardLayout *pLayout); 445 void emitLayoutNames();446 457 UISoftKeyboardLayout *findLayoutByName(const QString &strName); 447 458 … … 552 563 , m_pAltGrCaptionEdit(0) 553 564 , m_pKey(0) 565 , m_pLayout(0) 554 566 { 555 567 setAutoFillBackground(true); … … 580 592 void UILayoutEditor::setLayoutToEdit(UISoftKeyboardLayout *pLayout) 581 593 { 582 if (m_pLayout != pLayout) 583 return; 594 if (m_pLayout == pLayout) 595 return; 596 597 m_pLayout = pLayout; 598 if (!m_pLayout) 599 reset(); 600 584 601 if (m_pLayoutNameEdit) 585 m_pLayoutNameEdit->setText(m_pLayout->name()); 602 m_pLayoutNameEdit->setText(m_pLayout ? m_pLayout->name() : QString()); 603 604 if (m_pPhysicalLayoutCombo && m_pLayout) 605 { 606 int iIndex = m_pPhysicalLayoutCombo->findData(m_pLayout->m_physicalLayoutUuid); 607 if (iIndex != -1) 608 m_pPhysicalLayoutCombo->setCurrentIndex(iIndex); 609 } 586 610 update(); 587 611 } … … 589 613 void UILayoutEditor::setPhysicalLayoutList(const QVector<UISoftKeyboardPhysicalLayout> &physicalLayouts) 590 614 { 591 m_physicalLayouts = physicalLayouts;592 593 615 if (!m_pPhysicalLayoutCombo) 594 616 return; … … 627 649 return; 628 650 m_pKey->setBaseCaption(m_pBaseCaptionEdit->text()); 651 emit sigKeyCaptionsEdited(m_pKey); 652 } 653 654 void UILayoutEditor::sltKeyShiftCaptionChange() 655 { 656 if (!m_pKey || !m_pShiftCaptionEdit) 657 return; 658 m_pKey->setShiftCaption(m_pShiftCaptionEdit->text()); 659 emit sigKeyCaptionsEdited(m_pKey); 660 } 661 662 void UILayoutEditor::sltKeyAltGrCaptionChange() 663 { 664 if (!m_pKey || !m_pAltGrCaptionEdit) 665 return; 666 m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text()); 667 emit sigKeyCaptionsEdited(m_pKey); 668 } 669 670 void UILayoutEditor::sltHandlePhysicalLayoutChanged() 671 { 672 if (!m_pPhysicalLayoutCombo || !m_pLayout) 673 return; 674 QUuid currentData = m_pPhysicalLayoutCombo->currentData().toUuid(); 675 if (!currentData.isNull()) 676 m_pLayout->m_physicalLayoutUuid = currentData; 629 677 emit sigLayoutEdited(); 630 }631 632 void UILayoutEditor::sltKeyShiftCaptionChange()633 {634 if (!m_pKey || !m_pShiftCaptionEdit)635 return;636 m_pKey->setShiftCaption(m_pShiftCaptionEdit->text());637 emit sigLayoutEdited();638 }639 640 void UILayoutEditor::sltKeyAltGrCaptionChange()641 {642 if (!m_pKey || !m_pAltGrCaptionEdit)643 return;644 m_pKey->setAltGrCaption(m_pAltGrCaptionEdit->text());645 emit sigLayoutEdited();646 }647 648 void UILayoutEditor::sltLayoutNameChange()649 {650 if (!m_pLayoutNameEdit)651 return;652 emit sigLayoutEdited();653 }654 655 void UILayoutEditor::sltHandlePhysicalLayoutChanged()656 {657 if (!m_pPhysicalLayoutCombo)658 return;659 660 661 678 } 662 679 … … 678 695 m_pEditorLayout->addWidget(m_pLayoutNameLabel, 1, 0, 1, 1); 679 696 m_pEditorLayout->addWidget(m_pLayoutNameEdit, 1, 1, 1, 1); 680 connect(m_pLayoutNameEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::s ltLayoutNameChange);697 connect(m_pLayoutNameEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sigLayoutEdited); 681 698 682 699 … … 756 773 connect(m_pAltGrCaptionEdit, &QLineEdit::editingFinished, this, &UILayoutEditor::sltKeyAltGrCaptionChange); 757 774 758 759 775 QSpacerItem *pSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); 760 776 if (pSpacer) 761 777 pCaptionEditorLayout->addItem(pSpacer, 4, 1); 762 778 return m_pCaptionEditGroupBox; 779 } 780 781 void UILayoutEditor::reset() 782 { 783 if (m_pLayoutNameEdit) 784 m_pLayoutNameEdit->clear(); 785 if (m_pScanCodeEdit) 786 m_pScanCodeEdit->clear(); 787 if (m_pPositionEdit) 788 m_pPositionEdit->clear(); 789 if (m_pBaseCaptionEdit) 790 m_pBaseCaptionEdit->clear(); 791 if (m_pShiftCaptionEdit) 792 m_pShiftCaptionEdit->clear(); 793 if (m_pAltGrCaptionEdit) 794 m_pAltGrCaptionEdit->clear(); 763 795 } 764 796 … … 776 808 } 777 809 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) 810 void UILayoutSelector::setCurrentLayout(const QString &strLayoutName) 786 811 { 787 812 if (!m_pLayoutListWidget) 788 813 return; 814 if (strLayoutName.isEmpty()) 815 { 816 m_pLayoutListWidget->selectionModel()->clear(); 817 return; 818 } 789 819 QList<QListWidgetItem *> items = m_pLayoutListWidget->findItems(strLayoutName, Qt::MatchFixedString |Qt::MatchCaseSensitive); 790 820 if (items.isEmpty()) … … 823 853 m_pLayoutListWidget = new QListWidget; 824 854 pLayout->addWidget(m_pLayoutListWidget); 825 connect(m_pLayoutListWidget, &QListWidget::currentTextChanged, this, &UILayoutSelector::sig ApplySelectedLayout);855 connect(m_pLayoutListWidget, &QListWidget::currentTextChanged, this, &UILayoutSelector::sigLayoutSelectionChanged); 826 856 827 857 QHBoxLayout *pButtonsLayout = new QHBoxLayout; 828 858 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 859 835 860 m_pEditLayoutButton = new QToolButton; 836 861 m_pEditLayoutButton->setIcon(UIIconPool::iconSet(":/keyboard_settings_16px.png")); 837 862 pButtonsLayout->addWidget(m_pEditLayoutButton); 838 connect(m_pEditLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sig EditSelectedLayout);863 connect(m_pEditLayoutButton, &QToolButton::pressed, this, &UILayoutSelector::sigShowLayoutEditor); 839 864 840 865 pButtonsLayout->addStretch(2); … … 1189 1214 Q_UNUSED(pEvent); 1190 1215 1191 int iEditDialogWidth = 0; 1192 if (m_enmMode == Mode_LayoutEdit) 1193 iEditDialogWidth = 34 * QApplication::fontMetrics().width('x'); 1194 m_fScaleFactorX = (width() - iEditDialogWidth) / (float) m_iInitialWidth; 1216 m_fScaleFactorX = width() / (float) m_iInitialWidth; 1195 1217 m_fScaleFactorY = height() / (float) m_iInitialHeight; 1196 1218 … … 1208 1230 if (!m_pCurrentKeyboardLayout || m_iInitialWidth == 0 || m_iInitialHeight == 0) 1209 1231 return; 1210 if (!m_pCurrentKeyboardLayout->m_pPhysicalLayout) 1211 return; 1212 1213 QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows; 1232 1233 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid); 1234 if (!pPhysicalLayout) 1235 return; 1236 1237 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows; 1214 1238 for (int i = 0; i < rows.size(); ++i) 1215 1239 { … … 1371 1395 // { 1372 1396 // m_pLastSelectedLayout = pSenderAction; 1373 // emit sig LayoutChange(strLayout);1397 // emit sigCurrentLayoutChange(strLayout); 1374 1398 // return; 1375 1399 // } … … 1380 1404 // QString strLayout = m_pLastSelectedLayout->data().toString(); 1381 1405 // loadPhysicalLayout(strLayout); 1382 // emit sig LayoutChange(strLayout);1406 // emit sigCurrentLayoutChange(strLayout); 1383 1407 // m_pLastSelectedLayout->setChecked(true); 1384 1408 // } … … 1391 1415 if (strFileName.isEmpty()) 1392 1416 return; 1393 if (!m_pCurrentKeyboardLayout || !m_pCurrentKeyboardLayout->m_pPhysicalLayout) 1417 if (!m_pCurrentKeyboardLayout) 1418 return; 1419 1420 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid); 1421 if (!pPhysicalLayout) 1394 1422 return; 1395 1423 … … 1408 1436 xmlWriter.writeStartElement("layout"); 1409 1437 xmlWriter.writeTextElement("name", m_pCurrentKeyboardLayout->name()); 1410 xmlWriter.writeTextElement("physicallayoutid", m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_uId.toString());1411 1412 QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows;1438 xmlWriter.writeTextElement("physicallayoutid", pPhysicalLayout->m_uId.toString()); 1439 1440 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows; 1413 1441 for (int i = 0; i < rows.size(); ++i) 1414 1442 { … … 1460 1488 // } 1461 1489 1462 void UISoftKeyboardWidget:: sltHandleLayoutEditModeToggle(bool fToggle)1463 { 1464 if (f Toggle)1490 void UISoftKeyboardWidget::toggleEditMode(bool fIsEditMode) 1491 { 1492 if (fIsEditMode) 1465 1493 m_enmMode = Mode_LayoutEdit; 1466 1494 else … … 1471 1499 } 1472 1500 1501 void UISoftKeyboardWidget::updateKeyCaptionsInLayout(UISoftKeyboardKey *pKey) 1502 { 1503 if (!m_pCurrentKeyboardLayout || !pKey) 1504 return; 1505 1506 /* Assuming the key captions are changed for the current layout: */ 1507 KeyCaptions newCaptions; 1508 newCaptions.m_strBase = pKey->baseCaption(); 1509 newCaptions.m_strShift = pKey->shiftCaption(); 1510 newCaptions.m_strAltGr = pKey->altGrCaption(); 1511 m_pCurrentKeyboardLayout->updateKeyCaptions(pKey->position(), newCaptions); 1512 } 1513 1473 1514 void UISoftKeyboardWidget::sltHandleNewLayout() 1474 1515 { … … 1478 1519 m_layouts.append(UISoftKeyboardLayout()); 1479 1520 UISoftKeyboardLayout &newLayout = m_layouts.back(); 1480 newLayout.m_p PhysicalLayout = &(m_physicalLayouts[0]);1521 newLayout.m_physicalLayoutUuid = m_physicalLayouts[0].m_uId; 1481 1522 newLayout.setName(QString(UISoftKeyboard::tr("Unnamed"))); 1482 1523 setCurrentLayout(&newLayout); … … 1490 1531 return; 1491 1532 1492 if (m_pCurrentKeyboardLayout->m_p PhysicalLayout == &(m_physicalLayouts[iIndex]))1493 return; 1494 m_pCurrentKeyboardLayout->m_p PhysicalLayout = &(m_physicalLayouts[iIndex]);1533 if (m_pCurrentKeyboardLayout->m_physicalLayoutUuid == m_physicalLayouts[iIndex].m_uId) 1534 return; 1535 m_pCurrentKeyboardLayout->m_physicalLayoutUuid = m_physicalLayouts[iIndex].m_uId; 1495 1536 update(); 1496 1537 } … … 1516 1557 UISoftKeyboardKey *UISoftKeyboardWidget::keyUnderMouse(const QPoint &eventPosition) 1517 1558 { 1518 if (!m_pCurrentKeyboardLayout || !m_pCurrentKeyboardLayout->m_pPhysicalLayout)1559 if (!m_pCurrentKeyboardLayout) 1519 1560 return 0; 1561 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid); 1562 if (!pPhysicalLayout) 1563 return 0; 1564 1520 1565 UISoftKeyboardKey *pKey = 0; 1521 QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows;1566 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows; 1522 1567 for (int i = 0; i < rows.size(); ++i) 1523 1568 { … … 1586 1631 } 1587 1632 1588 void UISoftKeyboardWidget:: applyLayoutByName(const QString &strLayoutName)1633 void UISoftKeyboardWidget::setCurrentLayout(const QString &strLayoutName) 1589 1634 { 1590 1635 UISoftKeyboardLayout *pLayout = findLayoutByName(strLayoutName); … … 1592 1637 return; 1593 1638 setCurrentLayout(pLayout); 1639 } 1640 1641 UISoftKeyboardLayout *UISoftKeyboardWidget::currentLayout() 1642 { 1643 return m_pCurrentKeyboardLayout; 1594 1644 } 1595 1645 … … 1696 1746 m_layouts.append(UISoftKeyboardLayout()); 1697 1747 UISoftKeyboardLayout &newLayout = m_layouts.back(); 1698 newLayout.m_p PhysicalLayout = pPhysicalLayout;1748 newLayout.m_physicalLayoutUuid = pPhysicalLayout->m_uId; 1699 1749 newLayout.setName(keyboardLayoutReader.name()); 1700 1750 newLayout.m_keyCapMap = keyboardLayoutReader.keyCapMap(); 1701 1751 return true; 1752 } 1753 1754 UISoftKeyboardPhysicalLayout *UISoftKeyboardWidget::findPhysicalLayout(const QUuid &uuid) 1755 { 1756 for (int i = 0; i < m_physicalLayouts.size(); ++i) 1757 { 1758 if (m_physicalLayouts[i].m_uId == uuid) 1759 return &(m_physicalLayouts[i]); 1760 } 1761 return 0; 1702 1762 } 1703 1763 … … 1722 1782 foreach (const QString &strName, keyboardLayoutNames) 1723 1783 loadKeyboardLayout(strName); 1724 emitLayoutNames(); 1784 1725 1785 if (m_layouts.isEmpty()) 1726 1786 return; … … 1736 1796 1737 1797 m_pLayoutEditModeToggleAction = m_pContextMenu->addAction(UISoftKeyboard::tr("Edit the layout")); 1738 connect(m_pLayoutEditModeToggleAction, &QAction::toggled, this, &UISoftKeyboardWidget::sltHandleLayoutEditModeToggle);1739 1798 m_pLayoutEditModeToggleAction->setCheckable(true); 1740 1799 m_pLayoutEditModeToggleAction->setChecked(false); … … 1760 1819 return; 1761 1820 m_pKeyBeingEdited = pKey; 1762 // if (m_pLayoutEditor) 1763 // m_pLayoutEditor->setKey(pKey); 1821 emit sigKeyToEdit(pKey); 1764 1822 } 1765 1823 … … 1771 1829 if (!m_pCurrentKeyboardLayout) 1772 1830 { 1773 emit sig LayoutChange(QString());1774 return; 1775 } 1776 emit sig LayoutChange(m_pCurrentKeyboardLayout->name());1831 emit sigCurrentLayoutChange(); 1832 return; 1833 } 1834 emit sigCurrentLayoutChange(); 1777 1835 1778 1836 const QMap<int, KeyCaptions> &keyCapMap = m_pCurrentKeyboardLayout->m_keyCapMap; 1779 1837 1838 UISoftKeyboardPhysicalLayout *pPhysicalLayout = findPhysicalLayout(m_pCurrentKeyboardLayout->m_physicalLayoutUuid); 1839 if (!pPhysicalLayout) 1840 return; 1841 1780 1842 /* Update the key captions: */ 1781 QVector<UISoftKeyboardRow> &rows = m_pCurrentKeyboardLayout->m_pPhysicalLayout->m_rows;1843 QVector<UISoftKeyboardRow> &rows = pPhysicalLayout->m_rows; 1782 1844 for (int i = 0; i < rows.size(); ++i) 1783 1845 { … … 1794 1856 } 1795 1857 } 1796 } 1797 1798 void UISoftKeyboardWidget::emitLayoutNames() 1799 { 1800 emit sigLayoutListChanged(layoutNameList()); 1858 update(); 1801 1859 } 1802 1860 … … 2117 2175 , m_pSession(pSession) 2118 2176 , m_pMainLayout(0) 2119 , m_p ContainerWidget(0)2177 , m_pKeyboardWidget(0) 2120 2178 , m_strMachineName(strMachineName) 2121 2179 , m_pSplitter(0) … … 2129 2187 prepareConnections(); 2130 2188 2131 if (m_pContainerWidget) 2132 m_pContainerWidget->loadLayouts(); 2189 if (m_pKeyboardWidget) 2190 { 2191 m_pKeyboardWidget->loadLayouts(); 2192 /* Update the selector widget: */ 2193 if (m_pLayoutSelector) 2194 m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList()); 2195 if (m_pLayoutEditor) 2196 m_pLayoutEditor->setPhysicalLayoutList(m_pKeyboardWidget->physicalLayouts()); 2197 } 2133 2198 2134 2199 loadSettings(); 2135 2200 retranslateUi(); 2136 updateStatusBarMessage();2137 2201 } 2138 2202 … … 2158 2222 if (pMouseEvent && pMouseEvent->button() == Qt::LeftButton) 2159 2223 { 2160 if (m_p ContainerWidget)2161 m_p ContainerWidget->showContextMenu(m_pSettingsButton->mapToGlobal(pMouseEvent->pos()));2224 if (m_pKeyboardWidget) 2225 m_pKeyboardWidget->showContextMenu(m_pSettingsButton->mapToGlobal(pMouseEvent->pos())); 2162 2226 return true; 2163 2227 } … … 2181 2245 void UISoftKeyboard::sltHandleStatusBarContextMenuRequest(const QPoint &point) 2182 2246 { 2183 if (m_pContainerWidget) 2184 m_pContainerWidget->showContextMenu(statusBar()->mapToGlobal(point)); 2247 if (m_pKeyboardWidget) 2248 m_pKeyboardWidget->showContextMenu(statusBar()->mapToGlobal(point)); 2249 } 2250 2251 void UISoftKeyboard::sltLayoutSelectionChanged(const QString &strLayoutName) 2252 { 2253 if (m_pKeyboardWidget) 2254 m_pKeyboardWidget->setCurrentLayout(strLayoutName); 2255 } 2256 2257 void UISoftKeyboard::sltCurentLayoutChanged() 2258 { 2259 if (!m_pKeyboardWidget) 2260 return; 2261 UISoftKeyboardLayout *pCurrentLayout = m_pKeyboardWidget->currentLayout(); 2262 2263 /* Update the status bar string: */ 2264 QString strLayoutName = pCurrentLayout ? pCurrentLayout->name() : QString(); 2265 updateStatusBarMessage(strLayoutName); 2266 } 2267 2268 void UISoftKeyboard::sltShowLayoutSelector() 2269 { 2270 if (m_pSidePanelContainerWidget && m_pLayoutSelector) 2271 m_pSidePanelContainerWidget->setCurrentWidget(m_pLayoutSelector); 2272 if (m_pKeyboardWidget) 2273 m_pKeyboardWidget->toggleEditMode(false); 2274 } 2275 2276 void UISoftKeyboard::sltShowLayoutEditor() 2277 { 2278 if (m_pSidePanelContainerWidget && m_pLayoutEditor) 2279 { 2280 m_pLayoutEditor->setLayoutToEdit(m_pKeyboardWidget->currentLayout()); 2281 m_pSidePanelContainerWidget->setCurrentWidget(m_pLayoutEditor); 2282 } 2283 if (m_pKeyboardWidget) 2284 m_pKeyboardWidget->toggleEditMode(true); 2285 } 2286 2287 void UISoftKeyboard::sltKeyToEditChanged(UISoftKeyboardKey* pKey) 2288 { 2289 if (m_pLayoutEditor) 2290 m_pLayoutEditor->setKey(pKey); 2291 } 2292 2293 void UISoftKeyboard::sltLayoutEdited() 2294 { 2295 if (!m_pKeyboardWidget) 2296 return; 2297 m_pKeyboardWidget->update(); 2298 if (m_pLayoutSelector) 2299 { 2300 m_pLayoutSelector->setLayoutList(m_pKeyboardWidget->layoutNameList()); 2301 m_pLayoutSelector->setCurrentLayout(m_pKeyboardWidget->currentLayout() ? m_pKeyboardWidget->currentLayout()->name() : QString()); 2302 } 2303 } 2304 2305 void UISoftKeyboard::sltKeyCaptionsEdited(UISoftKeyboardKey* pKey) 2306 { 2307 if (m_pKeyboardWidget) 2308 { 2309 m_pKeyboardWidget->updateKeyCaptionsInLayout(pKey); 2310 m_pKeyboardWidget->update(); 2311 } 2185 2312 } 2186 2313 … … 2203 2330 m_pSidePanelContainerWidget->addWidget(m_pLayoutEditor); 2204 2331 2205 m_p ContainerWidget = new UISoftKeyboardWidget;2206 if (!m_p ContainerWidget)2207 return; 2208 m_p ContainerWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);2209 m_p ContainerWidget->updateGeometry();2210 m_pSplitter->addWidget(m_p ContainerWidget);2332 m_pKeyboardWidget = new UISoftKeyboardWidget; 2333 if (!m_pKeyboardWidget) 2334 return; 2335 m_pKeyboardWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); 2336 m_pKeyboardWidget->updateGeometry(); 2337 m_pSplitter->addWidget(m_pKeyboardWidget); 2211 2338 2212 2339 statusBar()->setContextMenuPolicy(Qt::CustomContextMenu); … … 2230 2357 { 2231 2358 connect(m_pSession, &UISession::sigKeyboardLedsChange, this, &UISoftKeyboard::sltHandleKeyboardLedsChange); 2232 connect(m_pContainerWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltHandlePutKeyboardSequence); 2359 connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigPutKeyboardSequence, this, &UISoftKeyboard::sltHandlePutKeyboardSequence); 2360 connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigCurrentLayoutChange, this, &UISoftKeyboard::sltCurentLayoutChanged); 2361 connect(m_pKeyboardWidget, &UISoftKeyboardWidget::sigKeyToEdit, this, &UISoftKeyboard::sltKeyToEditChanged); 2362 2363 connect(m_pLayoutSelector, &UILayoutSelector::sigLayoutSelectionChanged, this, &UISoftKeyboard::sltLayoutSelectionChanged); 2364 connect(m_pLayoutSelector, &UILayoutSelector::sigShowLayoutEditor, this, &UISoftKeyboard::sltShowLayoutEditor); 2365 connect(m_pLayoutEditor, &UILayoutEditor::sigGoBackButton, this, &UISoftKeyboard::sltShowLayoutSelector); 2366 connect(m_pLayoutEditor, &UILayoutEditor::sigLayoutEdited, this, &UISoftKeyboard::sltLayoutEdited); 2367 connect(m_pLayoutEditor, &UILayoutEditor::sigKeyCaptionsEdited, this, &UISoftKeyboard::sltKeyCaptionsEdited); 2233 2368 } 2234 2369 … … 2241 2376 } 2242 2377 2243 void UISoftKeyboard::updateStatusBarMessage( )2378 void UISoftKeyboard::updateStatusBarMessage(const QString &strName) 2244 2379 { 2245 2380 QString strMessage; 2246 if (!m_strLayoutName.isEmpty()) 2247 strMessage += QString("%1: %2").arg(tr("Layout")).arg(m_strLayoutName); 2248 if (!m_strKeyCapFileName.isEmpty()) 2249 strMessage += QString("\t/\t %1: %2").arg(tr("Key Captions File")).arg(m_strKeyCapFileName); 2250 statusBar()->showMessage(strMessage); 2381 if (!strName.isEmpty()) 2382 { 2383 strMessage += QString("%1: %2").arg(tr("Layout")).arg(strName); 2384 statusBar()->showMessage(strMessage); 2385 } 2386 else 2387 statusBar()->showMessage(QString()); 2251 2388 } 2252 2389 -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r79172 r79184 68 68 void sltHandleStatusBarContextMenuRequest(const QPoint &point); 69 69 70 /** Handles the signal we get from the layout selector widget. 71 * Selection changed is forwarded to the keyboard widget. */ 72 void sltLayoutSelectionChanged(const QString &strLayoutName); 73 74 /** Handles the signal we get from the keyboard widget. */ 75 void sltCurentLayoutChanged(); 76 77 void sltShowLayoutSelector(); 78 void sltShowLayoutEditor(); 79 void sltKeyToEditChanged(UISoftKeyboardKey* pKey); 80 void sltLayoutEdited(); 81 /** Make th necessary changes to data structures when th key captions updated. */ 82 void sltKeyCaptionsEdited(UISoftKeyboardKey* pKey); 83 70 84 private: 71 85 … … 74 88 void saveSettings(); 75 89 void loadSettings(); 76 void updateStatusBarMessage( );90 void updateStatusBarMessage(const QString &strLayoutName); 77 91 CKeyboard& keyboard() const; 78 92 79 93 UISession *m_pSession; 80 94 QHBoxLayout *m_pMainLayout; 81 UISoftKeyboardWidget *m_p ContainerWidget;95 UISoftKeyboardWidget *m_pKeyboardWidget; 82 96 QString m_strMachineName; 83 QString m_strLayoutName;84 QString m_strKeyCapFileName;85 97 QSplitter *m_pSplitter; 86 98 QToolButton *m_pSettingsButton; -
trunk/src/VBox/Frontends/VirtualBox/xml/german.xml
r79172 r79184 5 5 <key> 6 6 <position>110</position> 7 <basecaption>Esc </basecaption>7 <basecaption>Escxx</basecaption> 8 8 <shiftcaption></shiftcaption> 9 9 <altgrcaption></altgrcaption>
Note:
See TracChangeset
for help on using the changeset viewer.