Changeset 58346 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 20, 2015 4:24:35 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIIconPool.cpp
r56864 r58346 394 394 } 395 395 396 QPixmap UIIconPoolGeneral::guestOSTypePixmap(const QString &strOSTypeID, const QSize &physicalSize) const 397 { 398 /* Prepare fallback pixmap: */ 399 static QPixmap nullPixmap; 400 401 /* If we do NOT have that 'guest OS type' pixmap cached already: */ 402 if (!m_guestOSTypePixmaps.contains(strOSTypeID)) 403 { 404 /* Compose proper pixmap if we have that 'guest OS type' known: */ 405 if (m_guestOSTypeIconNames.contains(strOSTypeID)) 406 m_guestOSTypePixmaps[strOSTypeID] = QPixmap(m_guestOSTypeIconNames[strOSTypeID]); 407 /* Assign fallback pixmap if we do NOT have that 'guest OS type' known: */ 408 else 409 m_guestOSTypePixmaps[strOSTypeID] = nullPixmap; 410 } 411 412 /* Retrieve corresponding pixmap: */ 413 const QPixmap &pixmap = m_guestOSTypePixmaps.value(strOSTypeID); 414 AssertMsgReturn(!pixmap.isNull(), 415 ("Undefined pixmap for type '%s'.", strOSTypeID.toLatin1().constData()), 416 nullPixmap); 417 418 /* Return pixmap of the requested size: */ 419 return pixmap.size() == physicalSize ? pixmap : pixmap.scaled(physicalSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 420 } 421 422 QPixmap UIIconPoolGeneral::guestOSTypePixmapHiDPI(const QString &strOSTypeID, const QSize &physicalSize) const 423 { 424 /* Prepare fallback pixmap: */ 425 static QPixmap nullPixmap; 426 427 /* If we do NOT have that 'guest OS type' pixmap cached already: */ 428 if (!m_guestOSTypePixmapsHiDPI.contains(strOSTypeID)) 429 { 430 /* Compose proper pixmap if we have that 'guest OS type' known: */ 431 if (m_guestOSTypeIconNames.contains(strOSTypeID)) 432 { 433 /* Get name: */ 434 const QString strName = m_guestOSTypeIconNames.value(strOSTypeID); 435 /* Parse name to prefix and suffix: */ 436 const QString strPrefix = strName.section('.', 0, -2); 437 const QString strSuffix = strName.section('.', -1, -1); 438 /* Prepare HiDPI pixmap on the basis of values above: */ 439 const QPixmap pixmapHiDPI(strPrefix + "_hidpi." + strSuffix); 440 /* Remember HiDPI pixmap: */ 441 m_guestOSTypePixmapsHiDPI[strOSTypeID] = pixmapHiDPI; 442 } 443 /* Assign fallback pixmap if we do NOT have that 'guest OS type' known: */ 444 else 445 m_guestOSTypePixmapsHiDPI[strOSTypeID] = nullPixmap; 446 } 447 448 /* Retrieve corresponding pixmap: */ 449 const QPixmap &pixmap = m_guestOSTypePixmapsHiDPI.value(strOSTypeID); 450 AssertMsgReturn(!pixmap.isNull(), 451 ("Undefined pixmap for type '%s'.", strOSTypeID.toLatin1().constData()), 452 nullPixmap); 453 454 /* Return pixmap of the requested size: */ 455 return pixmap.size() == physicalSize ? pixmap : pixmap.scaled(physicalSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 456 } 457 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIIconPool.h
r55401 r58346 107 107 QPixmap guestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize = 0) const; 108 108 109 /** Returns pixmap corresponding to passed @a strOSTypeID and @a physicalSize. */ 110 QPixmap guestOSTypePixmap(const QString &strOSTypeID, const QSize &physicalSize) const; 111 /** Returns HiDPI pixmap corresponding to passed @a strOSTypeID and @a physicalSize. */ 112 QPixmap guestOSTypePixmapHiDPI(const QString &strOSTypeID, const QSize &physicalSize) const; 113 109 114 private: 110 115 … … 113 118 /** Guest OS type icons cache. */ 114 119 mutable QHash<QString, QIcon> m_guestOSTypeIcons; 120 /** Holds the guest OS type pixmaps cache. */ 121 mutable QHash<QString, QPixmap> m_guestOSTypePixmaps; 122 /** Holds the guest OS type HiDPI pixmaps cache. */ 123 mutable QHash<QString, QPixmap> m_guestOSTypePixmapsHiDPI; 115 124 }; 116 125 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r58310 r58346 658 658 /* Redirect to general icon-pool: */ 659 659 return m_pIconPool->guestOSTypeIcon(strOSTypeID, pLogicalSize); 660 } 661 662 QPixmap VBoxGlobal::vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &physicalSize) const 663 { 664 /* Prepare fallback pixmap: */ 665 static QPixmap nullPixmap; 666 667 /* Make sure general icon-pool initialized: */ 668 AssertReturn(m_pIconPool, nullPixmap); 669 670 /* Redirect to general icon-pool: */ 671 return m_pIconPool->guestOSTypePixmap(strOSTypeID, physicalSize); 672 } 673 674 QPixmap VBoxGlobal::vmGuestOSTypePixmapHiDPI(const QString &strOSTypeID, const QSize &physicalSize) const 675 { 676 /* Prepare fallback pixmap: */ 677 static QPixmap nullPixmap; 678 679 /* Make sure general icon-pool initialized: */ 680 AssertReturn(m_pIconPool, nullPixmap); 681 682 /* Redirect to general icon-pool: */ 683 return m_pIconPool->guestOSTypePixmapHiDPI(strOSTypeID, physicalSize); 660 684 } 661 685 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r58310 r58346 256 256 QPixmap vmGuestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize = 0) const; 257 257 258 /** Returns pixmap corresponding to passed @a strOSTypeID and @a physicalSize. */ 259 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &physicalSize) const; 260 /** Returns HiDPI pixmap corresponding to passed @a strOSTypeID and @a physicalSize. */ 261 QPixmap vmGuestOSTypePixmapHiDPI(const QString &strOSTypeID, const QSize &physicalSize) const; 262 258 263 CGuestOSType vmGuestOSType (const QString &aTypeId, 259 264 const QString &aFamilyId = QString::null) const; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r57998 r58346 1222 1222 /* Now the dock icon preview */ 1223 1223 QString osTypeId = guest().GetOSTypeId(); 1224 m_pDockIconPreview = new UIDockIconPreview(uisession(), vboxGlobal().vmGuestOSType Icon(osTypeId));1224 m_pDockIconPreview = new UIDockIconPreview(uisession(), vboxGlobal().vmGuestOSTypePixmapHiDPI(osTypeId, QSize(64, 64))); 1225 1225 1226 1226 /* Should the dock-icon be updated at runtime? */
Note:
See TracChangeset
for help on using the changeset viewer.