VirtualBox

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


Ignore:
Timestamp:
Jan 31, 2025 9:00:40 PM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167279
Message:

FE/Qt: bugref:10814: VBox Manager / Tools pane: Reorder code related to item background rendering for both popup and widget modes; The logic is not changed, just the order, hope that makes it simple.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp

    r108002 r108007  
    610610    const QPalette pal = QApplication::palette();
    611611
    612     /* Selection background for popup: */
    613     if (   model()->currentItem() == this
    614         && model()->tools()->isPopup())
    615     {
    616         /* Prepare color: */
    617         const QColor backgroundColor = isEnabled()
    618                                      ? pal.color(QPalette::Active, QPalette::Highlight)
    619                                      : pal.color(QPalette::Disabled, QPalette::Window);
    620         /* Draw gradient: */
    621         QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
    622         bgGrad.setColorAt(0, backgroundColor.lighter(m_iHighlightLightnessStart));
    623         bgGrad.setColorAt(1, backgroundColor.lighter(m_iHighlightLightnessFinal));
    624         pPainter->fillRect(rectangle, bgGrad);
    625 
    626         if (isEnabled() && isHovered())
     612    /* For popup: */
     613    if (model()->tools()->isPopup())
     614    {
     615        /* Selection background: */
     616        if (model()->currentItem() == this)
    627617        {
    628618            /* Prepare color: */
    629             QColor animationColor1 = QColor(Qt::white);
    630             QColor animationColor2 = QColor(Qt::white);
     619            const QColor backgroundColor = isEnabled()
     620                                         ? pal.color(QPalette::Active, QPalette::Highlight)
     621                                         : pal.color(QPalette::Disabled, QPalette::Window);
     622            /* Draw gradient: */
     623            QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
     624            bgGrad.setColorAt(0, backgroundColor.lighter(m_iHighlightLightnessStart));
     625            bgGrad.setColorAt(1, backgroundColor.lighter(m_iHighlightLightnessFinal));
     626            pPainter->fillRect(rectangle, bgGrad);
     627
     628            if (isEnabled() && isHovered())
     629            {
     630                /* Prepare color: */
     631                QColor animationColor1 = QColor(Qt::white);
     632                QColor animationColor2 = QColor(Qt::white);
    631633#ifdef VBOX_WS_MAC
    632             animationColor1.setAlpha(90);
     634                animationColor1.setAlpha(90);
    633635#else
    634             animationColor1.setAlpha(30);
     636                animationColor1.setAlpha(30);
    635637#endif
    636             animationColor2.setAlpha(0);
    637             /* Draw hovering animated gradient: */
    638             QRect animatedRect = rectangle;
    639             animatedRect.setWidth(animatedRect.height());
    640             const int iLength = 2 * animatedRect.width() + rectangle.width();
    641             const int iShift = - animatedRect.width() + iLength * animatedValue() / 100;
    642             animatedRect.moveLeft(iShift);
    643             QLinearGradient bgAnimatedGrad(animatedRect.topLeft(), animatedRect.bottomRight());
    644             bgAnimatedGrad.setColorAt(0,   animationColor2);
    645             bgAnimatedGrad.setColorAt(0.1, animationColor2);
    646             bgAnimatedGrad.setColorAt(0.5, animationColor1);
    647             bgAnimatedGrad.setColorAt(0.9, animationColor2);
    648             bgAnimatedGrad.setColorAt(1,   animationColor2);
    649             pPainter->fillRect(rectangle, bgAnimatedGrad);
     638                animationColor2.setAlpha(0);
     639                /* Draw hovering animated gradient: */
     640                QRect animatedRect = rectangle;
     641                animatedRect.setWidth(animatedRect.height());
     642                const int iLength = 2 * animatedRect.width() + rectangle.width();
     643                const int iShift = - animatedRect.width() + iLength * animatedValue() / 100;
     644                animatedRect.moveLeft(iShift);
     645                QLinearGradient bgAnimatedGrad(animatedRect.topLeft(), animatedRect.bottomRight());
     646                bgAnimatedGrad.setColorAt(0,   animationColor2);
     647                bgAnimatedGrad.setColorAt(0.1, animationColor2);
     648                bgAnimatedGrad.setColorAt(0.5, animationColor1);
     649                bgAnimatedGrad.setColorAt(0.9, animationColor2);
     650                bgAnimatedGrad.setColorAt(1,   animationColor2);
     651                pPainter->fillRect(rectangle, bgAnimatedGrad);
     652            }
    650653        }
    651     }
    652     /* Selection background for widget: */
    653     else if (   model()->currentItem() == this
    654              && !model()->tools()->isPopup())
    655 
    656     {
     654        /* Hovering background: */
     655        else if (isHovered())
     656        {
     657            /* Prepare color: */
     658            const QColor backgroundColor = isEnabled()
     659                                         ? pal.color(QPalette::Active, QPalette::Highlight)
     660                                         : pal.color(QPalette::Disabled, QPalette::Window);
     661            /* Draw gradient: */
     662            QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
     663            bgGrad.setColorAt(0, backgroundColor.lighter(m_iHoverLightnessStart));
     664            bgGrad.setColorAt(1, backgroundColor.lighter(m_iHoverLightnessFinal));
     665            pPainter->fillRect(rectangle, bgGrad);
     666
     667            if (isEnabled())
     668            {
     669                /* Prepare color: */
     670                QColor animationColor1 = QColor(Qt::white);
     671                QColor animationColor2 = QColor(Qt::white);
     672#ifdef VBOX_WS_MAC
     673                animationColor1.setAlpha(120);
     674#else
     675                animationColor1.setAlpha(50);
     676#endif
     677                animationColor2.setAlpha(0);
     678                /* Draw hovering animated gradient: */
     679                QRect animatedRect = rectangle;
     680                animatedRect.setWidth(animatedRect.height());
     681                const int iLength = 2 * animatedRect.width() + rectangle.width();
     682                const int iShift = - animatedRect.width() + iLength * animatedValue() / 100;
     683                animatedRect.moveLeft(iShift);
     684                QLinearGradient bgAnimatedGrad(animatedRect.topLeft(), animatedRect.bottomRight());
     685                bgAnimatedGrad.setColorAt(0,   animationColor2);
     686                bgAnimatedGrad.setColorAt(0.1, animationColor2);
     687                bgAnimatedGrad.setColorAt(0.5, animationColor1);
     688                bgAnimatedGrad.setColorAt(0.9, animationColor2);
     689                bgAnimatedGrad.setColorAt(1,   animationColor2);
     690                pPainter->fillRect(rectangle, bgAnimatedGrad);
     691            }
     692        }
     693        /* Default background: */
     694        else
     695        {
     696            /* Prepare color: */
     697            const QColor backgroundColor = isEnabled()
     698                                         ? pal.color(QPalette::Active, QPalette::Window)
     699                                         : pal.color(QPalette::Disabled, QPalette::Window);
     700            /* Draw gradient: */
     701            QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
     702            bgGrad.setColorAt(0, backgroundColor.lighter(m_iDefaultLightnessStart));
     703            bgGrad.setColorAt(1, backgroundColor.lighter(m_iDefaultLightnessFinal));
     704            pPainter->fillRect(rectangle, bgGrad);
     705        }
     706    }
     707    /* For widget: */
     708    else
     709    {
     710        /* Selection background: */
     711        if (model()->currentItem() == this)
     712        {
    657713            /* Prepare color: */
    658714            const QColor highlightColor = isEnabled()
     
    666722            hlGrad.setColorAt(1, highlightColor.darker(m_iHighlightLightnessFinal));
    667723            pPainter->fillRect(tokenRect, hlGrad);
    668     }
    669     /* Hovering background: */
    670     else if (isHovered())
    671     {
    672         /* Prepare color: */
    673         const QColor backgroundColor = isEnabled()
    674                                      ? pal.color(QPalette::Active, QPalette::Highlight)
    675                                      : pal.color(QPalette::Disabled, QPalette::Window);
    676         /* Draw gradient: */
    677         QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
    678         bgGrad.setColorAt(0, backgroundColor.lighter(m_iHoverLightnessStart));
    679         bgGrad.setColorAt(1, backgroundColor.lighter(m_iHoverLightnessFinal));
    680         pPainter->fillRect(rectangle, bgGrad);
    681 
    682         if (isEnabled())
    683         {
    684             /* Prepare color: */
    685             QColor animationColor1 = QColor(Qt::white);
    686             QColor animationColor2 = QColor(Qt::white);
    687 #ifdef VBOX_WS_MAC
    688             animationColor1.setAlpha(120);
    689 #else
    690             animationColor1.setAlpha(50);
    691 #endif
    692             animationColor2.setAlpha(0);
    693             /* Draw hovering animated gradient: */
    694             QRect animatedRect = rectangle;
    695             animatedRect.setWidth(animatedRect.height());
    696             const int iLength = 2 * animatedRect.width() + rectangle.width();
    697             const int iShift = - animatedRect.width() + iLength * animatedValue() / 100;
    698             animatedRect.moveLeft(iShift);
    699             QLinearGradient bgAnimatedGrad(animatedRect.topLeft(), animatedRect.bottomRight());
    700             bgAnimatedGrad.setColorAt(0,   animationColor2);
    701             bgAnimatedGrad.setColorAt(0.1, animationColor2);
    702             bgAnimatedGrad.setColorAt(0.5, animationColor1);
    703             bgAnimatedGrad.setColorAt(0.9, animationColor2);
    704             bgAnimatedGrad.setColorAt(1,   animationColor2);
    705             pPainter->fillRect(rectangle, bgAnimatedGrad);
    706724        }
    707     }
    708     /* Default background for popup only: */
    709     else if (model()->tools()->isPopup())
    710     {
    711         /* Prepare color: */
    712         const QColor backgroundColor = isEnabled()
    713                                      ? pal.color(QPalette::Active, QPalette::Window)
    714                                      : pal.color(QPalette::Disabled, QPalette::Window);
    715         /* Draw gradient: */
    716         QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft());
    717         bgGrad.setColorAt(0, backgroundColor.lighter(m_iDefaultLightnessStart));
    718         bgGrad.setColorAt(1, backgroundColor.lighter(m_iDefaultLightnessFinal));
    719         pPainter->fillRect(rectangle, bgGrad);
    720725    }
    721726
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