- Timestamp:
- Nov 28, 2012 1:32:14 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 82355
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
r43887 r43982 20 20 /* Qt includes: */ 21 21 #include <QApplication> 22 #include <QPainter> 23 #include <QStyleOptionGraphicsItem> 24 #include <QTextLayout> 25 #include <QGraphicsSceneMouseEvent> 22 #include <QGraphicsView> 26 23 #include <QStateMachine> 27 24 #include <QPropertyAnimation> 28 25 #include <QSignalTransition> 26 #include <QTextLayout> 27 #include <QStyleOptionGraphicsItem> 28 #include <QGraphicsSceneMouseEvent> 29 29 30 30 /* GUI includes: */ … … 61 61 prepareButton(); 62 62 63 /* Update size-policy/hint: */63 /* Setup size-policy: */ 64 64 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 65 /* Update: */ 65 66 /* Update hover access: */ 66 67 updateHoverAccessibility(); 67 68 68 69 /* Add item to the parent: */ 70 AssertMsg(parentItem(), ("No parent set for details element!")); 69 71 parentItem()->addItem(this); 70 72 } … … 75 77 AssertMsg(parentItem(), ("No parent set for details element!")); 76 78 parentItem()->removeItem(this); 77 }78 79 DetailsElementType UIGDetailsElement::elementType() const80 {81 return m_type;82 }83 84 bool UIGDetailsElement::closed() const85 {86 return m_fClosed;87 }88 89 bool UIGDetailsElement::opened() const90 {91 return !m_fClosed;92 79 } 93 80 … … 136 123 void UIGDetailsElement::markAnimationFinished() 137 124 { 125 /* Mark animation as non-running: */ 138 126 m_fAnimationRunning = false; 139 127 } … … 152 140 updateAnimationParameters(); 153 141 154 /* Toggle elementstate: */142 /* Invert toggle-state: */ 155 143 m_fClosed = !m_fClosed; 156 144 } … … 170 158 switch (iKey) 171 159 { 172 /* Layout hints: */160 /* Hints: */ 173 161 case ElementData_Margin: return 5; 174 162 case ElementData_Spacing: return 10; … … 347 335 } 348 336 349 UITextTable UIGDetailsElement::text() const350 {351 return m_text;352 }353 354 337 void UIGDetailsElement::setText(const UITextTable &text) 355 338 { … … 476 459 void UIGDetailsElement::setAdditionalHeight(int iAdditionalHeight) 477 460 { 461 /* Cache new value: */ 478 462 m_iAdditionalHeight = iAdditionalHeight; 463 /* Update layout: */ 479 464 updateLayout(); 465 /* Repaint: */ 480 466 update(); 481 }482 483 int UIGDetailsElement::additionalHeight() const484 {485 return m_iAdditionalHeight;486 }487 488 UIGraphicsRotatorButton* UIGDetailsElement::button() const489 {490 return m_pButton;491 467 } 492 468 … … 547 523 paintDecorations(pPainter, pOption); 548 524 549 /* Paint machineinfo: */525 /* Paint element info: */ 550 526 paintElementInfo(pPainter, pOption); 551 527 } … … 774 750 void UIGDetailsElement::mousePressEvent(QGraphicsSceneMouseEvent *pEvent) 775 751 { 776 if (m_fNameHovered) 777 { 778 pEvent->accept(); 779 QString strCategory; 780 if (m_type >= DetailsElementType_General && 781 m_type <= DetailsElementType_SF) 782 strCategory = QString("#%1").arg(gpConverter->toInternalString(m_type)); 783 else if (m_type == DetailsElementType_Description) 784 strCategory = QString("#%1%%mTeDescription").arg(gpConverter->toInternalString(m_type)); 785 emit sigLinkClicked(strCategory, QString(), machine().GetId()); 786 } 752 /* Only for hovered header: */ 753 if (!m_fNameHovered) 754 return; 755 756 /* Process link click: */ 757 pEvent->accept(); 758 QString strCategory; 759 if (m_type >= DetailsElementType_General && 760 m_type <= DetailsElementType_SF) 761 strCategory = QString("#%1").arg(gpConverter->toInternalString(m_type)); 762 else if (m_type == DetailsElementType_Description) 763 strCategory = QString("#%1%%mTeDescription").arg(gpConverter->toInternalString(m_type)); 764 emit sigLinkClicked(strCategory, QString(), machine().GetId()); 787 765 } 788 766 789 767 void UIGDetailsElement::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *pEvent) 790 768 { 769 /* Only for left-button: */ 770 if (pEvent->button() != Qt::LeftButton) 771 return; 772 791 773 /* Process left-button double-click: */ 792 if (pEvent->button() == Qt::LeftButton) 793 emit sigToggleElement(m_type, closed()); 774 emit sigToggleElement(m_type, closed()); 794 775 } 795 776 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h
r42909 r43982 75 75 76 76 /* API: Element type: */ 77 DetailsElementType elementType() const ;77 DetailsElementType elementType() const { return m_type; } 78 78 79 79 /* API: Open/close stuff: */ 80 bool closed() const ;81 bool opened() const ;80 bool closed() const { return m_fClosed; } 81 bool opened() const { return !m_fClosed; } 82 82 void close(bool fAnimated = true); 83 83 void open(bool fAnimated = true); … … 106 106 enum ElementData 107 107 { 108 /* Layout hints: */108 /* Hints: */ 109 109 ElementData_Margin, 110 110 ElementData_Spacing, … … 134 134 135 135 /* API: Text stuff: */ 136 UITextTable text() const ;136 UITextTable text() const { return m_text; } 137 137 void setText(const UITextTable &text); 138 138 … … 149 149 /* Helpers: Animation stuff: */ 150 150 void setAdditionalHeight(int iAdditionalHeight); 151 int additionalHeight() const; 152 UIGraphicsRotatorButton* button() const; 153 154 protected: 151 int additionalHeight() const { return m_iAdditionalHeight; } 152 UIGraphicsRotatorButton* button() const { return m_pButton; } 153 bool isAnimationRunning() const { return m_fAnimationRunning; } 154 155 private: 155 156 156 157 /* API: Children stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp
r43484 r43982 246 246 if (closed() && m_pPreview->isVisible()) 247 247 m_pPreview->hide(); 248 if (opened() && !m_pPreview->isVisible() && ! m_fAnimationRunning)248 if (opened() && !m_pPreview->isVisible() && !isAnimationRunning()) 249 249 m_pPreview->show(); 250 250 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.h
r42722 r43982 136 136 private: 137 137 138 /* Helpers: Size-hint stuff: */138 /* Helpers: Layout stuff: */ 139 139 int minimumWidthHint() const; 140 140 int minimumHeightHint(bool fClosed) const; -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp
r42881 r43982 27 27 #include "UIConverter.h" 28 28 #include "VBoxGlobal.h" 29 30 /* Other VBox includes: */31 #include <iprt/assert.h>32 29 33 30 UIGDetailsGroup::UIGDetailsGroup() -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.cpp
r43885 r43982 83 83 void UIGDetailsItem::updateSizeHint() 84 84 { 85 /* Update the geometry: */ 85 86 updateGeometry(); 86 87 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.cpp
r43937 r43982 20 20 /* Qt includes: */ 21 21 #include <QGraphicsScene> 22 #include <QGraphicsSceneContextMenuEvent> 22 23 #include <QGraphicsView> 23 #include <QGraphicsSceneContextMenuEvent>24 24 25 25 /* GUI includes: */ … … 27 27 #include "UIGDetailsGroup.h" 28 28 #include "UIGDetailsElement.h" 29 #include "UIGChooserItemGroup.h"30 #include "UIGChooserItemMachine.h"31 29 #include "VBoxGlobal.h" 32 #include "UIMessageCenter.h"33 30 #include "UIConverter.h" 34 35 /* COM includes: */36 #include "CMachine.h"37 31 38 32 UIGDetailsModel::UIGDetailsModel(QObject *pParent) … … 66 60 } 67 61 68 Q PaintDevice* UIGDetailsModel::paintDevice() const62 QGraphicsView* UIGDetailsModel::paintDevice() const 69 63 { 70 64 if (!m_pScene || m_pScene->views().isEmpty()) … … 73 67 } 74 68 75 QGraphicsItem* UIGDetailsModel::itemAt(const QPointF &position , const QTransform &deviceTransform /* = QTransform() */) const76 { 77 return scene()->itemAt(position , deviceTransform);69 QGraphicsItem* UIGDetailsModel::itemAt(const QPointF &position) const 70 { 71 return scene()->itemAt(position); 78 72 } 79 73 80 74 void UIGDetailsModel::updateLayout() 81 75 { 82 /* Initialize variables: */76 /* Prepare variables: */ 83 77 int iSceneMargin = data(DetailsModelData_Margin).toInt(); 84 QSize viewportSize = scene()->views()[0]->viewport()->size();78 QSize viewportSize = paintDevice()->viewport()->size(); 85 79 int iViewportWidth = viewportSize.width() - 2 * iSceneMargin; 86 80 int iViewportHeight = viewportSize.height() - 2 * iSceneMargin; 87 /* Set root item position: */ 81 82 /* Move root: */ 88 83 m_pRoot->setPos(iSceneMargin, iSceneMargin); 89 /* Set root item size: */84 /* Resize root: */ 90 85 m_pRoot->resize(iViewportWidth, iViewportHeight); 91 /* Relayout root item: */86 /* Layout root content: */ 92 87 m_pRoot->updateLayout(); 88 93 89 /* Notify listener about root-item relayouted: */ 94 90 emit sigRootItemResized(m_pRoot->geometry().size(), m_pRoot->minimumSizeHint().toSize().width()); … … 108 104 void UIGDetailsModel::sltToggleElements(DetailsElementType type, bool fToggled) 109 105 { 110 /* Make sure not started yet: */106 /* Make sure it is not started yet: */ 111 107 if (m_pAnimationCallback) 112 108 return; 109 113 110 /* Prepare/configure animation callback: */ 114 111 m_pAnimationCallback = new UIGDetailsElementAnimationCallback(this, type, fToggled); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsModel.h
r43937 r43982 23 23 #include <QObject> 24 24 #include <QPointer> 25 #include <QTransform>26 25 #include <QMap> 27 26 #include <QSet> … … 37 36 class QGraphicsScene; 38 37 class QGraphicsSceneContextMenuEvent; 38 class QGraphicsView; 39 39 class UIGDetailsGroup; 40 40 class UIVMItem; … … 63 63 /* API: Scene stuff: */ 64 64 QGraphicsScene* scene() const; 65 Q PaintDevice* paintDevice() const;66 QGraphicsItem* itemAt(const QPointF &position , const QTransform &deviceTransform = QTransform()) const;65 QGraphicsView* paintDevice() const; 66 QGraphicsItem* itemAt(const QPointF &position) const; 67 67 68 68 /* API: Layout stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsView.h
r43936 r43982 40 40 private slots: 41 41 42 /* Handler: R esizestuff: */42 /* Handler: Root-item stuff: */ 43 43 void sltHandleRootItemResized(const QSizeF &size, int iMinimumWidth); 44 44
Note:
See TracChangeset
for help on using the changeset viewer.