- Timestamp:
- Aug 8, 2012 11:25:47 AM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserHandlerMouse.cpp
r42632 r42678 72 72 pClickedItem = pMachineItem; 73 73 /* If we had clicked one of the required item types: */ 74 if (pClickedItem && pClickedItem->parentItem())74 if (pClickedItem && !pClickedItem->isRoot()) 75 75 { 76 76 /* Old selection list: */ … … 132 132 { 133 133 /* For non-root items: */ 134 if ( pClickedItem->parentItem())134 if (!pClickedItem->isRoot()) 135 135 { 136 136 /* Is clicked item in selection list: */ … … 177 177 if (iMouseDoubleClickX < iGroupItemWidth / 2) 178 178 { 179 /* Do not allow for unhovered root: */ 180 if (pGroupItem->isRoot() && !pGroupItem->isHovered()) 181 return false; 179 182 /* Unindent root if possible: */ 180 183 if (model()->root() != model()->mainRoot()) … … 186 189 else 187 190 { 191 /* Do not allow for root: */ 192 if (pGroupItem->isRoot()) 193 return false; 188 194 /* Indent root with group item: */ 189 195 pGroupItem->setHovered(false); … … 193 199 return true; 194 200 } 201 /* Or a machine one? */ 202 else if (pItemUnderMouse->type() == UIGChooserItemType_Machine) 203 { 204 /* Activate machine item: */ 205 model()->activate(); 206 } 207 #if 0 195 208 /* Or a machine one? */ 196 209 else if (UIGChooserItemMachine *pMachineItem = qgraphicsitem_cast<UIGChooserItemMachine*>(pItemUnderMouse)) … … 217 230 return true; 218 231 } 232 #endif 219 233 break; 220 234 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.cpp
r42593 r42678 53 53 setFocusPolicy(Qt::NoFocus); 54 54 setFlag(QGraphicsItem::ItemIsSelectable, false); 55 setAcceptHoverEvents(!isRoot()); 55 56 56 57 /* Non-root item? */ 57 58 if (!isRoot()) 58 59 { 59 /* Non-root item setup: */60 setAcceptHoverEvents(true);61 62 60 /* Create state machine: */ 63 61 m_pHighlightMachine = new QStateMachine(this); … … 133 131 { 134 132 m_fRoot = fRoot; 135 setAcceptHoverEvents(!m_fRoot);136 133 } 137 134 … … 139 136 { 140 137 return m_fRoot; 138 } 139 140 bool UIGChooserItem::isHovered() const 141 { 142 return m_fHovered; 143 } 144 145 void UIGChooserItem::setHovered(bool fHovered) 146 { 147 m_fHovered = fHovered; 148 if (m_fHovered) 149 emit sigHoverEnter(); 150 else 151 emit sigHoverLeave(); 141 152 } 142 153 … … 282 293 QPainterPath roundedPath; 283 294 roundedPath.addRoundedRect(pOption->rect, iRadius, iRadius); 284 pPainter->setRenderHint(QPainter::Antialiasing);285 295 pPainter->setClipPath(roundedPath); 286 296 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.h
r42632 r42678 82 82 void setRoot(bool fRoot); 83 83 bool isRoot() const; 84 bool isHovered() const { return m_fHovered; }85 void setHovered(bool fHovered) { m_fHovered = fHovered; }84 bool isHovered() const; 85 void setHovered(bool fHovered); 86 86 87 87 /* API: Children stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r42630 r42678 39 39 : UIGChooserItem(0) 40 40 , m_fClosed(false) 41 , m_pButton(0) 41 , m_pToggleButton(0) 42 , m_pEnterButton(0) 43 , m_pExitButton(0) 42 44 , m_pNameEditorWidget(0) 43 45 , m_pNameEditor(0) 44 46 , m_iAdditionalHeight(0) 45 47 , m_iCornerRadius(10) 46 { 48 , m_fMainRoot(true) 49 { 50 /* Prepare: */ 51 prepare(); 52 47 53 /* Add item to the scene: */ 48 54 if (pScene) … … 51 57 52 58 UIGChooserItemGroup::UIGChooserItemGroup(QGraphicsScene *pScene, 53 UIGChooserItemGroup *pCopyFrom) 59 UIGChooserItemGroup *pCopyFrom, 60 bool fMainRoot) 54 61 : UIGChooserItem(0) 55 62 , m_strName(pCopyFrom->name()) 56 63 , m_fClosed(pCopyFrom->closed()) 57 , m_pButton(0) 64 , m_pToggleButton(0) 65 , m_pEnterButton(0) 66 , m_pExitButton(0) 58 67 , m_pNameEditorWidget(0) 59 68 , m_pNameEditor(0) 60 69 , m_iAdditionalHeight(0) 61 70 , m_iCornerRadius(10) 62 { 71 , m_fMainRoot(fMainRoot) 72 { 73 /* Prepare: */ 74 prepare(); 75 63 76 /* Add item to the scene: */ 64 77 if (pScene) … … 76 89 , m_strName(strName) 77 90 , m_fClosed(!fOpened) 78 , m_pButton(0) 91 , m_pToggleButton(0) 92 , m_pEnterButton(0) 93 , m_pExitButton(0) 79 94 , m_pNameEditorWidget(0) 80 95 , m_pNameEditor(0) 81 96 , m_iAdditionalHeight(0) 82 97 , m_iCornerRadius(10) 98 , m_fMainRoot(false) 83 99 { 84 100 /* Prepare: */ … … 97 113 , m_strName(pCopyFrom->name()) 98 114 , m_fClosed(pCopyFrom->closed()) 99 , m_pButton(0) 115 , m_pToggleButton(0) 116 , m_pEnterButton(0) 117 , m_pExitButton(0) 100 118 , m_pNameEditorWidget(0) 101 119 , m_pNameEditor(0) 102 120 , m_iAdditionalHeight(0) 103 121 , m_iCornerRadius(10) 122 , m_fMainRoot(false) 104 123 { 105 124 /* Prepare: */ … … 158 177 { 159 178 AssertMsg(parentItem(), ("Can't close root-item!")); 160 m_p Button->setToggled(false ,fAnimated);179 m_pToggleButton->setToggled(false ,fAnimated); 161 180 } 162 181 … … 164 183 { 165 184 AssertMsg(parentItem(), ("Can't open root-item!")); 166 m_p Button->setToggled(true, fAnimated);185 m_pToggleButton->setToggled(true, fAnimated); 167 186 } 168 187 … … 244 263 } 245 264 265 void UIGChooserItemGroup::sltIndentRoot() 266 { 267 setHovered(false); 268 model()->indentRoot(this); 269 } 270 271 void UIGChooserItemGroup::sltUnindentRoot() 272 { 273 setHovered(false); 274 model()->unindentRoot(); 275 } 276 246 277 QVariant UIGChooserItemGroup::data(int iKey) const 247 278 { … … 250 281 { 251 282 /* Layout hints: */ 252 case GroupItemData_HorizonalMargin: return isRoot() ? 1 :8;253 case GroupItemData_VerticalMargin: return isRoot() ? 1 :5;254 case GroupItemData_MajorSpacing: return isRoot() ? 0 :10;255 case GroupItemData_MinorSpacing: return 0;283 case GroupItemData_HorizonalMargin: return 8; 284 case GroupItemData_VerticalMargin: return 5; 285 case GroupItemData_MajorSpacing: return 10; 286 case GroupItemData_MinorSpacing: return 3; 256 287 /* Pixmaps: */ 257 case GroupItemData_ButtonPixmap: return UIIconPool::iconSet(":/arrow_right_10px.png"); 288 case GroupItemData_ToggleButtonPixmap: return UIIconPool::iconSet(":/arrow_right_10px.png"); 289 case GroupItemData_EnterButtonPixmap: return UIIconPool::iconSet(":/start_16px.png"); 258 290 case GroupItemData_GroupPixmap: return UIIconPool::iconSet(":/nw_16px.png"); 259 291 case GroupItemData_MachinePixmap: return UIIconPool::iconSet(":/machine_16px.png"); … … 275 307 /* Prepare variables: */ 276 308 int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt(); 277 int iButtonWidth = data(GroupItemData_ButtonSize).toSize().width(); 278 int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt(); 309 int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt(); 310 int iToggleButtonWidth = data(GroupItemData_ToggleButtonSize).toSizeF().width(); 311 int iEnterButtonWidth = data(GroupItemData_EnterButtonSize).toSizeF().width(); 312 int iExitButtonWidth = data(GroupItemData_ExitButtonSize).toSizeF().width(); 279 313 int iGroupPixmapWidth = data(GroupItemData_GroupPixmapSize).toSize().width(); 280 314 int iMachinePixmapWidth = data(GroupItemData_MachinePixmapSize).toSize().width(); 281 315 int iGroupCountTextWidth = data(GroupItemData_GroupCountTextSize).toSize().width(); 282 316 int iMachineCountTextWidth = data(GroupItemData_MachineCountTextSize).toSize().width(); 283 int iMaximumWidth = (int)geometry().width() - iHorizontalMargin - 284 iButtonWidth - iMinorSpacing - 285 iHorizontalMargin - 286 iGroupPixmapWidth - iMinorSpacing - 287 iMachinePixmapWidth - iMinorSpacing - 288 iGroupCountTextWidth - iMinorSpacing - 289 iMachineCountTextWidth; 290 QString strCompressedName = compressText(data(GroupItemData_NameFont).value<QFont>(), 291 m_strName, iMaximumWidth); 292 return strCompressedName; 293 } 294 case GroupItemData_GroupCountText: return QString::number(m_groupItems.size()); 295 case GroupItemData_MachineCountText: return QString::number(m_machineItems.size()); 317 int iMaximumWidth = (int)geometry().width(); 318 QString strGroupCountText = data(GroupItemData_GroupCountText).toString(); 319 QString strMachineCountText = data(GroupItemData_MachineCountText).toString(); 320 321 /* Calculate name width: */ 322 iMaximumWidth -= 2 * iHorizontalMargin; 323 if (isRoot()) 324 iMaximumWidth -= (iExitButtonWidth + iMajorSpacing); 325 else 326 { 327 iMaximumWidth -= (iToggleButtonWidth + iMajorSpacing); 328 if (isHovered()) 329 iMaximumWidth -= (iEnterButtonWidth + iMajorSpacing); 330 } 331 if (isHovered() && !strGroupCountText.isEmpty()) 332 iMaximumWidth -= (iGroupPixmapWidth + iGroupCountTextWidth); 333 if (isHovered() && !strMachineCountText.isEmpty()) 334 iMaximumWidth -= (iMachinePixmapWidth + iMachineCountTextWidth); 335 return compressText(data(GroupItemData_NameFont).value<QFont>(), m_strName, iMaximumWidth); 336 } 337 case GroupItemData_GroupCountText: return m_groupItems.isEmpty() ? QString() : QString::number(m_groupItems.size()); 338 case GroupItemData_MachineCountText: return m_machineItems.isEmpty() ? QString() : QString::number(m_machineItems.size()); 296 339 /* Sizes: */ 297 case GroupItemData_ButtonSize: return m_pButton ? m_pButton->minimumSizeHint() : QSizeF(0, 0); 340 case GroupItemData_ToggleButtonSize: return m_pToggleButton ? m_pToggleButton->minimumSizeHint() : QSizeF(0, 0); 341 case GroupItemData_EnterButtonSize: return m_pEnterButton ? m_pEnterButton->minimumSizeHint() : QSizeF(0, 0); 342 case GroupItemData_ExitButtonSize: return m_pExitButton ? m_pExitButton->minimumSizeHint() : QSizeF(0, 0); 298 343 case GroupItemData_MinimumNameSize: 299 344 { 300 if (is Root())345 if (isMainRoot()) 301 346 return QSizeF(0, 0); 302 347 QFont font = data(GroupItemData_NameFont).value<QFont>(); … … 308 353 case GroupItemData_NameSize: 309 354 { 310 if (is Root())355 if (isMainRoot()) 311 356 return QSizeF(0, 0); 312 357 QFontMetrics fm(data(GroupItemData_NameFont).value<QFont>()); … … 320 365 } 321 366 case GroupItemData_GroupPixmapSize: 322 return is Root() ? QSizeF(0, 0) : data(GroupItemData_GroupPixmap).value<QIcon>().availableSizes().at(0);367 return isMainRoot() ? QSizeF(0, 0) : data(GroupItemData_GroupPixmap).value<QIcon>().availableSizes().at(0); 323 368 case GroupItemData_MachinePixmapSize: 324 return is Root() ? QSizeF(0, 0) : data(GroupItemData_MachinePixmap).value<QIcon>().availableSizes().at(0);369 return isMainRoot() ? QSizeF(0, 0) : data(GroupItemData_MachinePixmap).value<QIcon>().availableSizes().at(0); 325 370 case GroupItemData_GroupCountTextSize: 326 371 { 327 if (is Root())372 if (isMainRoot()) 328 373 return QSizeF(0, 0); 329 374 QFontMetrics fm(data(GroupItemData_InfoFont).value<QFont>()); … … 332 377 case GroupItemData_MachineCountTextSize: 333 378 { 334 if (is Root())379 if (isMainRoot()) 335 380 return QSizeF(0, 0); 336 381 QFontMetrics fm(data(GroupItemData_InfoFont).value<QFont>()); … … 341 386 /* Prepare variables: */ 342 387 int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt(); 343 int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt(); 344 QSize buttonSize = data(GroupItemData_ButtonSize).toSize(); 388 QSize toggleButtonSize = data(GroupItemData_ToggleButtonSize).toSize(); 389 QSize enterButtonSize = data(GroupItemData_EnterButtonSize).toSize(); 390 QSize exitButtonSize = data(GroupItemData_ExitButtonSize).toSize(); 345 391 QSize minimumNameSize = data(GroupItemData_MinimumNameSize).toSize(); 346 392 QSize groupPixmapSize = data(GroupItemData_GroupPixmapSize).toSize(); … … 350 396 351 397 /* Calculate minimum width: */ 352 int iGroupItemHeaderWidth = /* Button width: */ 353 buttonSize.width() + 354 /* Spacing between button and name: */ 355 iMajorSpacing + 356 /* Some hardcoded magic: */ 357 1 /* frame width from Qt sources */ + 358 2 /* internal QLineEdit margin from Qt sources */ + 359 1 /* internal QLineEdit align shifting from Qt sources */ + 360 /* Minimum name width: */ 361 minimumNameSize.width() + 362 /* Spacing between name and info: */ 363 iMajorSpacing + 364 /* Group stuff width: */ 365 groupPixmapSize.width() + iMinorSpacing + 366 groupCountTextSize.width() + iMinorSpacing + 367 /* Machine stuff width: */ 368 machinePixmapSize.width() + iMinorSpacing + 369 machineCountTextSize.width(); 398 int iGroupItemHeaderWidth = 0; 399 if (isRoot() && !isMainRoot()) 400 iGroupItemHeaderWidth += exitButtonSize.width(); 401 if (!isRoot()) 402 iGroupItemHeaderWidth += toggleButtonSize.width(); 403 if (!isMainRoot()) 404 iGroupItemHeaderWidth += /* Spacing between button and name: */ 405 iMajorSpacing + 406 minimumNameSize.width() + 407 /* Spacing between name and info: */ 408 iMajorSpacing + 409 /* Group stuff width: */ 410 groupPixmapSize.width() + 411 groupCountTextSize.width() + 412 /* Machine stuff width: */ 413 machinePixmapSize.width() + 414 machineCountTextSize.width(); 415 if (!isRoot()) 416 iGroupItemHeaderWidth += enterButtonSize.width(); 370 417 371 418 /* Search for maximum height: */ 372 419 QList<int> heights; 373 heights << buttonSize.height() 374 << minimumNameSize.height() 375 << groupPixmapSize.height() << machinePixmapSize.height() 376 << groupCountTextSize.height() << machineCountTextSize.height(); 420 if (isRoot() && !isMainRoot()) 421 heights << exitButtonSize.height(); 422 if (!isRoot()) 423 heights << toggleButtonSize.height(); 424 if (!isMainRoot()) 425 heights << minimumNameSize.height() 426 << groupPixmapSize.height() << machinePixmapSize.height() 427 << groupCountTextSize.height() << machineCountTextSize.height(); 428 if (!isRoot()) 429 heights << enterButtonSize.height(); 377 430 int iGroupItemHeaderHeight = 0; 378 431 foreach (int iHeight, heights) … … 426 479 case UIGChooserItemType_Group: 427 480 { 481 AssertMsg(!m_groupItems.contains(pItem), ("Group item already added!")); 428 482 if (iPosition < 0 || iPosition >= m_groupItems.size()) 429 483 m_groupItems.append(pItem); … … 435 489 case UIGChooserItemType_Machine: 436 490 { 491 AssertMsg(!m_machineItems.contains(pItem), ("Machine item already added!")); 437 492 if (iPosition < 0 || iPosition >= m_machineItems.size()) 438 493 m_machineItems.append(pItem); … … 457 512 case UIGChooserItemType_Group: 458 513 { 514 AssertMsg(m_groupItems.contains(pItem), ("Group item was not found!")); 459 515 scene()->removeItem(pItem); 460 516 m_groupItems.removeAt(m_groupItems.indexOf(pItem)); … … 463 519 case UIGChooserItemType_Machine: 464 520 { 521 AssertMsg(m_machineItems.contains(pItem), ("Machine item was not found!")); 465 522 scene()->removeItem(pItem); 466 523 m_machineItems.removeAt(m_machineItems.indexOf(pItem)); … … 524 581 case UIGChooserItemType_Group: 525 582 { 526 while (!m_groupItems.isEmpty()) { delete m_groupItems. takeLast(); }583 while (!m_groupItems.isEmpty()) { delete m_groupItems.last(); } 527 584 AssertMsg(m_groupItems.isEmpty(), ("Group items cleanup failed!")); 528 585 break; … … 530 587 case UIGChooserItemType_Machine: 531 588 { 532 while (!m_machineItems.isEmpty()) { delete m_machineItems. takeLast(); }589 while (!m_machineItems.isEmpty()) { delete m_machineItems.last(); } 533 590 AssertMsg(m_machineItems.isEmpty(), ("Machine items cleanup failed!")); 534 591 break; … … 551 608 int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt(); 552 609 int iVerticalMargin = data(GroupItemData_VerticalMargin).toInt(); 610 int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt(); 553 611 int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt(); 554 int iButtonHeight = data(GroupItemData_ButtonSize).toSize().height();555 int iButtonWidth = data(GroupItemData_ButtonSize).toSize().width();556 612 int iFullHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height(); 557 613 int iPreviousVerticalIndent = 0; … … 560 616 if (isRoot()) 561 617 { 562 /* Hide button: */ 563 if (m_pButton && m_pButton->isVisible()) 564 m_pButton->hide(); 565 566 /* Hide name-editor: */ 567 if (m_pNameEditor && m_pNameEditor->isVisible()) 568 m_pNameEditor->hide(); 569 570 /* Prepare body indent: */ 571 iPreviousVerticalIndent = iVerticalMargin; 618 /* Hide widgets: */ 619 if (m_pToggleButton) 620 m_pToggleButton->hide(); 621 if (m_pEnterButton) 622 m_pEnterButton->hide(); 623 624 if (!isMainRoot()) 625 { 626 /* Exit-button? */ 627 if (m_pExitButton) 628 { 629 /* Show exit-button: */ 630 m_pExitButton->show(); 631 632 /* Prepare variables: */ 633 int iExitButtonHeight = data(GroupItemData_ExitButtonSize).toSizeF().height(); 634 635 /* Layout exit-button: */ 636 int iExitButtonX = iHorizontalMargin; 637 int iExitButtonY = iExitButtonHeight == iFullHeaderHeight ? iVerticalMargin : 638 iVerticalMargin + (iFullHeaderHeight - iExitButtonHeight) / 2; 639 m_pExitButton->setPos(iExitButtonX, iExitButtonY); 640 } 641 642 /* Prepare body indent: */ 643 iPreviousVerticalIndent = iVerticalMargin + iFullHeaderHeight + iVerticalMargin + iMinorSpacing; 644 } 645 else 646 { 647 /* Prepare body indent: */ 648 iPreviousVerticalIndent = 2; 649 } 572 650 } 573 651 /* Header (non-root item): */ 574 652 else 575 653 { 576 /* Show button: */ 577 if (!m_pButton->isVisible()) 578 m_pButton->show(); 579 /* Layout button: */ 580 int iButtonX = iHorizontalMargin; 581 int iButtonY = iButtonHeight == iFullHeaderHeight ? iVerticalMargin : 582 iVerticalMargin + (iFullHeaderHeight - iButtonHeight) / 2; 583 m_pButton->setPos(iButtonX, iButtonY); 654 /* Hide exit-button: */ 655 if (m_pExitButton) 656 m_pExitButton->hide(); 657 /* Show toggle-button: */ 658 if (m_pToggleButton) 659 m_pToggleButton->show(); 660 661 /* Prepare variables: */ 662 int iFullWidth = geometry().width(); 663 QSizeF toggleButtonSize = data(GroupItemData_ToggleButtonSize).toSizeF().toSize(); 664 int iToggleButtonWidth = toggleButtonSize.width(); 665 int iButtonHeight = toggleButtonSize.height(); 666 QSizeF enterButtonSize = data(GroupItemData_EnterButtonSize).toSizeF().toSize(); 667 int iEnterButtonWidth = enterButtonSize.width(); 668 int iEnterButtonHeight = enterButtonSize.height(); 669 670 /* Layout toggle-button: */ 671 int iToggleButtonX = iHorizontalMargin; 672 int iToggleButtonY = iButtonHeight == iFullHeaderHeight ? iVerticalMargin : 673 iVerticalMargin + (iFullHeaderHeight - iButtonHeight) / 2; 674 m_pToggleButton->setPos(iToggleButtonX, iToggleButtonY); 675 676 /* Layout enter-button: */ 677 int iEnterButtonX = iFullWidth - iHorizontalMargin - iEnterButtonWidth; 678 int iEnterButtonY = iEnterButtonHeight == iFullHeaderHeight ? iVerticalMargin : 679 iVerticalMargin + (iFullHeaderHeight - iEnterButtonHeight) / 2; 680 m_pEnterButton->setPos(iEnterButtonX, iEnterButtonY); 584 681 585 682 /* Layout name-editor: */ 586 int iNameEditorX = iHorizontalMargin + i ButtonWidth + iMinorSpacing;683 int iNameEditorX = iHorizontalMargin + iToggleButtonWidth + iMajorSpacing; 587 684 int iNameEditorY = 1; 588 685 m_pNameEditor->setPos(iNameEditorX, iNameEditorY); … … 598 695 /* Hide all the items: */ 599 696 foreach (UIGChooserItem *pItem, items()) 600 if (pItem->isVisible()) 601 pItem->hide(); 697 pItem->hide(); 602 698 } 603 699 /* Body for opened group: */ … … 605 701 { 606 702 /* Prepare variables: */ 607 int i MinorSpacing = data(GroupItemData_MinorSpacing).toInt();703 int iHorizontalIndent = isRoot() ? 1 : iHorizontalMargin; 608 704 QRect geo = geometry().toRect(); 609 705 int iX = geo.x(); 610 706 int iY = geo.y(); 611 707 int iWidth = geo.width(); 708 612 709 /* Layout all the items: */ 613 710 foreach (UIGChooserItem *pItem, items()) 614 711 { 615 712 /* Show if hidden: */ 616 if (!pItem->isVisible()) 617 pItem->show(); 713 pItem->show(); 618 714 /* Get item's height-hint: */ 619 715 int iMinimumHeight = pItem->minimumHeightHint(); 620 716 /* Set item's position: */ 621 pItem->setPos(iX + iHorizontal Margin, iY + iPreviousVerticalIndent);717 pItem->setPos(iX + iHorizontalIndent, iY + iPreviousVerticalIndent); 622 718 /* Set item's size: */ 623 pItem->resize(iWidth - 2 * iHorizontal Margin, iMinimumHeight);719 pItem->resize(iWidth - 2 * iHorizontalIndent, iMinimumHeight); 624 720 /* Relayout group: */ 625 721 pItem->updateLayout(); … … 646 742 if (!fClosedGroup) 647 743 { 744 /* Prepare variables: */ 745 int iHorizontalIndent = isRoot() ? 1 : iHorizontalMargin; 648 746 /* We have to make sure that we had taken into account: */ 649 747 foreach (UIGChooserItem *pItem, items()) 650 748 { 651 int iItemWidth = 2 * iHorizontal Margin+ pItem->minimumWidthHint();749 int iItemWidth = 2 * iHorizontalIndent + pItem->minimumWidthHint(); 652 750 iProposedWidth = qMax(iProposedWidth, iItemWidth); 653 751 } … … 677 775 { 678 776 /* We should take into account: */ 679 for (int i = 0; i < m_groupItems.size(); ++i) 680 { 681 /* Every group item height: */ 682 UIGChooserItem *pItem = m_groupItems[i]; 683 iProposedHeight += pItem->minimumHeightHint(); 684 /* And every spacing between sub-groups: */ 685 if (i < m_groupItems.size() - 1) 686 iProposedHeight += iMinorSpacing; 687 } 688 /* Minor spacing between group and machine item: */ 689 if (hasItems(UIGChooserItemType_Group) && hasItems(UIGChooserItemType_Machine)) 690 iProposedHeight += iMinorSpacing; 691 for (int i = 0; i < m_machineItems.size(); ++i) 692 { 693 /* Every machine item height: */ 694 UIGChooserItem *pItem = m_machineItems[i]; 695 iProposedHeight += pItem->minimumHeightHint(); 696 /* And every spacing between sub-machines: */ 697 if (i < m_machineItems.size() - 1) 698 iProposedHeight += iMinorSpacing; 699 } 777 QList<UIGChooserItem*> allItems = items(); 778 for (int i = 0; i < allItems.size(); ++i) 779 { 780 /* Every item height: */ 781 UIGChooserItem *pItem = allItems[i]; 782 iProposedHeight += (pItem->minimumHeightHint() + iMinorSpacing); 783 } 784 /* Minus last spacing: */ 785 iProposedHeight -= iMinorSpacing; 700 786 /* Bottom margin: */ 701 787 iProposedHeight += iHorizontalMargin; 702 788 } 703 789 /* Finally, additional height during animation: */ 704 if (fClosedGroup && m_p Button && m_pButton->isAnimationRunning())790 if (fClosedGroup && m_pToggleButton && m_pToggleButton->isAnimationRunning()) 705 791 iProposedHeight += m_iAdditionalHeight; 706 792 … … 944 1030 void UIGChooserItemGroup::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, bool fClosedGroup) 945 1031 { 946 /* Non-root item: */ 947 if (!isRoot()) 948 { 949 /* Configure painter shape: */ 950 configurePainterShape(pPainter, pOption, m_iCornerRadius); 951 } 952 953 /* Any item: */ 954 { 955 /* Paint decorations: */ 956 paintDecorations(pPainter, pOption); 957 } 958 959 /* Non-root item: */ 960 if (!isRoot()) 1032 /* Setup: */ 1033 pPainter->setRenderHint(QPainter::Antialiasing); 1034 1035 /* Paint decorations: */ 1036 paintDecorations(pPainter, pOption); 1037 1038 /* Non for main root: */ 1039 if (!isMainRoot()) 961 1040 { 962 1041 /* Paint group info: */ … … 967 1046 void UIGChooserItemGroup::paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption) 968 1047 { 969 /* Prepare variables: */ 970 QRect fullRect = pOption->rect; 971 972 /* Any item: */ 973 { 974 /* Paint background: */ 975 paintBackground(/* Painter: */ 976 pPainter, 977 /* Rectangle to paint in: */ 978 fullRect); 979 } 980 981 /* Non-root item: */ 982 if (!isRoot()) 983 { 984 /* Paint frame: */ 985 paintFrameRect(/* Painter: */ 986 pPainter, 987 /* Rectangle to paint in: */ 988 fullRect, 989 /* Is item selected? */ 990 model()->selectionList().contains(this), 991 /* Rounded corner radius: */ 992 m_iCornerRadius); 993 } 1048 /* Paint background: */ 1049 paintBackground(pPainter, pOption->rect); 994 1050 } 995 1051 … … 1007 1063 if (isRoot()) 1008 1064 { 1009 /* Simple and clear: */ 1010 pPainter->fillRect(rect, base.darker(100)); 1065 /* Main root item: */ 1066 if (isMainRoot()) 1067 { 1068 /* Simple and clear: */ 1069 pPainter->fillRect(rect, base); 1070 } 1071 else 1072 { 1073 /* Prepare variables: */ 1074 int iMargin = data(GroupItemData_VerticalMargin).toInt(); 1075 int iHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height(); 1076 int iFullHeaderHeight = 2 * iMargin + iHeaderHeight; 1077 QRect backgroundRect = QRect(0, 0, rect.width(), iFullHeaderHeight); 1078 1079 /* Add clipping: */ 1080 QPainterPath path; 1081 path.moveTo(1, 0); 1082 path.lineTo(path.currentPosition().x(), iFullHeaderHeight - 10); 1083 path.arcTo(QRectF(path.currentPosition(), QSizeF(20, 20)).translated(0, -10), 180, 90); 1084 path.lineTo(rect.width() - 10 - 1, path.currentPosition().y()); 1085 path.arcTo(QRectF(path.currentPosition(), QSizeF(20, 20)).translated(-10, -20), 270, 90); 1086 path.lineTo(path.currentPosition().x(), 0); 1087 path.closeSubpath(); 1088 pPainter->setClipPath(path); 1089 1090 /* Fill background: */ 1091 QLinearGradient headerGradient(backgroundRect.bottomLeft(), backgroundRect.topLeft()); 1092 headerGradient.setColorAt(0, base.darker(gradient())); 1093 headerGradient.setColorAt(1, base.darker(110)); 1094 pPainter->fillRect(backgroundRect, headerGradient); 1095 1096 /* Stroke path: */ 1097 pPainter->setClipping(false); 1098 pPainter->strokePath(path, base.darker(130)); 1099 } 1011 1100 } 1012 1101 /* Non-root item: */ … … 1017 1106 int iHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height(); 1018 1107 int iFullHeaderHeight = 2 * iMargin + iHeaderHeight; 1019 1020 /* Fill rectangle with brush/color: */ 1021 pPainter->fillRect(rect, Qt::white); 1022 1023 /* Make even less rectangle: */ 1024 QRect backGroundRect = rect; 1025 backGroundRect.setTopLeft(backGroundRect.topLeft() + QPoint(2, 2)); 1026 backGroundRect.setBottomRight(backGroundRect.bottomRight() - QPoint(2, 2)); 1027 /* Add even more clipping: */ 1028 QPainterPath roundedPath; 1029 roundedPath.addRoundedRect(backGroundRect, m_iCornerRadius, m_iCornerRadius); 1030 pPainter->setClipPath(roundedPath); 1108 int iFullHeight = rect.height(); 1109 1110 /* Add clipping: */ 1111 QPainterPath path; 1112 path.moveTo(10, 0); 1113 path.arcTo(QRectF(path.currentPosition(), QSizeF(20, 20)).translated(-10, 0), 90, 90); 1114 path.lineTo(path.currentPosition().x(), iFullHeight - 10); 1115 path.arcTo(QRectF(path.currentPosition(), QSizeF(20, 20)).translated(0, -10), 180, 90); 1116 path.lineTo(rect.width() - 10, path.currentPosition().y()); 1117 path.arcTo(QRectF(path.currentPosition(), QSizeF(20, 20)).translated(-10, -20), 270, 90); 1118 path.lineTo(path.currentPosition().x(), 10); 1119 path.arcTo(QRectF(path.currentPosition(), QSizeF(20, 20)).translated(-20, -10), 0, 90); 1120 path.closeSubpath(); 1121 pPainter->setClipPath(path); 1031 1122 1032 1123 /* Calculate top rectangle: */ 1033 QRect tRect = backGroundRect;1124 QRect tRect = rect; 1034 1125 tRect.setBottom(tRect.top() + iFullHeaderHeight); 1035 1126 /* Prepare top gradient: */ … … 1040 1131 pPainter->fillRect(tRect, tGradient); 1041 1132 1042 if ( backGroundRect.height() > tRect.height())1133 if (rect.height() > tRect.height()) 1043 1134 { 1044 1135 /* Calculate middle rectangle: */ 1045 QRect midRect = QRect(tRect.bottomLeft(), backGroundRect.bottomRight());1136 QRect midRect = QRect(tRect.bottomLeft(), rect.bottomRight()); 1046 1137 /* Paint all the stuff: */ 1047 1138 pPainter->fillRect(midRect, base.darker(110)); 1048 1139 } 1049 1140 1141 /* Stroke path: */ 1142 pPainter->setClipping(false); 1143 pPainter->strokePath(path, base.darker(130)); 1144 pPainter->setClipPath(path); 1145 1050 1146 /* Paint drag token UP? */ 1051 1147 if (dragTokenPlace() != DragToken_Off) 1052 1148 { 1053 1149 QLinearGradient dragTokenGradient; 1054 QRect dragTokenRect = backGroundRect;1150 QRect dragTokenRect = rect; 1055 1151 if (dragTokenPlace() == DragToken_Up) 1056 1152 { … … 1078 1174 { 1079 1175 /* Prepare variables: */ 1080 int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();1081 1176 int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt(); 1082 1177 int iVerticalMargin = data(GroupItemData_VerticalMargin).toInt(); 1083 QSize buttonSize = data(GroupItemData_ButtonSize).toSize(); 1178 int iMajorSpacing = data(GroupItemData_MajorSpacing).toInt(); 1179 QSize toggleButtonSize = data(GroupItemData_ToggleButtonSize).toSize(); 1180 QSize exitButtonSize = data(GroupItemData_ExitButtonSize).toSize(); 1084 1181 QSize nameSize = data(GroupItemData_NameSize).toSize(); 1085 1182 int iFullHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height(); 1086 1183 1087 1184 /* Paint name: */ 1088 int iNameX = iHorizontalMargin + buttonSize.width() + iMinorSpacing + 1089 1 /* frame width from Qt sources */ + 1090 2 /* internal QLineEdit margin from Qt sources */ + 1091 1 /* internal QLineEdit align shifting from Qt sources */; 1185 int iNameX = iHorizontalMargin + iMajorSpacing; 1186 if (!isRoot()) 1187 iNameX += toggleButtonSize.width(); 1188 else if (!isMainRoot()) 1189 iNameX += exitButtonSize.width(); 1092 1190 int iNameY = nameSize.height() == iFullHeaderHeight ? iVerticalMargin : 1093 1191 iVerticalMargin + (iFullHeaderHeight - nameSize.height()) / 2; … … 1104 1202 if (isHovered()) 1105 1203 { 1204 /* Show enter-button: */ 1205 if (!isRoot() && m_pEnterButton) 1206 m_pEnterButton->show(); 1207 1106 1208 /* Prepare variables: */ 1107 1209 QRect fullRect = pOption->rect; 1210 int iEnterButtonWidth = data(GroupItemData_EnterButtonSize).toSizeF().width(); 1108 1211 QSize groupPixmapSize = data(GroupItemData_GroupPixmapSize).toSize(); 1109 1212 QSize machinePixmapSize = data(GroupItemData_MachinePixmapSize).toSize(); … … 1116 1219 QPixmap machinePixmap = data(GroupItemData_MachinePixmap).value<QIcon>().pixmap(machinePixmapSize); 1117 1220 1118 /* We should add machine count: */ 1119 int iMachineCountTextX = fullRect.right() - 1120 iHorizontalMargin - 1121 machineCountTextSize.width(); 1122 int iMachineCountTextY = machineCountTextSize.height() == iFullHeaderHeight ? 1123 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - machineCountTextSize.height()) / 2; 1124 paintText(/* Painter: */ 1125 pPainter, 1126 /* Rectangle to paint in: */ 1127 QRect(QPoint(iMachineCountTextX, iMachineCountTextY), machineCountTextSize), 1128 /* Font to paint text: */ 1129 infoFont, 1130 /* Text to paint: */ 1131 strMachineCountText); 1132 1133 /* We should draw machine pixmap: */ 1134 int iMachinePixmapX = iMachineCountTextX - 1135 iMinorSpacing - 1136 machinePixmapSize.width(); 1137 int iMachinePixmapY = machinePixmapSize.height() == iFullHeaderHeight ? 1138 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - machinePixmapSize.height()) / 2; 1139 paintPixmap(/* Painter: */ 1140 pPainter, 1141 /* Rectangle to paint in: */ 1142 QRect(QPoint(iMachinePixmapX, iMachinePixmapY), machinePixmapSize), 1143 /* Pixmap to paint: */ 1144 machinePixmap); 1145 1146 /* We should add group count: */ 1147 int iGroupCountTextX = iMachinePixmapX - 1148 iMinorSpacing - 1149 groupCountTextSize.width(); 1150 int iGroupCountTextY = groupCountTextSize.height() == iFullHeaderHeight ? 1151 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - groupCountTextSize.height()) / 2; 1152 paintText(/* Painter: */ 1153 pPainter, 1154 /* Rectangle to paint in: */ 1155 QRect(QPoint(iGroupCountTextX, iGroupCountTextY), groupCountTextSize), 1156 /* Font to paint text: */ 1157 infoFont, 1158 /* Text to paint: */ 1159 strGroupCountText); 1160 1161 /* We should draw group pixmap: */ 1162 int iGroupPixmapX = iGroupCountTextX - 1163 iMinorSpacing - 1164 groupPixmapSize.width(); 1165 int iGroupPixmapY = groupPixmapSize.height() == iFullHeaderHeight ? 1166 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - groupPixmapSize.height()) / 2; 1167 paintPixmap(/* Painter: */ 1168 pPainter, 1169 /* Rectangle to paint in: */ 1170 QRect(QPoint(iGroupPixmapX, iGroupPixmapY), groupPixmapSize), 1171 /* Pixmap to paint: */ 1172 groupPixmap); 1221 /* Indent: */ 1222 int iHorizontalIndent = fullRect.right() - iHorizontalMargin; 1223 if (!isRoot()) 1224 iHorizontalIndent -= iEnterButtonWidth; 1225 1226 /* Should we draw machine count info? */ 1227 if (!strMachineCountText.isEmpty()) 1228 { 1229 iHorizontalIndent -= machineCountTextSize.width(); 1230 int iMachineCountTextX = iHorizontalIndent; 1231 int iMachineCountTextY = machineCountTextSize.height() == iFullHeaderHeight ? 1232 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - machineCountTextSize.height()) / 2; 1233 paintText(/* Painter: */ 1234 pPainter, 1235 /* Rectangle to paint in: */ 1236 QRect(QPoint(iMachineCountTextX, iMachineCountTextY), machineCountTextSize), 1237 /* Font to paint text: */ 1238 infoFont, 1239 /* Text to paint: */ 1240 strMachineCountText); 1241 1242 iHorizontalIndent -= machinePixmapSize.width(); 1243 int iMachinePixmapX = iHorizontalIndent; 1244 int iMachinePixmapY = machinePixmapSize.height() == iFullHeaderHeight ? 1245 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - machinePixmapSize.height()) / 2; 1246 paintPixmap(/* Painter: */ 1247 pPainter, 1248 /* Rectangle to paint in: */ 1249 QRect(QPoint(iMachinePixmapX, iMachinePixmapY), machinePixmapSize), 1250 /* Pixmap to paint: */ 1251 machinePixmap); 1252 } 1253 1254 /* Should we draw group count info? */ 1255 if (!strGroupCountText.isEmpty()) 1256 { 1257 iHorizontalIndent -= groupCountTextSize.width(); 1258 int iGroupCountTextX = iHorizontalIndent; 1259 int iGroupCountTextY = groupCountTextSize.height() == iFullHeaderHeight ? 1260 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - groupCountTextSize.height()) / 2; 1261 paintText(/* Painter: */ 1262 pPainter, 1263 /* Rectangle to paint in: */ 1264 QRect(QPoint(iGroupCountTextX, iGroupCountTextY), groupCountTextSize), 1265 /* Font to paint text: */ 1266 infoFont, 1267 /* Text to paint: */ 1268 strGroupCountText); 1269 1270 iHorizontalIndent -= groupPixmapSize.width(); 1271 int iGroupPixmapX = iHorizontalIndent; 1272 int iGroupPixmapY = groupPixmapSize.height() == iFullHeaderHeight ? 1273 iVerticalMargin : iVerticalMargin + (iFullHeaderHeight - groupPixmapSize.height()) / 2; 1274 paintPixmap(/* Painter: */ 1275 pPainter, 1276 /* Rectangle to paint in: */ 1277 QRect(QPoint(iGroupPixmapX, iGroupPixmapY), groupPixmapSize), 1278 /* Pixmap to paint: */ 1279 groupPixmap); 1280 } 1281 } 1282 else 1283 { 1284 /* Hide enter-button: */ 1285 if (m_pEnterButton) 1286 m_pEnterButton->hide(); 1173 1287 } 1174 1288 } … … 1177 1291 { 1178 1292 /* Only for item with button: */ 1179 if (!m_p Button)1293 if (!m_pToggleButton) 1180 1294 return; 1181 1295 … … 1184 1298 QSizeF closedSize = minimumSizeHint(true); 1185 1299 int iAdditionalHeight = openedSize.height() - closedSize.height(); 1186 m_p Button->setAnimationRange(0, iAdditionalHeight);1300 m_pToggleButton->setAnimationRange(0, iAdditionalHeight); 1187 1301 } 1188 1302 … … 1200 1314 void UIGChooserItemGroup::prepare() 1201 1315 { 1202 /* Setup toggle-button: */ 1203 m_pButton = new UIGraphicsRotatorButton(this, "additionalHeight", opened()); 1204 m_pButton->setIcon(data(GroupItemData_ButtonPixmap).value<QIcon>()); 1205 connect(m_pButton, SIGNAL(sigRotationStart()), this, SLOT(sltGroupToggleStart())); 1206 connect(m_pButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltGroupToggleFinish(bool))); 1207 m_pButton->hide(); 1208 1209 /* Setup name-editor: */ 1210 m_pNameEditorWidget = new QLineEdit(m_strName); 1211 m_pNameEditorWidget->setTextMargins(0, 0, 0, 0); 1212 m_pNameEditorWidget->setFont(data(GroupItemData_NameFont).value<QFont>()); 1213 connect(m_pNameEditorWidget, SIGNAL(editingFinished()), this, SLOT(sltNameEditingFinished())); 1214 m_pNameEditor = new QGraphicsProxyWidget(this); 1215 m_pNameEditor->setWidget(m_pNameEditorWidget); 1216 m_pNameEditor->hide(); 1316 /* Non root item only: */ 1317 if (!isRoot()) 1318 { 1319 /* Setup toggle-button: */ 1320 m_pToggleButton = new UIGraphicsRotatorButton(this, "additionalHeight", opened()); 1321 m_pToggleButton->setIcon(data(GroupItemData_ToggleButtonPixmap).value<QIcon>()); 1322 connect(m_pToggleButton, SIGNAL(sigRotationStart()), this, SLOT(sltGroupToggleStart())); 1323 connect(m_pToggleButton, SIGNAL(sigRotationFinish(bool)), this, SLOT(sltGroupToggleFinish(bool))); 1324 m_pToggleButton->hide(); 1325 1326 /* Setup enter-button: */ 1327 m_pEnterButton = new UIGraphicsButton(this); 1328 m_pEnterButton->setIcon(data(GroupItemData_EnterButtonPixmap).value<QIcon>()); 1329 connect(m_pEnterButton, SIGNAL(sigButtonClicked()), this, SLOT(sltIndentRoot())); 1330 m_pEnterButton->hide(); 1331 1332 /* Setup name-editor: */ 1333 m_pNameEditorWidget = new QLineEdit(m_strName); 1334 m_pNameEditorWidget->setTextMargins(0, 0, 0, 0); 1335 m_pNameEditorWidget->setFont(data(GroupItemData_NameFont).value<QFont>()); 1336 connect(m_pNameEditorWidget, SIGNAL(editingFinished()), this, SLOT(sltNameEditingFinished())); 1337 m_pNameEditor = new QGraphicsProxyWidget(this); 1338 m_pNameEditor->setWidget(m_pNameEditorWidget); 1339 m_pNameEditor->hide(); 1340 } 1341 /* Root item but non main: */ 1342 if (!isMainRoot()) 1343 { 1344 /* Setup exit-button: */ 1345 m_pExitButton = new UIGraphicsButton(this); 1346 m_pExitButton->setIcon(data(GroupItemData_EnterButtonPixmap).value<QIcon>()); 1347 connect(m_pExitButton, SIGNAL(sigButtonClicked()), this, SLOT(sltUnindentRoot())); 1348 QSizeF sh = m_pExitButton->minimumSizeHint(); 1349 m_pExitButton->setTransformOriginPoint(sh.width() / 2, sh.height() / 2); 1350 m_pExitButton->setRotation(180); 1351 m_pExitButton->hide(); 1352 } 1217 1353 } 1218 1354 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r42630 r42678 25 25 /* Forward declarations: */ 26 26 class QGraphicsScene; 27 class UIGraphicsButton; 27 28 class UIGraphicsRotatorButton; 28 29 class QLineEdit; … … 47 48 /* Constructor/destructor: */ 48 49 UIGChooserItemGroup(QGraphicsScene *pScene); 49 UIGChooserItemGroup(QGraphicsScene *pScene, UIGChooserItemGroup *pCopyFrom); 50 UIGChooserItemGroup(QGraphicsScene *pScene, UIGChooserItemGroup *pCopyFrom, 51 bool fMainRoot); 50 52 UIGChooserItemGroup(UIGChooserItem *pParent, const QString &strName, 51 53 bool fOpened = false , int iPosition = -1 ); … … 73 75 void sltGroupToggleFinish(bool fToggled); 74 76 77 /* Handler: Indent root stuff: */ 78 void sltIndentRoot(); 79 void sltUnindentRoot(); 80 75 81 private: 76 82 … … 84 90 GroupItemData_MinorSpacing, 85 91 /* Pixmaps: */ 86 GroupItemData_ButtonPixmap, 92 GroupItemData_ToggleButtonPixmap, 93 GroupItemData_EnterButtonPixmap, 87 94 GroupItemData_GroupPixmap, 88 95 GroupItemData_MachinePixmap, … … 95 102 GroupItemData_MachineCountText, 96 103 /* Sizes: */ 97 GroupItemData_ButtonSize, 104 GroupItemData_ToggleButtonSize, 105 GroupItemData_EnterButtonSize, 106 GroupItemData_ExitButtonSize, 98 107 GroupItemData_MinimumNameSize, 99 108 GroupItemData_NameSize, … … 113 122 void hide(); 114 123 void startEditing(); 124 bool isMainRoot() const { return m_fMainRoot; } 115 125 116 126 /* Helpers: Children stuff: */ … … 161 171 QString m_strName; 162 172 bool m_fClosed; 163 UIGraphicsRotatorButton *m_pButton; 173 UIGraphicsRotatorButton *m_pToggleButton; 174 UIGraphicsButton *m_pEnterButton; 175 UIGraphicsButton *m_pExitButton; 164 176 QLineEdit *m_pNameEditorWidget; 165 177 QGraphicsProxyWidget *m_pNameEditor; … … 168 180 int m_iAdditionalHeight; 169 181 int m_iCornerRadius; 182 bool m_fMainRoot; 170 183 }; 171 184 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
r42658 r42678 502 502 void UIGChooserItemMachine::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget * /* pWidget = 0 */) 503 503 { 504 /* Setup: */ 505 pPainter->setRenderHint(QPainter::Antialiasing); 506 504 507 /* Configure painter shape: */ 505 508 configurePainterShape(pPainter, pOption, m_iCornerRadius); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r42659 r42678 129 129 130 130 /* Create left root: */ 131 m_pLeftRoot = new UIGChooserItemGroup(scene(), root()->toGroupItem()); 131 bool fLeftRootIsMain = root() == mainRoot(); 132 m_pLeftRoot = new UIGChooserItemGroup(scene(), root()->toGroupItem(), fLeftRootIsMain); 132 133 m_pLeftRoot->setPos(0, 0); 133 134 m_pLeftRoot->resize(root()->geometry().size()); 134 135 135 136 /* Create right root: */ 136 m_pRightRoot = new UIGChooserItemGroup(scene(), pNewRootItem->toGroupItem() );137 m_pRightRoot = new UIGChooserItemGroup(scene(), pNewRootItem->toGroupItem(), false); 137 138 m_pRightRoot->setPos(root()->geometry().width(), 0); 138 139 m_pRightRoot->resize(root()->geometry().size()); … … 162 163 163 164 /* Create left root: */ 164 m_pLeftRoot = new UIGChooserItemGroup(scene(), m_rootStack.at(m_rootStack.size() - 2)->toGroupItem()); 165 bool fLeftRootIsMain = m_rootStack.at(m_rootStack.size() - 2) == mainRoot(); 166 m_pLeftRoot = new UIGChooserItemGroup(scene(), m_rootStack.at(m_rootStack.size() - 2)->toGroupItem(), fLeftRootIsMain); 165 167 m_pLeftRoot->setPos(- root()->geometry().width(), 0); 166 168 m_pLeftRoot->resize(root()->geometry().size()); 167 169 168 170 /* Create right root: */ 169 m_pRightRoot = new UIGChooserItemGroup(scene(), root()->toGroupItem() );171 m_pRightRoot = new UIGChooserItemGroup(scene(), root()->toGroupItem(), false); 170 172 m_pRightRoot->setPos(0, 0); 171 173 m_pRightRoot->resize(root()->geometry().size()); … … 1491 1493 /* Get group item: */ 1492 1494 UIGChooserItem *pGroupItem = qgraphicsitem_cast<UIGChooserItemGroup*>(pItem); 1495 /* Make sure thats not root: */ 1496 if (pGroupItem->isRoot()) 1497 return false; 1493 1498 /* Is this group item only the one selected? */ 1494 1499 if (selectionList().contains(pGroupItem) && selectionList().size() == 1) -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
r42639 r42678 428 428 /* Add text height: */ 429 429 if (!m_text.isEmpty()) 430 iProposedHeight += iMargin + iTextHeight;430 iProposedHeight += 2 * iMargin + iTextHeight; 431 431 } 432 432 else … … 471 471 void UIGDetailsElement::paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption) 472 472 { 473 /* Prepare variables: */474 QRect fullRect = pOption->rect;475 476 473 /* Paint background: */ 477 474 paintBackground(/* Painter: */ 478 475 pPainter, 479 476 /* Rectangle to paint in: */ 480 fullRect,477 pOption->rect, 481 478 /* Rounded corners radius: */ 482 479 m_iCornerRadius, 483 480 /* Header height: */ 484 data(ElementData_Margin).toInt() + 485 data(ElementData_HeaderSize).toSize().height() + 486 1); 487 488 /* Paint frame: */ 489 paintFrameRect(/* Painter: */ 490 pPainter, 491 /* Rectangle to paint in: */ 492 fullRect, 493 /* Rounded corner radius: */ 494 m_iCornerRadius); 481 2 * data(ElementData_Margin).toInt() + 482 data(ElementData_HeaderSize).toSize().height()); 495 483 } 496 484 … … 565 553 /* Where to paint? */ 566 554 int iMachineTextX = iMachinePixmapX; 567 int iMachineTextY = iMachinePixmapY + iHeaderHeight + iMargin;555 int iMachineTextY = iMachinePixmapY + iHeaderHeight + 2 * iMargin; 568 556 569 557 /* For each the line: */ … … 604 592 pPainter->save(); 605 593 606 /* Fill rectangle with white color: */ 594 /* Prepare variables: */ 595 int iFullHeight = rect.height(); 596 597 /* Prepare color: */ 607 598 QPalette pal = QApplication::palette(); 608 pPainter->fillRect(rect, Qt::white);609 610 /* Prepare color: */611 599 QColor windowColor = pal.color(QPalette::Active, QPalette::Window); 612 600 613 /* Make even less rectangle: */ 614 QRect backGroundRect = rect; 615 backGroundRect.setTopLeft(backGroundRect.topLeft() + QPoint(2, 2)); 616 backGroundRect.setBottomRight(backGroundRect.bottomRight() - QPoint(2, 2)); 617 /* Add even more clipping: */ 618 QPainterPath roundedPath; 619 roundedPath.addRoundedRect(backGroundRect, iRadius, iRadius); 620 pPainter->setClipPath(roundedPath); 601 /* Add clipping: */ 602 QPainterPath path; 603 path.moveTo(iRadius, 0); 604 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-iRadius, 0), 90, 90); 605 path.lineTo(path.currentPosition().x(), iFullHeight - iRadius); 606 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(0, -iRadius), 180, 90); 607 path.lineTo(rect.width() - iRadius, path.currentPosition().y()); 608 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-iRadius, -2 * iRadius), 270, 90); 609 path.lineTo(path.currentPosition().x(), iRadius); 610 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-2 * iRadius, -iRadius), 0, 90); 611 path.closeSubpath(); 612 pPainter->setClipPath(path); 621 613 622 614 /* Calculate top rectangle: */ 623 QRect tRect = backGroundRect;615 QRect tRect = rect; 624 616 tRect.setBottom(tRect.top() + iHeaderHeight); 625 617 /* Calculate bottom rectangle: */ 626 QRect bRect = backGroundRect;618 QRect bRect = rect; 627 619 bRect.setTop(tRect.bottom()); 628 620 … … 633 625 634 626 /* Paint all the stuff: */ 635 pPainter->fillRect(bRect, windowColor.darker(99));636 627 pPainter->fillRect(tRect, tGradient); 628 pPainter->fillRect(bRect, windowColor.darker(97)); 629 630 /* Stroke path: */ 631 pPainter->setClipping(false); 632 pPainter->strokePath(path, windowColor.darker(130)); 637 633 638 634 /* Restore painter: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsGroup.cpp
r42608 r42678 122 122 { 123 123 /* Layout hints: */ 124 case GroupData_Margin: return 1;124 case GroupData_Margin: return 2; 125 125 case GroupData_Spacing: return 10; 126 126 /* Default: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsSet.cpp
r42626 r42678 106 106 /* Layout hints: */ 107 107 case SetData_Margin: return 0; 108 case SetData_Spacing: return 1;108 case SetData_Spacing: return 3; 109 109 /* Default: */ 110 110 default: break; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.cpp
r42526 r42678 20 20 /* Qt includes: */ 21 21 #include <QPainter> 22 #include <QGraphicsSceneMouseEvent> 22 23 23 24 /* GUI includes: */ … … 43 44 switch (iKey) 44 45 { 45 case GraphicsButton_Margin: return 3;46 case GraphicsButton_Margin: return 0; 46 47 case GraphicsButton_IconSize: return m_icon.isNull() ? QSize(16, 16) : m_icon.availableSizes().first(); 47 48 case GraphicsButton_Icon: return m_icon; … … 84 85 void UIGraphicsButton::mousePressEvent(QGraphicsSceneMouseEvent *pEvent) 85 86 { 87 /* Accepting this event allows to get release-event: */ 88 pEvent->accept(); 89 } 90 91 void UIGraphicsButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent) 92 { 93 /* Call to base-class: */ 94 QIGraphicsWidget::mouseReleaseEvent(pEvent); 86 95 /* Notify listeners about button click: */ 87 96 emit sigButtonClicked(); 88 /* Propagate to parent: */89 QIGraphicsWidget::mousePressEvent(pEvent);90 97 } 91 98 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsButton.h
r42526 r42678 66 66 virtual void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0); 67 67 68 /* Mouse -press handler: */68 /* Mouse handlers: */ 69 69 virtual void mousePressEvent(QGraphicsSceneMouseEvent *pEvent); 70 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *pEvent); 70 71 71 72 /* Helpers: Update stuff: */
Note:
See TracChangeset
for help on using the changeset viewer.