VirtualBox

Changeset 105105 in vbox


Ignore:
Timestamp:
Jul 2, 2024 6:26:10 PM (5 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: UIAdvancedSettingsDialog: Get rid of sticky scrolling, it's too hard to make it useful on every platform we want; Reworking scrolling to be more predictive, so that if scrollable widget it focused - it's being scrolled, otherwise main area being scrolled.

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

Legend:

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

    r104358 r105105  
    745745    , m_fValid(true)
    746746    , m_fSilent(true)
    747     , m_pScrollingTimer(0)
    748747    , m_pLayoutMain(0)
    749748    , m_pCheckBoxMode(0)
     
    838837    if (pEvent->type() != QEvent::Wheel)
    839838        return QMainWindow::eventFilter(pObject, pEvent);
     839    /* Ignore events to anything but widgets in this handler: */
     840    QWidget *pWidget = qobject_cast<QWidget*>(pObject);
     841    if (!pWidget)
     842        return QMainWindow::eventFilter(pObject, pEvent);
    840843
    841844    /* Do not touch wheel events for m_pScrollArea or it's children: */
    842     if (   pObject == m_pScrollArea
    843         || pObject->parent() == m_pScrollArea)
    844     {
    845         /* Moreover restart 'sticky scrolling timer' during which
    846          * all the scrolling will be redirected to m_pScrollViewport: */
    847         m_pScrollingTimer->start();
    848         return QMainWindow::eventFilter(pObject, pEvent);
    849     }
     845    if (   pWidget == m_pScrollArea
     846        || pWidget->parent() == m_pScrollArea)
     847        return QMainWindow::eventFilter(pWidget, pEvent);
    850848
    851849    /* Unconditionally and for good
    852850     * redirect wheel event for widgets of following types to m_pScrollViewport: */
    853     if (   qobject_cast<QAbstractButton*>(pObject)
    854         || qobject_cast<QAbstractSpinBox*>(pObject)
    855         || qobject_cast<QAbstractSpinBox*>(pObject->parent())
    856         || qobject_cast<QComboBox*>(pObject)
    857         || qobject_cast<QSlider*>(pObject)
    858         || qobject_cast<QTabWidget*>(pObject)
    859         || qobject_cast<QTabWidget*>(pObject->parent()))
     851    if (   qobject_cast<QAbstractButton*>(pWidget)
     852        || qobject_cast<QAbstractSpinBox*>(pWidget)
     853        || qobject_cast<QAbstractSpinBox*>(pWidget->parent())
     854        || qobject_cast<QComboBox*>(pWidget)
     855        || qobject_cast<QSlider*>(pWidget)
     856        || qobject_cast<QTabWidget*>(pWidget)
     857        || qobject_cast<QTabWidget*>(pWidget->parent()))
    860858    {
    861859        /* Check if redirected event was really handled, otherwise give it back: */
     
    864862    }
    865863
    866     /* While 'sticky scrolling timer' is active
    867      * redirect wheel event for widgets of following types to m_pScrollViewport: */
    868     if (   m_pScrollingTimer->isActive()
    869         && (   qobject_cast<QAbstractScrollArea*>(pObject)
    870             || qobject_cast<QAbstractScrollArea*>(pObject->parent())))
     864    /* Unless widget of QAbstractScrollArea subclass is focused
     865     * redirect it's wheel event to m_pScrollViewport: */
     866    if (   (   qobject_cast<QAbstractScrollArea*>(pWidget)
     867            || qobject_cast<QAbstractScrollArea*>(pWidget->parent()))
     868        && !pWidget->hasFocus()
     869        && !pWidget->parentWidget()->hasFocus())
    871870    {
    872871        /* Check if redirected event was really handled, otherwise give it back: */
     
    876875
    877876    /* Call to base-class: */
    878     return QMainWindow::eventFilter(pObject, pEvent);
     877    return QMainWindow::eventFilter(pWidget, pEvent);
    879878}
    880879
     
    917916void UIAdvancedSettingsDialog::polishEvent()
    918917{
     918    /* Install event-filters for all the required children.
     919     * These children can be added together with pages. */
     920    foreach (QWidget *pChild, findChildren<QWidget*>())
     921    {
     922        if (   qobject_cast<QAbstractButton*>(pChild)
     923            || qobject_cast<QAbstractScrollArea*>(pChild)
     924            || qobject_cast<QAbstractScrollArea*>(pChild->parent())
     925            || qobject_cast<QAbstractSpinBox*>(pChild)
     926            || qobject_cast<QAbstractSpinBox*>(pChild->parent())
     927            || qobject_cast<QComboBox*>(pChild)
     928            || qobject_cast<QSlider*>(pChild)
     929            || qobject_cast<QTabWidget*>(pChild)
     930            || qobject_cast<QTabWidget*>(pChild->parent()))
     931            pChild->installEventFilter(this);
     932    }
     933
    919934    /* Resize to minimum size: */
    920935    resize(minimumSizeHint());
     
    13181333void UIAdvancedSettingsDialog::prepare()
    13191334{
    1320     /* Prepare 'sticky scrolling timer': */
    1321     m_pScrollingTimer = new QTimer(this);
    1322     if (m_pScrollingTimer)
    1323     {
    1324         m_pScrollingTimer->setInterval(500);
    1325         m_pScrollingTimer->setSingleShot(true);
    1326     }
    1327 
    13281335    /* Prepare central-widget: */
    13291336    setCentralWidget(new QWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.h

    r104363 r105105  
    4444class QShowEvent;
    4545class QStackedWidget;
    46 class QTimer;
    4746class QIDialogButtonBox;
    4847class UIFilterEditor;
     
    275274    QMap<int, QString>  m_pageHelpKeywords;
    276275
    277     /** Holds the 'sticky scrolling timer' instance. */
    278     QTimer *m_pScrollingTimer;
    279 
    280276    /** @name Widgets
    281277     * @{ */
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