VirtualBox

Changeset 58921 in vbox


Ignore:
Timestamp:
Nov 30, 2015 7:07:00 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Qt5 migration (part 23): Adjusting X11 native stuff to Qt5: Host-combo editor.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.cpp

    r53221 r58921  
    2222/* Qt includes: */
    2323# include <QApplication>
     24# include <QKeyEvent>
    2425# include <QStyleOption>
    2526# include <QStylePainter>
    26 # include <QKeyEvent>
    2727# include <QTimer>
     28# ifdef Q_WS_X11
     29#  include <QX11Info>
     30# endif /* Q_WS_X11 */
    2831
    2932/* GUI includes: */
     
    3134# include "UIExtraDataDefs.h"
    3235# include "UIIconPool.h"
     36# include "VBoxGlobal.h"
    3337# include "QIToolButton.h"
    34 # include "VBoxGlobal.h"
     38#ifdef Q_WS_MAC
     39# include "UICocoaApplication.h"
     40# include "VBoxUtils-darwin.h"
     41#endif /* Q_WS_MAC */
    3542
    3643#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    3744
     45/* GUI includes: */
     46#ifdef Q_WS_MAC
     47# include "DarwinKeyboard.h"
     48#endif /* Q_WS_MAC */
    3849#ifdef Q_WS_WIN
    39 # undef LOWORD
    40 # undef HIWORD
    41 # undef LOBYTE
    42 # undef HIBYTE
    43 # include <windows.h>
    4450# include "WinKeyboard.h"
    4551#endif /* Q_WS_WIN */
    46 
     52#ifdef Q_WS_X11
     53# include "XKeyboard.h"
     54#endif /* Q_WS_X11 */
     55
     56/* External includes: */
     57#ifdef Q_WS_MAC
     58# include <Carbon/Carbon.h>
     59#endif /* Q_WS_MAC */
    4760#ifdef Q_WS_X11
    4861# include <X11/Xlib.h>
    4962# include <X11/Xutil.h>
    5063# include <X11/keysym.h>
    51 # ifdef KeyPress
    52    const int XKeyPress = KeyPress;
    53    const int XKeyRelease = KeyRelease;
    54 #  undef KeyPress
    55 #  undef KeyRelease
    56 # endif /* KeyPress */
    57 # include "XKeyboard.h"
    58 # include <QX11Info>
     64# if QT_VERSION >= 0x050000
     65#  include <xcb/xcb.h>
     66# endif /* QT_VERSION >= 0x050000 */
    5967#endif /* Q_WS_X11 */
    60 
    61 #ifdef Q_WS_MAC
    62 # include "UICocoaApplication.h"
    63 # include "DarwinKeyboard.h"
    64 # include "VBoxUtils.h"
    65 # include <Carbon/Carbon.h>
    66 #endif /* Q_WS_MAC */
    6768
    6869/* Namespaces: */
     
    518519
    519520#ifdef Q_WS_X11
    520 #pragma GCC diagnostic push
    521 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
     521# pragma GCC diagnostic push
     522# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
     523# if QT_VERSION >= 0x050000
     524bool UIHostComboEditorPrivate::nativeEvent(const QByteArray &eventType, void *pMessage, long *pResult)
     525{
     526    /* Make sure it's XCB event: */
     527    AssertReturn(eventType == "xcb_generic_event_t", QLineEdit::nativeEvent(eventType, pMessage, pResult));
     528    xcb_generic_event_t *pEvent = static_cast<xcb_generic_event_t*>(pMessage);
     529
     530    /* Check if some XCB event should be filtered out.
     531     * Returning @c true means filtering-out,
     532     * Returning @c false means passing event to Qt. */
     533    switch (pEvent->response_type & ~0x80)
     534    {
     535        /* Watch for key-events: */
     536        case XCB_KEY_PRESS:
     537        case XCB_KEY_RELEASE:
     538        {
     539            /* Parse key-event: */
     540            xcb_key_press_event_t *pKeyEvent = static_cast<xcb_key_press_event_t*>(pMessage);
     541            const KeySym ks = ::XKeycodeToKeysym(QX11Info::display(), pKeyEvent->detail, 0);
     542            const int iKeySym = static_cast<const int>(ks);
     543            /* Handle key-event: */
     544            return processKeyEvent(iKeySym, (pEvent->response_type & ~0x80) == XCB_KEY_PRESS);
     545        }
     546        default:
     547            break;
     548    }
     549
     550    /* Call to base-class: */
     551    return QLineEdit::nativeEvent(eventType, pMessage, pResult);
     552}
     553# else /* QT_VERSION < 0x050000 */
    522554bool UIHostComboEditorPrivate::x11Event(XEvent *pEvent)
    523555{
     
    542574    return false;
    543575}
    544 #pragma GCC diagnostic pop
     576# endif /* QT_VERSION < 0x050000 */
     577# pragma GCC diagnostic pop
    545578#endif /* Q_WS_X11 */
    546579
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h

    r55401 r58921  
    147147#endif /* Q_WS_WIN */
    148148#ifdef Q_WS_X11
     149# if QT_VERSION >= 0x050000
     150    bool nativeEvent(const QByteArray &eventType, void *pMessage, long *pResult);
     151# else /* QT_VERSION < 0x050000 */
    149152    bool x11Event(XEvent *pEvent);
     153# endif /* QT_VERSION < 0x050000 */
    150154#endif /* Q_WS_X11 */
    151155#ifdef Q_WS_MAC
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