VirtualBox

Changeset 106245 in vbox


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

FE/Qt: bugref:10513: Advanced Settings Dialog: Put a mask onto disabled widgets; Together with italic font that should give a meaningful hint for those who doubt.

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

Legend:

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

    r106244 r106245  
    989989    switch (pEvent->type())
    990990    {
    991         /* Only enabled-change events useful for us: */
     991        /* Only enabled-change and resize events useful for us: */
    992992        case QEvent::EnabledChange:
     993        case QEvent::Resize:
    993994        {
    994995            /* Start (or restart) corresponding timer: */
     
    16441645    font.setItalic(!pWidget->isEnabledTo(0));
    16451646    pWidget->setFont(font);
     1647
     1648    /* If widget is disabled and non of his parents have mask assigned: */
     1649    if (!pWidget->isEnabledTo(0) && !isOneOfWidgetParentsHasMask(pWidget))
     1650    {
     1651        /* Compose striped mask using tricky QImage=>QBitmap conversion: */
     1652        QImage img(pWidget->width(), pWidget->height(), QImage::Format_Mono);
     1653        for (int j = 0; j < img.height(); ++j)
     1654            for (int i = 0; i < img.width(); ++i)
     1655                img.setPixel(i, j, (i+j) % 10 == 0 ? 1 : 0);
     1656        /* Adjust mask to be striped for disabled widget: */
     1657        pWidget->setMask(QBitmap::fromImage(img, Qt::MonoOnly));
     1658    }
     1659    else
     1660    {
     1661        /* Disable mask for good: */
     1662        pWidget->clearMask();
     1663    }
     1664    pWidget->update();
     1665}
     1666
     1667/* static */
     1668bool UIAdvancedSettingsDialog::isOneOfWidgetParentsHasMask(QWidget *pWidget)
     1669{
     1670    AssertPtrReturn(pWidget, false);
     1671    if (QWidget *pParent = pWidget->parentWidget())
     1672        return !pParent->mask().isNull() || isOneOfWidgetParentsHasMask(pParent);
     1673    return false;
    16461674}
    16471675
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.h

    r106244 r106245  
    237237      * @param  pWidget   Brings the widget to adjust look&feel for. */
    238238    static void adjustLookAndFeelForDisabledWidget(QWidget *pWidget);
     239    /** Returns whether one of @a pWidget parents in hierarchy has mask assigned. */
     240    static bool isOneOfWidgetParentsHasMask(QWidget *pWidget);
    239241
    240242    /** Holds configuration access level. */
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