Changeset 84583 in vbox
- Timestamp:
- May 28, 2020 11:43:07 AM (5 years ago)
- 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 42 42 #include "iprt/assert.h" 43 43 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 }63 44 64 45 /** QAccessibleObject extension used as an accessibility interface for Chooser-view items. */ … … 210 191 UIChooserItem *item() const { return qobject_cast<UIChooserItem*>(object()); } 211 192 }; 193 194 195 /********************************************************************************************************************************* 196 * Class UIChooserDisabledItemEffect implementation. * 197 *********************************************************************************************************************************/ 198 199 UIChooserDisabledItemEffect::UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent /* = 0 */) 200 : QGraphicsEffect(pParent) 201 , m_iBlurRadius(iBlurRadius) 202 { 203 } 204 205 void 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 } 212 218 213 219 … … 311 317 m_pHoveringMachine->start(); 312 318 } 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 } 318 328 } 319 329 … … 402 412 } 403 413 404 void UIChooserItem:: disableEnableItem(bool fDisabled)414 void UIChooserItem::setDisabledEffect(bool fOn) 405 415 { 406 416 if (m_pDisabledEffect) 407 m_pDisabledEffect->setEnabled(f Disabled);417 m_pDisabledEffect->setEnabled(fOn); 408 418 } 409 419 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h
r84582 r84583 50 50 class UIChooserNode; 51 51 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. */ 53 55 class UIChooserDisabledItemEffect : public QGraphicsEffect 54 56 { … … 57 59 public: 58 60 61 /** Constructs blur effect passing @a pParent to the base-class. 62 * @param iBlurRadius Brings the blur effect radius. */ 59 63 UIChooserDisabledItemEffect(int iBlurRadius, QObject *pParent = 0); 60 64 61 65 protected: 62 66 63 virtual void draw(QPainter *painter); 67 /** Draws effect with passed @a pPainter. */ 68 virtual void draw(QPainter *pPainter); 69 70 private: 71 72 /** Holds the blur effect radius. */ 64 73 int m_iBlurRadius; 65 74 }; … … 145 154 * @note Base-class implementation does nothing. */ 146 155 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); 149 158 /** @} */ 150 159 … … 300 309 301 310 /** Holds whether item is hovered. */ 302 bool m_fHovered;311 bool m_fHovered; 303 312 /** Holds the hovering animation machine instance. */ 304 QStateMachine *m_pHoveringMachine;313 QStateMachine *m_pHoveringMachine; 305 314 /** Holds the forward hovering animation instance. */ 306 QPropertyAnimation *m_pHoveringAnimationForward;315 QPropertyAnimation *m_pHoveringAnimationForward; 307 316 /** Holds the backward hovering animation instance. */ 308 QPropertyAnimation *m_pHoveringAnimationBackward;317 QPropertyAnimation *m_pHoveringAnimationBackward; 309 318 /** Holds the animation duration. */ 310 int m_iAnimationDuration;319 int m_iAnimationDuration; 311 320 /** Holds the default animation value. */ 312 int m_iDefaultValue;321 int m_iDefaultValue; 313 322 /** Holds the hovered animation value. */ 314 int m_iHoveredValue;323 int m_iHoveredValue; 315 324 /** Holds the animated value. */ 316 int m_iAnimatedValue;317 /** Holds the pointer toblur effect instance. */325 int m_iAnimatedValue; 326 /** Holds the blur effect instance. */ 318 327 UIChooserDisabledItemEffect *m_pDisabledEffect; 319 328 /** @} */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserNode.cpp
r83063 r84583 82 82 m_fDisabled = fDisabled; 83 83 if (m_pItem) 84 m_pItem-> disableEnableItem(m_fDisabled);84 m_pItem->setDisabledEffect(m_fDisabled); 85 85 }
Note:
See TracChangeset
for help on using the changeset viewer.