- Timestamp:
- Aug 8, 2012 6:14:23 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.cpp
r42678 r42689 43 43 , m_pForwardAnimation(0) 44 44 , m_pBackwardAnimation(0) 45 , m_iAnimationDuration( 300)45 , m_iAnimationDuration(400) 46 46 , m_iDefaultDarkness(103) 47 47 , m_iHighlightDarkness(90) … … 186 186 void UIGChooserItem::hoverMoveEvent(QGraphicsSceneHoverEvent*) 187 187 { 188 if ( m_fHovered != true)188 if (!m_fHovered) 189 189 { 190 190 m_fHovered = true; … … 195 195 void UIGChooserItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*) 196 196 { 197 if (m_fHovered != false)197 if (m_fHovered) 198 198 { 199 199 m_fHovered = false; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
r42678 r42689 23 23 #include <QTextLayout> 24 24 #include <QGraphicsSceneMouseEvent> 25 #include <QStateMachine> 26 #include <QPropertyAnimation> 27 #include <QSignalTransition> 25 28 26 29 /* GUI includes: */ … … 45 48 , m_fNameHoveringAccessible(false) 46 49 , m_fNameHovered(false) 50 , m_pHighlightMachine(0) 51 , m_pForwardAnimation(0) 52 , m_pBackwardAnimation(0) 53 , m_iAnimationDuration(400) 54 , m_iDefaultDarkness(103) 55 , m_iHighlightDarkness(90) 56 , m_iGradient(m_iDefaultDarkness) 47 57 { 48 58 /* Prepare element: */ … … 350 360 void UIGDetailsElement::prepareElement() 351 361 { 362 /* Create highlight machine: */ 363 m_pHighlightMachine = new QStateMachine(this); 364 /* Create 'default' state: */ 365 QState *pStateDefault = new QState(m_pHighlightMachine); 366 /* Create 'highlighted' state: */ 367 QState *pStateHighlighted = new QState(m_pHighlightMachine); 368 369 /* Forward animation: */ 370 m_pForwardAnimation = new QPropertyAnimation(this, "gradient", this); 371 m_pForwardAnimation->setDuration(m_iAnimationDuration); 372 m_pForwardAnimation->setStartValue(m_iDefaultDarkness); 373 m_pForwardAnimation->setEndValue(m_iHighlightDarkness); 374 375 /* Backward animation: */ 376 m_pBackwardAnimation = new QPropertyAnimation(this, "gradient", this); 377 m_pBackwardAnimation->setDuration(m_iAnimationDuration); 378 m_pBackwardAnimation->setStartValue(m_iHighlightDarkness); 379 m_pBackwardAnimation->setEndValue(m_iDefaultDarkness); 380 381 /* Add state transitions: */ 382 QSignalTransition *pDefaultToHighlighted = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHighlighted); 383 pDefaultToHighlighted->addAnimation(m_pForwardAnimation); 384 QSignalTransition *pHighlightedToDefault = pStateHighlighted->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault); 385 pHighlightedToDefault->addAnimation(m_pBackwardAnimation); 386 387 /* Initial state is 'default': */ 388 m_pHighlightMachine->setInitialState(pStateDefault); 389 /* Start state-machine: */ 390 m_pHighlightMachine->start(); 391 352 392 connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString))); 353 393 connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltShouldWeUpdateAppearance(QString))); … … 480 520 /* Header height: */ 481 521 2 * data(ElementData_Margin).toInt() + 482 data(ElementData_HeaderSize).toSize().height()); 522 data(ElementData_HeaderSize).toSize().height(), 523 /* Gradient color: */ 524 gradient()); 483 525 } 484 526 … … 587 629 588 630 /* static */ 589 void UIGDetailsElement::paintBackground(QPainter *pPainter, const QRect &rect, int iRadius, int iHeaderHeight) 631 void UIGDetailsElement::paintBackground(QPainter *pPainter, const QRect &rect, 632 int iRadius, int iHeaderHeight, int iGradient) 590 633 { 591 634 /* Save painter: */ … … 622 665 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 623 666 tGradient.setColorAt(0, windowColor.darker(110)); 624 tGradient.setColorAt(1, windowColor.darker( 103));667 tGradient.setColorAt(1, windowColor.darker(iGradient)); 625 668 626 669 /* Paint all the stuff: */ … … 642 685 { 643 686 m_fHovered = true; 644 update();687 emit sigHoverEnter(); 645 688 } 646 689 … … 655 698 { 656 699 m_fHovered = false; 657 update();700 emit sigHoverLeave(); 658 701 } 659 702 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h
r42608 r42689 32 32 class UIGraphicsRotatorButton; 33 33 class QTextLayout; 34 class QStateMachine; 35 class QPropertyAnimation; 34 36 35 37 /* Typedefs: */ … … 43 45 { 44 46 Q_OBJECT; 47 Q_PROPERTY(int gradient READ gradient WRITE setGradient); 45 48 Q_PROPERTY(int additionalHeight READ additionalHeight WRITE setAdditionalHeight); 46 49 47 50 signals: 51 52 /* Notifiers: Hover stuff: */ 53 void sigHoverEnter(); 54 void sigHoverLeave(); 48 55 49 56 /* Notifier: Toggle stuff: */ … … 123 130 void updateLayout(); 124 131 132 /* Helpers: Hover stuff: */ 133 int gradient() const { return m_iGradient; } 134 void setGradient(int iGradient) { m_iGradient = iGradient; update(); } 135 125 136 /* Helpers: Animation stuff: */ 126 137 void setAdditionalHeight(int iAdditionalHeight); … … 159 170 void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 160 171 void paintElementInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 161 static void paintBackground(QPainter *pPainter, const QRect &rect, int iRadius, int iHeaderHeight); 172 static void paintBackground(QPainter *pPainter, const QRect &rect, 173 int iRadius, int iHeaderHeight, int iGradient); 162 174 163 175 /* Handlers: Mouse stuff: */ … … 189 201 int m_iAdditionalHeight; 190 202 int m_iCornerRadius; 203 204 /* Variables: Hover stuff: */ 191 205 bool m_fHovered; 192 206 bool m_fNameHoveringAccessible; 193 207 bool m_fNameHovered; 208 QStateMachine *m_pHighlightMachine; 209 QPropertyAnimation *m_pForwardAnimation; 210 QPropertyAnimation *m_pBackwardAnimation; 211 int m_iAnimationDuration; 212 int m_iDefaultDarkness; 213 int m_iHighlightDarkness; 214 int m_iGradient; 194 215 }; 195 216 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.cpp
r42608 r42689 86 86 } 87 87 88 #if 089 void UIGDetailsItem::hoverEnterEvent(QGraphicsSceneHoverEvent*)90 {91 }92 93 void UIGDetailsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*)94 {95 }96 #endif97 98 88 /* static */ 99 89 void UIGDetailsItem::configurePainterShape(QPainter *pPainter, -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.h
r42608 r42689 76 76 protected: 77 77 78 #if 079 /* Hover-enter event: */80 void hoverEnterEvent(QGraphicsSceneHoverEvent *pEvent);81 /* Hover-leave event: */82 void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);83 #endif84 85 78 /* Helpers: Paint stuff: */ 86 79 static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius);
Note:
See TracChangeset
for help on using the changeset viewer.