Changeset 79779 in vbox
- Timestamp:
- Jul 15, 2019 6:44:21 AM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
- Files:
-
- 2 edited
-
UISoftKeyboard.cpp (modified) (12 diffs)
-
UISoftKeyboard.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r79729 r79779 540 540 void keyStateChange(UISoftKeyboardKey* pKey); 541 541 void loadLayouts(); 542 void showContextMenu(const QPoint &globalPoint);543 542 544 543 void setCurrentLayout(const QString &strLayoutName); … … 584 583 private slots: 585 584 586 void sltContextMenuRequest(const QPoint &point);587 585 void sltPhysicalLayoutForLayoutChanged(int iIndex); 588 586 … … 597 595 void handleKeyPress(UISoftKeyboardKey *pKey); 598 596 void handleKeyRelease(UISoftKeyboardKey *pKey); 597 /** Sends usage id/page to API when a modifier key is right clicked. useful for testing and things like 598 * Window key press for start menu opening. This works orthogonal to left clicks.*/ 599 void modifierKeyPressRelease(UISoftKeyboardKey *pKey, bool fRelease); 599 600 bool loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad = false); 600 601 bool loadKeyboardLayout(const QString &strLayoutName); … … 634 635 int m_iBottomMargin; 635 636 636 QMenu *m_pContextMenu;637 637 Mode m_enmMode; 638 638 … … 2020 2020 , m_iRightMargin(10) 2021 2021 , m_iBottomMargin(10) 2022 , m_pContextMenu(0)2023 2022 , m_enmMode(Mode_Keyboard) 2024 2023 , m_fShowOSMenuKeys(true) … … 2125 2124 { 2126 2125 QWidget::mousePressEvent(pEvent); 2127 if (pEvent->button() != Qt::LeftButton) 2128 return; 2126 if (pEvent->button() != Qt::RightButton && pEvent->button() != Qt::LeftButton) 2127 return; 2128 2129 2129 m_pKeyPressed = keyUnderMouse(pEvent); 2130 2131 if (m_enmMode == Mode_Keyboard) 2132 handleKeyPress(m_pKeyPressed); 2133 else if (m_enmMode == Mode_LayoutEdit) 2134 setKeyBeingEdited(m_pKeyUnderMouse); 2130 if (!m_pKeyPressed) 2131 return; 2132 2133 /* Handling the right button press: */ 2134 if (pEvent->button() == Qt::RightButton) 2135 modifierKeyPressRelease(m_pKeyPressed, false); 2136 else 2137 { 2138 /* Handling the left button press: */ 2139 if (m_enmMode == Mode_Keyboard) 2140 handleKeyPress(m_pKeyPressed); 2141 else if (m_enmMode == Mode_LayoutEdit) 2142 setKeyBeingEdited(m_pKeyUnderMouse); 2143 } 2135 2144 update(); 2136 2145 } … … 2139 2148 { 2140 2149 QWidget::mouseReleaseEvent(pEvent); 2141 if (pEvent->button() != Qt::LeftButton) 2142 return; 2150 2151 if (pEvent->button() != Qt::RightButton && pEvent->button() != Qt::LeftButton) 2152 return; 2153 2143 2154 if (!m_pKeyPressed) 2144 2155 return; 2145 2146 if (m_enmMode == Mode_Keyboard) 2147 handleKeyRelease(m_pKeyPressed); 2148 2156 if (pEvent->button() == Qt::RightButton) 2157 modifierKeyPressRelease(m_pKeyPressed, true); 2158 else 2159 { 2160 if (m_enmMode == Mode_Keyboard) 2161 handleKeyRelease(m_pKeyPressed); 2162 } 2163 m_pKeyPressed = 0; 2149 2164 update(); 2150 m_pKeyPressed = 0;2151 2165 } 2152 2166 … … 2159 2173 void UISoftKeyboardWidget::retranslateUi() 2160 2174 { 2161 }2162 2163 void UISoftKeyboardWidget::sltContextMenuRequest(const QPoint &point)2164 {2165 showContextMenu(mapToGlobal(point));2166 2175 } 2167 2176 … … 2539 2548 } 2540 2549 2550 void UISoftKeyboardWidget::modifierKeyPressRelease(UISoftKeyboardKey *pKey, bool fRelease) 2551 { 2552 if (!pKey || pKey->type() != KeyType_Modifier) 2553 return; 2554 if (pKey->state() != KeyState_NotPressed) 2555 return; 2556 QVector<QPair<LONG, LONG> > sequence; 2557 sequence << pKey->usagePageIdPair(); 2558 if (fRelease) 2559 emit sigPutUsageCodesPress(sequence); 2560 else 2561 emit sigPutUsageCodesRelease(sequence); 2562 } 2563 2541 2564 void UISoftKeyboardWidget::keyStateChange(UISoftKeyboardKey* pKey) 2542 2565 { … … 2551 2574 m_pressedModifiers.append(pKey); 2552 2575 } 2553 }2554 2555 void UISoftKeyboardWidget::showContextMenu(const QPoint &globalPoint)2556 {2557 m_pContextMenu->exec(globalPoint);2558 update();2559 2576 } 2560 2577 … … 2783 2800 void UISoftKeyboardWidget::prepareObjects() 2784 2801 { 2785 m_pContextMenu = new QMenu(this);2786 2787 2802 setMouseTracking(true); 2788 setContextMenuPolicy(Qt::CustomContextMenu);2789 connect(this, &UISoftKeyboardWidget::customContextMenuRequested,2790 this, &UISoftKeyboardWidget::sltContextMenuRequest);2791 2803 } 2792 2804 … … 3485 3497 } 3486 3498 3487 void UISoftKeyboard::sltStatusBarContextMenuRequest(const QPoint &point)3488 {3489 if (m_pKeyboardWidget)3490 m_pKeyboardWidget->showContextMenu(statusBar()->mapToGlobal(point));3491 }3492 3493 3499 void UISoftKeyboard::sltLayoutSelectionChanged(const QUuid &layoutUid) 3494 3500 { -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r79729 r79779 70 70 void sltPutUsageCodesRelease(QVector<QPair<LONG, LONG> > sequence); 71 71 72 void sltStatusBarContextMenuRequest(const QPoint &point);73 72 /** Handles the signal we get from the layout selector widget. 74 73 * Selection changed is forwarded to the keyboard widget. */
Note:
See TracChangeset
for help on using the changeset viewer.

