VirtualBox

Changeset 106244 in vbox


Ignore:
Timestamp:
Oct 8, 2024 5:08:51 PM (7 weeks ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: Advanced Settings Dialog: Accumulate multiple enable-change events into async handler.

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

Legend:

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

    r106242 r106244  
    790790    , m_fValid(true)
    791791    , m_fSilent(true)
     792    , m_pTimerDisabledLookAndFeel(0)
    792793    , m_pLayoutMain(0)
    793794    , m_pCheckBoxMode(0)
     
    984985    }
    985986
    986     /* Handle enabled-change events: */
    987     if (pEvent->type() == QEvent::EnabledChange)
    988     {
    989         /* Check if watched object is of widget type: */
    990         QWidget *pWidget = qobject_cast<QWidget*>(pObject);
    991         if (pWidget)
    992             adjustLookAndFeelForDisabledWidget(pWidget);
     987    /* We'd like to accumulate multiple events of the same type to
     988     * process them the bundled way, once after the last one arrived. */
     989    switch (pEvent->type())
     990    {
     991        /* Only enabled-change events useful for us: */
     992        case QEvent::EnabledChange:
     993        {
     994            /* Start (or restart) corresponding timer: */
     995            m_pTimerDisabledLookAndFeel->start();
     996            break;
     997        }
     998        default:
     999            break;
    9931000    }
    9941001
     
    10511058    gpDesktop->centerWidget(this, parentWidget(), false);
    10521059
    1053     /* Make sure widgets disabled initially have font updated: */
    1054     foreach (QWidget *pChild, findChildren<QWidget*>())
    1055         if (!pChild->isEnabledTo(0))
    1056             adjustLookAndFeelForDisabledWidget(pChild);
     1060    /* Make sure widgets disabled initially have look&feel updated: */
     1061    sltUpdateDisabledWidgetsLookAndFeel();
    10571062}
    10581063
     
    14431448}
    14441449
     1450void UIAdvancedSettingsDialog::sltUpdateDisabledWidgetsLookAndFeel()
     1451{
     1452    /* Make sure all child widgets have look&feel updated: */
     1453    foreach (QWidget *pChild, findChildren<QWidget*>())
     1454        adjustLookAndFeelForDisabledWidget(pChild);
     1455}
     1456
    14451457void UIAdvancedSettingsDialog::prepare()
    14461458{
     1459    /* Create timer to update disabled widgets look&feel: */
     1460    m_pTimerDisabledLookAndFeel = new QTimer(this);
     1461    if (m_pTimerDisabledLookAndFeel)
     1462    {
     1463        m_pTimerDisabledLookAndFeel->setSingleShot(true);
     1464        m_pTimerDisabledLookAndFeel->setInterval(50);
     1465        connect(m_pTimerDisabledLookAndFeel, &QTimer::timeout,
     1466                this, &UIAdvancedSettingsDialog::sltUpdateDisabledWidgetsLookAndFeel);
     1467    }
     1468
    14471469    /* Prepare central-widget: */
    14481470    setCentralWidget(new QWidget);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.h

    r106242 r106244  
    4444class QShowEvent;
    4545class QStackedWidget;
     46class QTimer;
    4647class QIDialogButtonBox;
    4748class UIFilterEditor;
     
    213214    void sltHandleVerticalScrollAreaWheelEvent();
    214215
     216    /** Handles request to update disabled widgets look&feel: */
     217    void sltUpdateDisabledWidgetsLookAndFeel();
     218
    215219private:
    216220
     
    278282    QMap<int, QString>  m_pageHelpKeywords;
    279283
     284    /** Holds the timer to update disabled widgets look&feel. */
     285    QTimer *m_pTimerDisabledLookAndFeel;
     286
    280287    /** @name Widgets
    281288     * @{ */
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