VirtualBox

Changeset 106063 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Sep 16, 2024 5:16:03 PM (7 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
164829
Message:

FE/Qt: bugref:10513: Global Preferences / VM Settings: Small cleanup for event-filter stuff.

File:
1 edited

Legend:

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

    r106061 r106063  
    899899bool UIAdvancedSettingsDialog::eventFilter(QObject *pObject, QEvent *pEvent)
    900900{
    901     /* Ignore other than wheel events in this handler: */
    902     if (pEvent->type() != QEvent::Wheel)
    903         return QMainWindow::eventFilter(pObject, pEvent);
    904     /* Ignore events to anything but widgets in this handler: */
    905     QWidget *pWidget = qobject_cast<QWidget*>(pObject);
    906     if (!pWidget)
    907         return QMainWindow::eventFilter(pObject, pEvent);
    908 
    909     /* Do not touch wheel events for m_pScrollArea or it's children: */
    910     if (   pWidget == m_pScrollArea
    911         || pWidget->parent() == m_pScrollArea)
    912         return QMainWindow::eventFilter(pWidget, pEvent);
    913 
    914     /* Unconditionally and for good
    915      * redirect wheel event for widgets of following types to m_pScrollViewport: */
    916     if (   qobject_cast<QAbstractButton*>(pWidget)
    917         || qobject_cast<QAbstractSpinBox*>(pWidget)
    918         || qobject_cast<QAbstractSpinBox*>(pWidget->parent())
    919         || qobject_cast<QComboBox*>(pWidget)
    920         || qobject_cast<QSlider*>(pWidget)
    921         || qobject_cast<QTabWidget*>(pWidget)
    922         || qobject_cast<QTabWidget*>(pWidget->parent()))
    923     {
    924         /* Check if redirected event was really handled, otherwise give it back: */
    925         if (QCoreApplication::sendEvent(m_pScrollViewport, pEvent))
    926             return true;
    927     }
    928 
    929     /* Unless widget of QAbstractScrollArea subclass is focused
    930      * redirect it's wheel event to m_pScrollViewport: */
    931     if (   (   qobject_cast<QAbstractScrollArea*>(pWidget)
    932             || qobject_cast<QAbstractScrollArea*>(pWidget->parent()))
    933         && !pWidget->hasFocus()
    934         && !pWidget->parentWidget()->hasFocus())
    935     {
    936         /* Check if redirected event was really handled, otherwise give it back: */
    937         if (QCoreApplication::sendEvent(m_pScrollViewport, pEvent))
    938             return true;
     901    /* Handle wheel events: */
     902    if (pEvent->type() == QEvent::Wheel)
     903    {
     904        /* Ignore events to anything but widgets in this handler: */
     905        QWidget *pWidget = qobject_cast<QWidget*>(pObject);
     906        if (!pWidget)
     907            return QMainWindow::eventFilter(pObject, pEvent);
     908
     909        /* Do not touch wheel events for m_pScrollArea or it's children: */
     910        if (   pWidget == m_pScrollArea
     911            || pWidget->parent() == m_pScrollArea)
     912            return QMainWindow::eventFilter(pWidget, pEvent);
     913
     914        /* Unconditionally and for good
     915         * redirect wheel event for widgets of following types to m_pScrollViewport: */
     916        if (   qobject_cast<QAbstractButton*>(pWidget)
     917            || qobject_cast<QAbstractSpinBox*>(pWidget)
     918            || qobject_cast<QAbstractSpinBox*>(pWidget->parent())
     919            || qobject_cast<QComboBox*>(pWidget)
     920            || qobject_cast<QSlider*>(pWidget)
     921            || qobject_cast<QTabWidget*>(pWidget)
     922            || qobject_cast<QTabWidget*>(pWidget->parent()))
     923        {
     924            /* Check if redirected event was really handled, otherwise give it back: */
     925            if (QCoreApplication::sendEvent(m_pScrollViewport, pEvent))
     926                return true;
     927        }
     928
     929        /* Unless widget of QAbstractScrollArea subclass is focused
     930         * redirect it's wheel event to m_pScrollViewport: */
     931        if (   (   qobject_cast<QAbstractScrollArea*>(pWidget)
     932                || qobject_cast<QAbstractScrollArea*>(pWidget->parent()))
     933            && !pWidget->hasFocus()
     934            && !pWidget->parentWidget()->hasFocus())
     935        {
     936            /* Check if redirected event was really handled, otherwise give it back: */
     937            if (QCoreApplication::sendEvent(m_pScrollViewport, pEvent))
     938                return true;
     939        }
    939940    }
    940941
    941942    /* Call to base-class: */
    942     return QMainWindow::eventFilter(pWidget, pEvent);
     943    return QMainWindow::eventFilter(pObject, pEvent);
    943944}
    944945
Note: See TracChangeset for help on using the changeset viewer.

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