Changeset 42593 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 4, 2012 3:46:34 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 79778
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.cpp
r42558 r42593 44 44 , m_pBackwardAnimation(0) 45 45 , m_iAnimationDuration(300) 46 , m_iDefaultDarkness(1 15)46 , m_iDefaultDarkness(103) 47 47 , m_iHighlightDarkness(90) 48 48 , m_iGradient(m_iDefaultDarkness) … … 173 173 } 174 174 175 void UIGChooserItem::hover EnterEvent(QGraphicsSceneHoverEvent*)175 void UIGChooserItem::hoverMoveEvent(QGraphicsSceneHoverEvent*) 176 176 { 177 177 if (m_fHovered != true) … … 329 329 QString UIGChooserItem::compressText(const QFont &font, QString strText, int iWidth) 330 330 { 331 /* Check if passed text is empty: */ 332 if (strText.isEmpty()) 333 return strText; 334 331 335 /* Check if passed text feats maximum width: */ 332 336 QFontMetrics fm(font); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.h
r42563 r42593 111 111 112 112 /* Hover-enter event: */ 113 void hover EnterEvent(QGraphicsSceneHoverEvent *pEvent);113 void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent); 114 114 /* Hover-leave event: */ 115 115 void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent); … … 136 136 /* Hover stuff: */ 137 137 bool isHovered() const { return m_fHovered; } 138 void setHovered(bool fHovered) { m_fHovered = fHovered; } 138 139 int gradient() const { return m_iGradient; } 139 140 void setGradient(int iGradient) { m_iGradient = iGradient; update(); } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp
r42581 r42593 43 43 , m_pNameEditor(0) 44 44 , m_iAdditionalHeight(0) 45 , m_iCornerRadius( 6)45 , m_iCornerRadius(10) 46 46 { 47 47 /* Add item to the scene: */ … … 59 59 , m_pNameEditor(0) 60 60 , m_iAdditionalHeight(0) 61 , m_iCornerRadius( 6)61 , m_iCornerRadius(10) 62 62 { 63 63 /* Add item to the scene: */ … … 80 80 , m_pNameEditor(0) 81 81 , m_iAdditionalHeight(0) 82 , m_iCornerRadius( 6)82 , m_iCornerRadius(10) 83 83 { 84 84 /* Prepare: */ … … 101 101 , m_pNameEditor(0) 102 102 , m_iAdditionalHeight(0) 103 , m_iCornerRadius( 6)103 , m_iCornerRadius(10) 104 104 { 105 105 /* Prepare: */ … … 922 922 } 923 923 924 void UIGChooserItemGroup::hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent) 925 { 926 /* Prepare variables: */ 927 QPoint pos = pEvent->pos().toPoint(); 928 int iMargin = data(GroupItemData_VerticalMargin).toInt(); 929 int iHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height(); 930 int iFullHeaderHeight = 2 * iMargin + iHeaderHeight; 931 /* Check if group should be highlighted: */ 932 if ((pos.y() < iFullHeaderHeight) && !isHovered()) 933 { 934 setHovered(true); 935 emit sigHoverEnter(); 936 } 937 } 938 924 939 void UIGChooserItemGroup::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget* /* pWidget = 0 */) 925 940 { … … 1015 1030 pPainter->setClipPath(roundedPath); 1016 1031 1017 /* Calculate bottom rectangle: */1018 QRect bRect = backGroundRect;1019 bRect.setTop(bRect.bottom() - iFullHeaderHeight);1020 /* Prepare bottom gradient: */1021 QLinearGradient bGradient(bRect.topLeft(), bRect.bottomLeft());1022 bGradient.setColorAt(0, base.darker(gradient()));1023 bGradient.setColorAt(1, base.darker(104));1024 /* Fill bottom rectangle: */1025 pPainter->fillRect(bRect, bGradient);1026 1027 1032 /* Calculate top rectangle: */ 1028 1033 QRect tRect = backGroundRect; … … 1030 1035 /* Prepare top gradient: */ 1031 1036 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 1032 tGradient.setColorAt(0, base.darker( gradient()));1033 tGradient.setColorAt(1, base.darker( 104));1037 tGradient.setColorAt(0, base.darker(110)); 1038 tGradient.setColorAt(1, base.darker(gradient())); 1034 1039 /* Fill top rectangle: */ 1035 1040 pPainter->fillRect(tRect, tGradient); 1036 1041 1037 if (b Rect.top() > tRect.bottom())1042 if (backGroundRect.height() > tRect.height()) 1038 1043 { 1039 1044 /* Calculate middle rectangle: */ 1040 QRect midRect = QRect(tRect.bottomLeft(), b Rect.topRight());1045 QRect midRect = QRect(tRect.bottomLeft(), backGroundRect.bottomRight()); 1041 1046 /* Paint all the stuff: */ 1042 pPainter->fillRect(midRect, base.darker( gradient()));1047 pPainter->fillRect(midRect, base.darker(110)); 1043 1048 } 1044 1049 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h
r42563 r42593 139 139 QMimeData* createMimeData(); 140 140 141 /* Event handlers: */ 142 void hoverMoveEvent(QGraphicsSceneHoverEvent *pEvent); 143 141 144 /* Helpers: Paint stuff: */ 142 145 void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp
r42581 r42593 33 33 #include "UIIconPool.h" 34 34 #include "UIActionPoolSelector.h" 35 #include "UIImageTools.h" 35 36 36 37 /* COM includes: */ … … 51 52 , m_pPauseButton(0) 52 53 , m_pCloseButton(0) 53 , m_iCornerRadius( 6)54 , m_iCornerRadius(0) 54 55 { 55 56 // /* Prepare: */ … … 72 73 , m_pPauseButton(0) 73 74 , m_pCloseButton(0) 74 , m_iCornerRadius( 6)75 , m_iCornerRadius(0) 75 76 { 76 77 // /* Prepare: */ … … 119 120 case MachineItemData_MajorSpacing: return 10; 120 121 case MachineItemData_MinorSpacing: return 4; 121 case MachineItemData_TextSpacing: return 2; 122 case MachineItemData_TextSpacing: return 0; 123 122 124 /* Pixmaps: */ 123 125 case MachineItemData_Pixmap: return osIcon(); … … 127 129 case MachineItemData_PauseButtonPixmap: return UIIconPool::iconSet(":/pause_16px.png"); 128 130 case MachineItemData_CloseButtonPixmap: return UIIconPool::iconSet(":/exit_16px.png"); 131 129 132 /* Fonts: */ 130 133 case MachineItemData_NameFont: 131 134 { 132 135 QFont machineNameFont = qApp->font(); 133 machineNameFont.setPointSize(machineNameFont.pointSize() + 1);134 136 machineNameFont.setWeight(QFont::Bold); 135 137 return machineNameFont; … … 138 140 { 139 141 QFont snapshotStateFont = qApp->font(); 140 snapshotStateFont.setPointSize(snapshotStateFont.pointSize() + 1);141 142 return snapshotStateFont; 142 143 } … … 144 145 { 145 146 QFont machineStateFont = qApp->font(); 146 machineStateFont.setPointSize(machineStateFont.pointSize() + 1);147 147 return machineStateFont; 148 148 } 149 149 150 /* Texts: */ 150 151 case MachineItemData_Name: 151 152 { 152 /* Prepare variables: */ 153 int iMaximumWidth = data(MachineItemData_FirstRowMaximumWidth).toInt(); 154 int iMinimumSnapshotNameWidth = data(MachineItemData_MinimumSnapshotNameSize).toSize().width(); 155 /* Compress name to part width: */ 156 QString strCompressedName = compressText(data(MachineItemData_NameFont).value<QFont>(), 157 name(), iMaximumWidth - iMinimumSnapshotNameWidth); 158 return strCompressedName; 153 return compressText(data(MachineItemData_NameFont).value<QFont>(), name(), 154 data(MachineItemData_MaximumNameWidth).toInt()); 159 155 } 160 156 case MachineItemData_SnapshotName: 161 157 { 162 /* Prepare variables: */ 163 int iMaximumWidth = data(MachineItemData_FirstRowMaximumWidth).toInt(); 164 int iNameWidth = data(MachineItemData_NameSize).toSize().width(); 165 /* Compress name to part width: */ 166 QString strCompressedName = compressText(data(MachineItemData_SnapshotNameFont).value<QFont>(), 167 snapshotName(), iMaximumWidth - iNameWidth); 168 return strCompressedName; 158 int iBracketWidth = QFontMetrics(data(MachineItemData_SnapshotNameFont).value<QFont>()).width("()"); 159 QString strCompressedName = compressText(data(MachineItemData_SnapshotNameFont).value<QFont>(), snapshotName(), 160 data(MachineItemData_MaximumSnapshotNameWidth).toInt() - iBracketWidth); 161 return QString("(%1)").arg(strCompressedName); 169 162 } 170 163 case MachineItemData_StateText: return gpConverter->toString(machineState()); 164 171 165 /* Sizes: */ 172 166 case MachineItemData_PixmapSize: return osIcon().availableSizes().at(0); 173 167 case MachineItemData_StatePixmapSize: return machineStateIcon().availableSizes().at(0); 174 case MachineItemData_MinimumNameSize: 175 { 176 QFont font = data(MachineItemData_NameFont).value<QFont>(); 177 QFontMetrics fm(font); 178 int iMaximumTextWidth = textWidth(font, 15); 179 QString strCompressedName = compressText(font, name(), iMaximumTextWidth); 180 return QSize(fm.width(strCompressedName), fm.height()); 181 } 168 182 169 case MachineItemData_NameSize: 183 170 { … … 185 172 return QSize(fm.width(data(MachineItemData_Name).toString()) + 1, fm.height()); 186 173 } 187 case MachineItemData_MinimumSnapshotNameSize: 188 { 189 QFont font = data(MachineItemData_SnapshotNameFont).value<QFont>(); 190 QFontMetrics fm(font); 191 int iMaximumTextWidth = textWidth(font, 10); 192 QString strCompressedName = compressText(font, snapshotName(), iMaximumTextWidth); 193 return QSize(fm.width(strCompressedName), fm.height()); 194 } 174 case MachineItemData_MinimumNameWidth: 175 { 176 QFont font = data(MachineItemData_NameFont).value<QFont>(); 177 return QFontMetrics(font).width(compressText(font, name(), textWidth(font, 15))); 178 } 179 case MachineItemData_MaximumNameWidth: 180 { 181 return data(MachineItemData_FirstRowMaximumWidth).toInt() - 182 data(MachineItemData_MinimumSnapshotNameWidth).toInt(); 183 } 184 195 185 case MachineItemData_SnapshotNameSize: 196 186 { 197 187 QFontMetrics fm(data(MachineItemData_SnapshotNameFont).value<QFont>()); 198 return QSize(fm.width(QString("(%1)").arg(data(MachineItemData_SnapshotName).toString())) + 1, fm.height()); 199 } 188 return QSize(fm.width(data(MachineItemData_SnapshotName).toString()) + 1, fm.height()); 189 } 190 case MachineItemData_MinimumSnapshotNameWidth: 191 { 192 if (snapshotName().isEmpty()) 193 return 0; 194 QFontMetrics fm(data(MachineItemData_SnapshotNameFont).value<QFont>()); 195 int iBracketWidth = fm.width("()"); 196 int iActualTextWidth = fm.width(snapshotName()); 197 int iMinimumTextWidth = fm.width("..."); 198 return iBracketWidth + qMin(iActualTextWidth, iMinimumTextWidth); 199 } 200 case MachineItemData_MaximumSnapshotNameWidth: 201 { 202 return data(MachineItemData_FirstRowMaximumWidth).toInt() - 203 data(MachineItemData_NameSize).toSize().width(); 204 } 205 200 206 case MachineItemData_FirstRowMaximumWidth: 201 207 { … … 206 212 int iMachineItemMinorSpacing = data(MachineItemData_MinorSpacing).toInt(); 207 213 int iToolBarWidth = data(MachineItemData_ToolBarSize).toSize().width(); 208 int iMaximumWidth = (int)geometry().width() - iMargin -214 int iMaximumWidth = (int)geometry().width() - 2 * iMargin - 209 215 iPixmapWidth - 210 iMachineItemMajorSpacing - 211 iMachineItemMinorSpacing - 212 iMachineItemMajorSpacing - 213 iMargin; 216 iMachineItemMajorSpacing; 217 if (!snapshotName().isEmpty()) 218 iMaximumWidth -= iMachineItemMinorSpacing; 214 219 if (m_pToolBar) 215 iMaximumWidth -= iToolBarWidth;220 iMaximumWidth -= (iToolBarWidth + iMachineItemMajorSpacing); 216 221 return iMaximumWidth; 217 222 } … … 308 313 int iMachineItemMinorSpacing = data(MachineItemData_MinorSpacing).toInt(); 309 314 int iMachinePixmapWidth = data(MachineItemData_PixmapSize).toSize().width(); 310 int iMinimum MachineNameWidth = data(MachineItemData_MinimumNameSize).toSize().width();311 int iMinimumSnapshotNameWidth = data(MachineItemData_MinimumSnapshotName Size).toSize().width();315 int iMinimumNameWidth = data(MachineItemData_MinimumNameWidth).toInt(); 316 int iMinimumSnapshotNameWidth = data(MachineItemData_MinimumSnapshotNameWidth).toInt(); 312 317 int iMachineStatePixmapWidth = data(MachineItemData_StatePixmapSize).toSize().width(); 313 318 int iMachineStateTextWidth = data(MachineItemData_StateTextSize).toSize().width(); … … 317 322 int iProposedWidth = 0; 318 323 319 /* We are taking into account only left margin, 320 * tool-bar contains right one: */ 321 iProposedWidth += iMachineItemMargin; 324 /* Two margins: */ 325 iProposedWidth += 2 * iMachineItemMargin; 322 326 /* And machine item content to take into account: */ 323 int i FirstLineWidth = iMinimumMachineNameWidth +324 325 326 int i SecondLineWidth = iMachineStatePixmapWidth +327 int iTopLineWidth = iMinimumNameWidth + 328 iMachineItemMinorSpacing + 329 iMinimumSnapshotNameWidth; 330 int iBottomLineWidth = iMachineStatePixmapWidth + 327 331 iMachineItemMinorSpacing + 328 332 iMachineStateTextWidth; 329 int i SecondColumnWidth = qMax(iFirstLineWidth, iSecondLineWidth);333 int iRightColumnWidth = qMax(iTopLineWidth, iBottomLineWidth); 330 334 int iMachineItemWidth = iMachinePixmapWidth + 331 335 iMachineItemMajorSpacing + 332 i SecondColumnWidth +333 iMachineItemMajorSpacing +334 iToolBarWidth + 1;336 iRightColumnWidth; 337 if (m_pToolBar) 338 iMachineItemWidth += (iMachineItemMajorSpacing + iToolBarWidth); 335 339 iProposedWidth += iMachineItemWidth; 336 340 … … 354 358 int iProposedHeight = 0; 355 359 356 /* Simple machine item have 2 margins - top and bottom: */360 /* Two margins: */ 357 361 iProposedHeight += 2 * iMachineItemMargin; 358 362 /* And machine item content to take into account: */ 359 int i FirstLineHeight = qMax(iMachineNameHeight, iSnapshotNameHeight);360 int i SecondLineHeight = qMax(iMachineStatePixmapHeight, iMachineStateTextHeight);361 int i SecondColumnHeight = iFirstLineHeight +363 int iTopLineHeight = qMax(iMachineNameHeight, iSnapshotNameHeight); 364 int iBottomLineHeight = qMax(iMachineStatePixmapHeight, iMachineStateTextHeight); 365 int iRightColumnHeight = iTopLineHeight + 362 366 iMachineItemTextSpacing + 363 i SecondLineHeight;367 iBottomLineHeight; 364 368 QList<int> heights; 365 heights << iMachinePixmapHeight << iSecondColumnHeight 366 << (iToolBarHeight - 2 * iMachineItemMargin + 2); 369 heights << iMachinePixmapHeight << iRightColumnHeight << iToolBarHeight; 367 370 int iMaxHeight = 0; 368 371 foreach (int iHeight, heights) … … 506 509 507 510 /* Paint frame: */ 508 paintFrameRect (pPainter, fullRect, model()->selectionList().contains(this), m_iCornerRadius);511 paintFrameRectangle(pPainter, fullRect); 509 512 } 510 513 … … 514 517 pPainter->save(); 515 518 516 /* Fill rectangle with white color: */517 pPainter->fillRect(rect, Qt::white);518 519 519 /* Prepare color: */ 520 520 QPalette pal = palette(); 521 QColor base = pal.color(QPalette::Active, model()->selectionList().contains(this) ? 522 QPalette::Highlight : QPalette::Window); 523 524 /* Make even less rectangle: */ 525 QRect backGroundRect = rect; 526 backGroundRect.setTopLeft(backGroundRect.topLeft() + QPoint(2, 2)); 527 backGroundRect.setBottomRight(backGroundRect.bottomRight() - QPoint(2, 2)); 528 /* Add even more clipping: */ 529 QPainterPath roundedPath; 530 roundedPath.addRoundedRect(backGroundRect, m_iCornerRadius, m_iCornerRadius); 531 pPainter->setClipPath(roundedPath); 532 533 /* Calculate top rectangle: */ 534 QRect tRect = backGroundRect; 535 tRect.setBottom(tRect.top() + tRect.height() / 3); 536 /* Calculate bottom rectangle: */ 537 QRect bRect = backGroundRect; 538 bRect.setTop(bRect.bottom() - bRect.height() / 3); 539 /* Calculate middle rectangle: */ 540 QRect midRect = QRect(tRect.bottomLeft(), bRect.topRight()); 541 542 /* Prepare top gradient: */ 543 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 544 tGradient.setColorAt(0, base.darker(gradient())); 545 tGradient.setColorAt(1, base.darker(104)); 546 /* Prepare bottom gradient: */ 547 QLinearGradient bGradient(bRect.topLeft(), bRect.bottomLeft()); 548 bGradient.setColorAt(0, base.darker(gradient())); 549 bGradient.setColorAt(1, base.darker(104)); 550 551 /* Paint all the stuff: */ 552 pPainter->fillRect(midRect, base.darker(gradient())); 553 pPainter->fillRect(tRect, tGradient); 554 pPainter->fillRect(bRect, bGradient); 521 522 /* Selection background: */ 523 if (model()->selectionList().contains(this)) 524 { 525 /* Highlight color: */ 526 QColor highlight = pal.color(QPalette::Active, QPalette::Highlight); 527 528 /* Calculate top rectangle: */ 529 QRect tRect = rect; 530 tRect.setBottom(tRect.top() + tRect.height() / 3); 531 /* Calculate bottom rectangle: */ 532 QRect bRect = rect; 533 bRect.setTop(bRect.bottom() - bRect.height() / 3); 534 /* Calculate middle rectangle: */ 535 QRect midRect = QRect(tRect.bottomLeft(), bRect.topRight()); 536 537 /* Prepare top gradient: */ 538 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 539 tGradient.setColorAt(0, highlight.darker(103)); 540 tGradient.setColorAt(1, highlight.darker(110)); 541 /* Prepare bottom gradient: */ 542 QLinearGradient bGradient(bRect.topLeft(), bRect.bottomLeft()); 543 bGradient.setColorAt(0, highlight.darker(103)); 544 bGradient.setColorAt(1, highlight.darker(110)); 545 546 /* Paint all the stuff: */ 547 pPainter->fillRect(midRect, highlight.darker(103)); 548 pPainter->fillRect(tRect, tGradient); 549 pPainter->fillRect(bRect, bGradient); 550 } 551 552 /* Hovering background: */ 553 if (isHovered()) 554 { 555 /* Choose color: */ 556 QColor baseLight = pal.color(QPalette::Active, model()->selectionList().contains(this) || 557 model()->selectionList().contains(parentItem()) ? 558 QPalette::Highlight : QPalette::Window); 559 QColor blurBase = pal.color(QPalette::Active, model()->selectionList().contains(this) || 560 model()->selectionList().contains(parentItem()) ? 561 QPalette::Highlight : QPalette::Window); 562 if (!parentItem()->isRoot()) 563 blurBase = blurBase.darker(110); 564 blurBase.setAlpha(0); 565 566 /* Draw background for blur: */ 567 QImage background(rect.size(), QImage::Format_ARGB32); 568 background.fill(blurBase.rgba()); 569 570 /* Add blur itself: */ 571 QPainter blurPainter(&background); 572 blurPainter.setBrush(baseLight.darker(gradient())); 573 blurPainter.setPen(Qt::NoPen); 574 blurPainter.drawRoundedRect(rect.adjusted(5, 5, -5, -5), 5, 5); 575 blurPainter.end(); 576 QImage bluredBackground(rect.size(), QImage::Format_ARGB32); 577 blurImage(background, bluredBackground, 5); 578 579 /* Paint highlight bar: */ 580 pPainter->drawImage(QPoint(0, 0), bluredBackground); 581 } 555 582 556 583 /* Paint drag token UP? */ 557 584 if (dragTokenPlace() != DragToken_Off) 558 585 { 586 /* Window color: */ 587 QColor base = pal.color(QPalette::Active, model()->selectionList().contains(this) ? 588 QPalette::Highlight : QPalette::Window); 559 589 QLinearGradient dragTokenGradient; 560 QRect dragTokenRect = backGroundRect;590 QRect dragTokenRect = rect; 561 591 if (dragTokenPlace() == DragToken_Up) 562 592 { … … 580 610 } 581 611 612 void UIGChooserItemMachine::paintFrameRectangle(QPainter *pPainter, const QRect &rect) 613 { 614 /* Only chosen item should have a frame: */ 615 if (!model()->selectionList().contains(this)) 616 return; 617 618 /* Simple white frame: */ 619 pPainter->save(); 620 pPainter->setPen(Qt::white); 621 pPainter->drawRect(rect); 622 pPainter->restore(); 623 } 624 582 625 void UIGChooserItemMachine::paintMachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption) 583 626 { 584 /* Initialize some necessaryvariables: */627 /* Prepare variables: */ 585 628 QRect fullRect = pOption->rect; 586 int iMachineItemMargin = data(MachineItemData_Margin).toInt(); 629 int iFullHeight = fullRect.height(); 630 int iMargin = data(MachineItemData_Margin).toInt(); 587 631 int iMachineItemMajorSpacing = data(MachineItemData_MajorSpacing).toInt(); 588 632 int iMachineItemMinorSpacing = data(MachineItemData_MinorSpacing).toInt(); … … 590 634 QSize machinePixmapSize = data(MachineItemData_PixmapSize).toSize(); 591 635 QSize machineNameSize = data(MachineItemData_NameSize).toSize(); 592 QString strSnapshotName = data(MachineItemData_SnapshotName).toString();593 636 QSize snapshotNameSize = data(MachineItemData_SnapshotNameSize).toSize(); 594 637 QSize machineStatePixmapSize = data(MachineItemData_StatePixmapSize).toSize(); 595 638 QSize machineStateTextSize = data(MachineItemData_StateTextSize).toSize(); 596 639 597 /* Paint pixmap: */ 598 { 599 /* Calculate attributes: */ 600 int iMachinePixmapHeight = machinePixmapSize.height(); 601 int iFirstLineHeight = qMax(machineNameSize.height(), snapshotNameSize.height()); 602 int iSecondLineHeight = qMax(machineStatePixmapSize.height(), machineStateTextSize.height()); 603 int iRightSizeHeight = iFirstLineHeight + iMachineItemTextSpacing + iSecondLineHeight; 604 int iMinimumHeight = qMin(iMachinePixmapHeight, iRightSizeHeight); 605 int iMaximumHeight = qMax(iMachinePixmapHeight, iRightSizeHeight); 606 int iDelta = iMaximumHeight - iMinimumHeight; 607 int iHalfDelta = iDelta / 2; 608 int iMachinePixmapX = iMachineItemMargin; 609 int iMachinePixmapY = iMachinePixmapHeight >= iRightSizeHeight ? 610 iMachineItemMargin : iMachineItemMargin + iHalfDelta; 611 640 /* Calculate indents: */ 641 int iLeftColumnIndent = iMargin; 642 643 /* Paint left column: */ 644 { 645 /* Prepare variables: */ 646 int iMachinePixmapX = iLeftColumnIndent; 647 int iMachinePixmapY = (iFullHeight - machinePixmapSize.height()) / 2; 648 /* Paint pixmap: */ 612 649 paintPixmap(/* Painter: */ 613 650 pPainter, 614 651 /* Rectangle to paint in: */ 615 QRect(fullRect.topLeft() + 616 QPoint(iMachinePixmapX, iMachinePixmapY), 617 machinePixmapSize), 652 QRect(QPoint(iMachinePixmapX, iMachinePixmapY), machinePixmapSize), 618 653 /* Pixmap to paint: */ 619 654 data(MachineItemData_Pixmap).value<QIcon>().pixmap(machinePixmapSize)); 620 655 } 621 656 622 /* Paint name: */ 623 { 624 paintText(/* Painter: */ 625 pPainter, 626 /* Rectangle to paint in: */ 627 QRect(fullRect.topLeft() + 628 QPoint(iMachineItemMargin, iMachineItemMargin) + 629 QPoint(machinePixmapSize.width() + iMachineItemMajorSpacing, 0), 630 machineNameSize), 631 /* Font to paint text: */ 632 data(MachineItemData_NameFont).value<QFont>(), 633 /* Text to paint: */ 634 data(MachineItemData_Name).toString()); 635 } 636 637 /* Paint snapshot name (if necessary): */ 638 if (!strSnapshotName.isEmpty()) 639 { 640 paintText(/* Painter: */ 641 pPainter, 642 /* Rectangle to paint in: */ 643 QRect(fullRect.topLeft() + 644 QPoint(iMachineItemMargin, iMachineItemMargin) + 645 QPoint(machinePixmapSize.width() + iMachineItemMajorSpacing, 0) + 646 QPoint(machineNameSize.width() + iMachineItemMinorSpacing, 0), 647 snapshotNameSize), 648 /* Font to paint text: */ 649 data(MachineItemData_SnapshotNameFont).value<QFont>(), 650 /* Text to paint: */ 651 QString("(%1)").arg(strSnapshotName)); 652 } 653 654 /* Paint state pixmap: */ 655 { 656 paintPixmap(/* Painter: */ 657 pPainter, 658 /* Rectangle to paint in: */ 659 QRect(fullRect.topLeft() + 660 QPoint(iMachineItemMargin, iMachineItemMargin) + 661 QPoint(machinePixmapSize.width() + iMachineItemMajorSpacing, 0) + 662 QPoint(0, machineNameSize.height() + iMachineItemTextSpacing), 663 machineStatePixmapSize), 664 /* Pixmap to paint: */ 665 data(MachineItemData_StatePixmap).value<QIcon>().pixmap(machineStatePixmapSize)); 666 } 667 668 /* Paint state text: */ 669 { 670 paintText(/* Painter: */ 671 pPainter, 672 /* Rectangle to paint in: */ 673 QRect(fullRect.topLeft() + 674 QPoint(iMachineItemMargin, iMachineItemMargin) + 675 QPoint(machinePixmapSize.width() + iMachineItemMajorSpacing, 0) + 676 QPoint(0, machineNameSize.height() + iMachineItemTextSpacing) + 677 QPoint(machineStatePixmapSize.width() + iMachineItemMinorSpacing, 0), 678 machineStateTextSize), 679 /* Font to paint text: */ 680 data(MachineItemData_StateTextFont).value<QFont>(), 681 /* Text to paint: */ 682 data(MachineItemData_StateText).toString()); 683 } 684 657 /* Calculate indents: */ 658 int iRightColumnIndent = iLeftColumnIndent + 659 machinePixmapSize.width() + 660 iMachineItemMajorSpacing; 661 662 /* Paint right column: */ 663 { 664 /* Calculate indents: */ 665 int iTopLineHeight = qMax(machineNameSize.height(), snapshotNameSize.height()); 666 int iBottomLineHeight = qMax(machineStatePixmapSize.height(), machineStateTextSize.height()); 667 int iRightColumnHeight = iTopLineHeight + iMachineItemTextSpacing + iBottomLineHeight; 668 int iTopLineIndent = (iFullHeight - iRightColumnHeight) / 2; 669 670 /* Paint top line: */ 671 { 672 /* Paint left element: */ 673 { 674 /* Prepare variables: */ 675 int iNameX = iRightColumnIndent; 676 int iNameY = iTopLineIndent; 677 /* Paint name: */ 678 paintText(/* Painter: */ 679 pPainter, 680 /* Rectangle to paint in: */ 681 QRect(QPoint(iNameX, iNameY), machineNameSize), 682 /* Font to paint text: */ 683 data(MachineItemData_NameFont).value<QFont>(), 684 /* Text to paint: */ 685 data(MachineItemData_Name).toString()); 686 } 687 688 /* Calculate indents: */ 689 int iSnapshotNameIndent = iRightColumnIndent + 690 machineNameSize.width() + 691 iMachineItemMinorSpacing; 692 693 /* Paint right element: */ 694 if (!snapshotName().isEmpty()) 695 { 696 /* Prepare variables: */ 697 int iSnapshotNameX = iSnapshotNameIndent; 698 int iSnapshotNameY = iTopLineIndent; 699 /* Paint snapshot name: */ 700 paintText(/* Painter: */ 701 pPainter, 702 /* Rectangle to paint in: */ 703 QRect(QPoint(iSnapshotNameX, iSnapshotNameY), snapshotNameSize), 704 /* Font to paint text: */ 705 data(MachineItemData_SnapshotNameFont).value<QFont>(), 706 /* Text to paint: */ 707 data(MachineItemData_SnapshotName).toString()); 708 } 709 } 710 711 /* Calculate indents: */ 712 int iBottomLineIndent = iTopLineIndent + iTopLineHeight; 713 714 /* Paint bottom line: */ 715 { 716 /* Paint left element: */ 717 { 718 /* Prepare variables: */ 719 int iMachineStatePixmapX = iRightColumnIndent; 720 int iMachineStatePixmapY = iBottomLineIndent; 721 /* Paint state pixmap: */ 722 paintPixmap(/* Painter: */ 723 pPainter, 724 /* Rectangle to paint in: */ 725 QRect(QPoint(iMachineStatePixmapX, iMachineStatePixmapY), machineStatePixmapSize), 726 /* Pixmap to paint: */ 727 data(MachineItemData_StatePixmap).value<QIcon>().pixmap(machineStatePixmapSize)); 728 } 729 730 /* Calculate indents: */ 731 int iMachineStateTextIndent = iRightColumnIndent + 732 machineStatePixmapSize.width() + 733 iMachineItemMinorSpacing; 734 735 /* Paint right element: */ 736 { 737 /* Prepare variables: */ 738 int iMachineStateTextX = iMachineStateTextIndent; 739 int iMachineStateTextY = iBottomLineIndent; 740 /* Paint state text: */ 741 paintText(/* Painter: */ 742 pPainter, 743 /* Rectangle to paint in: */ 744 QRect(QPoint(iMachineStateTextX, iMachineStateTextY), machineStateTextSize), 745 /* Font to paint text: */ 746 data(MachineItemData_StateTextFont).value<QFont>(), 747 /* Text to paint: */ 748 data(MachineItemData_StateText).toString()); 749 } 750 } 751 } 752 753 /* Tool-bar: */ 685 754 if (m_pToolBar) 686 755 { -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h
r42563 r42593 80 80 MachineItemData_PixmapSize, 81 81 MachineItemData_StatePixmapSize, 82 MachineItemData_MinimumNameSize,83 82 MachineItemData_NameSize, 84 MachineItemData_MinimumSnapshotNameSize, 83 MachineItemData_MinimumNameWidth, 84 MachineItemData_MaximumNameWidth, 85 85 MachineItemData_SnapshotNameSize, 86 MachineItemData_MinimumSnapshotNameWidth, 87 MachineItemData_MaximumSnapshotNameWidth, 86 88 MachineItemData_FirstRowMaximumWidth, 87 89 MachineItemData_StateTextSize, … … 121 123 void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 122 124 void paintBackground(QPainter *pPainter, const QRect &rect); 125 void paintFrameRectangle(QPainter *pPainter, const QRect &rect); 123 126 void paintMachineInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 124 127 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
r42544 r42593 41 41 , m_pButton(0) 42 42 , m_iAdditionalHeight(0) 43 , m_iCornerRadius( 6)43 , m_iCornerRadius(10) 44 44 , m_fHovered(false) 45 45 , m_fNameHoveringAccessible(false) … … 544 544 /* Prepare top gradient: */ 545 545 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 546 tGradient.setColorAt(0, windowColor.darker(11 5));546 tGradient.setColorAt(0, windowColor.darker(110)); 547 547 tGradient.setColorAt(1, windowColor.darker(103)); 548 548
Note:
See TracChangeset
for help on using the changeset viewer.