Changeset 101590 in vbox
- Timestamp:
- Oct 25, 2023 12:54:48 PM (19 months ago)
- svn:sync-xref-src-repo-rev:
- 159671
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIIconPool.cpp
r101575 r101590 554 554 } 555 555 556 /* static */ 557 QIcon UIIconPoolGeneral::overlayedIconSet(const QString &strGuestOSTypeId, 558 const QString &strNormal, 559 const QString &strDisabled /* = QString() */, 560 const QString &strActive /* = QString() */) 561 { 562 /* Prepare fallback icon: */ 563 static QIcon nullIcon; 564 565 /* Prepare icon: */ 566 QIcon icon; 567 568 /* Add 'normal' pixmap: */ 569 AssertReturn(!strNormal.isEmpty(), nullIcon); 570 addNameAndOverlay(icon, strNormal, strGuestOSTypeId, QIcon::Normal); 571 572 /* Add 'disabled' pixmap (if any): */ 573 if (!strDisabled.isEmpty()) 574 addNameAndOverlay(icon, strDisabled, strGuestOSTypeId, QIcon::Disabled); 575 576 /* Add 'active' pixmap (if any): */ 577 if (!strActive.isEmpty()) 578 addNameAndOverlay(icon, strActive, strGuestOSTypeId, QIcon::Active); 579 580 /* Return icon: */ 581 return icon; 582 } 583 584 /* static */ 585 void UIIconPoolGeneral::addNameAndOverlay(QIcon &icon, const QString &strName, const QString &strGuestOSTypeId, 586 QIcon::Mode mode /* = QIcon::Normal */, QIcon::State state /* = QIcon::Off */ ) 587 { 588 /* Prepare pixmap on the basis of passed value: */ 589 QPixmap pixmap(strName); 590 overlayArchitectureTextOnPixmap(determineOSArchString(strGuestOSTypeId), pixmap); 591 /* Add pixmap: */ 592 icon.addPixmap(pixmap, mode, state); 593 594 /* Parse name to prefix and suffix: */ 595 QString strPrefix = strName.section('.', 0, -2); 596 QString strSuffix = strName.section('.', -1, -1); 597 /* Prepare HiDPI pixmaps: */ 598 const QStringList aPixmapNames = QStringList() << (strPrefix + "_x2." + strSuffix) 599 << (strPrefix + "_x3." + strSuffix) 600 << (strPrefix + "_x4." + strSuffix); 601 foreach (const QString &strPixmapName, aPixmapNames) 602 { 603 QPixmap pixmapHiDPI(strPixmapName); 604 if (!pixmapHiDPI.isNull()) 605 { 606 overlayArchitectureTextOnPixmap(determineOSArchString(strGuestOSTypeId), pixmapHiDPI); 607 icon.addPixmap(pixmapHiDPI, mode, state); 608 } 609 } 610 } 611 556 612 QIcon UIIconPoolGeneral::userMachineIcon(const CMachine &comMachine) const 557 613 { … … 654 710 /* Compose proper icon if we have that 'guest OS type' known: */ 655 711 if (m_guestOSTypeIconNames.contains(strOSTypeID)) 656 m_guestOSTypeIcons[strOSTypeID] = iconSet(m_guestOSTypeIconNames[strOSTypeID]);712 m_guestOSTypeIcons[strOSTypeID] = overlayedIconSet(strOSTypeID, m_guestOSTypeIconNames[strOSTypeID]); 657 713 /* Assign fallback icon if we do NOT have that 'guest OS type' registered: */ 658 714 else if (!strOSTypeID.isNull()) 659 m_guestOSTypeIcons[strOSTypeID] = iconSet(m_guestOSTypeIconNames[GUEST_OS_ID_STR_X86("Other")]);715 m_guestOSTypeIcons[strOSTypeID] = overlayedIconSet(strOSTypeID, m_guestOSTypeIconNames[GUEST_OS_ID_STR_X86("Other")]); 660 716 /* Assign fallback icon if we do NOT have that 'guest OS type' known: */ 661 717 else … … 720 776 } 721 777 722 overlayArchitectureTextOnPixmap(determineOSArchString(strOSTypeID), pixmap);723 778 /* Return pixmap: */ 724 779 return pixmap; 725 780 } 726 781 727 QString UIIconPoolGeneral::determineOSArchString(const QString &osTypeId) const 782 /* static */ 783 QString UIIconPoolGeneral::determineOSArchString(const QString &osTypeId) 728 784 { 729 785 if (osTypeId.contains("_x64") || osTypeId.contains("_64")) … … 736 792 } 737 793 738 void UIIconPoolGeneral::overlayArchitectureTextOnPixmap(const QString &strArch, QPixmap &pixmap) const 794 /* static */ 795 void UIIconPoolGeneral::overlayArchitectureTextOnPixmap(const QString &strArch, QPixmap &pixmap) 739 796 { 740 797 #if 0 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIIconPool.h
r101508 r101590 160 160 private: 161 161 162 /** Creates icon from passed pixmap names for 163 * @a strNormal, @a strDisabled and @a strActive icon states. Utilizes addNameAndOverlay to overlay pixmaps. */ 164 static QIcon overlayedIconSet(const QString &strGuestOSTypeId, 165 const QString &strNormal, 166 const QString &strDisabled = QString(), 167 const QString &strActive = QString()); 168 /* Just like UIIconPool::addName add resources to icon but additionally overlays corresponding text wrt. strGuestOSTypeId. */ 169 static void addNameAndOverlay(QIcon &icon, const QString &strName, const QString &strGuestOSTypeId, 170 QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off); 171 162 172 /** Constructs general icon-pool. */ 163 173 UIIconPoolGeneral(); … … 165 175 virtual ~UIIconPoolGeneral() /* override final */; 166 176 /** Overlay text @p strArch on top of @p pixmap. */ 167 void overlayArchitectureTextOnPixmap(const QString &strArch, QPixmap &pixmap) const;177 static void overlayArchitectureTextOnPixmap(const QString &strArch, QPixmap &pixmap); 168 178 /** Returns the architecture text we overlay on guest OS type id icon.*/ 169 QString determineOSArchString(const QString &osTypeId) const;179 static QString determineOSArchString(const QString &osTypeId); 170 180 /** Holds the singleton instance. */ 171 181 static UIIconPoolGeneral *s_pInstance;
Note:
See TracChangeset
for help on using the changeset viewer.