VirtualBox

Changeset 91002 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 30, 2021 3:07:42 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: Maybe a better solution to vm search widget show/hide bug than r146545.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerKeyboard.cpp

    r90909 r91002  
    307307            /* Start lookup only for non-empty and alphanumerical strings: */
    308308            const QString strText = pEvent->text();
    309             if (!strText.isEmpty() && !strText.contains(QRegExp("[^A-Za-z0-9]", Qt::CaseInsensitive)))
     309            if (!checkKey(pEvent->key()) && !strText.isEmpty())
    310310                model()->lookFor(strText);
    311311            break;
     
    393393    model()->saveGroups();
    394394}
     395
     396bool UIChooserHandlerKeyboard::checkKey(int iKey) const
     397{
     398    if (iKey == Qt::Key_Tab ||
     399        iKey == Qt::Key_Backtab ||
     400        iKey == Qt::Key_Backspace ||
     401        iKey == Qt::Key_Pause ||
     402        iKey == Qt::Key_Print ||
     403        iKey == Qt::Key_SysReq ||
     404        iKey == Qt::Key_Home ||
     405        iKey == Qt::Key_End ||
     406        iKey == Qt::Key_Left ||
     407        iKey == Qt::Key_Up ||
     408        iKey == Qt::Key_Right ||
     409        iKey == Qt::Key_Down ||
     410        iKey == Qt::Key_PageUp ||
     411        iKey == Qt::Key_PageDown ||
     412        iKey == Qt::Key_Shift ||
     413        iKey == Qt::Key_Alt ||
     414        iKey == Qt::Key_AltGr ||
     415        iKey == Qt::Key_CapsLock ||
     416        iKey == Qt::Key_NumLock ||
     417        iKey == Qt::Key_ScrollLock ||
     418        iKey == Qt::Key_Control)
     419        return true;
     420
     421    if ((Qt::Key)iKey >= Qt::Key_F1 &&
     422        (Qt::Key)iKey <= Qt::Key_F35)
     423        return true;
     424
     425    return false;
     426}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerKeyboard.h

    r82968 r91002  
    3030class QKeyEvent;
    3131
    32 /* Keyboard event type: */
     32/** Keyboard event type. */
    3333enum UIKeyboardEventType
    3434{
     
    3737};
    3838
    39 /* Item shift direction: */
     39/** Item shift direction. */
    4040enum UIItemShiftDirection
    4141{
     
    5151};
    5252
    53 /* Keyboard handler for graphics selector: */
     53/** Keyboard handler for graphics selector. */
    5454class UIChooserHandlerKeyboard : public QObject
    5555{
     
    5858public:
    5959
    60     /* Constructor: */
     60    /** Constructor. */
    6161    UIChooserHandlerKeyboard(UIChooserModel *pParent);
    6262
    63     /* API: Model keyboard-event handler delegate: */
     63    /** API: Model keyboard-event handler delegate. */
    6464    bool handle(QKeyEvent *pEvent, UIKeyboardEventType type) const;
    6565
    6666private:
    6767
    68     /* API: Model wrapper: */
     68    /** API: Model wrapper. */
    6969    UIChooserModel* model() const;
    7070
    71     /* Helpers: Model keyboard-event handler delegates: */
     71    /** Helpers: Model keyboard-event handler delegates. */
    7272    bool handleKeyPress(QKeyEvent *pEvent) const;
    7373    bool handleKeyRelease(QKeyEvent *pEvent) const;
    7474
    75     /* Helper: Item shift delegate: */
     75    /** Helper: Item shift delegate. */
    7676    void shift(UIItemShiftDirection enmDirection, UIItemShiftType enmShiftType) const;
    7777
    78     /* Variables: */
     78    /** Checks the iKey against a set of special keys and returns true if it is one of them.
     79      * Depending of this return value we either show the vm search widget or ignore the key event.
     80      * @param  iKey  Qt::key type we get from QKeyEvent::key(). */
     81    bool checkKey(int iKey) const;
     82
     83    /** Variables. */
    7984    UIChooserModel *m_pModel;
    8085    QMap<int, UIItemShiftType> m_shiftMap;
     
    8287
    8388#endif /* !FEQT_INCLUDED_SRC_manager_chooser_UIChooserHandlerKeyboard_h */
    84 
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