- Timestamp:
- Mar 14, 2019 11:57:06 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 129342
- 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 73 73 } 74 74 75 void UIImageTools::blurImage(const QImage &source, QImage &destinati ion, int iRadius)75 void UIImageTools::blurImage(const QImage &source, QImage &destination, int iRadius) 76 76 { 77 77 /* Blur in two steps, first horizontal and then vertical: */ 78 78 QImage tmpImage(source.size(), QImage::Format_ARGB32); 79 79 blurImageHorizontal(source, tmpImage, iRadius); 80 blurImageVertical(tmpImage, destinati ion, iRadius);81 } 82 83 void UIImageTools::blurImageHorizontal(const QImage &source, QImage &destinati ion, int iRadius)80 blurImageVertical(tmpImage, destination, iRadius); 81 } 82 83 void UIImageTools::blurImageHorizontal(const QImage &source, QImage &destination, int iRadius) 84 84 { 85 85 QSize s = source.size(); … … 95 95 * method. Unfortunately this doesn't work in the vertical case. */ 96 96 QRgb *ssl = (QRgb*)source.scanLine(y); 97 QRgb *dsl = (QRgb*)destinati ion.scanLine(y);97 QRgb *dsl = (QRgb*)destination.scanLine(y); 98 98 /* First process the horizontal zero line at once: */ 99 99 int b = iRadius + 1; … … 143 143 } 144 144 145 void UIImageTools::blurImageVertical(const QImage &source, QImage &destinati ion, int iRadius)145 void UIImageTools::blurImageVertical(const QImage &source, QImage &destination, int iRadius) 146 146 { 147 147 QSize s = source.size(); 148 destination = QImage(s, source.format()); 148 149 for (int x = 0; x < s.width(); ++x) 149 150 { … … 164 165 } 165 166 /* Set the new weighted pixel: */ 166 destinati ion.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)); 167 168 168 169 /* Now process the rest: */ … … 193 194 } 194 195 /* Set the new weighted pixel: */ 195 destinati ion.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)); 196 197 } 197 198 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIImageTools.h
r76581 r77701 39 39 40 40 /** 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); 42 42 /** 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); 44 44 /** 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); 46 46 47 47 /** Applies BET-label of passed @a size. */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp
r77638 r77701 38 38 #include "UIChooserModel.h" 39 39 #include "UIChooserNode.h" 40 #include "UIImageTools.h" 40 41 41 42 /* Other VBox includes: */ 42 43 #include "iprt/assert.h" 43 44 45 UIChooserDisabledItemEffect::UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent /* = 0 */) 46 :QGraphicsEffect(pParent) 47 , m_iBlurRadius(iBlurRadius) 48 { 49 } 50 51 void 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 } 44 64 45 65 /** QAccessibleObject extension used as an accessibility interface for Chooser-view items. */ … … 211 231 , m_iHoveredValue(iHoveredValue) 212 232 , m_iAnimatedValue(m_iDefaultValue) 233 , m_pDisabledEffect(0) 213 234 , m_iPreviousMinimumWidthHint(0) 214 235 , m_enmDragTokenPlace(UIChooserItemDragToken_Off) … … 294 315 } 295 316 } 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); 296 321 } 297 322 … … 405 430 else 406 431 emit sigHoverLeave(); 432 } 433 434 void UIChooserItem::disableEnableItem(bool fDisabled) 435 { 436 if (m_pDisabledEffect) 437 m_pDisabledEffect->setEnabled(fDisabled); 407 438 } 408 439 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h
r77638 r77701 23 23 24 24 /* Qt includes: */ 25 #include <QGraphicsEffect> 25 26 #include <QMimeData> 26 27 #include <QRectF> … … 49 50 class UIChooserNode; 50 51 52 /** A simple QGraphicsEffect extension to mark disabled UIChooserItems. Applies blur and gray scale filters. */ 53 class UIChooserDisabledItemEffect : public QGraphicsEffect 54 { 55 Q_OBJECT; 56 57 public: 58 59 UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent = 0); 60 61 protected: 62 63 virtual void draw(QPainter *painter); 64 int m_iBlurRadius; 65 }; 66 51 67 52 68 /** QIGraphicsWidget extension used as interface … … 142 158 * @note Base-class implementation does nothing. */ 143 159 virtual void installEventFilterHelper(QObject *pSource) { Q_UNUSED(pSource); } 160 /** Enables the visual effect for disabled item. */ 161 void disableEnableItem(bool fDisabled); 144 162 /** @} */ 145 163 … … 318 336 /** Holds the animated value. */ 319 337 int m_iAnimatedValue; 338 /** Holds the pointer to blur effect instance. */ 339 UIChooserDisabledItemEffect *m_pDisabledEffect; 320 340 /** @} */ 321 341 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r77686 r77701 454 454 void UIChooserModel::performSearch(const QString &strSearchTerm, int iItemSearchFlags) 455 455 { 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 } 461 485 } 462 486 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNode.cpp
r77638 r77701 27 27 , m_pParent(pParent) 28 28 , m_fFavorite(fFavorite) 29 , m_fDisabled(false) 29 30 { 30 31 } … … 55 56 return parentNode() ? parentNode()->positionOf(this) : 0; 56 57 } 58 59 bool UIChooserNode::isDisabled() const 60 { 61 return m_fDisabled; 62 } 63 64 void 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 107 107 UIChooserItem *item() const { return m_pItem.data(); } 108 108 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. */ 110 111 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); 111 117 112 118 protected: … … 122 128 /** Holds item description. */ 123 129 QString m_strDescription; 130 131 /** Holds the flag to indicate whether the node is disabled or not. */ 132 bool m_fDisabled; 133 124 134 }; 125 135 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGlobal.cpp
r77683 r77701 119 119 if (!(iItemSearchFlags & UIChooserItemSearchFlag_Global)) 120 120 return; 121 122 if (strSearchTerm.isEmpty()) 123 { 124 matchedItems << this; 125 return; 126 } 127 121 128 if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName) 122 129 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeGroup.cpp
r77683 r77701 188 188 } 189 189 190 191 190 void UIChooserNodeGroup::searchForNodes(const QString &strSearchTerm, int iItemSearchFlags, QList<UIChooserNode*> &matchedItems) 192 191 { … … 194 193 if (iItemSearchFlags & UIChooserItemSearchFlag_Group) 195 194 { 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()) 197 197 { 198 if (name() == strSearchTerm) 199 matchedItems << this; 198 matchedItems << this; 200 199 } 201 200 else 202 201 { 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 } 205 212 } 206 213 } … … 214 221 foreach (UIChooserNode* pNode, m_nodesMachine) 215 222 pNode->searchForNodes(strSearchTerm, iItemSearchFlags, matchedItems); 216 217 223 } 218 224 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNodeMachine.cpp
r77683 r77701 136 136 if (!(iItemSearchFlags & UIChooserItemSearchFlag_Machine)) 137 137 return; 138 139 if (strSearchTerm.isEmpty()) 140 { 141 matchedItems << this; 142 return; 143 } 144 138 145 if (iItemSearchFlags & UIChooserItemSearchFlag_ExactName) 139 146 {
Note:
See TracChangeset
for help on using the changeset viewer.