VirtualBox

Changeset 101118 in vbox


Ignore:
Timestamp:
Sep 13, 2023 6:12:28 PM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
159087
Message:

FE/Qt: bugref:10513: UIAdvancedSettingsDialog: Implementing sticky scrolling timer allowing to make scroll sessions through whole the advanced settings dialog even through other scrolling recipients.

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

Legend:

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

    r101032 r101118  
    2727
    2828/* Qt includes: */
     29#include <QAbstractButton>
     30#include <QAbstractScrollArea>
     31#include <QAbstractSpinBox>
    2932#include <QCloseEvent>
     33#include <QComboBox>
     34#include <QCoreApplication>
    3035#include <QGridLayout>
    3136#include <QProgressBar>
     
    3338#include <QScrollArea>
    3439#include <QScrollBar>
     40#include <QSlider>
    3541#include <QStackedWidget>
     42#include <QTimer>
    3643#include <QVariant>
    3744#include <QVBoxLayout>
     
    130137    , m_fValid(true)
    131138    , m_fSilent(true)
     139    , m_pScrollingTimer(0)
    132140    , m_pLayoutMain(0)
    133141    , m_pEditorFilter(0)
     
    210218    /* Mark serialization finished: */
    211219    m_fSerializationIsInProgress = false;
     220}
     221
     222bool UIAdvancedSettingsDialog::eventFilter(QObject *pObject, QEvent *pEvent)
     223{
     224    /* Ignore other than wheel events in this handler: */
     225    if (pEvent->type() != QEvent::Wheel)
     226        return QIWithRetranslateUI<QMainWindow>::eventFilter(pObject, pEvent);
     227
     228    /* Do not touch wheel events for m_pScrollArea or it's children: */
     229    if (   pObject == m_pScrollArea
     230        || pObject->parent() == m_pScrollArea)
     231    {
     232        /* Moreover restart 'sticky scrolling timer' during which
     233         * all the scrolling will be redirected to m_pScrollViewport: */
     234        m_pScrollingTimer->start();
     235        return QIWithRetranslateUI<QMainWindow>::eventFilter(pObject, pEvent);
     236    }
     237
     238    /* While 'sticky scrolling timer' is active
     239     * redirect wheel event for widgets of following types to m_pScrollViewport: */
     240    if (   m_pScrollingTimer->isActive()
     241        && (   qobject_cast<QAbstractButton*>(pObject)
     242            || qobject_cast<QAbstractScrollArea*>(pObject)
     243            || qobject_cast<QAbstractScrollArea*>(pObject->parent())
     244            || qobject_cast<QAbstractSpinBox*>(pObject)
     245            || qobject_cast<QAbstractSpinBox*>(pObject->parent())
     246            || qobject_cast<QComboBox*>(pObject)
     247            || qobject_cast<QSlider*>(pObject)
     248            || qobject_cast<QTabWidget*>(pObject)
     249            || qobject_cast<QTabWidget*>(pObject->parent())))
     250    {
     251        /* Check if redirected event was really handled, otherwise give it back: */
     252        if (QCoreApplication::sendEvent(m_pScrollViewport, pEvent))
     253            return true;
     254    }
     255
     256    /* Call to base-class: */
     257    return QIWithRetranslateUI<QMainWindow>::eventFilter(pObject, pEvent);
    212258}
    213259
     
    536582void UIAdvancedSettingsDialog::prepare()
    537583{
     584    /* Prepare 'sticky scrolling timer': */
     585    m_pScrollingTimer = new QTimer(this);
     586    if (m_pScrollingTimer)
     587    {
     588        m_pScrollingTimer->setInterval(500);
     589        m_pScrollingTimer->setSingleShot(true);
     590    }
     591
    538592    /* Prepare central-widget: */
    539593    setCentralWidget(new QWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.h

    r101032 r101118  
    4545class QShowEvent;
    4646class QStackedWidget;
     47class QTimer;
    4748class QVariant;
    4849class QIDialogButtonBox;
     
    107108
    108109protected:
     110
     111    /** Preprocesses Qt @a pEvent for passed @a pObject. */
     112    virtual bool eventFilter(QObject *pObject, QEvent *pEvent) RT_OVERRIDE;
    109113
    110114    /** Handles translation event. */
     
    239243    QMap<int, QString>  m_pageHelpKeywords;
    240244
     245    /** Holds the 'sticky scrolling timer' instance. */
     246    QTimer *m_pScrollingTimer;
     247
    241248    /** @name Widgets
    242249     * @{ */
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