Changeset 108690 in vbox
- Timestamp:
- Mar 21, 2025 1:49:37 PM (4 weeks ago)
- svn:sync-xref-src-repo-rev:
- 168106
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIGlobalToolsWidget.cpp
r108665 r108690 348 348 349 349 /* Create tool-menu: */ 350 m_pMenu = new UITools(this, UIToolClass_Invalid, actionPool() , Qt::Widget);350 m_pMenu = new UITools(this, UIToolClass_Invalid, actionPool()); 351 351 if (toolMenu()) 352 352 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.cpp
r108308 r108690 5 5 6 6 /* 7 * Copyright (C) 2012-202 4Oracle and/or its affiliates.7 * Copyright (C) 2012-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 40 40 UITools::UITools(QWidget *pParent, 41 41 UIToolClass enmClass, 42 UIActionPool *pActionPool, 43 Qt::WindowFlags theFlags /* = Qt::Popup */) 44 : QWidget(pParent, theFlags) 42 UIActionPool *pActionPool) 43 : QWidget(pParent, Qt::Widget) 45 44 , m_enmClass(enmClass) 46 45 , m_pActionPool(pActionPool) 47 , m_fPopup(theFlags == Qt::Popup)48 46 , m_pMainLayout(0) 49 47 , m_pToolsModel(0) … … 118 116 { 119 117 /* Prepare model: */ 120 m_pToolsModel = new UIToolsModel(this, m_pActionPool, m_enmClass , m_fPopup);118 m_pToolsModel = new UIToolsModel(this, m_pActionPool, m_enmClass); 121 119 if (m_pToolsModel) 122 120 prepareView(); … … 129 127 130 128 /* Prepare view: */ 131 m_pToolsView = new UIToolsView(this, m_pToolsModel , m_fPopup);129 m_pToolsView = new UIToolsView(this, m_pToolsModel); 132 130 if (m_pToolsView) 133 131 { … … 143 141 { 144 142 /* Model connections: */ 145 connect(m_pToolsModel, &UIToolsModel::sigClose,146 this, &UITools::close);147 143 connect(m_pToolsModel, &UIToolsModel::sigSelectionChanged, 148 144 this, &UITools::sigSelectionChanged); … … 157 153 { 158 154 /* Model connections: */ 159 disconnect(m_pToolsModel, &UIToolsModel::sigClose,160 this, &UITools::close);161 155 disconnect(m_pToolsModel, &UIToolsModel::sigSelectionChanged, 162 156 this, &UITools::sigSelectionChanged); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.h
r108308 r108690 5 5 6 6 /* 7 * Copyright (C) 2012-202 4Oracle and/or its affiliates.7 * Copyright (C) 2012-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 62 62 /** Constructs Tools-pane passing @a pParent to the base-class. 63 63 * @param enmClass Brings the tools class, it will be fixed one. 64 * @param pActionPool Brings the action-pool reference. 65 * @param theFlags Brings the widget flags. */ 64 * @param pActionPool Brings the action-pool reference. */ 66 65 UITools(QWidget *pParent, 67 66 UIToolClass enmClass, 68 UIActionPool *pActionPool, 69 Qt::WindowFlags theFlags = Qt::Popup); 67 UIActionPool *pActionPool); 70 68 /** Destructs Tools-pane. */ 71 69 virtual ~UITools(); … … 124 122 UIActionPool *m_pActionPool; 125 123 126 /** Holds whether tools represented as popup. */127 const bool m_fPopup;128 129 124 /** Holds the main layout instance. */ 130 125 QVBoxLayout *m_pMainLayout; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp
r108606 r108690 5 5 6 6 /* 7 * Copyright (C) 2012-202 4Oracle and/or its affiliates.7 * Copyright (C) 2012-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 31 31 #include <QGraphicsScene> 32 32 #include <QPainter> 33 #include <QPropertyAnimation>34 #include <QSignalTransition>35 #include <QStateMachine>36 33 #include <QStyle> 37 34 #include <QStyleOptionGraphicsItem> … … 41 38 /* GUI includes: */ 42 39 #include "UICommon.h" 43 #include "UIImageTools.h"44 #include "UITools.h"45 40 #include "UIToolsItem.h" 46 41 #include "UIToolsModel.h" … … 193 188 , m_enmReason(HidingReason_Null) 194 189 , m_fHovered(false) 195 , m_pHoveringMachine(0)196 , m_pHoveringAnimationForward(0)197 , m_pHoveringAnimationBackward(0)198 , m_iAnimationDuration(400)199 , m_iDefaultValue(0)200 , m_iHoveredValue(100)201 , m_iAnimatedValue(m_iDefaultValue)202 , m_iDefaultLightnessStart(0)203 , m_iDefaultLightnessFinal(0)204 , m_iHoverLightnessStart(0)205 , m_iHoverLightnessFinal(0)206 , m_iHighlightLightnessStart(0)207 , m_iHighlightLightnessFinal(0)208 190 , m_iPreviousMinimumWidthHint(0) 209 191 , m_iPreviousMinimumHeightHint(0) … … 253 235 } 254 236 255 void UIToolsItem::setHovered(bool fHovered)256 {257 m_fHovered = fHovered;258 if (m_fHovered)259 emit sigHoverEnter();260 else261 emit sigHoverLeave();262 }263 264 237 void UIToolsItem::updateGeometry() 265 238 { … … 297 270 iProposedWidth += 2 * iMargin; 298 271 #ifdef VBOX_WS_MAC 299 /* Additional 2 margins for widget mode: */ 300 if (!model()->isPopup()) 301 iProposedWidth += 2 * iMargin; 272 /* Additional 2 margins: */ 273 iProposedWidth += 2 * iMargin; 302 274 #else 303 /* Additional 1 margin for widget mode: */ 304 if (!model()->isPopup()) 305 iProposedWidth += iMargin; 275 /* Additional 1 margin: */ 276 iProposedWidth += iMargin; 306 277 #endif 307 278 … … 309 280 iProposedWidth += m_pixmapSize.width(); 310 281 311 /* Add text size for non-Aux tools in popup mode 312 * or if it is requested for widget mode: */ 282 /* Add text size for non-Aux tools if it is requested: */ 313 283 if ( m_enmClass != UIToolClass_Aux 314 && ( model()->isPopup() 315 || model()->showItemNames())) 284 && model()->showItemNames()) 316 285 { 317 286 iProposedWidth += m_nameSize.width(); … … 319 288 /* Add 1 spacing by default: */ 320 289 iProposedWidth += iSpacing; 321 /* Additional 1 spacing for widget mode: */ 322 if (!model()->isPopup()) 323 iProposedWidth += iSpacing; 290 /* Additional 1 spacing: */ 291 iProposedWidth += iSpacing; 324 292 } 325 293 … … 370 338 { 371 339 m_fHovered = true; 372 emit sigHoverEnter();373 340 update(); 374 341 375 /* Show tooltip at the right of item for widget mode: */ 376 if ( !model()->isPopup() 377 && !model()->showItemNames()) 342 /* Show tooltip if there is no name: */ 343 if (!model()->showItemNames()) 378 344 { 379 345 const QPointF posAtScene = mapToScene(rect().topRight() + QPoint(3, -3)); … … 389 355 { 390 356 m_fHovered = false; 391 emit sigHoverLeave();392 357 update(); 393 358 394 359 /* Hide tooltip for good: */ 395 if (!model()->isPopup()) 396 QToolTip::hideText(); 360 QToolTip::hideText(); 397 361 } 398 362 } … … 405 369 /* Paint background: */ 406 370 paintBackground(pPainter, rectangle); 407 /* Paint frame for popup only: */408 if (model()->isPopup())409 paintFrame(pPainter, rectangle);410 371 /* Paint tool info: */ 411 372 paintToolInfo(pPainter, rectangle); … … 426 387 /* Install Tools-view item accessibility interface factory: */ 427 388 QAccessible::installFactory(UIAccessibilityInterfaceForUIToolsItem::pFactory); 428 429 /* Prepare color tones: */430 #if defined(VBOX_WS_MAC)431 m_iDefaultLightnessStart = 120;432 m_iDefaultLightnessFinal = 110;433 m_iHoverLightnessStart = 125;434 m_iHoverLightnessFinal = 115;435 m_iHighlightLightnessStart = 115;436 m_iHighlightLightnessFinal = 105;437 #elif defined(VBOX_WS_WIN)438 m_iDefaultLightnessStart = 120;439 m_iDefaultLightnessFinal = 110;440 m_iHoverLightnessStart = 220;441 m_iHoverLightnessFinal = 210;442 m_iHighlightLightnessStart = 190;443 m_iHighlightLightnessFinal = 180;444 #else /* !VBOX_WS_MAC && !VBOX_WS_WIN */445 m_iDefaultLightnessStart = 110;446 m_iDefaultLightnessFinal = 100;447 m_iHoverLightnessStart = 125;448 m_iHoverLightnessFinal = 115;449 m_iHighlightLightnessStart = 110;450 m_iHighlightLightnessFinal = 100;451 #endif /* !VBOX_WS_MAC && !VBOX_WS_WIN */452 389 453 390 /* Configure item options: */ … … 457 394 setFlag(QGraphicsItem::ItemIsSelectable, false); 458 395 459 /* Prepare hover animation for popup mode only: */460 if (model()->isPopup())461 prepareHoverAnimation();462 396 /* Prepare connections: */ 463 397 prepareConnections(); … … 466 400 updatePixmap(); 467 401 updateNameSize(); 468 }469 470 void UIToolsItem::prepareHoverAnimation()471 {472 /* Create hovering animation machine: */473 m_pHoveringMachine = new QStateMachine(this);474 if (m_pHoveringMachine)475 {476 /* Create 'default' state: */477 QState *pStateDefault = new QState(m_pHoveringMachine);478 /* Create 'hovered' state: */479 QState *pStateHovered = new QState(m_pHoveringMachine);480 481 /* Configure 'default' state: */482 if (pStateDefault)483 {484 /* When we entering default state => we assigning animatedValue to m_iDefaultValue: */485 pStateDefault->assignProperty(this, "animatedValue", m_iDefaultValue);486 487 /* Add state transitions: */488 QSignalTransition *pDefaultToHovered = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHovered);489 if (pDefaultToHovered)490 {491 /* Create forward animation: */492 m_pHoveringAnimationForward = new QPropertyAnimation(this, "animatedValue", this);493 if (m_pHoveringAnimationForward)494 {495 m_pHoveringAnimationForward->setDuration(m_iAnimationDuration);496 m_pHoveringAnimationForward->setStartValue(m_iDefaultValue);497 m_pHoveringAnimationForward->setEndValue(m_iHoveredValue);498 499 /* Add to transition: */500 pDefaultToHovered->addAnimation(m_pHoveringAnimationForward);501 }502 }503 }504 505 /* Configure 'hovered' state: */506 if (pStateHovered)507 {508 /* When we entering hovered state => we assigning animatedValue to m_iHoveredValue: */509 pStateHovered->assignProperty(this, "animatedValue", m_iHoveredValue);510 511 /* Add state transitions: */512 QSignalTransition *pHoveredToDefault = pStateHovered->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault);513 if (pHoveredToDefault)514 {515 /* Create backward animation: */516 m_pHoveringAnimationBackward = new QPropertyAnimation(this, "animatedValue", this);517 if (m_pHoveringAnimationBackward)518 {519 m_pHoveringAnimationBackward->setDuration(m_iAnimationDuration);520 m_pHoveringAnimationBackward->setStartValue(m_iHoveredValue);521 m_pHoveringAnimationBackward->setEndValue(m_iDefaultValue);522 523 /* Add to transition: */524 pHoveredToDefault->addAnimation(m_pHoveringAnimationBackward);525 }526 }527 }528 529 /* Initial state is 'default': */530 m_pHoveringMachine->setInitialState(pStateDefault);531 /* Start state-machine: */532 m_pHoveringMachine->start();533 }534 402 } 535 403 … … 574 442 fnt.setWeight(QFont::Bold); 575 443 576 /* Make Machine & Management tool font smaller for widget mode: */ 577 if ( !model()->isPopup() 578 && ( itemClass() == UIToolClass_Machine 579 || itemClass() == UIToolClass_Management)) 444 /* Make Machine & Management tool font smaller: */ 445 if ( itemClass() == UIToolClass_Machine 446 || itemClass() == UIToolClass_Management) 580 447 fnt.setPointSize(fnt.pointSize() - 1); 581 448 … … 592 459 void UIToolsItem::updatePixmap() 593 460 { 594 /* Smaller Machine & Management tool icons in widget mode: */ 595 const int iIconMetric = !model()->isPopup() 596 && ( itemClass() == UIToolClass_Machine 597 || itemClass() == UIToolClass_Management) 461 /* Smaller Machine & Management tool icons: */ 462 const int iIconMetric = itemClass() == UIToolClass_Machine 463 || itemClass() == UIToolClass_Management 598 464 ? QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) 599 465 : QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.5; … … 638 504 const QPalette pal = QApplication::palette(); 639 505 640 /* For popup: */ 641 if (model()->isPopup()) 642 { 643 /* Selection background: */ 644 if (model()->currentItem(itemClass()) == this) 506 /* Selection background: */ 507 if (model()->currentItem(itemClass()) == this) 508 { 509 /* Acquire background color: */ 510 #ifdef VBOX_WS_MAC 511 const QColor selectionColor = uiCommon().isInDarkMode() 512 ? pal.color(QPalette::Active, QPalette::Button).lighter(150) 513 : pal.color(QPalette::Active, QPalette::Button).darker(150); 514 #else 515 const QColor selectionColor = uiCommon().isInDarkMode() 516 ? pal.color(QPalette::Active, QPalette::Accent) 517 : pal.color(QPalette::Active, QPalette::Accent); 518 #endif 519 QColor selectionColor1 = selectionColor; 520 QColor selectionColor2 = selectionColor; 521 selectionColor1.setAlpha(100); 522 selectionColor2.setAlpha(110); 523 524 /* Acquire token color: */ 525 const QColor highlightColor = isEnabled() 526 ? pal.color(QPalette::Active, QPalette::Highlight) 527 : pal.color(QPalette::Disabled, QPalette::Highlight); 528 const QColor highlightColor1 = uiCommon().isInDarkMode() 529 ? highlightColor.lighter(160) 530 : highlightColor.darker(160); 531 const QColor highlightColor2 = uiCommon().isInDarkMode() 532 ? highlightColor.lighter(140) 533 : highlightColor.darker(140); 534 535 /* Depending on item class: */ 536 switch (itemClass()) 645 537 { 646 /* Prepare color: */ 647 const QColor backgroundColor = isEnabled() 648 ? pal.color(QPalette::Active, QPalette::Highlight) 649 : pal.color(QPalette::Disabled, QPalette::Window); 650 /* Draw gradient: */ 651 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft()); 652 bgGrad.setColorAt(0, backgroundColor.lighter(m_iHighlightLightnessStart)); 653 bgGrad.setColorAt(1, backgroundColor.lighter(m_iHighlightLightnessFinal)); 654 pPainter->fillRect(rectangle, bgGrad); 655 656 if (isEnabled() && isHovered()) 538 case UIToolClass_Global: 657 539 { 658 /* Prepare color: */ 659 QColor animationColor1 = QColor(Qt::white); 660 QColor animationColor2 = QColor(Qt::white); 540 /* Draw gradient background: */ 541 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.topRight()); 542 bgGrad.setColorAt(0, selectionColor1); 543 bgGrad.setColorAt(1, selectionColor2); 544 pPainter->fillRect(rectangle, bgGrad); 545 546 /* Draw gradient token: */ 547 QRect tokenRect(rectangle.topLeft(), QSize(5, rectangle.height())); 548 QLinearGradient tkGrad(tokenRect.topLeft(), tokenRect.bottomLeft()); 549 tkGrad.setColorAt(0, highlightColor1); 550 tkGrad.setColorAt(1, highlightColor2); 551 pPainter->fillRect(tokenRect, tkGrad); 552 break; 553 } 554 case UIToolClass_Machine: 555 case UIToolClass_Management: 556 { 557 /* Draw gradient background: */ 558 QRect backgroundRect(rectangle.topLeft() + QPoint(5, 0), QSize(rectangle.width() - 5, rectangle.height())); 559 QLinearGradient bgGrad(backgroundRect.topLeft(), backgroundRect.topRight()); 560 bgGrad.setColorAt(0, selectionColor1); 561 bgGrad.setColorAt(1, selectionColor2); 562 pPainter->fillRect(backgroundRect, bgGrad); 563 564 /* Draw gradient token: */ 565 QRect tokenRect(rectangle.topRight() - QPoint(5, 0), QSize(5, rectangle.height())); 566 QLinearGradient hlGrad(tokenRect.topLeft(), tokenRect.bottomLeft()); 567 hlGrad.setColorAt(0, highlightColor1); 568 hlGrad.setColorAt(1, highlightColor2); 569 pPainter->fillRect(tokenRect, hlGrad); 570 break; 571 } 572 default: 573 break; 574 } 575 } 576 577 /* Hovering background for widget: */ 578 else if (m_fHovered) 579 { 580 /* Prepare variables: */ 581 const int iMargin = data(ToolsItemData_Margin).toInt(); 582 const int iPadding = data(ToolsItemData_Padding).toInt(); 583 584 /* Configure painter: */ 585 pPainter->setRenderHint(QPainter::Antialiasing, true); 586 /* Acquire background color: */ 661 587 #ifdef VBOX_WS_MAC 662 animationColor1.setAlpha(90); 588 const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window); 589 #else /* !VBOX_WS_MAC */ 590 const QColor windowColor = pal.color(QPalette::Active, QPalette::Window); 591 const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent); 592 const int iRed = iShift30(windowColor.red(), accentColor.red()); 593 const int iGreen = iShift30(windowColor.green(), accentColor.green()); 594 const int iBlue = iShift30(windowColor.blue(), accentColor.blue()); 595 const QColor backgroundColor = QColor(qRgb(iRed, iGreen, iBlue)); 596 #endif /* !VBOX_WS_MAC */ 597 598 /* A bit of indentation for Machine & Management tools in widget mode: */ 599 const int iIndent = itemClass() == UIToolClass_Machine || itemClass() == UIToolClass_Management 600 ? QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5 : 0; 601 602 /* Prepare icon sub-rect: */ 603 QRect subRect; 604 subRect.setHeight(m_pixmap.height() / m_pixmap.devicePixelRatio() + iPadding * 2); 605 subRect.setWidth(subRect.height()); 606 #ifdef VBOX_WS_MAC 607 subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 2 * iMargin - iPadding, iMargin - iPadding)); 663 608 #else 664 animationColor1.setAlpha(30);609 subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 1.5 * iMargin - iPadding, iMargin - iPadding)); 665 610 #endif 666 animationColor2.setAlpha(0); 667 /* Draw hovering animated gradient: */ 668 QRect animatedRect = rectangle; 669 animatedRect.setWidth(animatedRect.height()); 670 const int iLength = 2 * animatedRect.width() + rectangle.width(); 671 const int iShift = - animatedRect.width() + iLength * animatedValue() / 100; 672 animatedRect.moveLeft(iShift); 673 QLinearGradient bgAnimatedGrad(animatedRect.topLeft(), animatedRect.bottomRight()); 674 bgAnimatedGrad.setColorAt(0, animationColor2); 675 bgAnimatedGrad.setColorAt(0.1, animationColor2); 676 bgAnimatedGrad.setColorAt(0.5, animationColor1); 677 bgAnimatedGrad.setColorAt(0.9, animationColor2); 678 bgAnimatedGrad.setColorAt(1, animationColor2); 679 pPainter->fillRect(rectangle, bgAnimatedGrad); 680 } 681 } 682 /* Hovering background: */ 683 else if (isHovered()) 684 { 685 /* Prepare color: */ 686 const QColor backgroundColor = isEnabled() 687 ? pal.color(QPalette::Active, QPalette::Highlight) 688 : pal.color(QPalette::Disabled, QPalette::Window); 689 /* Draw gradient: */ 690 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft()); 691 bgGrad.setColorAt(0, backgroundColor.lighter(m_iHoverLightnessStart)); 692 bgGrad.setColorAt(1, backgroundColor.lighter(m_iHoverLightnessFinal)); 693 pPainter->fillRect(rectangle, bgGrad); 694 695 if (isEnabled()) 696 { 697 /* Prepare color: */ 698 QColor animationColor1 = QColor(Qt::white); 699 QColor animationColor2 = QColor(Qt::white); 611 612 /* Paint icon frame: */ 613 QPainterPath painterPath; 614 painterPath.addRoundedRect(subRect, iPadding, iPadding); 700 615 #ifdef VBOX_WS_MAC 701 animationColor1.setAlpha(120); 702 #else 703 animationColor1.setAlpha(50); 704 #endif 705 animationColor2.setAlpha(0); 706 /* Draw hovering animated gradient: */ 707 QRect animatedRect = rectangle; 708 animatedRect.setWidth(animatedRect.height()); 709 const int iLength = 2 * animatedRect.width() + rectangle.width(); 710 const int iShift = - animatedRect.width() + iLength * animatedValue() / 100; 711 animatedRect.moveLeft(iShift); 712 QLinearGradient bgAnimatedGrad(animatedRect.topLeft(), animatedRect.bottomRight()); 713 bgAnimatedGrad.setColorAt(0, animationColor2); 714 bgAnimatedGrad.setColorAt(0.1, animationColor2); 715 bgAnimatedGrad.setColorAt(0.5, animationColor1); 716 bgAnimatedGrad.setColorAt(0.9, animationColor2); 717 bgAnimatedGrad.setColorAt(1, animationColor2); 718 pPainter->fillRect(rectangle, bgAnimatedGrad); 719 } 720 } 721 /* Default background: */ 722 else 723 { 724 /* Prepare color: */ 725 const QColor backgroundColor = isEnabled() 726 ? pal.color(QPalette::Active, QPalette::Window) 727 : pal.color(QPalette::Disabled, QPalette::Window); 728 /* Draw gradient: */ 729 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.bottomLeft()); 730 bgGrad.setColorAt(0, backgroundColor.lighter(m_iDefaultLightnessStart)); 731 bgGrad.setColorAt(1, backgroundColor.lighter(m_iDefaultLightnessFinal)); 732 pPainter->fillRect(rectangle, bgGrad); 733 } 734 } 735 /* For widget: */ 736 else 737 { 738 /* Selection background: */ 739 if (model()->currentItem(itemClass()) == this) 740 { 741 /* Acquire background color: */ 616 const QColor backgroundColor1 = uiCommon().isInDarkMode() 617 ? backgroundColor.lighter(220) 618 : backgroundColor.darker(140); 619 #else /* !VBOX_WS_MAC */ 620 const QColor backgroundColor1 = uiCommon().isInDarkMode() 621 ? backgroundColor.lighter(140) 622 : backgroundColor.darker(120); 623 #endif /* !VBOX_WS_MAC */ 624 pPainter->setPen(QPen(backgroundColor1, 2, Qt::SolidLine, Qt::RoundCap)); 625 pPainter->drawPath(QPainterPathStroker().createStroke(painterPath)); 626 627 /* Fill icon body: */ 628 pPainter->setClipPath(painterPath); 742 629 #ifdef VBOX_WS_MAC 743 const QColor selectionColor = uiCommon().isInDarkMode() 744 ? pal.color(QPalette::Active, QPalette::Button).lighter(150) 745 : pal.color(QPalette::Active, QPalette::Button).darker(150); 746 #else 747 const QColor selectionColor = uiCommon().isInDarkMode() 748 ? pal.color(QPalette::Active, QPalette::Accent) 749 : pal.color(QPalette::Active, QPalette::Accent); 750 #endif 751 QColor selectionColor1 = selectionColor; 752 QColor selectionColor2 = selectionColor; 753 selectionColor1.setAlpha(100); 754 selectionColor2.setAlpha(110); 755 756 /* Acquire token color: */ 757 const QColor highlightColor = isEnabled() 758 ? pal.color(QPalette::Active, QPalette::Highlight) 759 : pal.color(QPalette::Disabled, QPalette::Highlight); 760 const QColor highlightColor1 = uiCommon().isInDarkMode() 761 ? highlightColor.lighter(160) 762 : highlightColor.darker(160); 763 const QColor highlightColor2 = uiCommon().isInDarkMode() 764 ? highlightColor.lighter(140) 765 : highlightColor.darker(140); 766 767 /* Depending on item class: */ 768 switch (itemClass()) 769 { 770 case UIToolClass_Global: 771 { 772 /* Draw gradient background: */ 773 QLinearGradient bgGrad(rectangle.topLeft(), rectangle.topRight()); 774 bgGrad.setColorAt(0, selectionColor1); 775 bgGrad.setColorAt(1, selectionColor2); 776 pPainter->fillRect(rectangle, bgGrad); 777 778 /* Draw gradient token: */ 779 QRect tokenRect(rectangle.topLeft(), QSize(5, rectangle.height())); 780 QLinearGradient tkGrad(tokenRect.topLeft(), tokenRect.bottomLeft()); 781 tkGrad.setColorAt(0, highlightColor1); 782 tkGrad.setColorAt(1, highlightColor2); 783 pPainter->fillRect(tokenRect, tkGrad); 784 break; 785 } 786 case UIToolClass_Machine: 787 case UIToolClass_Management: 788 { 789 /* Draw gradient background: */ 790 QRect backgroundRect(rectangle.topLeft() + QPoint(5, 0), QSize(rectangle.width() - 5, rectangle.height())); 791 QLinearGradient bgGrad(backgroundRect.topLeft(), backgroundRect.topRight()); 792 bgGrad.setColorAt(0, selectionColor1); 793 bgGrad.setColorAt(1, selectionColor2); 794 pPainter->fillRect(backgroundRect, bgGrad); 795 796 /* Draw gradient token: */ 797 QRect tokenRect(rectangle.topRight() - QPoint(5, 0), QSize(5, rectangle.height())); 798 QLinearGradient hlGrad(tokenRect.topLeft(), tokenRect.bottomLeft()); 799 hlGrad.setColorAt(0, highlightColor1); 800 hlGrad.setColorAt(1, highlightColor2); 801 pPainter->fillRect(tokenRect, hlGrad); 802 break; 803 } 804 default: 805 break; 806 } 807 } 808 809 /* Hovering background for widget: */ 810 else if (isHovered()) 811 { 812 /* Prepare variables: */ 813 const int iMargin = data(ToolsItemData_Margin).toInt(); 814 const int iPadding = data(ToolsItemData_Padding).toInt(); 815 816 /* Configure painter: */ 817 pPainter->setRenderHint(QPainter::Antialiasing, true); 818 /* Acquire background color: */ 819 #ifdef VBOX_WS_MAC 820 const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window); 630 const QColor backgroundColor2 = uiCommon().isInDarkMode() 631 ? backgroundColor.lighter(160) 632 : backgroundColor.darker(120); 821 633 #else /* !VBOX_WS_MAC */ 822 const QColor windowColor = pal.color(QPalette::Active, QPalette::Window); 823 const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent); 824 const int iRed = iShift30(windowColor.red(), accentColor.red()); 825 const int iGreen = iShift30(windowColor.green(), accentColor.green()); 826 const int iBlue = iShift30(windowColor.blue(), accentColor.blue()); 827 const QColor backgroundColor = QColor(qRgb(iRed, iGreen, iBlue)); 634 const QColor backgroundColor2 = uiCommon().isInDarkMode() 635 ? backgroundColor.lighter(105) 636 : backgroundColor.darker(105); 828 637 #endif /* !VBOX_WS_MAC */ 829 830 /* A bit of indentation for Machine & Management tools in widget mode: */ 831 const int iIndent = itemClass() == UIToolClass_Machine || itemClass() == UIToolClass_Management 832 ? QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5 : 0; 833 834 /* Prepare icon sub-rect: */ 835 QRect subRect; 836 subRect.setHeight(m_pixmap.height() / m_pixmap.devicePixelRatio() + iPadding * 2); 837 subRect.setWidth(subRect.height()); 838 #ifdef VBOX_WS_MAC 839 subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 2 * iMargin - iPadding, iMargin - iPadding)); 840 #else 841 subRect.moveTopLeft(rectangle.topLeft() + QPoint(iIndent + 1.5 * iMargin - iPadding, iMargin - iPadding)); 842 #endif 843 844 /* Paint icon frame: */ 845 QPainterPath painterPath; 846 painterPath.addRoundedRect(subRect, iPadding, iPadding); 847 #ifdef VBOX_WS_MAC 848 const QColor backgroundColor1 = uiCommon().isInDarkMode() 849 ? backgroundColor.lighter(220) 850 : backgroundColor.darker(140); 851 #else /* !VBOX_WS_MAC */ 852 const QColor backgroundColor1 = uiCommon().isInDarkMode() 853 ? backgroundColor.lighter(140) 854 : backgroundColor.darker(120); 855 #endif /* !VBOX_WS_MAC */ 856 pPainter->setPen(QPen(backgroundColor1, 2, Qt::SolidLine, Qt::RoundCap)); 857 pPainter->drawPath(QPainterPathStroker().createStroke(painterPath)); 858 859 /* Fill icon body: */ 860 pPainter->setClipPath(painterPath); 861 #ifdef VBOX_WS_MAC 862 const QColor backgroundColor2 = uiCommon().isInDarkMode() 863 ? backgroundColor.lighter(160) 864 : backgroundColor.darker(120); 865 #else /* !VBOX_WS_MAC */ 866 const QColor backgroundColor2 = uiCommon().isInDarkMode() 867 ? backgroundColor.lighter(105) 868 : backgroundColor.darker(105); 869 #endif /* !VBOX_WS_MAC */ 870 pPainter->fillRect(subRect, backgroundColor2); 871 } 872 } 873 874 /* Restore painter: */ 875 pPainter->restore(); 876 } 877 878 void UIToolsItem::paintFrame(QPainter *pPainter, const QRect &rectangle) const 879 { 880 /* Don't paint frame for disabled items: */ 881 if (!isEnabled()) 882 return; 883 884 /* Save painter: */ 885 pPainter->save(); 886 887 /* Prepare colors: */ 888 const QPalette pal = QApplication::palette(); 889 QColor strokeColor; 890 891 /* Selection frame: */ 892 if (model()->currentItem(itemClass()) == this) 893 strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHighlightLightnessStart - 40); 894 /* Hovering frame: */ 895 else if (isHovered()) 896 strokeColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(m_iHoverLightnessStart - 40); 897 /* Default frame: */ 898 else 899 strokeColor = pal.color(QPalette::Active, QPalette::Window).lighter(m_iDefaultLightnessStart); 900 901 /* Create/assign pen: */ 902 QPen pen(strokeColor); 903 pen.setWidth(0); 904 pPainter->setPen(pen); 905 906 /* Draw borders: */ 907 pPainter->drawLine(rectangle.topLeft(), rectangle.topRight()); 908 pPainter->drawLine(rectangle.bottomLeft(), rectangle.bottomRight()); 909 pPainter->drawLine(rectangle.topLeft(), rectangle.bottomLeft()); 910 pPainter->drawLine(rectangle.topRight(), rectangle.bottomRight()); 638 pPainter->fillRect(subRect, backgroundColor2); 639 } 911 640 912 641 /* Restore painter: */ … … 922 651 const QPalette pal = QApplication::palette(); 923 652 924 /* Selected or hovered item foreground for popup mode: */925 if ( model()->isPopup()926 && (model()->currentItem(itemClass()) == this || isHovered()))927 {928 /* Get background color: */929 const QColor highlight = pal.color(QPalette::Active, QPalette::Highlight);930 const QColor background = model()->currentItem(itemClass()) == this931 ? highlight.lighter(m_iHighlightLightnessStart)932 : highlight.lighter(m_iHoverLightnessStart);933 934 /* Gather foreground color for background one: */935 const QColor foreground = suitableForegroundColor(pal, background);936 pPainter->setPen(foreground);937 }938 653 /* Default item foreground: */ 939 else 940 { 941 const QColor foreground = isEnabled() 942 ? pal.color(QPalette::Active, QPalette::Text) 943 : pal.color(QPalette::Disabled, QPalette::Text); 944 pPainter->setPen(foreground); 945 } 654 const QColor foreground = isEnabled() 655 ? pal.color(QPalette::Active, QPalette::Text) 656 : pal.color(QPalette::Disabled, QPalette::Text); 657 pPainter->setPen(foreground); 946 658 947 659 /* Paint left column: */ … … 949 661 /* Prepare variables: */ 950 662 #ifdef VBOX_WS_MAC 951 int iPixmapX = model()->isPopup() ? iMargin :2 * iMargin;663 int iPixmapX = 2 * iMargin; 952 664 #else 953 int iPixmapX = model()->isPopup() ? iMargin :1.5 * iMargin;665 int iPixmapX = 1.5 * iMargin; 954 666 #endif 955 667 956 /* A bit of indentation for Machine & Management tools in widget mode: */ 957 if ( !model()->isPopup() 958 && ( itemClass() == UIToolClass_Machine 959 || itemClass() == UIToolClass_Management)) 668 /* A bit of indentation for Machine & Management tools: */ 669 if ( itemClass() == UIToolClass_Machine 670 || itemClass() == UIToolClass_Management) 960 671 iPixmapX += QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5; 961 672 … … 975 686 /* Prepare variables: */ 976 687 #ifdef VBOX_WS_MAC 977 int iNameX = model()->isPopup() ? iMargin + m_pixmapSize.width() + iSpacing 978 : 2 * iMargin + m_pixmapSize.width() + 2 * iSpacing; 688 int iNameX = 2 * iMargin + m_pixmapSize.width() + 2 * iSpacing; 979 689 #else 980 int iNameX = model()->isPopup() ? iMargin + m_pixmapSize.width() + iSpacing 981 : 1.5 * iMargin + m_pixmapSize.width() + 2 * iSpacing; 690 int iNameX = 1.5 * iMargin + m_pixmapSize.width() + 2 * iSpacing; 982 691 #endif 983 692 984 /* A bit of indentation for Machine & Management tools in widget mode: */ 985 if ( !model()->isPopup() 986 && ( itemClass() == UIToolClass_Machine 987 || itemClass() == UIToolClass_Management)) 693 /* A bit of indentation for Machine & Management tools: */ 694 if ( itemClass() == UIToolClass_Machine 695 || itemClass() == UIToolClass_Management) 988 696 iNameX += QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * .5; 989 697 990 698 const int iNameY = (iFullHeight - m_nameSize.height()) / 2; 991 /* Paint name (always for popup mode, if requested otherwise): */ 992 if ( model()->isPopup() 993 || model()->showItemNames()) 699 /* Paint name if requested: */ 700 if (model()->showItemNames()) 994 701 paintText(/* Painter: */ 995 702 pPainter, … … 1001 708 model()->paintDevice(), 1002 709 /* Text to paint: */ 1003 m_strName, 1004 /* Text for popup mode? */ 1005 model()->isPopup()); 710 m_strName); 1006 711 } 1007 712 } … … 1018 723 void UIToolsItem::paintText(QPainter *pPainter, QPoint point, 1019 724 const QFont &font, QPaintDevice *pPaintDevice, 1020 const QString &strText, 1021 bool fPopup) 725 const QString &strText) 1022 726 { 1023 727 /* Save painter: */ … … 1032 736 1033 737 /* Draw text: */ 1034 if (fPopup) 1035 pPainter->drawText(point, strText); 1036 else 1037 { 1038 QPainterPath textPath; 1039 textPath.addText(0, 0, font, strText); 1040 textPath.translate(point); 1041 pPainter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); 1042 pPainter->setPen(QPen(uiCommon().isInDarkMode() ? Qt::black : Qt::white, 2, Qt::SolidLine, Qt::RoundCap)); 1043 pPainter->drawPath(QPainterPathStroker().createStroke(textPath)); 1044 pPainter->setBrush(uiCommon().isInDarkMode() ? Qt::white: Qt::black); 1045 pPainter->setPen(Qt::NoPen); 1046 pPainter->drawPath(textPath); 1047 } 738 QPainterPath textPath; 739 textPath.addText(0, 0, font, strText); 740 textPath.translate(point); 741 pPainter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); 742 pPainter->setPen(QPen(uiCommon().isInDarkMode() ? Qt::black : Qt::white, 2, Qt::SolidLine, Qt::RoundCap)); 743 pPainter->drawPath(QPainterPathStroker().createStroke(textPath)); 744 pPainter->setBrush(uiCommon().isInDarkMode() ? Qt::white: Qt::black); 745 pPainter->setPen(Qt::NoPen); 746 pPainter->drawPath(textPath); 1048 747 1049 748 /* Restore painter: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.h
r108619 r108690 5 5 6 6 /* 7 * Copyright (C) 2012-202 4Oracle and/or its affiliates.7 * Copyright (C) 2012-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 34 34 /* Qt includes: */ 35 35 #include <QIcon> 36 #include <QMimeData>37 36 #include <QPixmap> 38 #include <QRectF>39 37 #include <QString> 40 38 … … 44 42 45 43 /* Forward declaration: */ 46 class QPropertyAnimation;47 44 class QGraphicsScene; 48 class QGraphicsSceneDragDropEvent;49 45 class QGraphicsSceneHoverEvent; 50 class QGraphicsSceneMouseEvent;51 class QStateMachine;52 class UIActionPool;53 class UIToolsItemGroup;54 class UIToolsItemGlobal;55 class UIToolsItemMachine;56 46 class UIToolsModel; 57 47 … … 61 51 { 62 52 Q_OBJECT; 63 Q_PROPERTY(int animatedValue READ animatedValue WRITE setAnimatedValue);64 53 65 54 signals: 66 67 /** @name Item stuff.68 * @{ */69 /** Notifies listeners about hover enter. */70 void sigHoverEnter();71 /** Notifies listeners about hover leave. */72 void sigHoverLeave();73 /** @} */74 55 75 56 /** @name Layout stuff. … … 122 103 /** Defines whether item is @a fHidden by the @a enmReason. */ 123 104 void setHiddenByReason(bool fHidden, HidingReason enmReason); 124 125 /** Returns whether item is hovered. */126 bool isHovered() const { return m_fHovered; }127 /** Defines whether item is @a fHovered. */128 void setHovered(bool fHovered);129 105 /** @} */ 130 106 … … 184 160 /** Prepares all. */ 185 161 void prepare(); 186 /** Prepares hover animation. */187 void prepareHoverAnimation();188 162 /** Prepares connections. */ 189 163 void prepareConnections(); … … 197 171 /** Returns abstractly stored data value for certain @a iKey. */ 198 172 QVariant data(int iKey) const; 199 200 /** Defines item's default animation @a iValue. */201 void setDefaultValue(int iValue) { m_iDefaultValue = iValue; update(); }202 /** Returns item's default animation value. */203 int defaultValue() const { return m_iDefaultValue; }204 205 /** Defines item's hovered animation @a iValue. */206 void setHoveredValue(int iValue) { m_iHoveredValue = iValue; update(); }207 /** Returns item's hovered animation value. */208 int hoveredValue() const { return m_iHoveredValue; }209 210 /** Defines item's animated @a iValue. */211 void setAnimatedValue(int iValue) { m_iAnimatedValue = iValue; update(); }212 /** Returns item's animated value. */213 int animatedValue() const { return m_iAnimatedValue; }214 173 /** @} */ 215 174 … … 227 186 * @param rectangle Brings the rectangle to fill with background. */ 228 187 void paintBackground(QPainter *pPainter, const QRect &rectangle) const; 229 /** Paints frame using using passed @a pPainter.230 * @param rectangle Brings the rectangle to stroke with frame. */231 void paintFrame(QPainter *pPainter, const QRect &rectangle) const;232 188 /** Paints tool info using using passed @a pPainter. 233 189 * @param rectangle Brings the rectangle to limit painting with. */ … … 241 197 * @param point Brings upper-left corner pixmap should be mapped to. 242 198 * @param font Brings the text font. 243 * @param pPaintDevice Brings the paint-device reference to initilize painting from. 244 * @param fPopup Brings whether it's a text for popup mode, widget mode otherwise. */ 199 * @param pPaintDevice Brings the paint-device reference to initilize painting from. */ 245 200 static void paintText(QPainter *pPainter, QPoint point, 246 201 const QFont &font, QPaintDevice *pPaintDevice, 247 const QString &strText, 248 bool fPopup); 202 const QString &strText); 249 203 250 204 #ifndef VBOX_WS_MAC … … 274 228 275 229 /** Holds whether item is hovered. */ 276 bool m_fHovered; 277 /** Holds the hovering animation machine instance. */ 278 QStateMachine *m_pHoveringMachine; 279 /** Holds the forward hovering animation instance. */ 280 QPropertyAnimation *m_pHoveringAnimationForward; 281 /** Holds the backward hovering animation instance. */ 282 QPropertyAnimation *m_pHoveringAnimationBackward; 283 /** Holds the animation duration. */ 284 int m_iAnimationDuration; 285 /** Holds the default animation value. */ 286 int m_iDefaultValue; 287 /** Holds the hovered animation value. */ 288 int m_iHoveredValue; 289 /** Holds the animated value. */ 290 int m_iAnimatedValue; 291 292 /** Holds start default lightness tone. */ 293 int m_iDefaultLightnessStart; 294 /** Holds final default lightness tone. */ 295 int m_iDefaultLightnessFinal; 296 /** Holds start hover lightness tone. */ 297 int m_iHoverLightnessStart; 298 /** Holds final hover lightness tone. */ 299 int m_iHoverLightnessFinal; 300 /** Holds start highlight lightness tone. */ 301 int m_iHighlightLightnessStart; 302 /** Holds final highlight lightness tone. */ 303 int m_iHighlightLightnessFinal; 230 bool m_fHovered; 304 231 /** @} */ 305 232 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.cpp
r108619 r108690 363 363 *********************************************************************************************************************************/ 364 364 365 UIToolsModel::UIToolsModel(QObject *pParent, UIActionPool *pActionPool, UIToolClass enmClass , bool fPopup)365 UIToolsModel::UIToolsModel(QObject *pParent, UIActionPool *pActionPool, UIToolClass enmClass) 366 366 : QObject(pParent) 367 367 , m_pActionPool(pActionPool) 368 368 , m_enmClass(enmClass) 369 , m_fPopup(fPopup)370 369 , m_pView(0) 371 370 , m_pScene(0) … … 513 512 } 514 513 return QVariant(); 515 }516 517 void UIToolsModel::close()518 {519 emit sigClose();520 514 } 521 515 … … 846 840 { 847 841 setCurrentItem(pClickedItem); 848 /* Close the widget in popup mode only: */849 if (isPopup())850 close();851 842 return true; 852 843 } … … 1024 1015 void UIToolsModel::prepareAnimationEngine() 1025 1016 { 1026 if ( !isPopup() &&m_enmClass == UIToolClass_Invalid)1017 if (m_enmClass == UIToolClass_Invalid) 1027 1018 m_pAnimationEngine = new UIToolsAnimationEngine(this); 1028 1019 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsModel.h
r108619 r108690 58 58 signals: 59 59 60 /** @name General stuff.61 * @{ */62 /** Notifies about closing request. */63 void sigClose();64 /** @} */65 66 60 /** @name Selection stuff. 67 61 * @{ */ … … 91 85 /** Constructs Tools-model passing @a pParent to the base-class. 92 86 * @param pActionPool Brings the action-pool reference. 93 * @param enmClass Brings the tools class, it will be const one. 94 * @param fPopup Brings whether tools represented as popup. */ 95 UIToolsModel(QObject *pParent, UIActionPool *pActionPool, UIToolClass enmClass, bool fPopup); 87 * @param enmClass Brings the tools class, it will be const one. */ 88 UIToolsModel(QObject *pParent, UIActionPool *pActionPool, UIToolClass enmClass); 96 89 /** Destructs Tools-model. */ 97 90 virtual ~UIToolsModel() RT_OVERRIDE; … … 104 97 /** Returns the action-pool reference. */ 105 98 UIActionPool *actionPool() const { return m_pActionPool; } 106 /** Returns whether tools represented as popup. */107 bool isPopup() const { return m_fPopup; }108 99 109 100 /** Returns the scene reference. */ … … 140 131 /** Returns abstractly stored data value for certain @a iKey. */ 141 132 QVariant data(int iKey) const; 142 143 /** Asks parent to close. */144 void close();145 133 /** @} */ 146 134 … … 256 244 const UIToolClass m_enmClass; 257 245 258 /** Holds whether tools represented as popup. */259 const bool m_fPopup;260 261 246 /** Holds the view reference. */ 262 247 UIToolsView *m_pView; -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsView.cpp
r108223 r108690 5 5 6 6 /* 7 * Copyright (C) 2012-202 4Oracle and/or its affiliates.7 * Copyright (C) 2012-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 115 115 116 116 117 UIToolsView::UIToolsView(QWidget *pParent, UIToolsModel *pModel , bool fPopup)117 UIToolsView::UIToolsView(QWidget *pParent, UIToolsModel *pModel) 118 118 : QIGraphicsView(pParent) 119 119 , m_pModel(pModel) 120 , m_fPopup(fPopup)121 120 , m_iMinimumWidthHint(0) 122 121 , m_iMinimumHeightHint(0) … … 199 198 model()->setView(this); 200 199 201 /* No minimum size-hint for widget mode: */ 202 if (!isPopup()) 203 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 200 /* No minimum size-hint: */ 201 setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); 204 202 205 203 /* Setup frame: */ … … 223 221 QColor backgroundColorActive = pal.color(QPalette::Active, QPalette::Window); 224 222 QColor backgroundColorInactive = pal.color(QPalette::Inactive, QPalette::Window); 225 if (!isPopup()) 226 { 227 backgroundColorActive = uiCommon().isInDarkMode() 228 ? backgroundColorActive.lighter(120) 229 : backgroundColorActive.darker(108); 230 backgroundColorInactive = uiCommon().isInDarkMode() 231 ? backgroundColorInactive.lighter(120) 232 : backgroundColorInactive.darker(108); 233 } 223 backgroundColorActive = uiCommon().isInDarkMode() 224 ? backgroundColorActive.lighter(120) 225 : backgroundColorActive.darker(108); 226 backgroundColorInactive = uiCommon().isInDarkMode() 227 ? backgroundColorInactive.lighter(120) 228 : backgroundColorInactive.darker(108); 234 229 pal.setColor(QPalette::Active, QPalette::Base, backgroundColorActive); 235 230 pal.setColor(QPalette::Inactive, QPalette::Base, backgroundColorInactive); … … 237 232 #else /* !VBOX_WS_MAC */ 238 233 239 if (isPopup()) 240 { 241 /* Same as on macOS for now, will go away soon: */ 242 QColor backgroundColorActive = pal.color(QPalette::Active, QPalette::Window); 243 QColor backgroundColorInactive = pal.color(QPalette::Inactive, QPalette::Window); 244 if (!isPopup()) 245 { 246 backgroundColorActive = uiCommon().isInDarkMode() 247 ? backgroundColorActive.lighter(120) 248 : backgroundColorActive.darker(108); 249 backgroundColorInactive = uiCommon().isInDarkMode() 250 ? backgroundColorInactive.lighter(120) 251 : backgroundColorInactive.darker(108); 252 } 253 pal.setColor(QPalette::Active, QPalette::Base, backgroundColorActive); 254 pal.setColor(QPalette::Inactive, QPalette::Base, backgroundColorInactive); 255 } 256 else 257 { 258 /* Blending Window color to 10% of Accent color: */ 259 const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window); 260 const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent); 261 const int iRed = iShift10(backgroundColor.red(), accentColor.red()); 262 const int iGreen = iShift10(backgroundColor.green(), accentColor.green()); 263 const int iBlue = iShift10(backgroundColor.blue(), accentColor.blue()); 264 const QColor blendColor = QColor(qRgb(iRed, iGreen, iBlue)); 265 pal.setColor(QPalette::Active, QPalette::Base, blendColor); 266 pal.setColor(QPalette::Inactive, QPalette::Base, blendColor); 267 } 234 /* Blending Window color to 10% of Accent color: */ 235 const QColor backgroundColor = pal.color(QPalette::Active, QPalette::Window); 236 const QColor accentColor = pal.color(QPalette::Active, QPalette::Accent); 237 const int iRed = iShift10(backgroundColor.red(), accentColor.red()); 238 const int iGreen = iShift10(backgroundColor.green(), accentColor.green()); 239 const int iBlue = iShift10(backgroundColor.blue(), accentColor.blue()); 240 const QColor blendColor = QColor(qRgb(iRed, iGreen, iBlue)); 241 pal.setColor(QPalette::Active, QPalette::Base, blendColor); 242 pal.setColor(QPalette::Inactive, QPalette::Base, blendColor); 268 243 269 244 #endif /* !VBOX_WS_MAC */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsView.h
r108223 r108690 5 5 6 6 /* 7 * Copyright (C) 2012-202 4Oracle and/or its affiliates.7 * Copyright (C) 2012-2025 Oracle and/or its affiliates. 8 8 * 9 9 * This file is part of VirtualBox base platform packages, as … … 46 46 47 47 /** Constructs a Tools-view passing @a pParent to the base-class. 48 * @param pModel Brings the tools model reference. 49 * @param fPopup Brings whether tools represented as popup. */ 50 UIToolsView(QWidget *pParent, UIToolsModel *pModel, bool fPopup); 48 * @param pModel Brings the tools model reference. */ 49 UIToolsView(QWidget *pParent, UIToolsModel *pModel); 51 50 /** Destructs a Tools-view. */ 52 51 virtual ~UIToolsView(); … … 103 102 /** @name General stuff. 104 103 * @{ */ 105 /** Returns whether tools represented as popup. */106 bool isPopup() const { return m_fPopup; }107 108 104 /** Updates scene rectangle. */ 109 105 void updateSceneRect(); … … 119 115 /** Holds the tools model reference. */ 120 116 UIToolsModel *m_pModel; 121 122 /** Holds whether tools represented as popup. */123 const bool m_fPopup;124 117 /** @} */ 125 118
Note:
See TracChangeset
for help on using the changeset viewer.