VirtualBox

Changeset 79779 in vbox


Ignore:
Timestamp:
Jul 15, 2019 6:44:21 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6143. Adding a way to send press/release of modifier keys immediately

Location:
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp

    r79729 r79779  
    540540    void keyStateChange(UISoftKeyboardKey* pKey);
    541541    void loadLayouts();
    542     void showContextMenu(const QPoint &globalPoint);
    543542
    544543    void setCurrentLayout(const QString &strLayoutName);
     
    584583private slots:
    585584
    586     void sltContextMenuRequest(const QPoint &point);
    587585    void sltPhysicalLayoutForLayoutChanged(int iIndex);
    588586
     
    597595    void               handleKeyPress(UISoftKeyboardKey *pKey);
    598596    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);
    599600    bool               loadPhysicalLayout(const QString &strLayoutFileName, bool isNumPad = false);
    600601    bool               loadKeyboardLayout(const QString &strLayoutName);
     
    634635    int   m_iBottomMargin;
    635636
    636     QMenu   *m_pContextMenu;
    637637    Mode     m_enmMode;
    638638
     
    20202020    , m_iRightMargin(10)
    20212021    , m_iBottomMargin(10)
    2022     , m_pContextMenu(0)
    20232022    , m_enmMode(Mode_Keyboard)
    20242023    , m_fShowOSMenuKeys(true)
     
    21252124{
    21262125    QWidget::mousePressEvent(pEvent);
    2127     if (pEvent->button() != Qt::LeftButton)
    2128         return;
     2126    if (pEvent->button() != Qt::RightButton && pEvent->button() != Qt::LeftButton)
     2127        return;
     2128
    21292129    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    }
    21352144    update();
    21362145}
     
    21392148{
    21402149    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
    21432154    if (!m_pKeyPressed)
    21442155        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;
    21492164    update();
    2150     m_pKeyPressed = 0;
    21512165}
    21522166
     
    21592173void UISoftKeyboardWidget::retranslateUi()
    21602174{
    2161 }
    2162 
    2163 void UISoftKeyboardWidget::sltContextMenuRequest(const QPoint &point)
    2164 {
    2165     showContextMenu(mapToGlobal(point));
    21662175}
    21672176
     
    25392548}
    25402549
     2550void 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
    25412564void UISoftKeyboardWidget::keyStateChange(UISoftKeyboardKey* pKey)
    25422565{
     
    25512574                m_pressedModifiers.append(pKey);
    25522575    }
    2553 }
    2554 
    2555 void UISoftKeyboardWidget::showContextMenu(const QPoint &globalPoint)
    2556 {
    2557     m_pContextMenu->exec(globalPoint);
    2558     update();
    25592576}
    25602577
     
    27832800void UISoftKeyboardWidget::prepareObjects()
    27842801{
    2785     m_pContextMenu = new QMenu(this);
    2786 
    27872802    setMouseTracking(true);
    2788     setContextMenuPolicy(Qt::CustomContextMenu);
    2789     connect(this, &UISoftKeyboardWidget::customContextMenuRequested,
    2790             this, &UISoftKeyboardWidget::sltContextMenuRequest);
    27912803}
    27922804
     
    34853497}
    34863498
    3487 void UISoftKeyboard::sltStatusBarContextMenuRequest(const QPoint &point)
    3488 {
    3489     if (m_pKeyboardWidget)
    3490         m_pKeyboardWidget->showContextMenu(statusBar()->mapToGlobal(point));
    3491 }
    3492 
    34933499void UISoftKeyboard::sltLayoutSelectionChanged(const QUuid &layoutUid)
    34943500{
  • trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h

    r79729 r79779  
    7070    void sltPutUsageCodesRelease(QVector<QPair<LONG, LONG> > sequence);
    7171
    72     void sltStatusBarContextMenuRequest(const QPoint &point);
    7372    /** Handles the signal we get from the layout selector widget.
    7473      * Selection changed is forwarded to the keyboard widget. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette