Changeset 58879 in vbox
- Timestamp:
- Nov 26, 2015 12:49:07 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 104368
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformation.cpp
r58726 r58879 31 31 32 32 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 33 34 33 35 34 UIGInformation::UIGInformation(QWidget *pParent) … … 102 101 connect(m_pDetailsModel, SIGNAL(sigRootItemMinimumHeightHintChanged(int)), 103 102 m_pDetailsView, SLOT(sltMinimumHeightHintChanged(int))); 104 connect(m_pDetailsModel, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),105 this, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)));106 connect(this, SIGNAL(sigSlidingStarted()),107 m_pDetailsModel, SLOT(sltHandleSlidingStarted()));108 connect(this, SIGNAL(sigToggleStarted()),109 m_pDetailsModel, SLOT(sltHandleToggleStarted()));110 connect(this, SIGNAL(sigToggleFinished()),111 m_pDetailsModel, SLOT(sltHandleToggleFinished()));112 103 113 104 /* Setup details-view connections: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformation.h
r58616 r58879 35 35 signals: 36 36 37 /* Notifier: Link processing stuff: */38 void sigLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId);39 40 37 /* Notifier: Sliding stuff: */ 41 38 void sigSlidingStarted(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformationElement.cpp
r58726 r58879 41 41 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 42 42 43 44 43 UIGInformationElement::UIGInformationElement(UIGInformationSet *pParent, InformationElementType type, bool fOpened) 45 44 : UIGInformationItem(pParent) 46 45 , m_pSet(pParent) 47 46 , m_type(type) 48 , m_iCornerRadius( 10)47 , m_iCornerRadius(0) 49 48 , m_iMinimumHeaderWidth(0) 50 49 , m_iMinimumHeaderHeight(0) 51 , m_pButton(0)52 , m_fClosed(!fOpened)53 , m_iAdditionalHeight(0)54 , m_fAnimationRunning(false)55 50 , m_pTextPane(0) 56 , m_fHovered(false)57 , m_fNameHovered(false)58 , m_pHighlightMachine(0)59 , m_pForwardAnimation(0)60 , m_pBackwardAnimation(0)61 , m_iAnimationDuration(400)62 , m_iDefaultDarkness(100)63 , m_iHighlightDarkness(90)64 , m_iAnimationDarkness(m_iDefaultDarkness)65 51 { 66 52 /* Prepare element: */ 67 53 prepareElement(); 68 /* Prepare button: */69 prepareButton();70 54 /* Prepare text-pane: */ 71 55 prepareTextPane(); 72 73 56 /* Setup size-policy: */ 74 57 setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 75 76 58 /* Add item to the parent: */ 77 59 AssertMsg(parentItem(), ("No parent set for details element!")); … … 86 68 } 87 69 88 void UIGInformationElement::close(bool fAnimated /* = true */)89 {90 m_pButton->setToggled(false, fAnimated);91 }92 93 void UIGInformationElement::open(bool fAnimated /* = true */)94 {95 m_pButton->setToggled(true, fAnimated);96 }97 98 70 void UIGInformationElement::updateAppearance() 99 71 { 100 /* Reset name hover state: */101 m_fNameHovered = false;102 updateNameHoverLink();103 104 72 /* Update anchor role restrictions: */ 105 73 ConfigurationAccessLevel cal = m_pSet->configurationAccessLevel(); 106 74 m_pTextPane->setAnchorRoleRestricted("#mount", cal == ConfigurationAccessLevel_Null); 107 75 m_pTextPane->setAnchorRoleRestricted("#attach", cal != ConfigurationAccessLevel_Full); 108 }109 110 void UIGInformationElement::markAnimationFinished()111 {112 /* Mark animation as non-running: */113 m_fAnimationRunning = false;114 115 /* Recursively update size-hint: */116 updateGeometry();117 /* Repaint: */118 update();119 }120 121 void UIGInformationElement::sltToggleButtonClicked()122 {123 emit sigToggleElement(m_type, closed());124 }125 126 void UIGInformationElement::sltElementToggleStart()127 {128 /* Mark animation running: */129 m_fAnimationRunning = true;130 131 /* Setup animation: */132 updateAnimationParameters();133 134 /* Invert toggle-state: */135 m_fClosed = !m_fClosed;136 }137 138 void UIGInformationElement::sltElementToggleFinish(bool fToggled)139 {140 /* Update toggle-state: */141 m_fClosed = !fToggled;142 143 /* Notify about finishing: */144 emit sigToggleElementFinished();145 }146 147 void UIGInformationElement::sltHandleAnchorClicked(const QString &strAnchor)148 {149 /* Current anchor role: */150 const QString strRole = strAnchor.section(',', 0, 0);151 const QString strData = strAnchor.section(',', 1);152 153 /* Handle known anchor roles: */154 if ( strRole == "#mount" // Optical and floppy attachments..155 || strRole == "#attach" // Hard-drive attachments..156 )157 {158 /* Prepare storage-menu: */159 UIMenu menu;160 menu.setShowToolTip(true);161 162 /* Storage-controller name: */163 QString strControllerName = strData.section(',', 0, 0);164 /* Storage-slot: */165 StorageSlot storageSlot = gpConverter->fromString<StorageSlot>(strData.section(',', 1));166 167 /* Fill storage-menu: */168 vboxGlobal().prepareStorageMenu(menu, this, SLOT(sltMountStorageMedium()),169 machine(), strControllerName, storageSlot);170 171 /* Exec menu: */172 menu.exec(QCursor::pos());173 }174 }175 176 void UIGInformationElement::sltMountStorageMedium()177 {178 /* Sender action: */179 QAction *pAction = qobject_cast<QAction*>(sender());180 AssertMsgReturnVoid(pAction, ("This slot should only be called by menu action!\n"));181 182 /* Current mount-target: */183 const UIMediumTarget target = pAction->data().value<UIMediumTarget>();184 185 /* Update current machine mount-target: */186 vboxGlobal().updateMachineStorage(machine(), target);187 76 } 188 77 … … 215 104 /* Update minimum-header-width: */ 216 105 m_iMinimumHeaderWidth = m_pixmapSize.width() + 217 iSpacing + m_nameSize.width() + 218 iSpacing + m_buttonSize.width(); 106 iSpacing + m_nameSize.width(); 219 107 } 220 108 … … 223 111 /* Update minimum-header-height: */ 224 112 m_iMinimumHeaderHeight = qMax(m_pixmapSize.height(), m_nameSize.height()); 225 m_iMinimumHeaderHeight = qMax(m_iMinimumHeaderHeight, m_buttonSize.height());226 113 } 227 114 … … 305 192 306 193 /* Header height: */ 307 iMinimumHeightHint += m_iMinimumHeaderHeight; 308 309 /* Element is opened? */ 310 if (!fClosed) 311 { 312 /* Add text height: */ 313 if (!m_pTextPane->isEmpty()) 314 iMinimumHeightHint += 2 * iMargin + (int)m_pTextPane->minimumSizeHint().height(); 315 } 316 317 /* Additional height during animation: */ 318 if (m_fAnimationRunning) 319 iMinimumHeightHint += m_iAdditionalHeight; 194 iMinimumHeightHint += m_iMinimumHeaderHeight + m_pTextPane->minimumSizeHint().height() + 10; 320 195 321 196 /* Return value: */ … … 325 200 int UIGInformationElement::minimumHeightHint() const 326 201 { 327 return minimumHeightHint( m_fClosed);202 return minimumHeightHint(false); 328 203 } 329 204 … … 333 208 QSize size = geometry().size().toSize(); 334 209 int iMargin = data(ElementData_Margin).toInt(); 335 336 /* Layout button: */ 337 int iButtonWidth = m_buttonSize.width(); 338 int iButtonHeight = m_buttonSize.height(); 339 int iButtonX = size.width() - 2 * iMargin - iButtonWidth; 340 int iButtonY = iButtonHeight == m_iMinimumHeaderHeight ? iMargin : 341 iMargin + (m_iMinimumHeaderHeight - iButtonHeight) / 2; 342 m_pButton->setPos(iButtonX, iButtonY); 343 344 /* If closed: */ 345 if (closed()) 346 { 347 /* Hide text-pane if still visible: */ 348 if (m_pTextPane->isVisible()) 349 m_pTextPane->hide(); 350 } 351 /* If opened: */ 352 else 353 { 354 /* Layout text-pane: */ 355 int iTextPaneX = 2 * iMargin; 356 int iTextPaneY = iMargin + m_iMinimumHeaderHeight + 2 * iMargin; 357 m_pTextPane->setPos(iTextPaneX, iTextPaneY); 358 m_pTextPane->resize(size.width() - 4 * iMargin, 359 size.height() - 4 * iMargin - m_iMinimumHeaderHeight); 360 /* Show text-pane if still invisible and animation finished: */ 361 if (!m_pTextPane->isVisible() && !isAnimationRunning()) 362 m_pTextPane->show(); 363 } 364 } 365 366 void UIGInformationElement::setAdditionalHeight(int iAdditionalHeight) 367 { 368 /* Cache new value: */ 369 m_iAdditionalHeight = iAdditionalHeight; 370 /* Update layout: */ 371 updateLayout(); 372 /* Repaint: */ 373 update(); 210 /* Layout text-pane: */ 211 int iTextPaneX = 2 * iMargin; 212 int iTextPaneY = iMargin + m_iMinimumHeaderHeight + 2 * iMargin; 213 m_pTextPane->setPos(iTextPaneX, iTextPaneY); 214 m_pTextPane->resize(size.width() - 4 * iMargin, 215 size.height() - 4 * iMargin - m_iMinimumHeaderHeight); 216 /* Show text-pane if still invisible and animation finished: */ 217 if (!m_pTextPane->isVisible()) 218 m_pTextPane->show(); 374 219 } 375 220 … … 407 252 m_nameFont.setWeight(QFont::Bold); 408 253 m_textFont = font(); 409 410 /* Create highlight machine: */411 m_pHighlightMachine = new QStateMachine(this);412 /* Create 'default' state: */413 QState *pStateDefault = new QState(m_pHighlightMachine);414 /* Create 'highlighted' state: */415 QState *pStateHighlighted = new QState(m_pHighlightMachine);416 417 /* Forward animation: */418 m_pForwardAnimation = new QPropertyAnimation(this, "animationDarkness", this);419 m_pForwardAnimation->setDuration(m_iAnimationDuration);420 m_pForwardAnimation->setStartValue(m_iDefaultDarkness);421 m_pForwardAnimation->setEndValue(m_iHighlightDarkness);422 423 /* Backward animation: */424 m_pBackwardAnimation = new QPropertyAnimation(this, "animationDarkness", this);425 m_pBackwardAnimation->setDuration(m_iAnimationDuration);426 m_pBackwardAnimation->setStartValue(m_iHighlightDarkness);427 m_pBackwardAnimation->setEndValue(m_iDefaultDarkness);428 429 /* Add state transitions: */430 QSignalTransition *pDefaultToHighlighted = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHighlighted);431 pDefaultToHighlighted->addAnimation(m_pForwardAnimation);432 QSignalTransition *pHighlightedToDefault = pStateHighlighted->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault);433 pHighlightedToDefault->addAnimation(m_pBackwardAnimation);434 435 /* Initial state is 'default': */436 m_pHighlightMachine->setInitialState(pStateDefault);437 /* Start state-machine: */438 m_pHighlightMachine->start();439 440 connect(this, SIGNAL(sigToggleElement(InformationElementType, bool)), model(), SLOT(sltToggleElements(InformationElementType, bool)));441 connect(this, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),442 model(), SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)));443 }444 445 void UIGInformationElement::prepareButton()446 {447 /* Setup toggle-button: */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()));451 connect(m_pButton, SIGNAL(sigRotationStart()), this, SLOT(sltElementToggleStart()));452 connect(m_pButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltElementToggleFinish(bool)));453 m_buttonSize = m_pButton->minimumSizeHint().toSize();454 254 } 455 255 … … 461 261 m_pTextPane->setFlag(QGraphicsItem::ItemIsSelectable); 462 262 connect(m_pTextPane, SIGNAL(sigGeometryChanged()), this, SLOT(sltUpdateGeometry())); 463 connect(m_pTextPane, SIGNAL(sigAnchorClicked(const QString&)), this, SLOT(sltHandleAnchorClicked(const QString&)));464 263 } 465 264 466 265 void UIGInformationElement::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget*) 467 266 { 468 /* Update button visibility: */469 updateButtonVisibility();470 471 /* Configure painter shape: */472 configurePainterShape(pPainter, pOption, m_iCornerRadius);473 474 267 /* Paint decorations: */ 475 268 paintDecorations(pPainter, pOption); … … 499 292 QPalette pal = palette(); 500 293 QColor buttonTextColor = pal.color(QPalette::Active, QPalette::ButtonText); 501 QColor linkTextColor = pal.color(QPalette::Active, QPalette::Link);502 294 503 295 /* Paint pixmap: */ … … 528 320 /* Text to paint: */ 529 321 m_strName, 530 /* Name hovered?*/531 m_fNameHovered ? linkTextColor :buttonTextColor);322 /* buttonTextColor: */ 323 buttonTextColor); 532 324 } 533 325 … … 541 333 int iHeaderHeight = 2 * iMargin + m_iMinimumHeaderHeight; 542 334 QRect optionRect = pOption->rect; 543 QRect fullRect = !m_fAnimationRunning ? optionRect : 544 QRect(optionRect.topLeft(), QSize(optionRect.width(), iHeaderHeight + m_iAdditionalHeight)); 335 QRect fullRect = optionRect; 545 336 int iFullHeight = fullRect.height(); 546 337 … … 574 365 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 575 366 tGradient.setColorAt(0, headerColor.darker(110)); 576 tGradient.setColorAt(1, headerColor.darker(animationDarkness()));577 367 578 368 /* Paint all the stuff: */ … … 588 378 } 589 379 590 void UIGInformationElement::hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent)591 {592 /* Update hover state: */593 if (!m_fHovered)594 {595 m_fHovered = true;596 emit sigHoverEnter();597 }598 599 /* Update name-hover state: */600 handleHoverEvent(pEvent);601 }602 603 void UIGInformationElement::hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent)604 {605 /* Update hover state: */606 if (m_fHovered)607 {608 m_fHovered = false;609 emit sigHoverLeave();610 }611 612 /* Update name-hover state: */613 handleHoverEvent(pEvent);614 }615 616 void UIGInformationElement::mousePressEvent(QGraphicsSceneMouseEvent *pEvent)617 {618 /* Only for hovered header: */619 if (!m_fNameHovered)620 return;621 622 /* Process link click: */623 pEvent->accept();624 QString strCategory;625 if (m_type >= InformationElementType_General &&626 m_type < InformationElementType_Description)627 strCategory = QString("#%1").arg(gpConverter->toInternalString(m_type));628 else if (m_type == InformationElementType_Description)629 strCategory = QString("#%1%%mTeDescription").arg(gpConverter->toInternalString(m_type));630 else if (m_type >= InformationElementType_RuntimeAttributes &&631 m_type < InformationElementType_NetworkStatistics)632 strCategory = QString("#%1").arg(gpConverter->toInternalString(m_type));633 emit sigLinkClicked(strCategory, QString(), machine().GetId());634 }635 636 void UIGInformationElement::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *pEvent)637 {638 /* Only for left-button: */639 if (pEvent->button() != Qt::LeftButton)640 return;641 642 /* Process left-button double-click: */643 emit sigToggleElement(m_type, closed());644 }645 646 void UIGInformationElement::updateButtonVisibility()647 {648 if (m_fHovered && !m_pButton->isVisible())649 m_pButton->show();650 else if (!m_fHovered && m_pButton->isVisible())651 m_pButton->hide();652 }653 654 void UIGInformationElement::handleHoverEvent(QGraphicsSceneHoverEvent *pEvent)655 {656 /* Not for 'preview' element type: */657 if (m_type == InformationElementType_Preview)658 return;659 660 /* Prepare variables: */661 int iMargin = data(ElementData_Margin).toInt();662 int iSpacing = data(ElementData_Spacing).toInt();663 int iNameHeight = m_nameSize.height();664 int iElementNameX = 2 * iMargin + m_pixmapSize.width() + iSpacing;665 int iElementNameY = iNameHeight == m_iMinimumHeaderHeight ?666 iMargin : iMargin + (m_iMinimumHeaderHeight - iNameHeight) / 2;667 668 /* Simulate hyperlink hovering: */669 QPoint point = pEvent->pos().toPoint();670 bool fNameHovered = QRect(QPoint(iElementNameX, iElementNameY), m_nameSize).contains(point);671 if ( m_pSet->configurationAccessLevel() != ConfigurationAccessLevel_Null672 && m_fNameHovered != fNameHovered)673 {674 m_fNameHovered = fNameHovered;675 updateNameHoverLink();676 }677 }678 679 void UIGInformationElement::updateNameHoverLink()680 {681 if (m_fNameHovered)682 setCursor(Qt::PointingHandCursor);683 else684 unsetCursor();685 update();686 }687 688 void UIGInformationElement::updateAnimationParameters()689 {690 /* Recalculate animation parameters: */691 int iOpenedHeight = minimumHeightHint(false);692 int iClosedHeight = minimumHeightHint(true);693 int iAdditionalHeight = iOpenedHeight - iClosedHeight;694 if (m_fClosed)695 m_iAdditionalHeight = 0;696 else697 m_iAdditionalHeight = iAdditionalHeight;698 m_pButton->setAnimationRange(0, iAdditionalHeight);699 }700 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformationElement.h
r58726 r58879 33 33 class QTextLayout; 34 34 class QStateMachine; 35 class QPropertyAnimation;36 35 37 36 /* Typedefs: */ … … 44 43 { 45 44 Q_OBJECT; 46 Q_PROPERTY(int animationDarkness READ animationDarkness WRITE setAnimationDarkness);47 Q_PROPERTY(int additionalHeight READ additionalHeight WRITE setAdditionalHeight);48 45 49 46 signals: 50 47 51 48 /* Notifiers: Hover stuff: */ 52 void sigHoverEnter();53 49 void sigHoverLeave(); 54 50 … … 56 52 void sigToggleElement(InformationElementType type, bool fToggled); 57 53 void sigToggleElementFinished(); 58 59 /* Notifier: Link-click stuff: */60 void sigLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId);61 54 62 55 public: … … 73 66 InformationElementType elementType() const { return m_type; } 74 67 75 /* API: Open/close stuff: */76 bool closed() const { return m_fClosed; }77 bool opened() const { return !m_fClosed; }78 void close(bool fAnimated = true);79 void open(bool fAnimated = true);80 81 68 /* API: Update stuff: */ 82 69 virtual void updateAppearance(); 83 70 84 /* API: Animation stuff: */85 void markAnimationFinished();86 87 71 protected slots: 88 89 /* Handlers: Toggle stuff: */90 void sltToggleButtonClicked();91 void sltElementToggleStart();92 void sltElementToggleFinish(bool fToggled);93 72 94 73 /** Handles children geometry changes. */ 95 74 void sltUpdateGeometry() { updateGeometry(); } 96 97 /** Handles children anchor clicks. */98 void sltHandleAnchorClicked(const QString &strAnchor);99 100 /** Handles mount storage medium requests. */101 void sltMountStorageMedium();102 75 103 76 protected: … … 143 116 void updateLayout(); 144 117 145 /* Helpers: Hover stuff: */146 int animationDarkness() const { return m_iAnimationDarkness; }147 void setAnimationDarkness(int iAnimationDarkness) { m_iAnimationDarkness = iAnimationDarkness; update(); }148 149 /* Helpers: Animation stuff: */150 void setAdditionalHeight(int iAdditionalHeight);151 int additionalHeight() const { return m_iAdditionalHeight; }152 UIGraphicsRotatorButton* button() const { return m_pButton; }153 bool isAnimationRunning() const { return m_fAnimationRunning; }154 155 118 private: 156 119 … … 164 127 /* Helpers: Prepare stuff: */ 165 128 void prepareElement(); 166 void prepareButton();167 129 void prepareTextPane(); 168 130 … … 172 134 void paintElementInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 173 135 void paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 174 175 /* Handlers: Mouse stuff: */176 void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent);177 void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);178 void mousePressEvent(QGraphicsSceneMouseEvent *pEvent);179 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *pEvent);180 181 /* Helpers: Mouse stuff: */182 void updateButtonVisibility();183 void handleHoverEvent(QGraphicsSceneHoverEvent *pEvent);184 void updateNameHoverLink();185 186 /* Helper: Animation stuff: */187 void updateAnimationParameters();188 136 189 137 /* Variables: */ … … 201 149 int m_iMinimumHeaderHeight; 202 150 203 /* Variables: Toggle-button stuff: */204 UIGraphicsRotatorButton *m_pButton;205 bool m_fClosed;206 int m_iAdditionalHeight;207 bool m_fAnimationRunning;208 209 151 /* Variables: Text-pane stuff: */ 210 152 UIGraphicsTextPane *m_pTextPane; 211 212 /* Variables: Hover stuff: */213 bool m_fHovered;214 bool m_fNameHovered;215 QStateMachine *m_pHighlightMachine;216 QPropertyAnimation *m_pForwardAnimation;217 QPropertyAnimation *m_pBackwardAnimation;218 int m_iAnimationDuration;219 int m_iDefaultDarkness;220 int m_iHighlightDarkness;221 int m_iAnimationDarkness;222 153 223 154 /* Friends: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformationElements.cpp
r58866 r58879 121 121 } 122 122 123 124 123 UIGInformationElementPreview::UIGInformationElementPreview(UIGInformationSet *pParent, bool fOpened) 125 124 : UIGInformationElement(pParent, InformationElementType_Preview, fOpened) … … 201 200 /* Header height: */ 202 201 iProposedHeight += minimumHeaderHeight(); 203 204 /* Element is opened? */ 205 if (!fClosed) 206 { 207 iProposedHeight += iMargin; 208 iProposedHeight += m_pPreview->minimumSizeHint().toSize().height(); 209 } 210 else 211 { 212 /* Additional height during animation: */ 213 if (button()->isAnimationRunning()) 214 iProposedHeight += additionalHeight(); 215 } 202 iProposedHeight += iMargin; 203 iProposedHeight += m_pPreview->minimumSizeHint().toSize().height(); 216 204 217 205 /* Return result: */ … … 223 211 /* Call to base-class: */ 224 212 UIGInformationElement::updateLayout(); 225 226 /* Show/hide preview: */227 if (closed() && m_pPreview->isVisible())228 m_pPreview->hide();229 if (opened() && !m_pPreview->isVisible() && !isAnimationRunning())230 m_pPreview->show();231 213 } 232 214 … … 240 222 emit sigBuildDone(); 241 223 } 242 243 224 244 225 void UIGInformationUpdateTaskGeneral::run() … … 288 269 } 289 270 290 291 271 void UIGInformationUpdateTaskSystem::run() 292 272 { … … 364 344 setProperty("table", QVariant::fromValue(table)); 365 345 } 366 367 346 368 347 void UIGInformationUpdateTaskDisplay::run() … … 467 446 setProperty("table", QVariant::fromValue(table)); 468 447 } 469 470 448 471 449 void UIGInformationUpdateTaskStorage::run() … … 548 526 } 549 527 550 551 528 void UIGInformationUpdateTaskAudio::run() 552 529 { … … 584 561 setProperty("table", QVariant::fromValue(table)); 585 562 } 586 587 563 588 564 void UIGInformationUpdateTaskNetwork::run() … … 681 657 } 682 658 683 684 659 void UIGInformationUpdateTaskSerial::run() 685 660 { … … 724 699 } 725 700 726 727 701 #ifdef VBOX_WITH_PARALLEL_PORTS 728 702 void UIGInformationUpdateTaskParallel::run() … … 762 736 } 763 737 #endif /* VBOX_WITH_PARALLEL_PORTS */ 764 765 738 766 739 void UIGInformationUpdateTaskUSB::run() … … 813 786 } 814 787 815 816 788 void UIGInformationUpdateTaskSF::run() 817 789 { … … 840 812 setProperty("table", QVariant::fromValue(table)); 841 813 } 842 843 814 844 815 void UIGInformationUpdateTaskUI::run() … … 930 901 } 931 902 932 933 903 void UIGInformationUpdateTaskDescription::run() 934 904 { … … 960 930 void UIGInformationUpdateTaskRuntimeAttributes::run() 961 931 { 962 963 } 964 932 } 933 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformationGroup.cpp
r58726 r58879 32 32 33 33 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 34 35 34 36 35 UIGInformationGroup::UIGInformationGroup(QGraphicsScene *pParent) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformationModel.cpp
r58855 r58879 40 40 , m_pScene(0) 41 41 , m_pRoot(0) 42 , m_pAnimationCallback(0)43 42 { 44 43 /* Prepare scene: */ … … 121 120 } 122 121 123 void UIGInformationModel::sltToggleElements(InformationElementType type, bool fToggled)124 {125 /* Make sure it is not started yet: */126 if (m_pAnimationCallback)127 return;128 129 /* Prepare/configure animation callback: */130 m_pAnimationCallback = new UIGInformationElementAnimationCallback(this, type, fToggled);131 connect(m_pAnimationCallback, SIGNAL(sigAllAnimationFinished(InformationElementType, bool)),132 this, SLOT(sltToggleAnimationFinished(InformationElementType, bool)), Qt::QueuedConnection);133 /* For each the set of the group: */134 foreach (UIGInformationItem *pSetItem, m_pRoot->items())135 {136 /* For each the element of the set: */137 foreach (UIGInformationItem *pElementItem, pSetItem->items())138 {139 /* Get each element: */140 UIGInformationElement *pElement = pElementItem->toElement();141 /* Check if this element is of required type: */142 if (pElement->elementType() == type)143 {144 if (fToggled && pElement->closed())145 {146 m_pAnimationCallback->addNotifier(pElement);147 pElement->open();148 }149 else if (!fToggled && pElement->opened())150 {151 m_pAnimationCallback->addNotifier(pElement);152 pElement->close();153 }154 }155 }156 }157 /* Update layout: */158 updateLayout();159 }160 161 void UIGInformationModel::sltToggleAnimationFinished(InformationElementType type, bool fToggled)162 {163 /* Cleanup animation callback: */164 delete m_pAnimationCallback;165 m_pAnimationCallback = 0;166 167 /* Mark animation finished: */168 foreach (UIGInformationItem *pSetItem, m_pRoot->items())169 {170 foreach (UIGInformationItem *pElementItem, pSetItem->items())171 {172 UIGInformationElement *pElement = pElementItem->toElement();173 if (pElement->elementType() == type)174 pElement->markAnimationFinished();175 }176 }177 /* Update layout: */178 updateLayout();179 180 /* Update element open/close status: */181 if (m_settings.contains(type))182 m_settings[type] = fToggled;183 }184 185 void UIGInformationModel::sltElementTypeToggled()186 {187 /* Which item was toggled? */188 QAction *pAction = qobject_cast<QAction*>(sender());189 InformationElementType type = pAction->data().value<InformationElementType>();190 191 /* Toggle element visibility status: */192 if (m_settings.contains(type))193 m_settings.remove(type);194 else195 m_settings[type] = true;196 197 /* Rebuild group: */198 m_pRoot->rebuildGroup();199 }200 201 void UIGInformationModel::sltHandleSlidingStarted()202 {203 m_pRoot->stopBuildingGroup();204 }205 206 void UIGInformationModel::sltHandleToggleStarted()207 {208 m_pRoot->stopBuildingGroup();209 }210 211 void UIGInformationModel::sltHandleToggleFinished()212 {213 m_pRoot->rebuildGroup();214 }215 216 122 QVariant UIGInformationModel::data(int iKey) const 217 123 { … … 227 133 { 228 134 m_pScene = new QGraphicsScene(this); 229 m_pScene->installEventFilter(this);230 135 } 231 136 … … 272 177 } 273 178 274 bool UIGInformationModel::eventFilter(QObject *pObject, QEvent *pEvent)275 {276 /* Ignore if no scene object: */277 if (pObject != scene())278 return QObject::eventFilter(pObject, pEvent);279 280 /* Ignore if no context-menu event: */281 if (pEvent->type() != QEvent::GraphicsSceneContextMenu)282 return QObject::eventFilter(pObject, pEvent);283 284 /* Process context menu event: */285 return processContextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent*>(pEvent));286 }287 288 bool UIGInformationModel::processContextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent)289 {290 /* Pass preview context menu instead: */291 if (QGraphicsItem *pItem = itemAt(pEvent->scenePos()))292 if (pItem->type() == UIGInformationItemType_Preview)293 return false;294 295 /* Prepare context-menu: */296 QMenu contextMenu;297 /* Enumerate elements settings: */298 for (int iType = InformationElementType_General; iType <= InformationElementType_RuntimeAttributes; ++iType)299 {300 InformationElementType currentElementType = (InformationElementType)iType;301 QAction *pAction = contextMenu.addAction(gpConverter->toString(currentElementType), this, SLOT(sltElementTypeToggled()));302 pAction->setCheckable(true);303 pAction->setChecked(m_settings.contains(currentElementType));304 pAction->setData(QVariant::fromValue(currentElementType));305 }306 /* Exec context-menu: */307 contextMenu.exec(pEvent->screenPos());308 309 /* Filter: */310 return true;311 }312 313 UIGInformationElementAnimationCallback::UIGInformationElementAnimationCallback(QObject *pParent, InformationElementType type, bool fToggled)314 : QObject(pParent)315 , m_type(type)316 , m_fToggled(fToggled)317 {318 }319 320 void UIGInformationElementAnimationCallback::addNotifier(UIGInformationItem *pItem)321 {322 /* Connect notifier: */323 connect(pItem, SIGNAL(sigToggleElementFinished()), this, SLOT(sltAnimationFinished()));324 /* Remember notifier: */325 m_notifiers << pItem;326 }327 328 void UIGInformationElementAnimationCallback::sltAnimationFinished()329 {330 /* Determine notifier: */331 UIGInformationItem *pItem = qobject_cast<UIGInformationItem*>(sender());332 /* Disconnect notifier: */333 disconnect(pItem, SIGNAL(sigToggleElementFinished()), this, SLOT(sltAnimationFinished()));334 /* Remove notifier: */335 m_notifiers.removeAll(pItem);336 /* Check if we finished: */337 if (m_notifiers.isEmpty())338 emit sigAllAnimationFinished(m_type, m_fToggled);339 }340 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformationModel.h
r58726 r58879 38 38 class UIGInformationGroup; 39 39 class UIVMItem; 40 class UIGInformationElementAnimationCallback;40 //class UIGInformationElementAnimationCallback; 41 41 class UIGInformationItem; 42 42 … … 53 53 54 54 /* Notifier: Link processing stuff: */ 55 void sigLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId);55 //void sigLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId); 56 56 57 57 public: … … 82 82 void sltHandleViewResize(); 83 83 84 /* Handlers: Element-items stuff: */85 void sltToggleElements(InformationElementType type, bool fToggled);86 void sltToggleAnimationFinished(InformationElementType type, bool fToggled);87 void sltElementTypeToggled();88 89 /* Handlers: Chooser stuff: */90 void sltHandleSlidingStarted();91 void sltHandleToggleStarted();92 void sltHandleToggleFinished();93 94 84 private: 95 85 … … 115 105 116 106 /* Handler: Event-filter: */ 117 bool eventFilter(QObject *pObject, QEvent *pEvent); 118 119 /* Handler: Context-menu stuff: */ 120 bool processContextMenuEvent(QGraphicsSceneContextMenuEvent *pEvent); 107 //bool eventFilter(QObject *pObject, QEvent *pEvent); 121 108 122 109 /* Variables: */ 123 110 QGraphicsScene *m_pScene; 124 111 UIGInformationGroup *m_pRoot; 125 UIGInformationElementAnimationCallback *m_pAnimationCallback;112 //UIGInformationElementAnimationCallback *m_pAnimationCallback; 126 113 /** Holds the details settings. */ 127 114 QMap<InformationElementType, bool> m_settings; 128 115 }; 129 116 130 /* Details-element animation callback: */131 class UIGInformationElementAnimationCallback : public QObject132 {133 Q_OBJECT;134 135 signals:136 137 /* Notifier: Complete stuff: */138 void sigAllAnimationFinished(InformationElementType type, bool fToggled);139 140 public:141 142 /* Constructor: */143 UIGInformationElementAnimationCallback(QObject *pParent, InformationElementType type, bool fToggled);144 145 /* API: Notifiers stuff: */146 void addNotifier(UIGInformationItem *pItem);147 148 private slots:149 150 /* Handler: Progress stuff: */151 void sltAnimationFinished();152 153 private:154 155 /* Variables: */156 QList<UIGInformationItem*> m_notifiers;157 InformationElementType m_type;158 bool m_fToggled;159 };160 161 117 #endif /* __UIGInformationModel_h__ */ 162 118 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGInformationSet.cpp
r58726 r58879 34 34 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 35 35 36 37 36 UIGInformationSet::UIGInformationSet(UIGInformationItem *pParent) 38 37 : UIGInformationItem(pParent) … … 128 127 bool fVisible = m_settings.contains(elementType); 129 128 /* Should the element be opened? */ 130 bool fOpen = fVisible && m_settings[elementType];129 //bool fOpen = fVisible && m_settings[elementType]; 131 130 132 131 /* Check if element is present already: */ 133 132 UIGInformationElement *pElement = element(elementType); 134 if (pElement && fOpen)135 pElement->open(false);133 //if (pElement && fOpen) 134 //pElement->open(false); 136 135 /* Create element if necessary: */ 137 136 bool fJustCreated = false; … … 139 138 { 140 139 fJustCreated = true; 141 pElement = createElement(elementType, fOpen);140 pElement = createElement(elementType, true); 142 141 } 143 142 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGRuntimeInformation.cpp
r58726 r58879 103 103 connect(m_pDetailsModel, SIGNAL(sigRootItemMinimumHeightHintChanged(int)), 104 104 m_pDetailsView, SLOT(sltMinimumHeightHintChanged(int))); 105 connect(m_pDetailsModel, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),106 this, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)));107 connect(this, SIGNAL(sigSlidingStarted()),108 m_pDetailsModel, SLOT(sltHandleSlidingStarted()));109 connect(this, SIGNAL(sigToggleStarted()),110 m_pDetailsModel, SLOT(sltHandleToggleStarted()));111 connect(this, SIGNAL(sigToggleFinished()),112 m_pDetailsModel, SLOT(sltHandleToggleFinished()));113 105 114 106 /* Setup details-view connections: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIGRuntimeInformation.h
r58690 r58879 36 36 37 37 /* Notifier: Link processing stuff: */ 38 void sigLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId);38 //void sigLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId); 39 39 40 40 /* Notifier: Sliding stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/UIVMInformationDialog.h
r58616 r58879 158 158 159 159 #endif /* !___UIVMInformationDialog_h___ */ 160
Note:
See TracChangeset
for help on using the changeset viewer.