VirtualBox

Changeset 84583 in vbox


Ignore:
Timestamp:
May 28, 2020 11:43:07 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Chooser pane: Cleanup/rework for search functionality; Make sure disabled items are disabled even if recreated; Do not create disabled effect for root item; Coding style cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp

    r84582 r84583  
    4242#include "iprt/assert.h"
    4343
    44 UIChooserDisabledItemEffect::UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent /* = 0 */)
    45     :QGraphicsEffect(pParent)
    46     , m_iBlurRadius(iBlurRadius)
    47 {
    48 }
    49 
    50 void UIChooserDisabledItemEffect::draw(QPainter *painter)
    51 {
    52     QPoint offset;
    53     QPixmap pixmap;
    54     /* Get the original pixmap: */
    55     pixmap = sourcePixmap( Qt::LogicalCoordinates, &offset );
    56     QImage resultImage;
    57     /* Apply our blur and grayscale filters to the original pixmap: */
    58     UIImageTools::blurImage(pixmap.toImage(), resultImage, m_iBlurRadius);
    59     pixmap.convertFromImage(UIImageTools::toGray(resultImage));
    60     /* Use the filtered pixmap: */
    61     painter->drawPixmap( offset, pixmap );
    62 }
    6344
    6445/** QAccessibleObject extension used as an accessibility interface for Chooser-view items. */
     
    210191    UIChooserItem *item() const { return qobject_cast<UIChooserItem*>(object()); }
    211192};
     193
     194
     195/*********************************************************************************************************************************
     196*   Class UIChooserDisabledItemEffect implementation.                                                                            *
     197*********************************************************************************************************************************/
     198
     199UIChooserDisabledItemEffect::UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent /* = 0 */)
     200    : QGraphicsEffect(pParent)
     201    , m_iBlurRadius(iBlurRadius)
     202{
     203}
     204
     205void UIChooserDisabledItemEffect::draw(QPainter *pPainter)
     206{
     207    QPoint offset;
     208    QPixmap pixmap;
     209    /* Get the original pixmap: */
     210    pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset);
     211    QImage resultImage;
     212    /* Apply our blur and grayscale filters to the original pixmap: */
     213    UIImageTools::blurImage(pixmap.toImage(), resultImage, m_iBlurRadius);
     214    pixmap.convertFromImage(UIImageTools::toGray(resultImage));
     215    /* Use the filtered pixmap: */
     216    pPainter->drawPixmap(offset, pixmap);
     217}
    212218
    213219
     
    311317            m_pHoveringMachine->start();
    312318        }
    313     }
    314     /* Allocate the effect instance which we use when the item is marked as disablec: */
    315     m_pDisabledEffect = new UIChooserDisabledItemEffect(1 /* Blur Radius */);
    316     setGraphicsEffect(m_pDisabledEffect);
    317     m_pDisabledEffect->setEnabled(false);
     319
     320        /* Allocate the effect instance which we use when the item is marked as disabled: */
     321        m_pDisabledEffect = new UIChooserDisabledItemEffect(1 /* Blur Radius */);
     322        if (m_pDisabledEffect)
     323        {
     324            setGraphicsEffect(m_pDisabledEffect);
     325            m_pDisabledEffect->setEnabled(node()->isDisabled());
     326        }
     327    }
    318328}
    319329
     
    402412}
    403413
    404 void UIChooserItem::disableEnableItem(bool fDisabled)
     414void UIChooserItem::setDisabledEffect(bool fOn)
    405415{
    406416    if (m_pDisabledEffect)
    407         m_pDisabledEffect->setEnabled(fDisabled);
     417        m_pDisabledEffect->setEnabled(fOn);
    408418}
    409419
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h

    r84582 r84583  
    5050class UIChooserNode;
    5151
    52 /** A simple QGraphicsEffect extension to mark disabled UIChooserItems. Applies blur and gray scale filters. */
     52
     53/** A simple QGraphicsEffect extension to mark disabled UIChooserItem.
     54  * @note Applies blur and gray scale filters. */
    5355class UIChooserDisabledItemEffect : public QGraphicsEffect
    5456{
     
    5759public:
    5860
     61    /** Constructs blur effect passing @a pParent to the base-class.
     62      * @param  iBlurRadius  Brings the blur effect radius. */
    5963    UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent = 0);
    6064
    6165protected:
    6266
    63     virtual void draw(QPainter *painter);
     67    /** Draws effect with passed @a pPainter. */
     68    virtual void draw(QPainter *pPainter);
     69
     70private:
     71
     72    /** Holds the blur effect radius. */
    6473    int m_iBlurRadius;
    6574};
     
    145154          * @note  Base-class implementation does nothing. */
    146155        virtual void installEventFilterHelper(QObject *pSource) { Q_UNUSED(pSource); }
    147         /** Enables the visual effect for disabled item. */
    148         void disableEnableItem(bool fDisabled);
     156        /** Defines whether visual effect for disabled item is @a fOn. */
     157        void setDisabledEffect(bool fOn);
    149158    /** @} */
    150159
     
    300309
    301310        /** Holds whether item is hovered. */
    302         bool                m_fHovered;
     311        bool                         m_fHovered;
    303312        /** Holds the hovering animation machine instance. */
    304         QStateMachine      *m_pHoveringMachine;
     313        QStateMachine               *m_pHoveringMachine;
    305314        /** Holds the forward hovering animation instance. */
    306         QPropertyAnimation *m_pHoveringAnimationForward;
     315        QPropertyAnimation          *m_pHoveringAnimationForward;
    307316        /** Holds the backward hovering animation instance. */
    308         QPropertyAnimation *m_pHoveringAnimationBackward;
     317        QPropertyAnimation          *m_pHoveringAnimationBackward;
    309318        /** Holds the animation duration. */
    310         int                 m_iAnimationDuration;
     319        int                          m_iAnimationDuration;
    311320        /** Holds the default animation value. */
    312         int                 m_iDefaultValue;
     321        int                          m_iDefaultValue;
    313322        /** Holds the hovered animation value. */
    314         int                 m_iHoveredValue;
     323        int                          m_iHoveredValue;
    315324        /** Holds the animated value. */
    316         int                 m_iAnimatedValue;
    317         /** Holds the pointer to blur effect instance. */
     325        int                          m_iAnimatedValue;
     326        /** Holds the blur effect instance. */
    318327        UIChooserDisabledItemEffect *m_pDisabledEffect;
    319328    /** @} */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNode.cpp

    r83063 r84583  
    8282    m_fDisabled = fDisabled;
    8383    if (m_pItem)
    84         m_pItem->disableEnableItem(m_fDisabled);
     84        m_pItem->setDisabledEffect(m_fDisabled);
    8585}
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