VirtualBox

Changeset 77701 in vbox for trunk


Ignore:
Timestamp:
Mar 14, 2019 11:57:06 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129342
Message:

FE/Qt: bugref:9378. Marking matched chooser pane machine items visually.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.cpp

    r76606 r77701  
    7373}
    7474
    75 void UIImageTools::blurImage(const QImage &source, QImage &destinatiion, int iRadius)
     75void UIImageTools::blurImage(const QImage &source, QImage &destination, int iRadius)
    7676{
    7777    /* Blur in two steps, first horizontal and then vertical: */
    7878    QImage tmpImage(source.size(), QImage::Format_ARGB32);
    7979    blurImageHorizontal(source, tmpImage, iRadius);
    80     blurImageVertical(tmpImage, destinatiion, iRadius);
    81 }
    82 
    83 void UIImageTools::blurImageHorizontal(const QImage &source, QImage &destinatiion, int iRadius)
     80    blurImageVertical(tmpImage, destination, iRadius);
     81}
     82
     83void UIImageTools::blurImageHorizontal(const QImage &source, QImage &destination, int iRadius)
    8484{
    8585    QSize s = source.size();
     
    9595         * method. Unfortunately this doesn't work in the vertical case. */
    9696        QRgb *ssl = (QRgb*)source.scanLine(y);
    97         QRgb *dsl = (QRgb*)destinatiion.scanLine(y);
     97        QRgb *dsl = (QRgb*)destination.scanLine(y);
    9898        /* First process the horizontal zero line at once: */
    9999        int b = iRadius + 1;
     
    143143}
    144144
    145 void UIImageTools::blurImageVertical(const QImage &source, QImage &destinatiion, int iRadius)
     145void UIImageTools::blurImageVertical(const QImage &source, QImage &destination, int iRadius)
    146146{
    147147    QSize s = source.size();
     148    destination = QImage(s, source.format());
    148149    for (int x = 0; x < s.width(); ++x)
    149150    {
     
    164165        }
    165166        /* Set the new weighted pixel: */
    166         destinatiion.setPixel(x, 0, qRgba(rt / b, gt / b, bt / b, at / b));
     167        destination.setPixel(x, 0, qRgba(rt / b, gt / b, bt / b, at / b));
    167168
    168169        /* Now process the rest: */
     
    193194            }
    194195            /* Set the new weighted pixel: */
    195             destinatiion.setPixel(x, y, qRgba(rt / b, gt / b, bt / b, at / b));
     196            destination.setPixel(x, y, qRgba(rt / b, gt / b, bt / b, at / b));
    196197        }
    197198    }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.h

    r76581 r77701  
    3939
    4040    /** Blurs passed @a source image to @a destination cropping by certain @a iRadius. */
    41     void blurImage(const QImage &source, QImage &destination, int iRadius);
     41    SHARED_LIBRARY_STUFF void blurImage(const QImage &source, QImage &destination, int iRadius);
    4242    /** Blurs passed @a source image horizontally to @a destination cropping by certain @a iRadius. */
    43     void blurImageHorizontal(const QImage &source, QImage &destination, int iRadius);
     43    SHARED_LIBRARY_STUFF void blurImageHorizontal(const QImage &source, QImage &destination, int iRadius);
    4444    /** Blurs passed @a source image vertically to @a destination cropping by certain @a iRadius. */
    45     void blurImageVertical(const QImage &source, QImage &destination, int iRadius);
     45    SHARED_LIBRARY_STUFF void blurImageVertical(const QImage &source, QImage &destination, int iRadius);
    4646
    4747    /** Applies BET-label of passed @a size. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp

    r77638 r77701  
    3838#include "UIChooserModel.h"
    3939#include "UIChooserNode.h"
     40#include "UIImageTools.h"
    4041
    4142/* Other VBox includes: */
    4243#include "iprt/assert.h"
    4344
     45UIChooserDisabledItemEffect::UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent /* = 0 */)
     46    :QGraphicsEffect(pParent)
     47    , m_iBlurRadius(iBlurRadius)
     48{
     49}
     50
     51void UIChooserDisabledItemEffect::draw(QPainter *painter)
     52{
     53    QPoint offset;
     54    QPixmap pixmap;
     55    /* Get the original pixmap: */
     56    pixmap = sourcePixmap( Qt::LogicalCoordinates, &offset );
     57    QImage resultImage;
     58    /* Apply our blur and grayscale filters to the original pixmap: */
     59    UIImageTools::blurImage(pixmap.toImage(), resultImage, m_iBlurRadius);
     60    pixmap.convertFromImage(UIImageTools::toGray(resultImage));
     61    /* Use the filtered pixmap: */
     62    painter->drawPixmap( offset, pixmap );
     63}
    4464
    4565/** QAccessibleObject extension used as an accessibility interface for Chooser-view items. */
     
    211231    , m_iHoveredValue(iHoveredValue)
    212232    , m_iAnimatedValue(m_iDefaultValue)
     233    , m_pDisabledEffect(0)
    213234    , m_iPreviousMinimumWidthHint(0)
    214235    , m_enmDragTokenPlace(UIChooserItemDragToken_Off)
     
    294315        }
    295316    }
     317    /* Allocate the effect instance which we use when the item is marked as disablec: */
     318    m_pDisabledEffect = new UIChooserDisabledItemEffect(1 /* Blur Radius */);
     319    setGraphicsEffect(m_pDisabledEffect);
     320    m_pDisabledEffect->setEnabled(false);
    296321}
    297322
     
    405430    else
    406431        emit sigHoverLeave();
     432}
     433
     434void UIChooserItem::disableEnableItem(bool fDisabled)
     435{
     436    if (m_pDisabledEffect)
     437        m_pDisabledEffect->setEnabled(fDisabled);
    407438}
    408439
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h

    r77638 r77701  
    2323
    2424/* Qt includes: */
     25#include <QGraphicsEffect>
    2526#include <QMimeData>
    2627#include <QRectF>
     
    4950class UIChooserNode;
    5051
     52/** A simple QGraphicsEffect extension to mark disabled UIChooserItems. Applies blur and gray scale filters. */
     53class UIChooserDisabledItemEffect : public QGraphicsEffect
     54{
     55    Q_OBJECT;
     56
     57public:
     58
     59    UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent = 0);
     60
     61protected:
     62
     63    virtual void draw(QPainter *painter);
     64    int m_iBlurRadius;
     65};
     66
    5167
    5268/** QIGraphicsWidget extension used as interface
     
    142158          * @note  Base-class implementation does nothing. */
    143159        virtual void installEventFilterHelper(QObject *pSource) { Q_UNUSED(pSource); }
     160        /** Enables the visual effect for disabled item. */
     161        void disableEnableItem(bool fDisabled);
    144162    /** @} */
    145163
     
    318336        /** Holds the animated value. */
    319337        int                 m_iAnimatedValue;
     338        /** Holds the pointer to blur effect instance. */
     339        UIChooserDisabledItemEffect *m_pDisabledEffect;
    320340    /** @} */
    321341
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r77686 r77701  
    454454void UIChooserModel::performSearch(const QString &strSearchTerm, int iItemSearchFlags)
    455455{
    456     if (!m_pInvisibleRootNode || strSearchTerm.isEmpty())
    457         return;
    458 
    459     QList<UIChooserNode*> matchedItems;
    460     m_pInvisibleRootNode->searchForNodes(strSearchTerm, iItemSearchFlags, matchedItems);
     456    if (!m_pInvisibleRootNode)
     457        return;
     458
     459    /* Currently we perform the search only for machines. when this to be changed make sure the disabled flags
     460       of the other item types are also managed correctly: */
     461    QList<UIChooserNode*> allNodes;
     462    /* Calling UIChooserNode::searchForNodes with an empty search string returns a list all nodes (of the whole treee) of the required type: */
     463    m_pInvisibleRootNode->searchForNodes(QString(), iItemSearchFlags, allNodes);
     464
     465    /* Reset the disabled flag of the node items first. */
     466    foreach (UIChooserNode* pNode, allNodes)
     467    {
     468        if (!pNode)
     469            continue;
     470        pNode->setDisabled(false);
     471    }
     472
     473    if (strSearchTerm.isEmpty())
     474        return;
     475
     476    QList<UIChooserNode*> matchedNodes;
     477    m_pInvisibleRootNode->searchForNodes(strSearchTerm, iItemSearchFlags, matchedNodes);
     478
     479    foreach (UIChooserNode* pNode, allNodes)
     480    {
     481        if (!pNode)
     482            continue;
     483        pNode->setDisabled(!matchedNodes.contains(pNode));
     484    }
    461485}
    462486
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNode.cpp

    r77638 r77701  
    2727    , m_pParent(pParent)
    2828    , m_fFavorite(fFavorite)
     29    , m_fDisabled(false)
    2930{
    3031}
     
    5556    return parentNode() ? parentNode()->positionOf(this) : 0;
    5657}
     58
     59bool UIChooserNode::isDisabled() const
     60{
     61    return m_fDisabled;
     62}
     63
     64void UIChooserNode::setDisabled(bool fDisabled)
     65{
     66    if (fDisabled == m_fDisabled)
     67        return;
     68    m_fDisabled = fDisabled;
     69    if (m_pItem)
     70        m_pItem->disableEnableItem(m_fDisabled);
     71}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNode.h

    r77686 r77701  
    107107    UIChooserItem *item() const { return m_pItem.data(); }
    108108
    109     /** Performs search wrt. @a strSearchTerm and @a iItemSearchFlags and updates @a matchedItems. */
     109    /** Performs search wrt. @a strSearchTerm and @a iItemSearchFlags and updates @a matchedItems. For an empty
     110      * @a strSearchTerm all items are added wrt. node type from @a iItemSearchFlags. */
    110111    virtual void searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems) = 0;
     112
     113    /** Returns if node is disabled. */
     114    bool isDisabled() const;
     115    /** Sets the disabled flag. */
     116    void setDisabled(bool fDisabled);
    111117
    112118protected:
     
    122128    /** Holds item description. */
    123129    QString  m_strDescription;
     130
     131    /** Holds the flag to indicate whether the node is disabled or not. */
     132    bool m_fDisabled;
     133
    124134};
    125135
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGlobal.cpp

    r77683 r77701  
    119119    if (!(iItemSearchFlags & UIChooserItemSearchFlag_Global))
    120120        return;
     121
     122    if (strSearchTerm.isEmpty())
     123    {
     124        matchedItems << this;
     125        return;
     126    }
     127
    121128    if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName)
    122129    {
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGroup.cpp

    r77683 r77701  
    188188}
    189189
    190 
    191190void UIChooserNodeGroup::searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems)
    192191{
     
    194193    if (iItemSearchFlags & UIChooserItemSearchFlag_Group)
    195194    {
    196         if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName)
     195        /* if the search term is empty we just add the node to the matched list: */
     196        if (strSearchTerm.isEmpty())
    197197        {
    198             if (name() == strSearchTerm)
    199                 matchedItems << this;
     198            matchedItems << this;
    200199        }
    201200        else
    202201        {
    203             if (name().contains(strSearchTerm, Qt::CaseInsensitive))
    204                 matchedItems << this;
     202            if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName)
     203            {
     204                if (name() == strSearchTerm)
     205                    matchedItems << this;
     206            }
     207            else
     208            {
     209                if (name().contains(strSearchTerm, Qt::CaseInsensitive))
     210                    matchedItems << this;
     211            }
    205212        }
    206213    }
     
    214221    foreach (UIChooserNode* pNode, m_nodesMachine)
    215222        pNode->searchForNodes(strSearchTerm, iItemSearchFlags, matchedItems);
    216 
    217223}
    218224
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.cpp

    r77683 r77701  
    136136    if (!(iItemSearchFlags & UIChooserItemSearchFlag_Machine))
    137137        return;
     138
     139    if (strSearchTerm.isEmpty())
     140    {
     141        matchedItems << this;
     142        return;
     143    }
     144
    138145    if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName)
    139146    {
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