VirtualBox

Changeset 68315 in vbox for trunk


Ignore:
Timestamp:
Aug 7, 2017 12:50:54 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: Wipe out all the QT_VERSION related stuff from the GUI code.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
47 edited

Legend:

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

    r65653 r68315  
    36703670    const OverlayList & overlays = mDisplay.overlays();
    36713671    QRect overInter = overlaysRectIntersection();
    3672 #if QT_VERSION >= 0x050000
    36733672    overInter = overInter.intersected(aRect);
    3674 #else /* QT_VERSION < 0x050000 */
    3675     overInter = overInter.intersect(aRect);
    3676 #endif /* QT_VERSION < 0x050000 */
    36773673
    36783674    bool bDisplayPrimary = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp

    r64762 r68315  
    2020#else  /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2121
    22 /* Qt includes: */
    23 # ifdef VBOX_WS_WIN
    24 #  include <QtGlobal> /* for QT_VERSION */
    25 #  if QT_VERSION < 0x050000
    26 #   include <QLibrary>
    27 #  endif
    28 # endif
    29 
    3022/* GUI includes: */
    3123# include "QILineEdit.h"
    32 
    33 /* Other VBox includes: */
    34 # ifdef VBOX_WS_WIN
    35 #  if QT_VERSION < 0x050000
    36 #   include "iprt/ldr.h"
    37 #  endif
    38 # endif
    39 
    40 /* External includes: */
    41 # ifdef VBOX_WS_WIN
    42 #  if QT_VERSION < 0x050000
    43 #   include <iprt/win/windows.h>
    44 #  endif
    45 # endif
    4624
    4725#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    4927/* Qt includes: */
    5028#include <QStyleOptionFrame>
    51 #ifdef VBOX_WS_WIN
    52 # if QT_VERSION < 0x050000
    53 #  include <QWindowsVistaStyle>
    54 # endif
    55 #endif
    5629
    5730
     
    8154    QSize sa = style()->sizeFromContents (QStyle::CT_LineEdit, &sof, sc, this);
    8255
    83 #ifdef VBOX_WS_WIN
    84 # if QT_VERSION < 0x050000
    85     /* Vista l&f style has a bug where the last parameter of sizeFromContents
    86      * function ('widget' what corresponds to 'this' in our class) is ignored.
    87      * Due to it QLineEdit processed as QComboBox and size calculation includes
    88      * non-existing combo-box button of 23 pix in width. So fixing it here: */
    89     if (qobject_cast <QWindowsVistaStyle*> (style()))
    90     {
    91         /* Check if l&f style theme is really active else painting performed by
    92          * Windows Classic theme and there is no such shifting error. */
    93         typedef BOOL (WINAPI *PFNISAPPTHEMED)(VOID);
    94         static PFNISAPPTHEMED s_pfnIsAppThemed = (PFNISAPPTHEMED)~(uintptr_t)0;
    95         if (s_pfnIsAppThemed == (PFNISAPPTHEMED)~(uintptr_t)0 )
    96             s_pfnIsAppThemed = (PFNISAPPTHEMED)RTLdrGetSystemSymbol("uxtheme.dll", "IsAppThemed");
    97 
    98         if (s_pfnIsAppThemed && s_pfnIsAppThemed())
    99             sa -= QSize(23, 0);
    100     }
    101 # endif /* QT_VERSION < 0x050000 */
    102 #endif /* VBOX_WS_WIN */
    103 
    10456    return sa;
    10557}
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/graphics/QIGraphicsView.cpp

    r62493 r68315  
    5252            AssertPtrReturn(pTouchEvent, QGraphicsView::event(pEvent));
    5353            /* For touch-screen event we have something special: */
    54 #if QT_VERSION >= 0x050000
    5554            if (pTouchEvent->device()->type() == QTouchDevice::TouchScreen)
    56 #else /* QT_VERSION < 0x050000 */
    57             if (pTouchEvent->deviceType() == QTouchEvent::TouchScreen)
    58 #endif /* QT_VERSION < 0x050000 */
    5955            {
    6056                /* Remember where the scrolling was started: */
     
    7369            AssertPtrReturn(pTouchEvent, QGraphicsView::event(pEvent));
    7470            /* For touch-screen event we have something special: */
    75 #if QT_VERSION >= 0x050000
    7671            if (pTouchEvent->device()->type() == QTouchDevice::TouchScreen)
    77 #else /* QT_VERSION < 0x050000 */
    78             if (pTouchEvent->deviceType() == QTouchEvent::TouchScreen)
    79 #endif /* QT_VERSION < 0x050000 */
    8072            {
    8173                /* Determine vertical shift (inverted): */
     
    10092            AssertPtrReturn(pTouchEvent, QGraphicsView::event(pEvent));
    10193            /* For touch-screen event we have something special: */
    102 #if QT_VERSION >= 0x050000
    10394            if (pTouchEvent->device()->type() == QTouchDevice::TouchScreen)
    104 #else /* QT_VERSION < 0x050000 */
    105             if (pTouchEvent->deviceType() == QTouchEvent::TouchScreen)
    106 #endif /* QT_VERSION < 0x050000 */
    10795            {
    10896                /* Reset the scrolling start position: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r68304 r68315  
    15381538            {
    15391539                /* Configure chooser-filter: */
    1540 #if QT_VERSION >= 0x040700
    15411540                m_pFilterOfChooser->setPlaceholderText("Search..");
    1542 #endif /* QT_VERSION >= 0x040700 */
    15431541                connect(m_pFilterOfChooser, SIGNAL(textChanged(const QString&)),
    15441542                        this, SLOT(sltChooserApplyFilter(const QString&)));
     
    16051603            {
    16061604                /* Configure data-filter: */
    1607 #if QT_VERSION >= 0x040700
    16081605                m_pFilterOfData->setPlaceholderText("Search..");
    1609 #endif /* QT_VERSION >= 0x040700 */
    16101606                connect(m_pFilterOfData, SIGNAL(textChanged(const QString&)),
    16111607                        this, SLOT(sltDataApplyFilter(const QString&)));
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp

    r68190 r68315  
    2323# include <QApplication>
    2424# include <QDesktopWidget>
     25# include <QScreen>
    2526# ifdef VBOX_WS_X11
    2627#  include <QTimer>
    2728# endif
    28 # if QT_VERSION >= 0x050000
    29 #  include <QScreen>
    30 # endif /* QT_VERSION >= 0x050000 */
    3129
    3230/* GUI includes: */
     
    343341}
    344342
    345 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     343#ifdef VBOX_WS_X11
    346344bool UIDesktopWidgetWatchdog::isFakeScreenDetected() const
    347345{
     
    355353           || (qApp->screens().size() == 1 && qApp->screens().first()->name() == ":0.0");
    356354}
    357 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
    358 
    359 #if QT_VERSION < 0x050000
    360 
    361 void UIDesktopWidgetWatchdog::sltHandleHostScreenCountChanged(int cHostScreenCount)
    362 {
    363 //    printf("UIDesktopWidgetWatchdog::sltHandleHostScreenCountChanged(%d)\n", cHostScreenCount);
    364 
    365 # ifdef VBOX_WS_X11
    366     /* Update host-screen configuration: */
    367     updateHostScreenConfiguration(cHostScreenCount);
    368 # endif /* VBOX_WS_X11 */
    369 
    370     /* Notify listeners: */
    371     emit sigHostScreenCountChanged(cHostScreenCount);
    372 }
    373 
    374 void UIDesktopWidgetWatchdog::sltHandleHostScreenResized(int iHostScreenIndex)
    375 {
    376 //    printf("UIDesktopWidgetWatchdog::sltHandleHostScreenResized(%d)\n", iHostScreenIndex);
    377 
    378 # ifdef VBOX_WS_X11
    379     /* Update host-screen available-geometry: */
    380     updateHostScreenAvailableGeometry(iHostScreenIndex);
    381 # endif /* VBOX_WS_X11 */
    382 
    383     /* Notify listeners: */
    384     emit sigHostScreenResized(iHostScreenIndex);
    385 }
    386 
    387 void UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized(int iHostScreenIndex)
    388 {
    389 //    printf("UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized(%d)\n", iHostScreenIndex);
    390 
    391 # ifdef VBOX_WS_X11
    392     /* Update host-screen available-geometry: */
    393     updateHostScreenAvailableGeometry(iHostScreenIndex);
    394 # endif /* VBOX_WS_X11 */
    395 
    396     /* Notify listeners: */
    397     emit sigHostScreenWorkAreaResized(iHostScreenIndex);
    398 }
    399 
    400 #else /* QT_VERSION >= 0x050000 */
     355#endif /* VBOX_WS_X11 */
    401356
    402357void UIDesktopWidgetWatchdog::sltHostScreenAdded(QScreen *pHostScreen)
     
    483438    emit sigHostScreenWorkAreaResized(iHostScreenIndex);
    484439}
    485 
    486 #endif /* QT_VERSION >= 0x050000 */
    487440
    488441#ifdef VBOX_WS_X11
     
    512465{
    513466    /* Prepare connections: */
    514 #if QT_VERSION < 0x050000
    515     connect(QApplication::desktop(), &QDesktopWidget::screenCountChanged,
    516             this, &UIDesktopWidgetWatchdog::sltHandleHostScreenCountChanged);
    517     connect(QApplication::desktop(), &QDesktopWidget::resized,
    518             this, &UIDesktopWidgetWatchdog::sltHandleHostScreenResized);
    519     connect(QApplication::desktop(), &QDesktopWidget::workAreaResized,
    520             this, &UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized);
    521 #else /* QT_VERSION >= 0x050000 */
    522467    connect(qApp, &QGuiApplication::screenAdded,
    523468            this, &UIDesktopWidgetWatchdog::sltHostScreenAdded);
     
    531476                this, &UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized);
    532477    }
    533 #endif /* QT_VERSION >= 0x050000 */
    534478
    535479#ifdef VBOX_WS_X11
     
    542486{
    543487    /* Cleanup connections: */
    544 #if QT_VERSION < 0x050000
    545     disconnect(QApplication::desktop(), &QDesktopWidget::screenCountChanged,
    546                this, &UIDesktopWidgetWatchdog::sltHandleHostScreenCountChanged);
    547     disconnect(QApplication::desktop(), &QDesktopWidget::resized,
    548                this, &UIDesktopWidgetWatchdog::sltHandleHostScreenResized);
    549     disconnect(QApplication::desktop(), &QDesktopWidget::workAreaResized,
    550                this, &UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized);
    551 #else /* QT_VERSION >= 0x050000 */
    552488    disconnect(qApp, &QGuiApplication::screenAdded,
    553489               this, &UIDesktopWidgetWatchdog::sltHostScreenAdded);
     
    561497                   this, &UIDesktopWidgetWatchdog::sltHandleHostScreenWorkAreaResized);
    562498    }
    563 #endif /* QT_VERSION >= 0x050000 */
    564499
    565500#ifdef VBOX_WS_X11
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.h

    r64767 r68315  
    101101    const QRegion overallAvailableRegion() const;
    102102
    103 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     103#ifdef VBOX_WS_X11
    104104    /** Qt5: X11: Returns whether no or fake screen detected. */
    105105    bool isFakeScreenDetected() const;
    106 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     106#endif
    107107
    108108private slots:
     
    111111    /** Stupid moc does not warn if it cannot find headers! */
    112112    void QT_VERSION_NOT_DEFINED
    113 #elif QT_VERSION < 0x050000
    114     /** Handles host-screen count change to @a cHostScreenCount. */
    115     void sltHandleHostScreenCountChanged(int cHostScreenCount);
    116     /** Handles resize for the host-screen with @a iHostScreenIndex. */
    117     void sltHandleHostScreenResized(int iHostScreenIndex);
    118     /** Handles work-area resize for the host-screen with @a iHostScreenIndex. */
    119     void sltHandleHostScreenWorkAreaResized(int iHostScreenIndex);
    120 #else /* QT_VERSION >= 0x050000 */
     113#else
    121114    /** Handles @a pHostScreen adding. */
    122115    void sltHostScreenAdded(QScreen *pHostScreen);
     
    127120    /** Handles host-screen work-area resize to passed @a availableGeometry. */
    128121    void sltHandleHostScreenWorkAreaResized(const QRect &availableGeometry);
    129 #endif /* QT_VERSION >= 0x050000 */
     122#endif
    130123
    131124#ifdef VBOX_WS_X11
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r68190 r68315  
    2424# include <QToolTip>
    2525# include <QTranslator>
    26 # if QT_VERSION >= 0x050000
    2726#  include <QStandardPaths>
    28 # endif /* QT_VERSION >= 0x050000 */
    2927# include <QDesktopServices>
    3028# include <QMutex>
     
    4846#  include <QTextStream>
    4947# endif /* VBOX_GUI_WITH_PIDFILE */
    50 # if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     48# ifdef VBOX_WS_X11
    5149#  include <QScreen>
    52 #  include <xcb/xcb.h>
    53 # endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     50# endif
    5451
    5552/* GUI includes: */
     
    132129# ifdef VBOX_WS_WIN
    133130#  include <iprt/win/shlobj.h>
    134 # endif /* VBOX_WS_WIN */
     131# endif
     132# ifdef VBOX_WS_X11
     133#  include <xcb/xcb.h>
     134# endif
    135135
    136136#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    18041804
    18051805    /* Try to load the corresponding Qt translation */
    1806 #if QT_VERSION < 0x050000
    1807     if (sLoadedLangId != gVBoxBuiltInLangName)
    1808 #else /* QT_VERSION >= 0x050000 */
    18091806    if (sLoadedLangId != gVBoxBuiltInLangName && sLoadedLangId != "en")
    1810 #endif /* QT_VERSION >= 0x050000 */
    18111807    {
    18121808#ifdef Q_OS_UNIX
     
    31223118QString VBoxGlobal::documentsPath()
    31233119{
    3124 #if QT_VERSION >= 0x050000
    31253120    QString path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
    3126 #else /* QT_VERSION < 0x050000 */
    3127     QString path = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
    3128 #endif /* QT_VERSION < 0x050000 */
    31293121    QDir dir(path);
    31303122    if (dir.exists())
     
    32433235}
    32443236
    3245 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     3237#ifdef VBOX_WS_X11
    32463238typedef struct {
    32473239/** User specified flags */
     
    32663258uint32_t win_gravity;
    32673259} xcb_size_hints_t;
    3268 #endif /* defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 */
     3260#endif /* VBOX_WS_X11 */
    32693261
    32703262/* static */
     
    32723264{
    32733265    AssertPtrReturnVoid(pWidget);
    3274 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     3266#ifdef VBOX_WS_X11
    32753267# define QWINDOWSIZE_MAX ((1<<24)-1)
    32763268    if (pWidget->isWindow() && pWidget->isVisible())
     
    33203312         * Configure event will arrive to tell Qt what geometry we want. */
    33213313        pWidget->setGeometry(x, y, w, h);
    3322 # else /* !defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 */
     3314# else /* !VBOX_WS_X11 */
    33233315    pWidget->setGeometry(x, y, w, h);
    3324 # endif /* !defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 */
     3316# endif /* !VBOX_WS_X11 */
    33253317}
    33263318
     
    36543646    QString vmNameOrUuid;
    36553647
    3656 #if QT_VERSION >= 0x050000
    36573648    const QStringList arguments = qApp->arguments();
    36583649    const int argc = arguments.size();
    3659 #else /* QT_VERSION < 0x050000 */
    3660     int argc = qApp->argc();
    3661 #endif /* QT_VERSION < 0x050000 */
    36623650    int i = 1;
    36633651    while (i < argc)
    36643652    {
    3665 #if QT_VERSION >= 0x050000
    36663653        QByteArray  argBytes = arguments.at(i).toUtf8();
    36673654        const char *arg = argBytes.constData();
    3668 #else /* QT_VERSION < 0x050000 */
    3669         const char *arg = qApp->argv() [i];
    3670 #endif /* QT_VERSION < 0x050000 */
    36713655        /* NOTE: the check here must match the corresponding check for the
    36723656         * options to start a VM in main.cpp and hardenedmain.cpp exactly,
     
    36773661            if (++i < argc)
    36783662            {
    3679 #if QT_VERSION >= 0x050000
    36803663                vmNameOrUuid = arguments.at(i);
    3681 #else /* QT_VERSION < 0x050000 */
    3682                 vmNameOrUuid = QString (qApp->argv() [i]);
    3683 #endif /* QT_VERSION < 0x050000 */
    36843664                startVM = true;
    36853665            }
     
    36933673        {
    36943674            if (++i < argc)
    3695 # if QT_VERSION >= 0x050000
    36963675                m_strPidfile = arguments.at(i);
    3697 # else /* QT_VERSION < 0x050000 */
    3698                 m_strPidfile = QString(qApp->argv()[i]);
    3699 # endif /* QT_VERSION < 0x050000 */
    37003676        }
    37013677#endif /* VBOX_GUI_WITH_PIDFILE */
     
    37143690            if (++i < argc)
    37153691            {
    3716 #if QT_VERSION >= 0x050000
    37173692                RTStrCopy(mSettingsPw, sizeof(mSettingsPw), arguments.at(i).toLocal8Bit().constData());
    3718 #else /* QT_VERSION < 0x050000 */
    3719                 RTStrCopy(mSettingsPw, sizeof(mSettingsPw), qApp->argv() [i]);
    3720 #endif /* QT_VERSION < 0x050000 */
    37213693                mSettingsPwSet = true;
    37223694            }
     
    37273699            {
    37283700                size_t cbFile;
    3729 #if QT_VERSION >= 0x050000
    37303701                const char *pszFile = arguments.at(i).toLocal8Bit().constData();
    3731 #else /* QT_VERSION < 0x050000 */
    3732                 char *pszFile = qApp->argv() [i];
    3733 #endif /* QT_VERSION < 0x050000 */
    37343702                bool fStdIn = !::strcmp(pszFile, "stdin");
    37353703                int vrc = VINF_SUCCESS;
     
    37753743        {
    37763744            if (++i < argc)
    3777 # if QT_VERSION >= 0x050000
    37783745                m_strFloppyImage = arguments.at(i);
    3779 # else /* QT_VERSION < 0x050000 */
    3780                 m_strFloppyImage = qApp->argv()[i];
    3781 # endif /* QT_VERSION < 0x050000 */
    37823746        }
    37833747        else if (!::strcmp(arg, "--dvd") || !::strcmp(arg, "--cdrom"))
    37843748        {
    37853749            if (++i < argc)
    3786 # if QT_VERSION >= 0x050000
    37873750                m_strDvdImage = arguments.at(i);
    3788 # else /* QT_VERSION < 0x050000 */
    3789                 m_strDvdImage = qApp->argv()[i];
    3790 # endif /* QT_VERSION < 0x050000 */
    37913751        }
    37923752        /* VMM Options: */
     
    38063766        {
    38073767            if (++i < argc)
    3808 #if QT_VERSION >= 0x050000
    38093768                mWarpPct = RTStrToUInt32(arguments.at(i).toLocal8Bit().constData());
    3810 #else /* QT_VERSION < 0x050000 */
    3811                 mWarpPct = RTStrToUInt32(qApp->argv() [i]);
    3812 #endif /* QT_VERSION < 0x050000 */
    38133769        }
    38143770#ifdef VBOX_WITH_DEBUGGER_GUI
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r64528 r68315  
    5353/* Qt includes: */
    5454#ifdef VBOX_WS_X11
    55 # ifdef Q_OS_SOLARIS
    56 #  if QT_VERSION < 0x050000
    57 #   include <QPlastiqueStyle>
    58 #  endif /* QT_VERSION < 0x050000 */
    59 # endif /* Q_OS_SOLARIS */
    6055# ifndef Q_OS_SOLARIS
    6156#  include <QFontDatabase>
     
    228223#endif /* VBOX_WS_X11 */
    229224
    230 #if QT_VERSION >= 0x050000
    231225/** Qt5 message handler, function that prints out
    232226  * debug, warning, critical, fatal and system error messages.
     
    272266    }
    273267}
    274 #else /* QT_VERSION < 0x050000 */
    275 /** Qt4 message handler, function that prints out
    276   * debug, warning, critical, fatal and system error messages.
    277   * @param  type  Holds the type of the message.
    278   * @param  pMsg  Holds the message body. */
    279 static void QtMessageOutput(QtMsgType type, const char *pMsg)
    280 {
    281 # ifndef VBOX_WS_X11
    282     NOREF(pMsg);
    283 # endif /* !VBOX_WS_X11 */
    284     switch (type)
    285     {
    286         case QtDebugMsg:
    287             Log(("Qt DEBUG: %s\n", pMsg));
    288             break;
    289         case QtWarningMsg:
    290             Log(("Qt WARNING: %s\n", pMsg));
    291 # ifdef VBOX_WS_X11
    292             /* Needed for instance for the message ``cannot connect to X server'': */
    293             RTStrmPrintf(g_pStdErr, "Qt WARNING: %s\n", pMsg);
    294 # endif /* VBOX_WS_X11 */
    295             break;
    296         case QtCriticalMsg:
    297             Log(("Qt CRITICAL: %s\n", pMsg));
    298 # ifdef VBOX_WS_X11
    299             /* Needed for instance for the message ``cannot connect to X server'': */
    300             RTStrmPrintf(g_pStdErr, "Qt CRITICAL: %s\n", pMsg);
    301 # endif /* VBOX_WS_X11 */
    302             break;
    303         case QtFatalMsg:
    304             Log(("Qt FATAL: %s\n", pMsg));
    305 # ifdef VBOX_WS_X11
    306             /* Needed for instance for the message ``cannot connect to X server'': */
    307             RTStrmPrintf(g_pStdErr, "Qt FATAL: %s\n", pMsg);
    308 # endif /* VBOX_WS_X11 */
    309     }
    310 }
    311 #endif /* QT_VERSION < 0x050000 */
    312268
    313269/** Shows all available command line parameters. */
     
    439395#endif /* VBOX_WS_X11 */
    440396
    441 #if QT_VERSION >= 0x050000
    442397        /* Install Qt console message handler: */
    443398        qInstallMessageHandler(QtMessageOutput);
    444 #else /* QT_VERSION < 0x050000 */
    445         /* Install Qt console message handler: */
    446         qInstallMsgHandler(QtMessageOutput);
    447 #endif /* QT_VERSION < 0x050000 */
    448399
    449400        /* Create application: */
     
    480431
    481432# ifdef Q_OS_SOLARIS
    482 #  if QT_VERSION < 0x050000
    483         /* Use plastique look&feel for Solaris instead of the default motif (Qt 4.7.x): */
    484         QApplication::setStyle(new QPlastiqueStyle);
    485 #  else /* QT_VERSION >= 0x050000 */
    486433        a.setStyle("fusion");
    487 #  endif /* QT_VERSION >= 0x050000 */
    488434# endif /* Q_OS_SOLARIS */
    489435
     
    496442        bool isSubScaleable = fontDataBase.isScalable(subFamily);
    497443        if (isCurrentScaleable && !isSubScaleable)
    498 #  if QT_VERSION >= 0x050000
    499444            QFont::removeSubstitutions(currentFamily);
    500 #  else /* QT_VERSION < 0x050000 */
    501             QFont::removeSubstitution(currentFamily);
    502 #  endif /* QT_VERSION < 0x050000 */
    503445# endif /* !Q_OS_SOLARIS */
    504446
     
    569511int main(int argc, char **argv, char **envp)
    570512{
    571 #ifdef VBOX_WS_X11
     513# ifdef VBOX_WS_X11
    572514    /* Make sure multi-threaded environment is safe: */
    573515    if (!MakeSureMultiThreadingIsSafe())
    574516        return 1;
    575 #endif /* VBOX_WS_X11 */
     517# endif /* VBOX_WS_X11 */
    576518
    577519    /* Initialize VBox Runtime.
     
    609551        Q_UNUSED(a);
    610552
    611 #ifdef Q_OS_SOLARIS
    612 # if QT_VERSION < 0x050000
    613         /* Use plastique look&feel for Solaris instead of the default motif (Qt 4.7.x): */
    614         QApplication::setStyle(new QPlastiqueStyle);
    615 #else /* QT_VERSION >= 0x050000 */
     553# ifdef Q_OS_SOLARIS
    616554        a.setStyle("fusion");
    617 # endif /* QT_VERSION >= 0x050000 */
    618 #endif /* Q_OS_SOLARIS */
     555# endif /* Q_OS_SOLARIS */
    619556
    620557        /* Prepare the error-message: */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r68264 r68315  
    15281528        pTreeWidget->sortItems(0, Qt::AscendingOrder);
    15291529        if (iColumns > 0)
    1530 #if QT_VERSION >= 0x050000
    15311530            pTreeWidget->header()->setSectionResizeMode(0, QHeaderView::Fixed);
    1532 #else /* QT_VERSION < 0x050000 */
    1533             pTreeWidget->header()->setResizeMode(0, QHeaderView::Fixed);
    1534 #endif /* QT_VERSION < 0x050000 */
    15351531        if (iColumns > 1)
    1536 #if QT_VERSION >= 0x050000
    15371532            pTreeWidget->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
    1538 #else /* QT_VERSION < 0x050000 */
    1539             pTreeWidget->header()->setResizeMode(1, QHeaderView::ResizeToContents);
    1540 #endif /* QT_VERSION < 0x050000 */
    15411533        if (iColumns > 2)
    1542 #if QT_VERSION >= 0x050000
    15431534            pTreeWidget->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
    1544 #else /* QT_VERSION < 0x050000 */
    1545             pTreeWidget->header()->setResizeMode(2, QHeaderView::ResizeToContents);
    1546 #endif /* QT_VERSION < 0x050000 */
    15471535        pTreeWidget->header()->setStretchLastSection(false);
    15481536        pTreeWidget->setSortingEnabled(true);
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp

    r68041 r68315  
    2424# include <QDir>
    2525# include <QPointer>
    26 # if QT_VERSION >= 0x050000
    27 #  include <QUrl>
    28 #  include <QUrlQuery>
    29 # endif /* QT_VERSION >= 0x050000 */
     26# include <QUrl>
     27# include <QUrlQuery>
    3028
    3129/* GUI includes: */
     
    181179    {
    182180        /* Compose query: */
    183 #if QT_VERSION >= 0x050000
    184181        QUrlQuery url;
    185 #else /* QT_VERSION < 0x050000 */
    186         QUrl url(m_url);
    187 #endif /* QT_VERSION < 0x050000 */
    188182        url.addQueryItem("platform", vboxGlobal().virtualBox().GetPackageType());
    189183        /* Check if branding is active: */
     
    209203        UserDictionary headers;
    210204        headers["User-Agent"] = strUserAgent;
    211 #if QT_VERSION >= 0x050000
    212205        QUrl fullUrl(m_url);
    213206        fullUrl.setQuery(url);
    214207        createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << fullUrl, headers);
    215 #else /* QT_VERSION < 0x050000 */
    216         createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << url, headers);
    217 #endif /* QT_VERSION < 0x050000 */
    218208    }
    219209
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaSpecialControls.mm

    r65223 r68315  
    2929#import <AppKit/NSImage.h>
    3030#import <AppKit/NSSegmentedControl.h>
    31 #if QT_VERSION >= 0x050000
    32 # import <AppKit/NSEvent.h>
    33 # import <AppKit/NSColor.h>
    34 # import <AppKit/NSSearchFieldCell.h>
    35 # import <AppKit/NSSearchField.h>
    36 # import <AppKit/NSSegmentedCell.h>
    37 #endif /* QT_VERSION >= 0x050000 */
     31#import <AppKit/NSEvent.h>
     32#import <AppKit/NSColor.h>
     33#import <AppKit/NSSearchFieldCell.h>
     34#import <AppKit/NSSearchField.h>
     35#import <AppKit/NSSegmentedCell.h>
    3836
    3937/* Qt includes */
     
    4644/* Other VBox includes: */
    4745#include <iprt/assert.h>
    48 
    49 #if 0 /* This is a built-in according to clang. Not sure how it relates to QT_VERSION... */
    50 /* Interface Builder Constant,
    51  * hmm, where is it declared with Qt4? */
    52 #if QT_VERSION >= 0x050000
    53 # define IBAction void
    54 #endif /* QT_VERSION >= 0x050000 */
    55 #endif
    5646
    5747/* Forward declarations: */
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UIWindowMenuManager.cpp

    r62493 r68315  
    287287    const QEvent::Type type = pEvent->type();
    288288
    289 #if defined(VBOX_OSE) || (QT_VERSION < 0x040700)
     289#ifdef VBOX_OSE // TODO: Do we still need it?
    290290    /* Stupid Qt: Qt doesn't check if a window is minimized when a command is
    291291     * executed. This leads to strange behaviour. The minimized window is
     
    305305        }
    306306    }
    307 #endif /* VBOX_OSE || QT_VERSION < 0x040700 */
     307#endif /* VBOX_OSE */
    308308
    309309    /* We need to track several events which leads to different window
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin-cocoa.mm

    r63492 r68315  
    2626#import <AppKit/NSColor.h>
    2727#import <AppKit/NSFont.h>
    28 #if QT_VERSION >= 0x050000
    29 # import <AppKit/NSScreen.h>
    30 # import <AppKit/NSWindow.h>
    31 # import <AppKit/NSImageView.h>
    32 #endif /* QT_VERSION >= 0x050000 */
     28#import <AppKit/NSScreen.h>
     29#import <AppKit/NSWindow.h>
     30#import <AppKit/NSImageView.h>
    3331
    3432#import <objc/objc-class.h>
     
    293291    return 1.0;
    294292}
    295 
    296 #if QT_VERSION < 0x050000
    297 void darwinSetDockIconMenu(QMenu* pMenu)
    298 {
    299     extern void qt_mac_set_dock_menu(QMenu *);
    300     qt_mac_set_dock_menu(pMenu);
    301 }
    302 #endif /* QT_VERSION < 0x050000 */
    303293
    304294/**
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.cpp

    r62493 r68315  
    3030#include <QPixmap>
    3131#include <QContextMenuEvent>
    32 #if QT_VERSION >= 0x050000
    33 # include <QtMac>
    34 #endif /* QT_VERSION >= 0x050000 */
     32#include <QtMac>
    3533
    3634#include <Carbon/Carbon.h>
     
    329327                                              kCGImageAlphaPremultipliedFirst);
    330328    /* Get the CGImageRef from Qt */
    331 #if QT_VERSION < 0x050000
    332     CGImageRef qtPixmap = pPixmap->toMacCGImageRef();
    333 #else /* QT_VERSION >= 0x050000 */
    334329    CGImageRef qtPixmap = QtMac::toCGImageRef(*pPixmap);
    335 #endif /* QT_VERSION >= 0x050000 */
    336330    /* Draw the image from Qt & convert the context back to a new CGImageRef. */
    337331    CGContextDrawImage(ctx, CGRectMake(0, 0, pPixmap->width(), pPixmap->height()), qtPixmap);
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/VBoxUtils-darwin.h

    r62493 r68315  
    254254void darwinSetShowsWindowTransparent(QWidget *pWidget, bool fEnabled);
    255255void darwinSetWindowHasShadow(QWidget *pWidget, bool fEnabled);
    256 #if QT_VERSION < 0x050000
    257 void darwinSetDockIconMenu(QMenu *pMenu);
    258 #endif /* QT_VERSION < 0x050000 */
    259256void darwinDisableIconsInMenus(void);
    260257
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.cpp

    r64162 r68315  
    425425    verticalHeader()->setDefaultSectionSize((int)(verticalHeader()->minimumSectionSize() * 1.33));
    426426    horizontalHeader()->setStretchLastSection(false);
    427 #if QT_VERSION >= 0x050000
    428427    horizontalHeader()->setSectionResizeMode(UIEncryptionDataTableSection_Id, QHeaderView::Interactive);
    429428    horizontalHeader()->setSectionResizeMode(UIEncryptionDataTableSection_Password, QHeaderView::Stretch);
    430 #else /* QT_VERSION < 0x050000 */
    431     horizontalHeader()->setResizeMode(UIEncryptionDataTableSection_Id, QHeaderView::Interactive);
    432     horizontalHeader()->setResizeMode(UIEncryptionDataTableSection_Password, QHeaderView::Stretch);
    433 #endif /* QT_VERSION < 0x050000 */
    434429}
    435430
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIDnDHandler.cpp

    r63327 r68315  
    287287QTextStream *g_pStrmLogQt = NULL; /* Output stream for Qt debug logging. */
    288288
    289 # if QT_VERSION >= 0x050000
    290289/* static */
    291290void UIDnDHandler::debugOutputQt(QtMsgType type, const QMessageLogContext &context, const QString &strMessage)
     
    312311        (*g_pStrmLogQt) << strMsg << " " << strMessage << endl;
    313312}
    314 # else /* QT_VERSION < 0x050000 */
    315 /* static */
    316 void UIDnDHandler::debugOutputQt(QtMsgType type, const char *pszMsg)
    317 {
    318     AssertPtr(pszMsg);
    319 
    320     QString strMsg;
    321     switch (type)
    322     {
    323     case QtWarningMsg:
    324         strMsg += "[W]";
    325         break;
    326     case QtCriticalMsg:
    327         strMsg += "[C]";
    328         break;
    329     case QtFatalMsg:
    330         strMsg += "[F]";
    331         break;
    332     case QtDebugMsg:
    333     default:
    334         strMsg += "[D]";
    335         break;
    336     }
    337 
    338     if (g_pStrmLogQt)
    339         (*g_pStrmLogQt) << strMsg << " " << pszMsg << endl;
    340 }
    341 # endif /* QT_VERSION < 0x050000 */
    342313#endif /* DEBUG_DND_QT */
    343314
     
    367338        g_pStrmLogQt = new QTextStream(pFileDebugQt);
    368339
    369 #if QT_VERSION >= 0x050000
    370340        qInstallMessageHandler(UIDnDHandler::debugOutputQt);
    371 #else /* QT_VERSION < 0x050000 */
    372         qInstallMsgHandler(UIDnDHandler::debugOutputQt);
    373 #endif /* QT_VERSION < 0x050000 */
    374341        qDebug("========================================================================");
    375342    }
     
    438405#  ifdef RT_OS_DARWIN
    439406#    ifdef VBOX_WITH_DRAG_AND_DROP_PROMISES
    440 #     if QT_VERSION < 0x050000
    441         dropAction = pDrag->exec(actions, defAction, true /* fUsePromises */);
    442 #     else /* QT_VERSION >= 0x050000 */
    443407        dropAction = pDrag->exec(actions, defAction);
    444 #     endif /* QT_VERSION >= 0x050000 */
    445408#    else
    446409        /* Without having VBOX_WITH_DRAG_AND_DROP_PROMISES enabled drag and drop
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r65444 r68315  
    6464# include <QX11Info>
    6565# include <X11/Xlib.h>
    66 # if QT_VERSION >= 0x050000
    67 #  undef Bool // Qt5 vs Xlib gift..
    68 # endif /* QT_VERSION >= 0x050000 */
     66# undef Bool // Qt5 vs Xlib gift..
    6967#endif /* VBOX_WS_X11 */
    7068
     
    13841382
    13851383#ifdef VBOX_WS_MAC
    1386 # if QT_VERSION >= 0x050000
    13871384    /* On OSX for Qt5 we need to erase backing store first: */
    13881385    QRect eraseRect = paintRect;
     
    13971394    painter.fillRect(eraseRect, QColor(Qt::black));
    13981395    painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
    1399 # endif /* QT_VERSION >= 0x050000 */
    14001396#endif /* VBOX_WS_MAC */
    14011397
     
    14701466
    14711467#if defined(VBOX_WITH_TRANSLUCENT_SEAMLESS)
    1472 # if defined(VBOX_WS_WIN) || defined(VBOX_WS_X11) || QT_VERSION >= 0x050000
    14731468    /* On OSX for Qt5 we need to erase backing store first: */
    14741469    QRect eraseRect = paintRect;
     
    14831478    painter.fillRect(eraseRect, QColor(Qt::black));
    14841479    painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
    1485 # endif /* VBOX_WS_WIN || VBOX_WS_X11 || QT_VERSION >= 0x050000 */
    14861480#endif /* VBOX_WITH_TRANSLUCENT_SEAMLESS */
    14871481
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp

    r66589 r68315  
    3737/* Qt includes: */
    3838# include <QKeyEvent>
     39# include <QTimer>
    3940# ifdef VBOX_WS_X11
    4041#  include <QX11Info>
    41 # endif
    42 # if QT_VERSION >= 0x050000
    43 #   include <QTimer>
    4442# endif
    4543
     
    7068/* Other VBox includes: */
    7169# ifdef VBOX_WS_MAC
    72 #  if QT_VERSION >= 0x050000
    73 #   include "iprt/cpp/utils.h"
    74 #  endif /* QT_VERSION >= 0x050000 */
     70#  include "iprt/cpp/utils.h"
    7571# endif /* VBOX_WS_MAC */
    7672
     
    105101#  undef FocusIn
    106102# endif /* KeyPress */
    107 # if QT_VERSION >= 0x050000
    108 #  include <xcb/xcb.h>
    109 # endif /* QT_VERSION >= 0x050000 */
     103# include <xcb/xcb.h>
    110104#endif /* VBOX_WS_X11 */
    111105
     
    212206}
    213207
    214 #ifdef VBOX_WS_X11
    215 # if QT_VERSION < 0x050000
    216 struct CHECKFORX11FOCUSEVENTSDATA
    217 {
    218     Window hWindow;
    219     bool fEventFound;
    220 };
    221 
    222 static Bool checkForX11FocusEventsWorker(Display *pDisplay, XEvent *pEvent,
    223                                          XPointer pArg)
    224 {
    225     NOREF(pDisplay);
    226     struct CHECKFORX11FOCUSEVENTSDATA *pStruct;
    227 
    228     pStruct = (struct CHECKFORX11FOCUSEVENTSDATA *)pArg;
    229     if (   pEvent->xany.type == XFocusIn
    230         || pEvent->xany.type == XFocusOut)
    231         if (pEvent->xany.window == pStruct->hWindow)
    232             pStruct->fEventFound = true;
    233     return false;
    234 }
    235 
    236 bool UIKeyboardHandler::checkForX11FocusEvents(Window hWindow)
    237 {
    238     XEvent dummy;
    239     struct CHECKFORX11FOCUSEVENTSDATA data;
    240 
    241     data.hWindow = hWindow;
    242     data.fEventFound = false;
    243     XCheckIfEvent(QX11Info::display(), &dummy, checkForX11FocusEventsWorker,
    244                   (XPointer)&data);
    245     return data.fEventFound;
    246 }
    247 # endif /* QT_VERSION < 0x050000 */
    248 #endif /* VBOX_WS_X11 */
    249 
    250208void UIKeyboardHandler::captureKeyboard(ulong uScreenId)
    251209{
     
    264222        m_iKeyboardCaptureViewIndex = uScreenId;
    265223
    266 #if QT_VERSION < 0x050000
    267         /* Finalise keyboard capture: */
    268         finaliseCaptureKeyboard();
    269 #else
    270224        /* On X11, we do not grab the keyboard as soon as it is captured, but delay it
    271225         * for 300 milliseconds after the formal capture. We do this for several reasons:
     
    281235         *            common behavior everywhere while X11 is forced to behave that way. */
    282236        QTimer::singleShot(300, this, SLOT(sltFinaliseCaptureKeyboard()));
    283 #endif
    284237    }
    285238}
     
    318271
    319272#elif defined(VBOX_WS_X11)
    320 # if QT_VERSION < 0x050000
    321 
    322         /* On X11, we are using passive XGrabKey for normal (windowed) mode
    323          * instead of XGrabKeyboard (called by QWidget::grabKeyboard()) because
    324          * XGrabKeyboard causes a problem under metacity - a window cannot be moved
    325          * using the mouse if it is currently actively grabbing the keyboard;
    326          * For static modes we are using usual (active) keyboard grabbing. */
    327 
    328         switch (machineLogic()->visualStateType())
    329         {
    330             /* If window is moveable we are making passive keyboard grab: */
    331             case UIVisualStateType_Normal:
    332             case UIVisualStateType_Scale:
    333             {
    334                 XGrabKey(QX11Info::display(), AnyKey, AnyModifier, m_windows[m_iKeyboardCaptureViewIndex]->winId(), False, GrabModeAsync, GrabModeAsync);
    335                 break;
    336             }
    337             /* If window is NOT moveable we are making active keyboard grab: */
    338             case UIVisualStateType_Fullscreen:
    339             case UIVisualStateType_Seamless:
    340             {
    341                 /* Keyboard grabbing can fail because of some keyboard shortcut is still grabbed by window manager.
    342                  * We can't be sure this shortcut will be released at all, so we will retry to grab keyboard for 50 times,
    343                  * and after we will just ignore that issue: */
    344                 int cTriesLeft = 50;
    345                 Window hWindow;
    346 
    347                 /* Only do our keyboard grab if there are no other focus events
    348                  * for this window on the queue.  This can prevent problems
    349                  * including two windows fighting to grab the keyboard. */
    350                 hWindow = m_windows[m_iKeyboardCaptureViewIndex]->winId();
    351                 if (!checkForX11FocusEvents(hWindow))
    352                     while (cTriesLeft && XGrabKeyboard(QX11Info::display(),
    353                            hWindow, False, GrabModeAsync, GrabModeAsync,
    354                            CurrentTime))
    355                         --cTriesLeft;
    356                 break;
    357             }
    358             /* Should we try to grab keyboard in default case? I think - NO. */
    359             default:
    360                 break;
    361         }
    362 
    363 # else /* QT_VERSION >= 0x050000 */
    364273
    365274        /* On X11, we are using XCB stuff to grab the keyboard.
     
    398307        free(pGrabReply);
    399308
    400 # endif /* QT_VERSION >= 0x050000 */
    401309#else
    402310
     
    451359
    452360#elif defined(VBOX_WS_X11)
    453 # if QT_VERSION < 0x050000
    454 
    455         /* On X11, we are using passive XGrabKey for normal (windowed) mode
    456          * instead of XGrabKeyboard (called by QWidget::grabKeyboard()) because
    457          * XGrabKeyboard causes a problem under metacity - a window cannot be moved
    458          * using the mouse if it is currently actively grabbing the keyboard;
    459          * For static modes we are using usual (active) keyboard grabbing. */
    460 
    461         switch (machineLogic()->visualStateType())
    462         {
    463             /* If window is moveable we are making passive keyboard ungrab: */
    464             case UIVisualStateType_Normal:
    465             case UIVisualStateType_Scale:
    466             {
    467                 XUngrabKey(QX11Info::display(), AnyKey, AnyModifier, m_windows[m_iKeyboardCaptureViewIndex]->winId());
    468                 break;
    469             }
    470             /* If window is NOT moveable we are making active keyboard ungrab: */
    471             case UIVisualStateType_Fullscreen:
    472             case UIVisualStateType_Seamless:
    473             {
    474                 XUngrabKeyboard(QX11Info::display(), CurrentTime);
    475                 break;
    476             }
    477             /* Should we try to release keyboard in default case? I think - NO. */
    478             default:
    479                 break;
    480         }
    481 
    482 # else /* QT_VERSION >= 0x050000 */
    483361
    484362        /* On X11, we are using XCB stuff to grab the keyboard.
     
    496374        m_hButtonGrabWindow = 0;
    497375
    498 # endif /* QT_VERSION >= 0x050000 */
    499376#else
    500377
     
    613490#endif /* VBOX_WS_WIN */
    614491
    615 #if QT_VERSION < 0x050000
    616 # if defined(VBOX_WS_MAC)
    617 
    618 bool UIKeyboardHandler::macEventFilter(const void *pvCocoaEvent, EventRef event, ulong uScreenId)
    619 {
     492bool UIKeyboardHandler::nativeEventFilter(void *pMessage, ulong uScreenId)
     493{
     494    /* Make sure view with passed index exists: */
     495    if (!m_views.contains(uScreenId))
     496        return false;
     497
    620498    /* Check if some system event should be filtered out.
    621499     * Returning @c true means filtering-out,
    622500     * Returning @c false means passing event to Qt. */
    623501    bool fResult = false; /* Pass to Qt by default. */
     502
     503# if defined(VBOX_WS_MAC)
     504
     505    /* Acquire carbon event reference from the cocoa one: */
     506    EventRef event = static_cast<EventRef>(darwinCocoaToCarbonEvent(pMessage));
    624507
    625508    /* Depending on event kind: */
     
    691574
    692575            /* Adjust new modifier mask to distinguish left/right modifiers: */
    693             uNewMask = ::DarwinAdjustModifierMask(uNewMask, pvCocoaEvent);
     576            uNewMask = ::DarwinAdjustModifierMask(uNewMask, pMessage);
    694577
    695578            /* Determine what is really changed: */
     
    753636    }
    754637
    755     /* Return result: */
    756     return fResult;
    757 }
    758 
    759638# elif defined(VBOX_WS_WIN)
    760639
    761 bool UIKeyboardHandler::winEventFilter(MSG *pMsg, ulong uScreenId)
    762 {
    763640    /* Ignore this event if m_fSkipKeyboardEvents is set by winSkipKeyboardEvents(). */
    764641    if (m_fSkipKeyboardEvents)
    765642        return false;
    766643
    767     /* Check if some system event should be filtered out.
    768      * Returning @c true means filtering-out,
    769      * Returning @c false means passing event to Qt. */
    770     bool fResult = false; /* Pass to Qt by default. */
     644    /* Cast to MSG event: */
     645    MSG *pMsg = static_cast<MSG*>(pMessage);
    771646
    772647    /* Depending on message type: */
     
    779654        case WM_SYSKEYUP:
    780655        {
     656            // WORKAROUND:
     657            // Can't do COM inter-process calls from a SendMessage handler,
     658            // see http://support.microsoft.com/kb/131056.
     659            if (vboxGlobal().isSeparateProcess() && InSendMessage())
     660            {
     661                PostMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
     662                fResult = true;
     663                break;
     664            }
     665
    781666            /* Check for our own special flag to ignore this event.
    782667             * That flag could only be set later in this function
     
    918803    }
    919804
    920     /* Return result: */
    921     return fResult;
    922 }
    923 
    924 # elif defined(VBOX_WS_X11)
    925 
    926 static Bool UIKeyboardHandlerCompEvent(Display*, XEvent *pEvent, XPointer pvArg)
    927 {
    928     XEvent *pKeyEvent = (XEvent*)pvArg;
    929     if ((pEvent->type == XKeyPress) && (pEvent->xkey.keycode == pKeyEvent->xkey.keycode))
    930         return True;
    931     else
    932         return False;
    933 }
    934 
    935 bool UIKeyboardHandler::x11EventFilter(XEvent *pEvent, ulong uScreenId)
    936 {
    937     /* Check if some system event should be filtered out.
    938      * Returning @c true means filtering-out,
    939      * Returning @c false means passing event to Qt. */
    940     bool fResult = false; /* Pass to Qt by default. */
    941 
    942     /* Depending on event type: */
    943     switch (pEvent->type)
    944     {
    945         /* We have to handle XFocusOut right here as this event is not passed to UIMachineView::event().
    946          * Handling this event is important for releasing the keyboard before the screen saver gets active.
    947          * See public ticket #3894: Apparently this makes problems with newer versions of Qt
    948          * and this hack is probably not necessary anymore. So disable it for Qt >= 4.5.0. */
    949         case XFocusOut:
    950         case XFocusIn:
    951         {
    952             if (isSessionRunning())
    953             {
    954                 if (VBoxGlobal::qtRTVersion() < ((4 << 16) | (5 << 8) | 0))
    955                 {
    956                     if (pEvent->type == XFocusIn)
    957                     {
    958                         /* Capture keyboard by chosen view number: */
    959                         captureKeyboard(uScreenId);
    960                         /* Reset the single-time disable capture flag: */
    961                         if (isAutoCaptureDisabled())
    962                             setAutoCaptureDisabled(false);
    963                     }
    964                     else
    965                     {
    966                         /* Release keyboard: */
    967                         releaseKeyboard();
    968                         /* And all pressed keys including host-one: */
    969                         releaseAllPressedKeys(true);
    970                     }
    971                 }
    972             }
    973             fResult = false;
    974             break;
    975         }
    976         /* Watch for key-events: */
    977         case XKeyPress:
    978         case XKeyRelease:
    979         {
    980             /* Translate the keycode to a PC scan code: */
    981             unsigned uScan = handleXKeyEvent(pEvent->xkey.display, pEvent->xkey.keycode);
    982 
    983             /* Scan codes 0x00 (no valid translation) and 0x80 (extended flag) are ignored: */
    984             if (!(uScan & 0x7F))
    985             {
    986                 fResult = true;
    987                 break;
    988             }
    989 
    990             /* Fix for http://www.virtualbox.org/ticket/1296:
    991              * when X11 sends events for repeated keys, it always inserts an XKeyRelease before the XKeyPress. */
    992             XEvent returnEvent;
    993             if ((pEvent->type == XKeyRelease) && (XCheckIfEvent(pEvent->xkey.display, &returnEvent,
    994                 UIKeyboardHandlerCompEvent, (XPointer)pEvent) == True))
    995             {
    996                 XPutBackEvent(pEvent->xkey.display, &returnEvent);
    997                 fResult = true;
    998                 break;
    999             }
    1000 
    1001             /* Calculate flags: */
    1002             int iFlags = 0;
    1003             if (uScan >> 8)
    1004                 iFlags |= KeyExtended;
    1005             if (pEvent->type == XKeyPress)
    1006                 iFlags |= KeyPressed;
    1007 
    1008             /* Remove the extended flag: */
    1009             uScan &= 0x7F;
    1010 
    1011             /* Special Korean keys must send scan code 0xF1/0xF2
    1012              * when pressed and nothing when released. */
    1013             if (uScan == 0x71 || uScan == 0x72)
    1014             {
    1015                 if (pEvent->type == XKeyRelease)
    1016                 {
    1017                     fResult = true;
    1018                     break;
    1019                 }
    1020                 /* Re-create the bizarre scan code: */
    1021                 uScan |= 0x80;
    1022             }
    1023 
    1024             /* Translate the keycode to a keysym: */
    1025             KeySym ks = ::wrapXkbKeycodeToKeysym(pEvent->xkey.display, pEvent->xkey.keycode, 0, 0);
    1026 
    1027             /* Update special flags: */
    1028             switch (ks)
    1029             {
    1030                 case XK_Print:
    1031                     iFlags |= KeyPrint;
    1032                     break;
    1033                 case XK_Pause:
    1034                     if (pEvent->xkey.state & ControlMask) /* Break */
    1035                     {
    1036                         ks = XK_Break;
    1037                         iFlags |= KeyExtended;
    1038                         uScan = 0x46;
    1039                     }
    1040                     else
    1041                         iFlags |= KeyPause;
    1042                     break;
    1043             }
    1044 
    1045             /* Finally, handle parsed key-event: */
    1046             fResult = keyEvent(ks, uScan, iFlags, uScreenId);
    1047 
    1048             break;
    1049         }
    1050         default:
    1051             break;
    1052     }
    1053 
    1054     /* Return result: */
    1055     return fResult;
    1056 }
    1057 
    1058 # endif /* VBOX_WS_X11 */
    1059 #else /* QT_VERSION >= 0x050000 */
    1060 
    1061 bool UIKeyboardHandler::nativeEventFilter(void *pMessage, ulong uScreenId)
    1062 {
    1063     /* Make sure view with passed index exists: */
    1064     if (!m_views.contains(uScreenId))
    1065         return false;
    1066 
    1067     /* Check if some system event should be filtered out.
    1068      * Returning @c true means filtering-out,
    1069      * Returning @c false means passing event to Qt. */
    1070     bool fResult = false; /* Pass to Qt by default. */
    1071 
    1072 # if defined(VBOX_WS_MAC)
    1073 
    1074     /* Acquire carbon event reference from the cocoa one: */
    1075     EventRef event = static_cast<EventRef>(darwinCocoaToCarbonEvent(pMessage));
    1076 
    1077     /* Depending on event kind: */
    1078     const UInt32 uEventKind = ::GetEventKind(event);
    1079     switch (uEventKind)
    1080     {
    1081         /* Watch for simple key-events: */
    1082         case kEventRawKeyDown:
    1083         case kEventRawKeyRepeat:
    1084         case kEventRawKeyUp:
    1085         {
    1086             /* Acquire keycode: */
    1087             UInt32 uKeyCode = ~0U;
    1088             ::GetEventParameter(event, kEventParamKeyCode, typeUInt32,
    1089                                 NULL, sizeof(uKeyCode), NULL, &uKeyCode);
    1090 
    1091             /* The usb keyboard driver translates these codes to different virtual
    1092              * keycodes depending of the keyboard type. There are ANSI, ISO, JIS
    1093              * and unknown. For European keyboards (ISO) the key 0xa and 0x32 have
    1094              * to be switched. Here we are doing this at runtime, cause the user
    1095              * can have more than one keyboard (of different type), where he may
    1096              * switch at will all the time. Default is the ANSI standard as defined
    1097              * in g_aDarwinToSet1. Please note that the "~" on some English ISO
    1098              * keyboards will be wrongly swapped. This can maybe fixed by
    1099              * using a Apple keyboard layout in the guest. */
    1100             if (   (uKeyCode == 0xa || uKeyCode == 0x32)
    1101                 && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO)
    1102                 uKeyCode = 0x3c - uKeyCode;
    1103 
    1104             /* Translate keycode to set 1 scan code: */
    1105             unsigned uScanCode = ::DarwinKeycodeToSet1Scancode(uKeyCode);
    1106 
    1107             /* If scan code is valid: */
    1108             if (uScanCode)
    1109             {
    1110                 /* Calculate flags: */
    1111                 int iFlags = 0;
    1112                 if (uEventKind != kEventRawKeyUp)
    1113                     iFlags |= KeyPressed;
    1114                 if (uScanCode & VBOXKEY_EXTENDED)
    1115                     iFlags |= KeyExtended;
    1116                 /** @todo KeyPause, KeyPrint. */
    1117                 uScanCode &= VBOXKEY_SCANCODE_MASK;
    1118 
    1119                 /* Get the unicode string (if present): */
    1120                 AssertCompileSize(wchar_t, 2);
    1121                 AssertCompileSize(UniChar, 2);
    1122                 ByteCount cbWritten = 0;
    1123                 wchar_t ucs[8];
    1124                 if (::GetEventParameter(event, kEventParamKeyUnicodes, typeUnicodeText,
    1125                                         NULL, sizeof(ucs), &cbWritten, &ucs[0]) != 0)
    1126                     cbWritten = 0;
    1127                 ucs[cbWritten / sizeof(wchar_t)] = 0; /* The api doesn't terminate it. */
    1128 
    1129                 /* Finally, handle parsed key-event: */
    1130                 fResult = keyEvent(uKeyCode, uScanCode, iFlags, uScreenId, ucs[0] ? ucs : NULL);
    1131             }
    1132 
    1133             break;
    1134         }
    1135         /* Watch for modifier key-events: */
    1136         case kEventRawKeyModifiersChanged:
    1137         {
    1138             /* Acquire new modifier mask, it may contain
    1139              * multiple modifier changes, kind of annoying: */
    1140             UInt32 uNewMask = 0;
    1141             ::GetEventParameter(event, kEventParamKeyModifiers, typeUInt32,
    1142                                 NULL, sizeof(uNewMask), NULL, &uNewMask);
    1143 
    1144             /* Adjust new modifier mask to distinguish left/right modifiers: */
    1145             uNewMask = ::DarwinAdjustModifierMask(uNewMask, pMessage);
    1146 
    1147             /* Determine what is really changed: */
    1148             const UInt32 changed = uNewMask ^ m_uDarwinKeyModifiers;
    1149             if (changed)
    1150             {
    1151                 for (UInt32 bit = 0; bit < 32; ++bit)
    1152                 {
    1153                     /* Skip unchanged bits: */
    1154                     if (!(changed & (1 << bit)))
    1155                         continue;
    1156                     /* Acquire set 1 scan code from new mask: */
    1157                     unsigned uScanCode = ::DarwinModifierMaskToSet1Scancode(1 << bit);
    1158                     /* Skip invalid scan codes: */
    1159                     if (!uScanCode)
    1160                         continue;
    1161                     /* Acquire darwin keycode from new mask: */
    1162                     unsigned uKeyCode = ::DarwinModifierMaskToDarwinKeycode(1 << bit);
    1163                     /* Assert invalid keycodes: */
    1164                     Assert(uKeyCode);
    1165 
    1166                     /* For non-lockable modifier: */
    1167                     if (!(uScanCode & VBOXKEY_LOCK))
    1168                     {
    1169                         /* Calculate flags: */
    1170                         unsigned uFlags = (uNewMask & (1 << bit)) ? KeyPressed : 0;
    1171                         if (uScanCode & VBOXKEY_EXTENDED)
    1172                             uFlags |= KeyExtended;
    1173                         uScanCode &= VBOXKEY_SCANCODE_MASK;
    1174 
    1175                         /* Finally, handle parsed key-event: */
    1176                         keyEvent(uKeyCode, uScanCode & 0xff, uFlags, uScreenId);
    1177                     }
    1178                     /* For lockable modifier: */
    1179                     else
    1180                     {
    1181                         /* Calculate flags: */
    1182                         unsigned uFlags = 0;
    1183                         if (uScanCode & VBOXKEY_EXTENDED)
    1184                             uFlags |= KeyExtended;
    1185                         uScanCode &= VBOXKEY_SCANCODE_MASK;
    1186 
    1187                         /* Finally, handle parsed press/release pair: */
    1188                         keyEvent(uKeyCode, uScanCode, uFlags | KeyPressed, uScreenId);
    1189                         keyEvent(uKeyCode, uScanCode, uFlags, uScreenId);
    1190                     }
    1191                 }
    1192             }
    1193 
    1194             /* Remember new modifier mask: */
    1195             m_uDarwinKeyModifiers = uNewMask;
    1196 
    1197             /* Always return true here because we'll otherwise getting a Qt event
    1198              * we don't want and that will only cause the Pause warning to pop up: */
    1199             fResult = true;
    1200 
    1201             break;
    1202         }
    1203         default:
    1204             break;
    1205     }
    1206 
    1207 # elif defined(VBOX_WS_WIN)
    1208 
    1209     /* Ignore this event if m_fSkipKeyboardEvents is set by winSkipKeyboardEvents(). */
    1210     if (m_fSkipKeyboardEvents)
    1211         return false;
    1212 
    1213     /* Cast to MSG event: */
    1214     MSG *pMsg = static_cast<MSG*>(pMessage);
    1215 
    1216     /* Depending on message type: */
    1217     switch (pMsg->message)
    1218     {
    1219         /* Watch for key-events: */
    1220         case WM_KEYDOWN:
    1221         case WM_KEYUP:
    1222         case WM_SYSKEYDOWN:
    1223         case WM_SYSKEYUP:
    1224         {
    1225             // WORKAROUND:
    1226             // Can't do COM inter-process calls from a SendMessage handler,
    1227             // see http://support.microsoft.com/kb/131056.
    1228             if (vboxGlobal().isSeparateProcess() && InSendMessage())
    1229             {
    1230                 PostMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
    1231                 fResult = true;
    1232                 break;
    1233             }
    1234 
    1235             /* Check for our own special flag to ignore this event.
    1236              * That flag could only be set later in this function
    1237              * so having it here means this event came here
    1238              * for the second time already. */
    1239             if (pMsg->lParam & (0x1 << 25))
    1240             {
    1241                 /* Remove that flag as well: */
    1242                 pMsg->lParam &= ~(0x1 << 25);
    1243                 fResult = false;
    1244                 break;
    1245             }
    1246 
    1247             /* Scan codes 0x80 and 0x00 should be filtered out: */
    1248             unsigned uScan = (pMsg->lParam >> 16) & 0x7F;
    1249             if (!uScan)
    1250             {
    1251                 fResult = true;
    1252                 break;
    1253             }
    1254 
    1255             /* Get the virtual key: */
    1256             int iVKey = pMsg->wParam;
    1257 
    1258             /* Calculate flags: */
    1259             int iFlags = 0;
    1260             if (pMsg->lParam & 0x1000000)
    1261                 iFlags |= KeyExtended;
    1262             if (!(pMsg->lParam & 0x80000000))
    1263                 iFlags |= KeyPressed;
    1264 
    1265             /* Make sure AltGr monitor exists: */
    1266             AssertPtrReturn(m_pAltGrMonitor, false);
    1267             {
    1268                 /* Filter event out if we are sure that this is a fake left control event: */
    1269                 if (m_pAltGrMonitor->isCurrentEventDefinitelyFake(uScan, iFlags & KeyPressed, iFlags & KeyExtended))
    1270                 {
    1271                     fResult = true;
    1272                     break;
    1273                 }
    1274                 /* Update AltGR monitor state from key-event: */
    1275                 m_pAltGrMonitor->updateStateFromKeyEvent(uScan, iFlags & KeyPressed, iFlags & KeyExtended);
    1276                 /* And release left Ctrl key early (if required): */
    1277                 if (m_pAltGrMonitor->isLeftControlReleaseNeeded())
    1278                     keyboard().PutScancode(0x1D | 0x80);
    1279             }
    1280 
    1281             /* Check for special Korean keys. Based on the keyboard layout selected
    1282              * on the host, the scan code in lParam might be 0x71/0x72 or 0xF1/0xF2.
    1283              * In either case, we must deliver 0xF1/0xF2 scan code to the guest when
    1284              * the key is pressed and nothing when it's released. */
    1285             if (uScan == 0x71 || uScan == 0x72)
    1286             {
    1287                 uScan |= 0x80;
    1288                 iFlags = KeyPressed;   /* Because a release would be ignored. */
    1289                 iVKey = VK_PROCESSKEY; /* In case it was 0xFF. */
    1290             }
    1291 
    1292             /* When one of the SHIFT keys is held and one of the cursor movement
    1293              * keys is pressed, Windows duplicates SHIFT press/release messages,
    1294              * but with the virtual keycode set to 0xFF. These virtual keys are also
    1295              * sent in some other situations (Pause, PrtScn, etc.). Filter out such messages. */
    1296             if (iVKey == 0xFF)
    1297             {
    1298                 fResult = true;
    1299                 break;
    1300             }
    1301 
    1302             /* Handle special virtual keys: */
    1303             switch (iVKey)
    1304             {
    1305                 case VK_SHIFT:
    1306                 case VK_CONTROL:
    1307                 case VK_MENU:
    1308                 {
    1309                     /* Overcome Win32 modifier key generalization: */
    1310                     int iKeyscan = uScan;
    1311                     if (iFlags & KeyExtended)
    1312                         iKeyscan |= 0xE000;
    1313                     switch (iKeyscan)
    1314                     {
    1315                         case 0x002A: iVKey = VK_LSHIFT;   break;
    1316                         case 0x0036: iVKey = VK_RSHIFT;   break;
    1317                         case 0x001D: iVKey = VK_LCONTROL; break;
    1318                         case 0xE01D: iVKey = VK_RCONTROL; break;
    1319                         case 0x0038: iVKey = VK_LMENU;    break;
    1320                         case 0xE038: iVKey = VK_RMENU;    break;
    1321                     }
    1322                     break;
    1323                 }
    1324                 case VK_NUMLOCK:
    1325                     /* Win32 sets the extended bit for the NumLock key. Reset it: */
    1326                     iFlags &= ~KeyExtended;
    1327                     break;
    1328                 case VK_SNAPSHOT:
    1329                     iFlags |= KeyPrint;
    1330                     break;
    1331                 case VK_PAUSE:
    1332                     iFlags |= KeyPause;
    1333                     break;
    1334             }
    1335 
    1336             /* Finally, handle parsed key-event: */
    1337             fResult = keyEvent(iVKey, uScan, iFlags, uScreenId);
    1338 
    1339             /* Always let Windows see key releases to prevent stuck keys.
    1340              * Hopefully this won't cause any other issues. */
    1341             if (pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYUP)
    1342             {
    1343                 fResult = false;
    1344                 break;
    1345             }
    1346 
    1347             /* Above keyEvent() returned that it didn't processed the event, but since the
    1348              * keyboard is captured, we don't want to pass it to Windows. We just want
    1349              * to let Qt process the message (to handle non-alphanumeric <HOST>+key
    1350              * shortcuts for example). So send it directly to the window with the
    1351              * special flag in the reserved area of lParam (to avoid recursion). */
    1352             if (!fResult && m_fIsKeyboardCaptured)
    1353             {
    1354                 ::SendMessage(pMsg->hwnd, pMsg->message,
    1355                               pMsg->wParam, pMsg->lParam | (0x1 << 25));
    1356                 fResult = true;
    1357                 break;
    1358             }
    1359 
    1360             /* These special keys have to be handled by Windows as well to update the
    1361              * internal modifier state and to enable/disable the keyboard LED: */
    1362             if (iVKey == VK_NUMLOCK || iVKey == VK_CAPITAL || iVKey == VK_LSHIFT || iVKey == VK_RSHIFT)
    1363             {
    1364                 fResult = false;
    1365                 break;
    1366             }
    1367 
    1368             break;
    1369         }
    1370         default:
    1371             break;
    1372     }
    1373 
    1374805# elif defined(VBOX_WS_X11)
    1375806
     
    1470901    return fResult;
    1471902}
    1472 
    1473 #endif /* QT_VERSION >= 0x050000 */
    1474903
    1475904/* Machine state-change handler: */
     
    1527956}
    1528957
    1529 #if QT_VERSION >= 0x050000
    1530958void UIKeyboardHandler::sltFinaliseCaptureKeyboard()
    1531959{
     
    1537965    }
    1538966}
    1539 #endif
    1540967
    1541968/* Keyboard-handler constructor: */
     
    1559986    , m_pAltGrMonitor(0)
    1560987#elif defined(VBOX_WS_X11)
    1561 # if QT_VERSION >= 0x050000
    1562988    , m_hButtonGrabWindow(0)
    1563 # endif
    1564989#endif /* VBOX_WS_X11 */
    1565990    , m_cMonitors(1)
     
    18661291
    18671292    /* Pass event to machine-view's event handler: */
    1868 #if QT_VERSION < 0x050000
    1869     return m_views[m_iKeyboardHookViewIndex]->macEvent(pvCocoaEvent, event);
    1870 #else /* QT_VERSION >= 0x050000 */
    18711293    Q_UNUSED(event);
    18721294    return nativeEventFilter(unconst(pvCocoaEvent), m_iKeyboardHookViewIndex);
    1873 #endif /* QT_VERSION >= 0x050000 */
    18741295}
    18751296
     
    19311352
    19321353    /* Pass event to view's event handler: */
    1933 #if QT_VERSION < 0x050000
    1934     long dummyResult;
    1935     return m_views[m_iKeyboardHookViewIndex]->winEvent(&message, &dummyResult);
    1936 #else /* QT_VERSION >= 0x050000 */
    19371354    return nativeEventFilter(&message, m_iKeyboardHookViewIndex);
    1938 #endif /* QT_VERSION >= 0x050000 */
    19391355}
    19401356
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.h

    r66571 r68315  
    4545#ifdef VBOX_WS_WIN
    4646class WinAltGrMonitor;
    47 #endif /* VBOX_WS_WIN */
     47#endif
    4848#ifdef VBOX_WS_X11
    49 # if QT_VERSION < 0x050000
    50 typedef union _XEvent XEvent;
    51 #else
    5249#  include <xcb/xcb.h>
    53 # endif /* QT_VERSION >= 0x050000 */
    54 #endif /* VBOX_WS_X11 */
     50#endif
    5551
    5652
     
    7470    void prepareListener(ulong uScreenId, UIMachineWindow *pMachineWindow);
    7571    void cleanupListener(ulong uScreenId);
    76 
    77     /* Commands to capture/release keyboard: */
    78 #ifdef VBOX_WS_X11
    79 # if QT_VERSION < 0x050000
    80     bool checkForX11FocusEvents(unsigned long hWindow);
    81 # endif /* QT_VERSION < 0x050000 */
    82 #endif /* VBOX_WS_X11 */
    8372
    8473    /** Captures the keyboard for @a uScreenId. */
     
    113102#endif /* VBOX_WS_WIN */
    114103
    115 #if QT_VERSION < 0x050000
    116 # if defined(VBOX_WS_MAC)
    117     /** Qt4: Mac: Performs pre-processing of all the native events. */
    118     bool macEventFilter(const void *pvCocoaEvent, EventRef event, ulong uScreenId);
    119 # elif defined(VBOX_WS_WIN)
    120     /** Qt4: Win: Performs pre-processing of all the native events. */
    121     bool winEventFilter(MSG *pMsg, ulong uScreenId);
    122 # elif defined(VBOX_WS_X11)
    123     /** Qt4: X11: Performs pre-processing of all the native events. */
    124     bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
    125 # endif /* VBOX_WS_X11 */
    126 #else
    127104    /** Qt5: Performs pre-processing of all the native events. */
    128105    bool nativeEventFilter(void *pMessage, ulong uScreenId);
    129 #endif
    130106
    131107protected slots:
     
    134110    virtual void sltMachineStateChanged();
    135111
    136 #if QT_VERSION >= 0x050000
     112#if QT_VERSION == 0
     113    /** Stupid moc does not warn if it cannot find headers! */
     114    void QT_VERSION_NOT_DEFINED
     115#else
    137116    /** Finalises keyboard capture. */
    138117    void sltFinaliseCaptureKeyboard();
    139 #elif QT_VERSION == 0
    140     /** Stupid moc does not warn if it cannot find headers! */
    141     void QT_VERSION_NOT_DEFINED
    142118#endif
    143119
     
    244220    static UIKeyboardHandler *m_spKeyboardHandler;
    245221#elif defined(VBOX_WS_X11)
    246 # if QT_VERSION >= 0x050000
    247222    /** The root window at the time we grab the mouse buttons. */
    248223    xcb_window_t m_hButtonGrabWindow;
    249 # endif
    250224#endif /* VBOX_WS_X11 */
    251225
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r67535 r68315  
    12681268    pDockMenu->addMenu(pDockSettingsMenu);
    12691269
    1270 # if QT_VERSION < 0x050000
    1271     /* Add it to the dock. */
    1272     ::darwinSetDockIconMenu(pDockMenu);
    1273 # else /* QT_VERSION >= 0x050000 */
    12741270    /* Add it to the dock: */
    12751271    pDockMenu->setAsDockMenu();
    1276 # endif /* QT_VERSION >= 0x050000 */
    12771272
    12781273    /* Now the dock icon preview: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r67664 r68315  
    7272
    7373/* Qt includes: */
    74 #if QT_VERSION >= 0x050000
    7574# include <QAbstractNativeEventFilter>
    76 #endif
    7775
    7876/* GUI includes: */
     
    10098#ifdef VBOX_WS_MAC
    10199# include <Carbon/Carbon.h>
    102 #endif /* VBOX_WS_MAC */
     100#endif
    103101#ifdef VBOX_WS_X11
    104 # if QT_VERSION < 0x050000
    105 #  include <X11/XKBlib.h>
    106 #  ifdef KeyPress
    107 const int XFocusIn = FocusIn;
    108 const int XFocusOut = FocusOut;
    109 const int XKeyPress = KeyPress;
    110 const int XKeyRelease = KeyRelease;
    111 #   undef KeyRelease
    112 #   undef KeyPress
    113 #   undef FocusOut
    114 #   undef FocusIn
    115 #  endif /* KeyPress */
    116 # else /* QT_VERSION >= 0x050000 */
    117102#  include <xcb/xcb.h>
    118 # endif /* QT_VERSION >= 0x050000 */
    119 #endif /* VBOX_WS_X11 */
     103#endif
    120104
    121105#ifdef DEBUG_andy
     
    128112
    129113
    130 #if QT_VERSION >= 0x050000
    131114/** QAbstractNativeEventFilter extension
    132115  * allowing to pre-process native platform events. */
     
    151134    UIMachineView *m_pParent;
    152135};
    153 #endif
    154136
    155137
     
    660642    , m_fIsDraggingFromGuest(false)
    661643#endif
    662 #if QT_VERSION >= 0x050000
    663644    , m_pNativeEventFilter(0)
    664 #endif
    665645{
    666646}
     
    888868void UIMachineView::cleanupNativeFilters()
    889869{
    890 #if QT_VERSION >= 0x050000
    891870    /* If native event filter exists: */
    892871    if (m_pNativeEventFilter)
     
    897876        m_pNativeEventFilter = 0;
    898877    }
    899 #endif
    900878}
    901879
     
    15251503    {
    15261504        /* We have a snapshot for the paused state: */
    1527 #if QT_VERSION >= 0x050000
    15281505        QRect rect = pPaintEvent->rect().intersected(viewport()->rect());
    1529 #else /* QT_VERSION < 0x050000 */
    1530         QRect rect = pPaintEvent->rect().intersect(viewport()->rect());
    1531 #endif /* QT_VERSION < 0x050000 */
    15321506        QPainter painter(viewport());
    15331507        /* Take the scale-factor into account: */
     
    15531527}
    15541528
    1555 #if QT_VERSION >= 0x050000
    15561529void UIMachineView::focusInEvent(QFocusEvent *pEvent)
    15571530{
     
    15821555    QAbstractScrollArea::focusOutEvent(pEvent);
    15831556}
    1584 #endif
    15851557
    15861558#ifdef VBOX_WITH_DRAG_AND_DROP
     
    17631735}
    17641736#endif /* VBOX_WITH_DRAG_AND_DROP */
    1765 
    1766 #if QT_VERSION < 0x050000
    1767 # if defined(VBOX_WS_MAC)
    1768 
    1769 bool UIMachineView::macEvent(const void *pvCocoaEvent, EventRef event)
    1770 {
    1771     /* Make sure arguments valid: */
    1772     AssertPtrReturn(pvCocoaEvent, false);
    1773     AssertReturn(event != NULL, false);
    1774 
    1775     /* Check if some system event should be filtered out.
    1776      * Returning @c true means filtering-out,
    1777      * Returning @c false means passing event to Qt. */
    1778     bool fResult = false; /* Pass to Qt by default. */
    1779     switch (::GetEventClass(event))
    1780     {
    1781         /* Watch for keyboard-events: */
    1782         case kEventClassKeyboard:
    1783         {
    1784             switch (::GetEventKind(event))
    1785             {
    1786                 /* Watch for key-events: */
    1787                 case kEventRawKeyDown:
    1788                 case kEventRawKeyRepeat:
    1789                 case kEventRawKeyUp:
    1790                 case kEventRawKeyModifiersChanged:
    1791                 {
    1792                     /* Filter using keyboard-filter? */
    1793                     bool fKeyboardFilteringResult =
    1794                         machineLogic()->keyboardHandler()->macEventFilter(pvCocoaEvent, event, screenId());
    1795                     /* Keyboard filter rules the result? */
    1796                     fResult = fKeyboardFilteringResult;
    1797                     break;
    1798                 }
    1799                 default:
    1800                     break;
    1801             }
    1802             break;
    1803         }
    1804         default:
    1805             break;
    1806     }
    1807 
    1808     /* Return result: */
    1809     return fResult;
    1810 }
    1811 
    1812 # elif defined(VBOX_WS_WIN)
    1813 
    1814 bool UIMachineView::winEvent(MSG *pMsg, long* /* piResult */)
    1815 {
    1816     /* Make sure arguments valid: */
    1817     AssertPtrReturn(pMsg, false);
    1818 
    1819     /* Check if some system event should be filtered out.
    1820      * Returning @c true means filtering-out,
    1821      * Returning @c false means passing event to Qt. */
    1822     bool fResult = false; /* Pass to Qt by default. */
    1823     switch (pMsg->message)
    1824     {
    1825         /* Watch for key-events: */
    1826         case WM_KEYDOWN:
    1827         case WM_KEYUP:
    1828         case WM_SYSKEYDOWN:
    1829         case WM_SYSKEYUP:
    1830         {
    1831             /* Can't do COM inter-process calls from a SendMessage handler,
    1832              * see http://support.microsoft.com/kb/131056. */
    1833             if (vboxGlobal().isSeparateProcess() && InSendMessage())
    1834             {
    1835                 PostMessage(pMsg->hwnd, pMsg->message, pMsg->wParam, pMsg->lParam);
    1836                 fResult = true;
    1837                 break;
    1838             }
    1839             /* Filter using keyboard filter? */
    1840             bool fKeyboardFilteringResult =
    1841                 machineLogic()->keyboardHandler()->winEventFilter(pMsg, screenId());
    1842             /* Keyboard filter rules the result? */
    1843             fResult = fKeyboardFilteringResult;
    1844             break;
    1845         }
    1846         default:
    1847             break;
    1848     }
    1849 
    1850     /* Return result: */
    1851     return fResult;
    1852 }
    1853 
    1854 # elif defined(VBOX_WS_X11)
    1855 
    1856 bool UIMachineView::x11Event(XEvent *pEvent)
    1857 {
    1858     /* Make sure arguments valid: */
    1859     AssertPtrReturn(pEvent, false);
    1860 
    1861     /* Check if some system event should be filtered out.
    1862      * Returning @c true means filtering-out,
    1863      * Returning @c false means passing event to Qt. */
    1864     bool fResult = false; /* Pass to Qt by default. */
    1865     switch (pEvent->type)
    1866     {
    1867         /* Watch for focus-events: */
    1868         case XFocusIn:
    1869         case XFocusOut:
    1870         /* Watch for key-events: */
    1871         case XKeyPress:
    1872         case XKeyRelease:
    1873         {
    1874             /* Filter using keyboard-filter? */
    1875             bool fKeyboardFilteringResult =
    1876                 machineLogic()->keyboardHandler()->x11EventFilter(pEvent, screenId());
    1877             /* Filter using mouse-filter? */
    1878             bool fMouseFilteringResult =
    1879                 machineLogic()->mouseHandler()->x11EventFilter(pEvent, screenId());
    1880             /* If at least one of filters wants to filter event out then the result is true. */
    1881             fResult = fKeyboardFilteringResult || fMouseFilteringResult;
    1882             break;
    1883         }
    1884         default:
    1885             break;
    1886     }
    1887 
    1888     /* Return result: */
    1889     return fResult;
    1890 }
    1891 
    1892 # endif /* VBOX_WS_X11 */
    1893 #else /* QT_VERSION >= 0x050000 */
    18941737
    18951738bool UIMachineView::nativeEventPreprocessor(const QByteArray &eventType, void *pMessage)
     
    20241867}
    20251868
    2026 #endif /* QT_VERSION >= 0x050000 */
    2027 
    20281869QSize UIMachineView::scaledForward(QSize size) const
    20291870{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r66588 r68315  
    3636#include "VBox/com/ptr.h"
    3737#ifdef VBOX_WS_MAC
    38 # if QT_VERSION >= 0x050000
    3938#  include <ApplicationServices/ApplicationServices.h>
    40 # endif /* QT_VERSION >= 0x050000 */
    4139#endif /* VBOX_WS_MAC */
    4240
     
    5250class UIMachineWindow;
    5351class UIFrameBuffer;
     52class UINativeEventFilter;
    5453class CConsole;
    5554class CDisplay;
     
    5756class CMachine;
    5857class CSession;
    59 #ifdef VBOX_WS_X11
    60 # if QT_VERSION < 0x050000
    61 typedef union _XEvent XEvent;
    62 # endif /* QT_VERSION < 0x050000 */
    63 #endif /* VBOX_WS_X11 */
    6458#ifdef VBOX_WITH_DRAG_AND_DROP
    65  class CDnDTarget;
    66 #endif /* VBOX_WITH_DRAG_AND_DROP */
    67 #if QT_VERSION >= 0x050000
    68 class UINativeEventFilter;
     59class CDnDTarget;
    6960#endif
    7061
     
    271262    void paintEvent(QPaintEvent *pEvent);
    272263
    273 #if QT_VERSION >= 0x050000
    274264    /** Handles focus-in @a pEvent. */
    275265    void focusInEvent(QFocusEvent *pEvent);
    276266    /** Handles focus-out @a pEvent. */
    277267    void focusOutEvent(QFocusEvent *pEvent);
    278 #endif
    279268
    280269#ifdef VBOX_WITH_DRAG_AND_DROP
     
    344333#endif /* VBOX_WITH_DRAG_AND_DROP */
    345334
    346 #if QT_VERSION < 0x050000
    347 # if defined(VBOX_WS_MAC)
    348     /** Qt4: Mac: Performs pre-processing of all the native events.
    349       * @note     Take into account this function is _not_ called by
    350       *           the Qt itself because it has another signature,
    351       *           only by the keyboard-hook of the keyboard-handler. */
    352     virtual bool macEvent(const void *pvCocoaEvent, EventRef event);
    353 # elif defined(VBOX_WS_WIN)
    354     /** Qt4: Win: Performs pre-processing of all the native events.
    355       * @note     Take into account this function is called by
    356       *           the Qt as well opposing to other host (Mac)
    357       *           because it has required signature. */
    358     virtual bool winEvent(MSG *pMsg, long *piResult);
    359 # elif defined(VBOX_WS_X11)
    360     /** Qt4: X11: Performs pre-processing of all the native events.
    361       * @note     Take into account this function is called by
    362       *           the Qt as well opposing to other host (Mac)
    363       *           because it has required signature. */
    364     virtual bool x11Event(XEvent *pEvent);
    365 # endif /* VBOX_WS_X11 */
    366 #else /* QT_VERSION >= 0x050000 */
    367335    /** Qt5: Performs pre-processing of all the native events. */
    368336    virtual bool nativeEventPreprocessor(const QByteArray &eventType, void *pMessage);
    369 #endif /* QT_VERSION >= 0x050000 */
    370337
    371338    /** Scales passed size forward. */
     
    424391#endif
    425392
    426 #if QT_VERSION >= 0x050000
    427393    /** Holds the native event filter instance. */
    428394    UINativeEventFilter *m_pNativeEventFilter;
     
    430396      * events directly to nativeEventPreprocessor(). */
    431397    friend class UINativeEventFilter;
    432 #endif
    433398
    434399    /* Friend classes: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r66660 r68315  
    5555#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    5656
    57 /* External includes: */
    58 #ifdef VBOX_WS_X11
    59 # if QT_VERSION < 0x050000
    60 #  include <X11/Xlib.h>
    61 # endif /* QT_VERSION < 0x050000 */
    62 #endif /* VBOX_WS_X11 */
    63 
    6457
    6558/* static */
     
    252245    updateAppearanceOf(UIVisualElement_WindowTitle);
    253246}
    254 
    255 #ifdef VBOX_WS_X11
    256 # if QT_VERSION < 0x050000
    257 bool UIMachineWindow::x11Event(XEvent *pEvent)
    258 {
    259     /// @todo Is that really needed?
    260     /* Qt bug: when the machine-view grabs the keyboard,
    261      * FocusIn, FocusOut, WindowActivate and WindowDeactivate Qt events are
    262      * not properly sent on top level window deactivation.
    263      * The fix is to substiute the mode in FocusOut X11 event structure
    264      * to NotifyNormal to cause Qt to process it as desired. */
    265     if (pEvent->type == FocusOut)
    266     {
    267         if (pEvent->xfocus.mode == NotifyWhileGrabbed  &&
    268             (pEvent->xfocus.detail == NotifyAncestor ||
    269              pEvent->xfocus.detail == NotifyInferior ||
    270              pEvent->xfocus.detail == NotifyNonlinear))
    271         {
    272              pEvent->xfocus.mode = NotifyNormal;
    273         }
    274     }
    275     return false;
    276 }
    277 # endif /* QT_VERSION < 0x050000 */
    278 #endif /* VBOX_WS_X11 */
    279247
    280248void UIMachineWindow::showEvent(QShowEvent *pShowEvent)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.h

    r63229 r68315  
    4242class UIMachineView;
    4343class CSession;
    44 #ifdef VBOX_WS_X11
    45 # if QT_VERSION < 0x050000
    46 typedef union _XEvent XEvent;
    47 # endif /* QT_VERSION < 0x050000 */
    48 #endif /* VBOX_WS_X11 */
    4944
    5045
     
    129124    /* Translate stuff: */
    130125    void retranslateUi();
    131 
    132     /* Event handlers: */
    133 #ifdef VBOX_WS_X11
    134 # if QT_VERSION < 0x050000
    135     /** X11: Qt4: Handles all native events. */
    136     bool x11Event(XEvent *pEvent);
    137 # endif /* QT_VERSION < 0x050000 */
    138 #endif /* VBOX_WS_X11 */
    139126
    140127    /** Show event handler. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp

    r66278 r68315  
    2323# include <QMouseEvent>
    2424# include <QTimer>
    25 # if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     25# ifdef VBOX_WS_X11
    2626#  include <QX11Info>
    2727# endif
     
    5959
    6060/* GUI includes: */
    61 #if defined(VBOX_WS_MAC) && QT_VERSION >= 0x050000
     61#ifdef VBOX_WS_MAC
    6262# include "CocoaEventHelper.h"
    6363#endif
     
    6868/* External includes: */
    6969#ifdef VBOX_WS_X11
    70 # if QT_VERSION < 0x050000
    71 #  include <X11/Xlib.h>
    72 #  ifdef FocusOut
    73 const int XFocusOut = FocusOut;
    74 #   undef FocusOut
    75 #  endif /* FocusOut */
    76 # else
    77 #  include <xcb/xcb.h>
    78 # endif
     70# include <xcb/xcb.h>
    7971#endif
    8072
     
    273265           (uisession()->isMouseIntegrated() ? 0 : UIMouseStateType_MouseAbsoluteDisabled);
    274266}
    275 
    276 #if QT_VERSION < 0x050000
    277 # ifdef VBOX_WS_X11
    278 
    279 bool UIMouseHandler::x11EventFilter(XEvent *pEvent, ulong /* uScreenId */)
    280 {
    281     /* Check if some system event should be filtered-out.
    282      * Returning 'true' means filtering-out,
    283      * Returning 'false' means passing event to Qt. */
    284     bool fResult = false; /* Pass to Qt by default: */
    285     switch (pEvent->type)
    286     {
    287         /* We have to handle XFocusOut right here as this event is not passed to UIMachineView::event().
    288          * Handling this event is important for releasing the keyboard before the screen saver gets active.
    289          * See public ticket #3894: Apparently this makes problems with newer versions of Qt
    290          * and this hack is probably not necessary anymore. So disable it for Qt >= 4.5.0. */
    291         case XFocusOut:
    292         {
    293             if (uisession()->isRunning())
    294             {
    295                 if (VBoxGlobal::qtRTVersion() < ((4 << 16) | (5 << 8) | 0))
    296                     releaseMouse();
    297             }
    298             fResult = false;
    299         }
    300         default:
    301             break;
    302     }
    303     /* Return result: */
    304     return fResult;
    305 }
    306 
    307 # endif /* VBOX_WS_X11 */
    308 #else /* QT_VERSION >= 0x050000 */
    309267
    310268bool UIMouseHandler::nativeEventFilter(void *pMessage, ulong uScreenId)
     
    413371    return fResult;
    414372}
    415 
    416 #endif /* QT_VERSION >= 0x050000 */
    417373
    418374/* Machine state-change handler: */
     
    774730                {
    775731                    QMouseEvent *pMouseEvent = static_cast<QMouseEvent*>(pEvent);
    776 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     732#ifdef VBOX_WS_X11
    777733                    /* When the keyboard is captured, we also capture mouse button
    778734                     * events, and release the keyboard and re-capture it delayed
     
    783739                    if (pEvent->type() == QEvent::MouseButtonPress)
    784740                        machineLogic()->keyboardHandler()->finaliseCaptureKeyboard();
    785 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     741#endif /* VBOX_WS_X11 */
    786742                    m_iLastMouseWheelDelta = 0;
    787743                    if (mouseEvent(pMouseEvent->type(), uScreenId,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.h

    r63579 r68315  
    3838class CDisplay;
    3939class CMouse;
    40 #ifdef VBOX_WS_X11
    41 # if QT_VERSION < 0x050000
    42 typedef union _XEvent XEvent;
    43 # endif /* QT_VERSION < 0x050000 */
    44 #endif /* VBOX_WS_X11 */
    4540
    4641
     
    7570    int state() const;
    7671
    77 #if QT_VERSION < 0x050000
    78 # ifdef VBOX_WS_X11
    79     /** Qt4: X11: Performs pre-processing of all the native events. */
    80     bool x11EventFilter(XEvent *pEvent, ulong uScreenId);
    81 # endif
    82 #else
    8372    /** Qt5: Performs pre-processing of all the native events. */
    8473    bool nativeEventFilter(void *pMessage, ulong uScreenId);
    85 #endif
    8674
    8775protected slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r67611 r68315  
    7575/* Qt includes: */
    7676#ifdef VBOX_WS_WIN
    77 # if QT_VERSION >= 0x050000
    78 #  include <QtWin>
    79 # endif /* QT_VERSION >= 0x050000 */
     77# include <QtWin>
    8078#endif /* VBOX_WS_WIN */
    8179
     
    15411539}
    15421540
    1543 #if defined(VBOX_WS_WIN) && QT_VERSION >= 0x050000
     1541#ifdef VBOX_WS_WIN
    15441542static bool isPointer1bpp(const uint8_t *pu8XorMask,
    15451543                          uint uWidth,
     
    15651563    return true;
    15661564}
    1567 #endif
     1565#endif /* VBOX_WS_WIN */
    15681566
    15691567void UISession::setPointerShape(const uchar *pShapeData, bool fHasAlpha,
     
    15801578#if defined (VBOX_WS_WIN)
    15811579
    1582 # if QT_VERSION < 0x050000
    1583     BITMAPV5HEADER bi;
    1584     HBITMAP hBitmap;
    1585     void *lpBits;
    1586 
    1587     ::ZeroMemory(&bi, sizeof (BITMAPV5HEADER));
    1588     bi.bV5Size = sizeof(BITMAPV5HEADER);
    1589     bi.bV5Width = uWidth;
    1590     bi.bV5Height = - (LONG)uHeight;
    1591     bi.bV5Planes = 1;
    1592     bi.bV5BitCount = 32;
    1593     bi.bV5Compression = BI_BITFIELDS;
    1594     bi.bV5RedMask   = 0x00FF0000;
    1595     bi.bV5GreenMask = 0x0000FF00;
    1596     bi.bV5BlueMask  = 0x000000FF;
    1597     if (fHasAlpha)
    1598         bi.bV5AlphaMask = 0xFF000000;
    1599     else
    1600         bi.bV5AlphaMask = 0;
    1601 
    1602     HDC hdc = GetDC(NULL);
    1603 
    1604     /* Create the DIB section with an alpha channel: */
    1605     hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, (void **)&lpBits, NULL, (DWORD) 0);
    1606 
    1607     ReleaseDC(NULL, hdc);
    1608 
    1609     HBITMAP hMonoBitmap = NULL;
    1610     if (fHasAlpha)
    1611     {
    1612         /* Create an empty mask bitmap: */
    1613         hMonoBitmap = CreateBitmap(uWidth, uHeight, 1, 1, NULL);
    1614     }
    1615     else
    1616     {
    1617         /* Word aligned AND mask. Will be allocated and created if necessary. */
    1618         uint8_t *pu8AndMaskWordAligned = NULL;
    1619 
    1620         /* Width in bytes of the original AND mask scan line. */
    1621         uint32_t cbAndMaskScan = (uWidth + 7) / 8;
    1622 
    1623         if (cbAndMaskScan & 1)
    1624         {
    1625             /* Original AND mask is not word aligned. */
    1626 
    1627             /* Allocate memory for aligned AND mask. */
    1628             pu8AndMaskWordAligned = (uint8_t *)RTMemTmpAllocZ((cbAndMaskScan + 1) * uHeight);
    1629 
    1630             Assert(pu8AndMaskWordAligned);
    1631 
    1632             if (pu8AndMaskWordAligned)
    1633             {
    1634                 /* According to MSDN the padding bits must be 0.
    1635                  * Compute the bit mask to set padding bits to 0 in the last byte of original AND mask. */
    1636                 uint32_t u32PaddingBits = cbAndMaskScan * 8  - uWidth;
    1637                 Assert(u32PaddingBits < 8);
    1638                 uint8_t u8LastBytesPaddingMask = (uint8_t)(0xFF << u32PaddingBits);
    1639 
    1640                 Log(("u8LastBytesPaddingMask = %02X, aligned w = %d, width = %d, cbAndMaskScan = %d\n",
    1641                       u8LastBytesPaddingMask, (cbAndMaskScan + 1) * 8, uWidth, cbAndMaskScan));
    1642 
    1643                 uint8_t *src = (uint8_t *)srcAndMaskPtr;
    1644                 uint8_t *dst = pu8AndMaskWordAligned;
    1645 
    1646                 unsigned i;
    1647                 for (i = 0; i < uHeight; i++)
    1648                 {
    1649                     memcpy(dst, src, cbAndMaskScan);
    1650 
    1651                     dst[cbAndMaskScan - 1] &= u8LastBytesPaddingMask;
    1652 
    1653                     src += cbAndMaskScan;
    1654                     dst += cbAndMaskScan + 1;
    1655                 }
    1656             }
    1657         }
    1658 
    1659         /* Create the AND mask bitmap: */
    1660         hMonoBitmap = ::CreateBitmap(uWidth, uHeight, 1, 1,
    1661                                      pu8AndMaskWordAligned? pu8AndMaskWordAligned: srcAndMaskPtr);
    1662 
    1663         if (pu8AndMaskWordAligned)
    1664         {
    1665             RTMemTmpFree(pu8AndMaskWordAligned);
    1666         }
    1667     }
    1668 
    1669     Assert(hBitmap);
    1670     Assert(hMonoBitmap);
    1671     if (hBitmap && hMonoBitmap)
    1672     {
    1673         DWORD *dstShapePtr = (DWORD *) lpBits;
    1674 
    1675         for (uint y = 0; y < uHeight; y ++)
    1676         {
    1677             memcpy(dstShapePtr, srcShapePtr, srcShapePtrScan);
    1678             srcShapePtr += srcShapePtrScan;
    1679             dstShapePtr += uWidth;
    1680         }
    1681 
    1682         ICONINFO ii;
    1683         ii.fIcon = FALSE;
    1684         ii.xHotspot = uXHot;
    1685         ii.yHotspot = uYHot;
    1686         ii.hbmMask = hMonoBitmap;
    1687         ii.hbmColor = hBitmap;
    1688 
    1689         HCURSOR hAlphaCursor = CreateIconIndirect(&ii);
    1690         Assert(hAlphaCursor);
    1691         if (hAlphaCursor)
    1692         {
    1693             /* Set the new cursor: */
    1694             m_cursor = QCursor(hAlphaCursor);
    1695             if (m_alphaCursor)
    1696                 DestroyIcon(m_alphaCursor);
    1697             m_alphaCursor = hAlphaCursor;
    1698             m_fIsValidPointerShapePresent = true;
    1699         }
    1700     }
    1701 
    1702     if (hMonoBitmap)
    1703         DeleteObject(hMonoBitmap);
    1704     if (hBitmap)
    1705         DeleteObject(hBitmap);
    1706 # else /* QT_VERSION >= 0x050000 */
    17071580    /* Create a ARGB image out of the shape data: */
    17081581
     
    18491722    m_fIsValidPointerShapePresent = true;
    18501723    NOREF(srcShapePtrScan);
    1851 # endif /* QT_VERSION >= 0x050000 */
    18521724
    18531725#elif defined(VBOX_WS_X11) || defined(VBOX_WS_MAC)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIInformationModel.cpp

    r65337 r68315  
    8787    roleNames[Qt::UserRole + 1] = "";
    8888    roleNames[Qt::UserRole + 2] = "";
    89     # if QT_VERSION < 0x050000
    90     setRoleNames(roleNames);
    91     # endif /* QT_VERSION < 0x050000 */
    9289
    9390    /* Register meta-type: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r63567 r68315  
    254254void UIMachineLogicNormal::sltHostScreenAvailableAreaChange()
    255255{
    256 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     256#ifdef VBOX_WS_X11
    257257    /* Prevent handling if fake screen detected: */
    258258    if (gpDesktop->isFakeScreenDetected())
     
    262262    foreach (UIMachineWindow *pMachineWindow, machineWindows())
    263263        pMachineWindow->restoreCachedGeometry();
    264 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     264#endif /* VBOX_WS_X11 */
    265265
    266266    /* Call to base-class: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp

    r67942 r68315  
    468468        case QEvent::Resize:
    469469        {
    470 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     470#ifdef VBOX_WS_X11
    471471            /* Prevent handling if fake screen detected: */
    472472            if (gpDesktop->isFakeScreenDetected())
    473473                break;
    474 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     474#endif /* VBOX_WS_X11 */
    475475
    476476            QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
     
    488488        case QEvent::Move:
    489489        {
    490 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     490#ifdef VBOX_WS_X11
    491491            /* Prevent handling if fake screen detected: */
    492492            if (gpDesktop->isFakeScreenDetected())
    493493                break;
    494 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     494#endif /* VBOX_WS_X11 */
    495495
    496496            if (!isMaximizedChecked())
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineLogicScale.cpp

    r63567 r68315  
    7878void UIMachineLogicScale::sltHostScreenAvailableAreaChange()
    7979{
    80 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     80#ifdef VBOX_WS_X11
    8181    /* Prevent handling if fake screen detected: */
    8282    if (gpDesktop->isFakeScreenDetected())
     
    8686    foreach (UIMachineWindow *pMachineWindow, machineWindows())
    8787        pMachineWindow->restoreCachedGeometry();
    88 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     88#endif /* VBOX_WS_X11 */
    8989
    9090    /* Call to base-class: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp

    r64334 r68315  
    217217        case QEvent::Resize:
    218218        {
    219 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     219#ifdef VBOX_WS_X11
    220220            /* Prevent handling if fake screen detected: */
    221221            if (gpDesktop->isFakeScreenDetected())
    222222                break;
    223 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     223#endif /* VBOX_WS_X11 */
    224224
    225225            QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent);
     
    236236        case QEvent::Move:
    237237        {
    238 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     238#ifdef VBOX_WS_X11
    239239            /* Prevent handling if fake screen detected: */
    240240            if (gpDesktop->isFakeScreenDetected())
    241241                break;
    242 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     242#endif /* VBOX_WS_X11 */
    243243
    244244            if (!isMaximizedChecked())
     
    258258}
    259259
    260 #ifdef VBOX_WS_WIN
    261 # if QT_VERSION < 0x050000
    262 bool UIMachineWindowScale::winEvent(MSG *pMessage, long *pResult)
    263 {
    264     /* Try to keep aspect ratio during window resize if:
    265      * 1. machine view exists and 2. event-type is WM_SIZING and 3. shift key is NOT pressed: */
    266     if (machineView() && pMessage->message == WM_SIZING && !(QApplication::keyboardModifiers() & Qt::ShiftModifier))
    267     {
    268         double dAspectRatio = machineView()->aspectRatio();
    269         if (dAspectRatio)
    270         {
    271             RECT *pRect = reinterpret_cast<RECT*>(pMessage->lParam);
    272             switch (pMessage->wParam)
    273             {
    274                 case WMSZ_LEFT:
    275                 case WMSZ_RIGHT:
    276                 {
    277                     pRect->bottom = pRect->top + (double)(pRect->right - pRect->left) / dAspectRatio;
    278                     break;
    279                 }
    280                 case WMSZ_TOP:
    281                 case WMSZ_BOTTOM:
    282                 {
    283                     pRect->right = pRect->left + (double)(pRect->bottom - pRect->top) * dAspectRatio;
    284                     break;
    285                 }
    286                 case WMSZ_BOTTOMLEFT:
    287                 case WMSZ_BOTTOMRIGHT:
    288                 {
    289                     pRect->bottom = pRect->top + (double)(pRect->right - pRect->left) / dAspectRatio;
    290                     break;
    291                 }
    292                 case WMSZ_TOPLEFT:
    293                 case WMSZ_TOPRIGHT:
    294                 {
    295                     pRect->top = pRect->bottom - (double)(pRect->right - pRect->left) / dAspectRatio;
    296                     break;
    297                 }
    298                 default:
    299                     break;
    300             }
    301         }
    302     }
    303     /* Call to base-class: */
    304     return UIMachineWindow::winEvent(pMessage, pResult);
    305 }
    306 # endif /* QT_VERSION < 0x050000 */
    307 #endif /* VBOX_WS_WIN */
    308 
    309260bool UIMachineWindowScale::isMaximizedChecked()
    310261{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.h

    r63230 r68315  
    6363    /** Common @a pEvent handler. */
    6464    bool event(QEvent *pEvent);
    65 #ifdef VBOX_WS_WIN
    66 # if QT_VERSION < 0x050000
    67     /** Qt4: Win: Handles all native messages. */
    68     bool winEvent(MSG *pMessage, long *pResult);
    69 # endif /* QT_VERSION < 0x050000 */
    70 #endif /* VBOX_WS_WIN */
    7165
    7266    /** Returns whether this window is maximized. */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r68304 r68315  
    167167}
    168168
    169 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     169#ifdef VBOX_WS_X11
    170170void UISelectorWindow::sltHandleHostScreenAvailableAreaChange()
    171171{
     
    178178    move(m_geometry.topLeft());
    179179}
    180 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     180#endif /* VBOX_WS_X11 */
    181181
    182182void UISelectorWindow::sltShowSelectorWindowContextMenu(const QPoint &position)
     
    10531053        const CMachine &machine = pItem->machine();
    10541054        UIDesktopServices::createMachineShortcut(machine.GetSettingsFilePath(),
    1055 #if QT_VERSION >= 0x050000
    10561055                                                 QStandardPaths::writableLocation(QStandardPaths::DesktopLocation),
    1057 #else /* QT_VERSION < 0x050000 */
    1058                                                  QDesktopServices::storageLocation(QDesktopServices::DesktopLocation),
    1059 #endif /* QT_VERSION < 0x050000 */
    10601056                                                 machine.GetName(), machine.GetId());
    10611057    }
     
    11801176    sltHandleChooserPaneIndexChange(false /* update details? */, false /* update snapshots? */);
    11811177
    1182 #if defined(VBOX_WS_MAC) && QT_VERSION < 0x050000
    1183     /* Avoid bug in Qt Cocoa which results in showing a "more arrow" on size-hint changes: */
     1178#ifdef VBOX_WS_MAC
     1179    // WORKAROUND:
     1180    // There is a bug in Qt Cocoa which result in showing a "more arrow" when
     1181    // the necessary size of the toolbar is increased. Also for some languages
     1182    // the with doesn't match if the text increase. So manually adjust the size
     1183    // after changing the text.
    11841184    m_pToolBar->updateLayout();
    11851185#endif
     
    11941194        case QEvent::Resize:
    11951195        {
    1196 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     1196#ifdef VBOX_WS_X11
    11971197            /* Prevent handling if fake screen detected: */
    11981198            if (gpDesktop->isFakeScreenDetected())
    11991199                break;
    1200 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     1200#endif /* VBOX_WS_X11 */
    12011201
    12021202            if (isVisible() && (windowState() & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)) == 0)
     
    12091209        case QEvent::Move:
    12101210        {
    1211 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     1211#ifdef VBOX_WS_X11
    12121212            /* Prevent handling if fake screen detected: */
    12131213            if (gpDesktop->isFakeScreenDetected())
    12141214                break;
    1215 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     1215#endif /* VBOX_WS_X11 */
    12161216
    12171217            if (isVisible() && (windowState() & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)) == 0)
     
    19691969void UISelectorWindow::prepareConnections()
    19701970{
    1971 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     1971#ifdef VBOX_WS_X11
    19721972    /* Desktop event handlers: */
    19731973    connect(gpDesktop, SIGNAL(sigHostScreenWorkAreaResized(int)), this, SLOT(sltHandleHostScreenAvailableAreaChange()));
    1974 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     1974#endif /* VBOX_WS_X11 */
    19751975
    19761976    /* Medium enumeration connections: */
     
    23772377    actionPool()->action(UIActionIndexST_M_Machine_T_Pause)->blockSignals(false);
    23782378
    2379 #if defined(VBOX_WS_MAC) && QT_VERSION < 0x050000
    2380     /* Avoid bug in Qt Cocoa which results in showing a "more arrow" on size-hint changes: */
     2379#ifdef VBOX_WS_MAC
     2380    // WORKAROUND:
     2381    // There is a bug in Qt Cocoa which result in showing a "more arrow" when
     2382    // the necessary size of the toolbar is increased. Also for some languages
     2383    // the with doesn't match if the text increase. So manually adjust the size
     2384    // after changing the text.
    23812385    m_pToolBar->updateLayout();
    23822386#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r68304 r68315  
    7979    void sltHandlePolishEvent();
    8080
    81 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000
     81#if QT_VERSION == 0
     82    /** Stupid moc does not warn if it cannot find headers! */
     83    void QT_VERSION_NOT_DEFINED
     84#elif defined(VBOX_WS_X11)
    8285    /** Handles host-screen available-area change. */
    8386    void sltHandleHostScreenAvailableAreaChange();
    84 #elif QT_VERSION == 0
    85     /** Stupid moc does not warn if it cannot find headers! */
    86     void QT_VERSION_NOT_DEFINED
    87 #endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */
     87#endif /* VBOX_WS_X11 */
    8888
    8989    /** Handles selector-window context-menu call for passed @a position. */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp

    r68264 r68315  
    5151
    5252#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    53 
    54 /* Qt includes: */
    55 #if QT_VERSION < 0x050000
    56 # include <QWindowsStyle>
    57 #endif /* QT_VERSION < 0x050000 */
    5853
    5954
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.cpp

    r63763 r68315  
    401401        m_fHovered = true;
    402402        emit sigHoverEnter();
    403 #if QT_VERSION >= 0x050000
    404403        update();
    405 #endif /* QT_VERSION >= 0x050000 */
    406404    }
    407405}
     
    413411        m_fHovered = false;
    414412        emit sigHoverLeave();
    415 #if QT_VERSION >= 0x050000
    416413        update();
    417 #endif /* QT_VERSION >= 0x050000 */
    418414    }
    419415}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGMachinePreview.cpp

    r65632 r68315  
    395395
    396396#ifdef VBOX_WS_MAC
    397 # if QT_VERSION >= 0x050000
    398397        /* Set composition-mode to opaque: */
    399398        pPainter->setCompositionMode(QPainter::CompositionMode_Source);
     
    402401        /* Return default composition-mode back: */
    403402        pPainter->setCompositionMode(QPainter::CompositionMode_SourceAtop);
    404 # endif /* QT_VERSION >= 0x050000 */
    405403#endif /* VBOX_WS_MAC */
    406404
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp

    r65600 r68315  
    190190    int index = m_pages[cId];
    191191#ifdef VBOX_WS_MAC
    192 # if QT_VERSION < 0x050000
    193     QSize cs = size();
    194     if (index < m_sizeList.count())
    195     {
    196         QSize ss = m_sizeList.at(index);
    197         /* Switch to the new page first if we are shrinking: */
    198         if (cs.height() > ss.height())
    199             m_pStack->setCurrentIndex(index);
    200         /* Do the animation: */
    201         ::darwinWindowAnimateResize(this, QRect (x(), y(), ss.width(), ss.height()));
    202         /* Switch to the new page last if we are zooming: */
    203         if (cs.height() <= ss.height())
    204             m_pStack->setCurrentIndex(index);
    205     }
    206     ::darwinSetShowsResizeIndicator(this, false);
    207 # else /* QT_VERSION >= 0x050000 */
    208192    /* If index is within the stored size list bounds: */
    209193    if (index < m_sizeList.count())
     
    234218        }
    235219    }
    236 # endif /* QT_VERSION >= 0x050000 */
    237220#else
    238221    m_pStack->setCurrentIndex(index);
     
    632615    ::darwinSetHidesAllTitleButtons(this);
    633616
    634 # if QT_VERSION < 0x050000
    635     /* Set all size policies to ignored: */
    636     for (int i = 0; i < m_pStack->count(); ++i)
    637         m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
    638     /* Activate every single page to get the optimal size: */
    639     for (int i = m_pStack->count() - 1; i >= 0; --i)
    640     {
    641         m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    642         /* Prevent this widgets to go in the Small/Mini size state which is
    643          * available on Mac OS X. Not sure why this happens but this seems to help
    644          * against. */
    645         QList <QWidget*> list = m_pStack->widget(i)->findChildren<QWidget*>();
    646         for (int a = 0; a < list.size(); ++a)
    647         {
    648             QWidget *w = list.at(a);
    649             if (w->parent() == m_pStack->widget(i))
    650                 w->setFixedHeight(w->sizeHint().height());
    651         }
    652         m_pStack->setCurrentIndex(i);
    653         /* Now make sure the layout is freshly calculated. */
    654         layout()->activate();
    655         QSize s = minimumSize();
    656         if (iMinWidth > s.width())
    657             s.setWidth(iMinWidth);
    658         m_sizeList.insert(0, s);
    659         m_pStack->widget(i)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
    660     }
    661 # else /* QT_VERSION >= 0x050000 */
    662617    /* Unlock all page policies initially: */
    663618    for (int i = 0; i < m_pStack->count(); ++i)
     
    695650        m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored);
    696651    }
    697 # endif /* QT_VERSION >= 0x050000 */
    698652
    699653    sltCategoryChanged(m_pSelector->currentId());
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsInput.cpp

    r66626 r68315  
    822822    verticalHeader()->setDefaultSectionSize((int)(verticalHeader()->minimumSectionSize() * 1.33));
    823823    horizontalHeader()->setStretchLastSection(false);
    824 #if QT_VERSION >= 0x050000
    825824    horizontalHeader()->setSectionResizeMode(UIHotKeyColumnIndex_Description, QHeaderView::Interactive);
    826825    horizontalHeader()->setSectionResizeMode(UIHotKeyColumnIndex_Sequence, QHeaderView::Stretch);
    827 #else /* QT_VERSION < 0x050000 */
    828     horizontalHeader()->setResizeMode(UIHotKeyColumnIndex_Description, QHeaderView::Interactive);
    829     horizontalHeader()->setResizeMode(UIHotKeyColumnIndex_Sequence, QHeaderView::Stretch);
    830 #endif /* QT_VERSION < 0x050000 */
    831826
    832827    /* Connect model: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp

    r66658 r68315  
    13451345                    m_pTreeViewSettings->header()->setStretchLastSection(true);
    13461346                    m_pTreeViewSettings->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding);
    1347 #if QT_VERSION < 0x050000
    1348                     m_pTreeViewSettings->header()->setResizeMode(QHeaderView::ResizeToContents);
    1349 #else
    13501347                    m_pTreeViewSettings->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
    1351 #endif
    13521348
    13531349                    /* Add tree-view into information layout: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIBootTable.cpp

    r63322 r68315  
    7171    int h = 2 * frameWidth();
    7272    int w = h;
    73 #if QT_VERSION < 0x040700
    74     w += 4; // WTF?
    75 #endif /* QT_VERSION < 0x040700 */
    7673    setFixedSize(sizeHintForColumn(0) + w,
    7774                 sizeHintForRow(0) * count() + h);
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.cpp

    r66589 r68315  
    4545/* Qt includes: */
    4646#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
    47 # if QT_VERSION >= 0x050000
    48 #  include <QAbstractNativeEventFilter>
    49 # endif /* QT_VERSION >= 0x050000 */
     47# include <QAbstractNativeEventFilter>
    5048#endif /* VBOX_WS_MAC || VBOX_WS_WIN */
    5149
     
    7169# include <X11/Xutil.h>
    7270# include <X11/keysym.h>
    73 # if QT_VERSION >= 0x050000
    74 #  include <xcb/xcb.h>
    75 # else /* QT_VERSION < 0x050000 */
    76 #  ifdef KeyPress
    77 const int XKeyPress = KeyPress;
    78 const int XKeyRelease = KeyRelease;
    79 #   undef KeyPress
    80 #   undef KeyRelease
    81 #  endif /* KeyPress */
    82 # endif /* QT_VERSION < 0x050000 */
     71# include <xcb/xcb.h>
    8372#endif /* VBOX_WS_X11 */
    8473
     
    8877
    8978#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
    90 # if QT_VERSION >= 0x050000
    9179/** QAbstractNativeEventFilter extension
    9280  * allowing to handle native platform events.
     
    119107    UIHostComboEditorPrivate *m_pParent;
    120108};
    121 # endif /* QT_VERSION >= 0x050000 */
    122109#endif /* VBOX_WS_MAC || VBOX_WS_WIN */
    123110
     
    546533    , m_fStartNewSequence(true)
    547534#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
    548 # if QT_VERSION >= 0x050000
    549535    , m_pPrivateEventFilter(0)
    550 # endif /* QT_VERSION >= 0x050000 */
    551536#endif /* VBOX_WS_MAC || VBOX_WS_WIN */
    552537#ifdef VBOX_WS_WIN
     
    566551
    567552#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
    568 # if QT_VERSION >= 0x050000
    569553    /* Prepare private event filter: */
    570554    m_pPrivateEventFilter = new ComboEditorEventFilter(this);
    571555    qApp->installNativeEventFilter(m_pPrivateEventFilter);
    572 # endif /* QT_VERSION >= 0x050000 */
    573556#endif /* VBOX_WS_MAC || VBOX_WS_WIN */
    574557
    575558#if defined(VBOX_WS_MAC)
    576559    m_uDarwinKeyModifiers = 0;
    577 # if QT_VERSION < 0x050000
    578     UICocoaApplication::instance()->registerForNativeEvents(RT_BIT_32(10) | RT_BIT_32(11) | RT_BIT_32(12) /* NSKeyDown  | NSKeyUp | | NSFlagsChanged */, UIHostComboEditorPrivate::darwinEventHandlerProc, this);
    579     ::DarwinGrabKeyboard(false /* just modifiers */);
    580 # endif /* QT_VERSION < 0x050000 */
    581560#elif defined(VBOX_WS_WIN)
    582561    /* Prepare AltGR monitor: */
     
    590569UIHostComboEditorPrivate::~UIHostComboEditorPrivate()
    591570{
    592 #if defined(VBOX_WS_MAC)
    593 # if QT_VERSION < 0x050000
    594     ::DarwinReleaseKeyboard();
    595     UICocoaApplication::instance()->unregisterForNativeEvents(RT_BIT_32(10) | RT_BIT_32(11) | RT_BIT_32(12) /* NSKeyDown  | NSKeyUp | | NSFlagsChanged */, UIHostComboEditorPrivate::darwinEventHandlerProc, this);
    596 # endif /* QT_VERSION < 0x050000 */
    597 #elif defined(VBOX_WS_WIN)
     571#if defined(VBOX_WS_WIN)
    598572    /* Cleanup AltGR monitor: */
    599573    delete m_pAltGrMonitor;
     
    602576
    603577#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
    604 # if QT_VERSION >= 0x050000
    605578    /* Cleanup private event filter: */
    606579    qApp->removeNativeEventFilter(m_pPrivateEventFilter);
    607580    delete m_pPrivateEventFilter;
    608581    m_pPrivateEventFilter = 0;
    609 # endif /* QT_VERSION >= 0x050000 */
    610582#endif /* VBOX_WS_MAC || VBOX_WS_WIN */
    611583}
     
    651623    emit sigDataChanged();
    652624}
    653 
    654 #if QT_VERSION >= 0x050000
    655625
    656626bool UIHostComboEditorPrivate::nativeEvent(const QByteArray &eventType, void *pMessage, long *pResult)
     
    800770}
    801771
    802 #else /* QT_VERSION < 0x050000 */
    803 
    804 # if defined(VBOX_WS_MAC)
    805 
    806 /* static */
    807 bool UIHostComboEditorPrivate::darwinEventHandlerProc(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser)
    808 {
    809     UIHostComboEditorPrivate *pEditor = static_cast<UIHostComboEditorPrivate*>(pvUser);
    810     EventRef inEvent = (EventRef)pvCarbonEvent;
    811     UInt32 EventClass = ::GetEventClass(inEvent);
    812     if (EventClass == kEventClassKeyboard)
    813         return pEditor->darwinKeyboardEvent(pvCocoaEvent, inEvent);
    814     return false;
    815 }
    816 
    817 bool UIHostComboEditorPrivate::darwinKeyboardEvent(const void *pvCocoaEvent, EventRef inEvent)
    818 {
    819     /* Ignore key changes unless we're the focus widget: */
    820     if (!hasFocus())
    821         return false;
    822 
    823     UInt32 eventKind = ::GetEventKind(inEvent);
    824     switch (eventKind)
    825     {
    826         //case kEventRawKeyDown:
    827         //case kEventRawKeyUp:
    828         //case kEventRawKeyRepeat:
    829         case kEventRawKeyModifiersChanged:
    830         {
    831             /* Get modifier mask: */
    832             UInt32 modifierMask = 0;
    833             ::GetEventParameter(inEvent, kEventParamKeyModifiers, typeUInt32, NULL,
    834                                 sizeof(modifierMask), NULL, &modifierMask);
    835             modifierMask = ::DarwinAdjustModifierMask(modifierMask, pvCocoaEvent);
    836             UInt32 changed = m_uDarwinKeyModifiers ^ modifierMask;
    837 
    838             if (!changed)
    839                 break;
    840 
    841             /* Convert to keycode: */
    842             unsigned uKeyCode = ::DarwinModifierMaskToDarwinKeycode(changed);
    843 
    844             if (!uKeyCode || uKeyCode == ~0U)
    845                 return false;
    846 
    847             /* Process the key event: */
    848             if (processKeyEvent(uKeyCode, changed & modifierMask))
    849             {
    850                 /* Save the new modifier mask state. */
    851                 m_uDarwinKeyModifiers = modifierMask;
    852                 return true;
    853             }
    854             break;
    855         }
    856         default:
    857             break;
    858     }
    859     return false;
    860 }
    861 
    862 # elif defined(VBOX_WS_WIN)
    863 
    864 bool UIHostComboEditorPrivate::winEvent(MSG *pMsg, long* /* pResult */)
    865 {
    866     switch (pMsg->message)
    867     {
    868         case WM_KEYDOWN:
    869         case WM_SYSKEYDOWN:
    870         case WM_KEYUP:
    871         case WM_SYSKEYUP:
    872         {
    873             /* Get key-code: */
    874             int iKeyCode = UINativeHotKey::distinguishModifierVKey((int)pMsg->wParam, (int)pMsg->lParam);
    875             unsigned iDownScanCode = (pMsg->lParam >> 16) & 0x7F;
    876             bool fPressed = !(pMsg->lParam & 0x80000000);
    877             bool fExtended = pMsg->lParam & 0x1000000;
    878 
    879             /* If present - why not just assert this? */
    880             if (m_pAltGrMonitor)
    881             {
    882                 /* Update AltGR monitor state from key-event: */
    883                 m_pAltGrMonitor->updateStateFromKeyEvent(iDownScanCode, fPressed, fExtended);
    884                 /* And release left Ctrl key early (if required): */
    885                 if (m_pAltGrMonitor->isLeftControlReleaseNeeded())
    886                 {
    887                     m_pressedKeys.remove(VK_LCONTROL);
    888                     m_shownKeys.remove(VK_LCONTROL);
    889                 }
    890                 /* Fake LCtrl release events can also end up in the released
    891                  * key set.  Detect them on the immediately following RAlt up. */
    892                 if (!m_pressedKeys.contains(VK_LCONTROL))
    893                     m_releasedKeys.remove(VK_LCONTROL);
    894             }
    895 
    896             /* Process the key event: */
    897             return processKeyEvent(iKeyCode, pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN);
    898         }
    899         default:
    900             break;
    901     }
    902 
    903     return false;
    904 }
    905 
    906 # elif defined(VBOX_WS_X11)
    907 
    908 bool UIHostComboEditorPrivate::x11Event(XEvent *pEvent)
    909 {
    910     switch (pEvent->type)
    911     {
    912         case XKeyPress:
    913         case XKeyRelease:
    914         {
    915             /* Get key-code: */
    916             XKeyEvent *pKeyEvent = (XKeyEvent*)pEvent;
    917             RT_GCC_NO_WARN_DEPRECATED_BEGIN
    918             KeySym ks = ::XKeycodeToKeysym(pKeyEvent->display, pKeyEvent->keycode, 0);
    919             RT_GCC_NO_WARN_DEPRECATED_END
    920 
    921             int iKeySym = (int)ks;
    922 
    923             /* Process the key event: */
    924             return processKeyEvent(iKeySym, pEvent->type == XKeyPress);
    925         }
    926         default:
    927             break;
    928     }
    929 
    930     return false;
    931 }
    932 
    933 # endif /* VBOX_WS_X11 */
    934 
    935 #endif /* QT_VERSION < 0x050000 */
    936 
    937772void UIHostComboEditorPrivate::keyPressEvent(QKeyEvent *pEvent)
    938773{
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h

    r62493 r68315  
    3232class UIHostComboEditorPrivate;
    3333#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
    34 # if QT_VERSION >= 0x050000
    3534class ComboEditorEventFilter;
    36 # endif /* QT_VERSION >= 0x050000 */
    3735#endif /* VBOX_WS_MAC || VBOX_WS_WIN */
    3836#ifdef VBOX_WS_WIN
     
    155153protected:
    156154
    157 #if QT_VERSION >= 0x050000
    158155    /** Qt5: Handles all native events. */
    159156    bool nativeEvent(const QByteArray &eventType, void *pMessage, long *pResult);
    160 #else /* QT_VERSION < 0x050000 */
    161 # if defined(VBOX_WS_MAC)
    162     /** Mac: Qt4: Handles all native events (static callback). */
    163     static bool darwinEventHandlerProc(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
    164     /** Mac: Qt4: Handles all native events. */
    165     bool darwinKeyboardEvent(const void *pvCocoaEvent, EventRef inEvent);
    166 # elif defined(VBOX_WS_WIN)
    167     /** Win: Qt4: Handles all native events. */
    168     bool winEvent(MSG *pMsg, long *pResult);
    169 # elif defined(VBOX_WS_X11)
    170     /** X11: Qt4: Handles all native events. */
    171     bool x11Event(XEvent *pEvent);
    172 # endif /* VBOX_WS_X11 */
    173 #endif /* QT_VERSION < 0x050000 */
    174157
    175158    void keyPressEvent(QKeyEvent *pEvent);
     
    195178
    196179#if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN)
    197 # if QT_VERSION >= 0x050000
    198180    /** Mac, Win: Holds the native event filter instance. */
    199181    ComboEditorEventFilter *m_pPrivateEventFilter;
     
    201183      * redirect events directly to nativeEvent handler. */
    202184    friend class ComboEditorEventFilter;
    203 # endif /* QT_VERSION >= 0x050000 */
    204185#endif /* VBOX_WS_MAC || VBOX_WS_WIN */
    205186
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIToolBar.cpp

    r62493 r68315  
    3131
    3232#endif /* VBOX_WS_MAC */
    33 
    34 /* Qt includes: */
    35 #if QT_VERSION < 0x050000
    36 # include <QWindowsStyle>
    37 # include <QCleanlooksStyle>
    38 #endif /* QT_VERSION < 0x050000 */
    3933
    4034
     
    9387    setMovable(false);
    9488
    95 #if QT_VERSION < 0x050000
    96     /* Remove that ugly frame panel around the toolbar.
    97      * Doing that currently for Cleanlooks & Windows styles. */
    98     if (qobject_cast <QWindowsStyle*>(QToolBar::style()) ||
    99         qobject_cast <QCleanlooksStyle*>(QToolBar::style()))
     89#ifdef VBOX_WS_MAC
    10090        setStyleSheet("QToolBar { border: 0px none black; }");
    101 #else /* QT_VERSION >= 0x050000 */
    102 # ifdef VBOX_WS_MAC
    103         setStyleSheet("QToolBar { border: 0px none black; }");
    104 # endif /* VBOX_WS_MAC */
    105 #endif /* QT_VERSION >= 0x050000 */
     91#endif /* VBOX_WS_MAC */
    10692
    10793    /* Configure tool-bar' layout: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.cpp

    r62493 r68315  
    8080{
    8181    setFinalPage(pButton != m_pFullCloneRadio);
    82 #if QT_VERSION < 0x040700
    83     /* On older Qt versions the content of the current page isn't updated when
    84      * using setFinalPage. So switch back and for to simulate it. */
    85     wizard()->back();
    86     wizard()->next();
    87 #endif /* QT_VERSION < 0x040700 */
    8882}
    8983
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