- Timestamp:
- Sep 26, 2018 3:43:18 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.cpp
r74246 r74481 32 32 # include "UIVirtualBoxManager.h" 33 33 34 /* Other VBox includes: */ 35 #include "iprt/cpp/utils.h" 36 34 37 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 35 38 … … 176 179 } 177 180 178 void UIChooserItemGlobal::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget * /* pWidget = 0 */) 179 { 180 /* Setup: */ 181 pPainter->setRenderHint(QPainter::Antialiasing); 182 183 /* Paint decorations: */ 184 paintDecorations(pPainter, pOption); 185 181 void UIChooserItemGlobal::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions, QWidget * /* pWidget = 0 */) 182 { 183 /* Acquire rectangle: */ 184 const QRect rectangle = pOptions->rect; 185 186 /* Paint background: */ 187 paintBackground(pPainter, rectangle); 188 /* Paint frame: */ 189 paintFrame(pPainter, rectangle); 186 190 /* Paint global info: */ 187 paintGlobalInfo(pPainter, pOption);191 paintGlobalInfo(pPainter, rectangle); 188 192 } 189 193 … … 508 512 } 509 513 510 void UIChooserItemGlobal::paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption) 511 { 512 /* Prepare variables: */ 513 QRect fullRect = pOption->rect; 514 515 /* Paint background: */ 516 paintBackground(pPainter, fullRect); 517 518 /* Paint frame: */ 519 paintFrameRectangle(pPainter, fullRect); 520 } 521 522 void UIChooserItemGlobal::paintBackground(QPainter *pPainter, const QRect &rect) 514 void UIChooserItemGlobal::paintBackground(QPainter *pPainter, const QRect &rectangle) const 523 515 { 524 516 /* Save painter: */ … … 529 521 530 522 /* Selection background: */ 531 if (model()->currentItems().contains( this))523 if (model()->currentItems().contains(unconst(this))) 532 524 { 533 525 /* Prepare color: */ 534 526 QColor highlight = pal.color(QPalette::Active, QPalette::Highlight); 535 527 /* Draw gradient: */ 536 QLinearGradient bgGrad(rect .topLeft(), rect.bottomLeft());528 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft()); 537 529 bgGrad.setColorAt(0, highlight.lighter(m_iHighlightLightness)); 538 530 bgGrad.setColorAt(1, highlight); 539 pPainter->fillRect(rect , bgGrad);531 pPainter->fillRect(rectangle, bgGrad); 540 532 } 541 533 /* Hovering background: */ … … 545 537 QColor highlight = pal.color(QPalette::Active, QPalette::Highlight); 546 538 /* Draw gradient: */ 547 QLinearGradient bgGrad(rect .topLeft(), rect.bottomLeft());539 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft()); 548 540 bgGrad.setColorAt(0, highlight.lighter(m_iHoverHighlightLightness)); 549 541 bgGrad.setColorAt(1, highlight.lighter(m_iHoverLightness)); 550 pPainter->fillRect(rect , bgGrad);542 pPainter->fillRect(rectangle, bgGrad); 551 543 } 552 544 … … 555 547 } 556 548 557 void UIChooserItemGlobal::paintFrame Rectangle(QPainter *pPainter, const QRect &rect)549 void UIChooserItemGlobal::paintFrame(QPainter *pPainter, const QRect &rectangle) const 558 550 { 559 551 /* Only chosen and/or hovered item should have a frame: */ 560 if (!model()->currentItems().contains( this) && !isHovered())552 if (!model()->currentItems().contains(unconst(this)) && !isHovered()) 561 553 return; 562 554 563 /* S imple frame: */555 /* Save painter: */ 564 556 pPainter->save(); 557 558 /* Prepare color: */ 565 559 const QPalette pal = palette(); 566 560 QColor strokeColor = pal.color(QPalette::Active, 567 model()->currentItems().contains( this) ?561 model()->currentItems().contains(unconst(this)) ? 568 562 QPalette::Mid : QPalette::Highlight); 569 pPainter->setPen(strokeColor); 570 pPainter->drawRect(rect); 563 564 /* Create/assign pen: */ 565 QPen pen(strokeColor); 566 pen.setWidth(0); 567 pPainter->setPen(pen); 568 569 /* Draw rectangle: */ 570 pPainter->drawRect(rectangle); 571 572 /* Restore painter: */ 571 573 pPainter->restore(); 572 574 } 573 575 574 void UIChooserItemGlobal::paintGlobalInfo(QPainter *pPainter, const Q StyleOptionGraphicsItem *pOption)576 void UIChooserItemGlobal::paintGlobalInfo(QPainter *pPainter, const QRect &rectangle) const 575 577 { 576 578 /* Prepare variables: */ 577 const QRect fullRect = pOption->rect; 578 const int iFullHeight = fullRect.height(); 579 const int iFullHeight = rectangle.height(); 579 580 const int iMargin = data(GlobalItemData_Margin).toInt(); 580 581 const int iSpacing = data(GlobalItemData_Spacing).toInt(); 581 582 582 583 /* Selected item foreground: */ 583 if (model()->currentItems().contains( this))584 if (model()->currentItems().contains(unconst(this))) 584 585 { 585 586 const QPalette pal = palette(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGlobal.h
r74138 r74481 205 205 /** @name Painting stuff. 206 206 * @{ */ 207 /** Paints decorations using specified @a pPainter and certain @a pOptions. */ 208 void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOptions); 209 /** Paints background using specified @a pPainter and certain @a rect. */ 210 void paintBackground(QPainter *pPainter, const QRect &rect); 211 /** Paints frame rectangle using specified @a pPainter and certain @a rect. */ 212 void paintFrameRectangle(QPainter *pPainter, const QRect &rect); 207 /** Paints background using specified @a pPainter and certain @a rectangle. */ 208 void paintBackground(QPainter *pPainter, const QRect &rectangle) const; 209 /** Paints frame using specified @a pPainter and certain @a rect. */ 210 void paintFrame(QPainter *pPainter, const QRect &rectangle) const; 213 211 /** Paints global info using specified @a pPainter and certain @a pOptions. */ 214 void paintGlobalInfo(QPainter *pPainter, const Q StyleOptionGraphicsItem *pOptions);212 void paintGlobalInfo(QPainter *pPainter, const QRect &rectangle) const; 215 213 /** @} */ 216 214
Note:
See TracChangeset
for help on using the changeset viewer.