Changeset 42856 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 17, 2012 12:21:30 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
r42827 r42856 94 94 void UIGDetailsElement::close() 95 95 { 96 m_pButton->setToggled(false , false);96 m_pButton->setToggled(false); 97 97 } 98 98 99 99 void UIGDetailsElement::open() 100 100 { 101 m_pButton->setToggled(true , false);101 m_pButton->setToggled(true); 102 102 } 103 103 … … 134 134 } 135 135 136 void UIGDetailsElement::markAnimationFinished() 137 { 138 m_fAnimationRunning = false; 139 } 140 141 void UIGDetailsElement::sltToggleButtonClicked() 142 { 143 emit sigToggleElement(m_type, closed()); 144 } 145 136 146 void UIGDetailsElement::sltElementToggleStart() 137 147 { … … 144 154 /* Toggle element state: */ 145 155 m_fClosed = !m_fClosed; 146 /* Relayout model: */147 model()->updateLayout();148 update();149 156 } 150 157 151 158 void UIGDetailsElement::sltElementToggleFinish(bool fToggled) 152 159 { 153 /* Mark animation stopped: */154 m_fAnimationRunning = false;155 156 160 /* Update toggle-state: */ 157 161 m_fClosed = !fToggled; 158 /* Relayout model: */ 159 model()->updateLayout();160 update();162 163 /* Notify about finishing: */ 164 emit sigToggleElementFinished(); 161 165 } 162 166 … … 443 447 /* Setup toggle-button: */ 444 448 m_pButton = new UIGraphicsRotatorButton(this, "additionalHeight", !m_fClosed, true /* reflected */); 449 m_pButton->setAutoHandleButtonClick(false); 450 connect(m_pButton, SIGNAL(sigButtonClicked()), this, SLOT(sltToggleButtonClicked())); 445 451 connect(m_pButton, SIGNAL(sigRotationStart()), this, SLOT(sltElementToggleStart())); 446 452 connect(m_pButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltElementToggleFinish(bool))); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h
r42827 r42856 57 57 void sigHoverLeave(); 58 58 59 /* Notifier : Toggle stuff: */59 /* Notifiers: Toggle stuff: */ 60 60 void sigToggleElement(DetailsElementType type, bool fToggled); 61 void sigToggleElementFinished(); 61 62 62 63 /* Notifier: Link-click stuff: */ … … 90 91 virtual void updateAppearance() = 0; 91 92 93 /* API: Animation stuff: */ 94 void markAnimationFinished(); 95 92 96 protected slots: 93 97 94 /* Handlers: Collapse/expand stuff: */ 98 /* Handlers: Toggle stuff: */ 99 void sltToggleButtonClicked(); 95 100 void sltElementToggleStart(); 96 101 void sltElementToggleFinish(bool fToggled); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.cpp
r42734 r42856 40 40 , m_pScene(0) 41 41 , m_pRoot(0) 42 , m_pAnimationCallback(0) 42 43 { 43 44 /* Prepare scene: */ … … 46 47 /* Prepare root: */ 47 48 prepareRoot(); 49 50 /* Register meta-type: */ 51 qRegisterMetaType<DetailsElementType>(); 48 52 } 49 53 … … 97 101 void UIGDetailsModel::sltToggleElements(DetailsElementType type, bool fToggled) 98 102 { 103 /* Make sure not started yet: */ 104 if (m_pAnimationCallback) 105 return; 106 /* Prepare/configure animation callback: */ 107 m_pAnimationCallback = new UIGDetailsElementAnimationCallback(this, type, fToggled); 108 connect(m_pAnimationCallback, SIGNAL(sigAllAnimationFinished(DetailsElementType, bool)), 109 this, SLOT(sltToggleAnimationFinished(DetailsElementType, bool)), Qt::QueuedConnection); 99 110 /* For each the set of the group: */ 100 111 foreach (UIGDetailsItem *pSetItem, m_pRoot->items()) … … 109 120 { 110 121 if (fToggled && pElement->closed()) 122 { 123 m_pAnimationCallback->addNotifier(pElement); 111 124 pElement->open(); 125 } 112 126 else if (!fToggled && pElement->opened()) 127 { 128 m_pAnimationCallback->addNotifier(pElement); 113 129 pElement->close(); 130 } 114 131 } 115 132 } 116 133 } 134 /* Update layout: */ 135 updateLayout(); 136 } 137 138 void UIGDetailsModel::sltToggleAnimationFinished(DetailsElementType type, bool fToggled) 139 { 140 /* Cleanup animation callback: */ 141 delete m_pAnimationCallback; 142 m_pAnimationCallback = 0; 143 144 /* Mark animation finished: */ 145 foreach (UIGDetailsItem *pSetItem, m_pRoot->items()) 146 { 147 foreach (UIGDetailsItem *pElementItem, pSetItem->items()) 148 { 149 UIGDetailsElement *pElement = pElementItem->toElement(); 150 if (pElement->elementType() == type) 151 pElement->markAnimationFinished(); 152 } 153 } 154 /* Update layout: */ 155 updateLayout(); 117 156 118 157 /* Update details settings: */ … … 246 285 } 247 286 287 UIGDetailsElementAnimationCallback::UIGDetailsElementAnimationCallback(QObject *pParent, DetailsElementType type, bool fToggled) 288 : QObject(pParent) 289 , m_type(type) 290 , m_fToggled(fToggled) 291 { 292 } 293 294 void UIGDetailsElementAnimationCallback::addNotifier(UIGDetailsItem *pItem) 295 { 296 /* Connect notifier: */ 297 connect(pItem, SIGNAL(sigToggleElementFinished()), this, SLOT(sltAnimationFinished())); 298 /* Remember notifier: */ 299 m_notifiers << pItem; 300 } 301 302 void UIGDetailsElementAnimationCallback::sltAnimationFinished() 303 { 304 /* Determine notifier: */ 305 UIGDetailsItem *pItem = qobject_cast<UIGDetailsItem*>(sender()); 306 /* Disconnect notifier: */ 307 disconnect(pItem, SIGNAL(sigToggleElementFinished()), this, SLOT(sltAnimationFinished())); 308 /* Remove notifier: */ 309 m_notifiers.removeAll(pItem); 310 /* Check if we finished: */ 311 if (m_notifiers.isEmpty()) 312 emit sigAllAnimationFinished(m_type, m_fToggled); 313 } 314 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h
r42734 r42856 39 39 class UIGDetailsGroup; 40 40 class UIVMItem; 41 class UIGDetailsElementAnimationCallback; 42 class UIGDetailsItem; 41 43 42 44 /* Graphics selector model: */ … … 78 80 /* Handler: Toggle stuff: */ 79 81 void sltToggleElements(DetailsElementType type, bool fToggled); 82 void sltToggleAnimationFinished(DetailsElementType type, bool fToggled); 80 83 81 84 /* Handler: Context-menu stuff: */ … … 118 121 QGraphicsScene *m_pScene; 119 122 UIGDetailsGroup *m_pRoot; 123 UIGDetailsElementAnimationCallback *m_pAnimationCallback; 124 }; 125 126 /* Details-element animation callback: */ 127 class UIGDetailsElementAnimationCallback : public QObject 128 { 129 Q_OBJECT; 130 131 signals: 132 133 /* Notifier: Complete stuff: */ 134 void sigAllAnimationFinished(DetailsElementType type, bool fToggled); 135 136 public: 137 138 /* Constructor: */ 139 UIGDetailsElementAnimationCallback(QObject *pParent, DetailsElementType type, bool fToggled); 140 141 /* API: Notifiers stuff: */ 142 void addNotifier(UIGDetailsItem *pItem); 143 144 private slots: 145 146 /* Handler: Progress stuff: */ 147 void sltAnimationFinished(); 148 149 private: 150 151 /* Variables: */ 152 QList<UIGDetailsItem*> m_notifiers; 153 DetailsElementType m_type; 154 bool m_fToggled; 120 155 }; 121 156 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsRotatorButton.cpp
r42795 r42856 42 42 , m_pBackwardSubordinateAnimation(0) 43 43 { 44 /* Configure: */ 45 setAutoHandleButtonClick(true); 46 44 47 /* Create state machine: */ 45 48 m_pAnimationMachine = new QStateMachine(this); … … 107 110 } 108 111 112 void UIGraphicsRotatorButton::setAutoHandleButtonClick(bool fEnabled) 113 { 114 /* Disconnect button-click signal: */ 115 disconnect(this, SIGNAL(sigButtonClicked()), this, SLOT(sltButtonClicked())); 116 if (fEnabled) 117 { 118 /* Connect button-click signal: */ 119 connect(this, SIGNAL(sigButtonClicked()), this, SLOT(sltButtonClicked())); 120 } 121 } 122 109 123 void UIGraphicsRotatorButton::setToggled(bool fToggled, bool fAnimated /* = true */) 110 124 { … … 159 173 return m_pForwardSubordinateAnimation->state() == QAbstractAnimation::Running || 160 174 m_pBackwardSubordinateAnimation->state() == QAbstractAnimation::Running; 175 } 176 177 void UIGraphicsRotatorButton::sltButtonClicked() 178 { 179 /* Toggle state: */ 180 switch (state()) 181 { 182 case UIGraphicsRotatorButtonState_Default: setToggled(true); break; 183 case UIGraphicsRotatorButtonState_Rotated: setToggled(false); break; 184 default: break; 185 } 161 186 } 162 187 … … 172 197 } 173 198 174 void UIGraphicsRotatorButton::mousePressEvent(QGraphicsSceneMouseEvent*)175 {176 /* Toggle state: */177 switch (state())178 {179 case UIGraphicsRotatorButtonState_Default: setToggled(true); break;180 case UIGraphicsRotatorButtonState_Rotated: setToggled(false); break;181 default: break;182 }183 }184 185 void UIGraphicsRotatorButton::mouseReleaseEvent(QGraphicsSceneMouseEvent*)186 {187 /* Do nothing (do NOT propagate to parent!)... */188 }189 190 199 void UIGraphicsRotatorButton::updateRotationState() 191 200 { -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsRotatorButton.h
r42526 r42856 62 62 int iAnimationDuration = 300); 63 63 64 /* API: Button-click stuff: */ 65 void setAutoHandleButtonClick(bool fEnabled); 66 64 67 /* API: Toggle stuff: */ 65 68 void setToggled(bool fToggled, bool fAnimated = true); … … 69 72 bool isAnimationRunning() const; 70 73 74 protected slots: 75 76 /* Handler: Button-click stuff: */ 77 void sltButtonClicked(); 78 71 79 protected: 72 80 73 81 /* Helpers: Update stuff: */ 74 82 void refresh(); 75 76 /* Mouse-buttons handler: */77 void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);78 void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent);79 83 80 84 private:
Note:
See TracChangeset
for help on using the changeset viewer.