- Timestamp:
- Apr 24, 2017 5:10:56 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r66593 r66657 412 412 /* If proper machine ID passed => return corresponding pixmap/size: */ 413 413 if (index.data(Field_ID).toString() != UIExtraDataManager::GlobalID) 414 pixmap = vboxGlobal().vmGuestOSType Icon(index.data(Field_OsTypeID).toString(), &pixmapSize);414 pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(index.data(Field_OsTypeID).toString(), &pixmapSize); 415 415 else 416 416 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIIconPool.cpp
r66229 r66657 5 5 6 6 /* 7 * Copyright (C) 2010-201 6Oracle Corporation7 * Copyright (C) 2010-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 22 22 /* Qt includes: */ 23 23 # include <QApplication> 24 # include <QStyle> 24 25 # include <QWidget> 25 # include <QStyle>26 26 27 27 /* GUI includes: */ … … 355 355 } 356 356 357 Q Pixmap UIIconPoolGeneral::guestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize /* = 0 */) const358 { 359 /* Prepare fallback pixmap: */360 static QPixmap null Pixmap;357 QIcon UIIconPoolGeneral::guestOSTypeIcon(const QString &strOSTypeID) const 358 { 359 /* Prepare fallback icon: */ 360 static QPixmap nullIcon; 361 361 362 362 /* If we do NOT have that 'guest OS type' icon cached already: */ … … 368 368 /* Assign fallback icon if we do NOT have that 'guest OS type' known: */ 369 369 else 370 m_guestOSTypeIcons[strOSTypeID] = iconSet(null Pixmap);370 m_guestOSTypeIcons[strOSTypeID] = iconSet(nullIcon); 371 371 } 372 372 … … 375 375 AssertMsgReturn(!icon.isNull(), 376 376 ("Undefined icon for type '%s'.", strOSTypeID.toLatin1().constData()), 377 nullPixmap); 378 379 /* Retrieve available sizes for that icon: */ 380 const QList<QSize> availableSizes = icon.availableSizes(); 381 AssertMsgReturn(!availableSizes.isEmpty(), 382 ("Undefined icon for type '%s'.", strOSTypeID.toLatin1().constData()), 383 nullPixmap); 384 385 /* Determine desired icon size: */ 386 const QStyle *pStyle = QApplication::style(); 387 const int iIconMetric = pStyle->pixelMetric(QStyle::PM_LargeIconSize); 388 const QSize iconSize = QSize(iIconMetric, iIconMetric); 389 390 /* Pass up logical size if necessary: */ 391 if (pLogicalSize) 392 *pLogicalSize = iconSize; 393 394 /* Return pixmap of first available size: */ 395 return icon.pixmap(iconSize); 396 } 397 398 QPixmap UIIconPoolGeneral::guestOSTypePixmap(const QString &strOSTypeID, const QSize &physicalSize) const 399 { 400 /* Prepare fallback pixmap: */ 401 static QPixmap nullPixmap; 402 403 /* If we do NOT have that 'guest OS type' pixmap cached already: */ 404 if (!m_guestOSTypePixmaps.contains(strOSTypeID)) 377 nullIcon); 378 379 /* Return icon: */ 380 return icon; 381 } 382 383 QPixmap UIIconPoolGeneral::guestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const 384 { 385 /* Acquire icon: */ 386 const QIcon icon = guestOSTypeIcon(strOSTypeID); 387 388 /* Prepare pixmap: */ 389 QPixmap pixmap; 390 391 /* Check whether we have valid icon: */ 392 if (!icon.isNull()) 405 393 { 406 /* Compose proper pixmap if we have that 'guest OS type' known: */ 407 if (m_guestOSTypeIconNames.contains(strOSTypeID)) 408 m_guestOSTypePixmaps[strOSTypeID] = QPixmap(m_guestOSTypeIconNames[strOSTypeID]); 409 /* Assign fallback pixmap if we do NOT have that 'guest OS type' known: */ 410 else 411 m_guestOSTypePixmaps[strOSTypeID] = nullPixmap; 394 /* Get pixmap of requested size: */ 395 pixmap = icon.pixmap(size); 396 /* And even scale it if size is not valid: */ 397 if (pixmap.size() != size) 398 pixmap = pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 412 399 } 413 400 414 /* Retrieve corresponding pixmap: */ 415 const QPixmap &pixmap = m_guestOSTypePixmaps.value(strOSTypeID); 416 AssertMsgReturn(!pixmap.isNull(), 417 ("Undefined pixmap for type '%s'.", strOSTypeID.toLatin1().constData()), 418 nullPixmap); 419 420 /* Return pixmap of the requested size: */ 421 return pixmap.size() == physicalSize ? pixmap : pixmap.scaled(physicalSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 422 } 423 424 QPixmap UIIconPoolGeneral::guestOSTypePixmapHiDPI(const QString &strOSTypeID, const QSize &physicalSize) const 425 { 426 /* Prepare fallback pixmap: */ 427 static QPixmap nullPixmap; 428 429 /* If we do NOT have that 'guest OS type' pixmap cached already: */ 430 if (!m_guestOSTypePixmapsHiDPI.contains(strOSTypeID)) 401 /* Return pixmap: */ 402 return pixmap; 403 } 404 405 QPixmap UIIconPoolGeneral::guestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize /* = 0 */) const 406 { 407 /* Acquire icon: */ 408 const QIcon icon = guestOSTypeIcon(strOSTypeID); 409 410 /* Prepare pixmap: */ 411 QPixmap pixmap; 412 413 /* Check whether we have valid icon: */ 414 if (!icon.isNull()) 431 415 { 432 /* Compose proper pixmap if we have that 'guest OS type' known: */ 433 if (m_guestOSTypeIconNames.contains(strOSTypeID)) 434 { 435 /* Get name: */ 436 const QString strName = m_guestOSTypeIconNames.value(strOSTypeID); 437 /* Parse name to prefix and suffix: */ 438 const QString strPrefix = strName.section('.', 0, -2); 439 const QString strSuffix = strName.section('.', -1, -1); 440 /* Prepare HiDPI pixmap on the basis of values above: */ 441 const QPixmap pixmapHiDPI(strPrefix + "_hidpi." + strSuffix); 442 /* Remember HiDPI pixmap: */ 443 m_guestOSTypePixmapsHiDPI[strOSTypeID] = pixmapHiDPI; 444 } 445 /* Assign fallback pixmap if we do NOT have that 'guest OS type' known: */ 446 else 447 m_guestOSTypePixmapsHiDPI[strOSTypeID] = nullPixmap; 416 /* Determine desired icon size: */ 417 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); 418 const QSize iconSize = QSize(iIconMetric, iIconMetric); 419 420 /* Pass up logical size if necessary: */ 421 if (pLogicalSize) 422 *pLogicalSize = iconSize; 423 424 /* Get pixmap of requested size: */ 425 pixmap = icon.pixmap(iconSize); 448 426 } 449 427 450 /* Retrieve corresponding pixmap: */ 451 const QPixmap &pixmap = m_guestOSTypePixmapsHiDPI.value(strOSTypeID); 452 AssertMsgReturn(!pixmap.isNull(), 453 ("Undefined pixmap for type '%s'.", strOSTypeID.toLatin1().constData()), 454 nullPixmap); 455 456 /* Return pixmap of the requested size: */ 457 return pixmap.size() == physicalSize ? pixmap : pixmap.scaled(physicalSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 458 } 459 428 /* Return pixmap: */ 429 return pixmap; 430 } 431 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIIconPool.h
r64715 r66657 5 5 6 6 /* 7 * Copyright (C) 2010-201 6Oracle Corporation7 * Copyright (C) 2010-2017 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 23 23 #include <QPixmap> 24 24 #include <QHash> 25 25 26 26 27 /** Interface which provides GUI with static API … … 103 104 UIIconPoolGeneral(); 104 105 106 /** Returns icon corresponding to passed @a strOSTypeID. */ 107 QIcon guestOSTypeIcon(const QString &strOSTypeID) const; 108 /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */ 109 QPixmap guestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const; 105 110 /** Returns pixmap corresponding to passed @a strOSTypeID. 106 111 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */ 107 QPixmap guestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize = 0) const; 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; 112 QPixmap guestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const; 113 113 114 114 private: … … 118 118 /** Guest OS type icons cache. */ 119 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;124 120 }; 125 121 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r66593 r66657 558 558 } 559 559 560 QPixmap VBoxGlobal::vmGuestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize /* = 0 */) const 560 QIcon VBoxGlobal::vmGuestOSTypeIcon(const QString &strOSTypeID) const 561 { 562 /* Prepare fallback icon: */ 563 static QIcon nullIcon; 564 565 /* Make sure general icon-pool initialized: */ 566 AssertReturn(m_pIconPool, nullIcon); 567 568 /* Redirect to general icon-pool: */ 569 return m_pIconPool->guestOSTypeIcon(strOSTypeID); 570 } 571 572 QPixmap VBoxGlobal::vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const 561 573 { 562 574 /* Prepare fallback pixmap: */ … … 567 579 568 580 /* Redirect to general icon-pool: */ 569 return m_pIconPool->guestOSType Icon(strOSTypeID, pLogicalSize);570 } 571 572 QPixmap VBoxGlobal::vmGuestOSTypePixmap (const QString &strOSTypeID, const QSize &physicalSize) const581 return m_pIconPool->guestOSTypePixmap(strOSTypeID, size); 582 } 583 584 QPixmap VBoxGlobal::vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize /* = 0 */) const 573 585 { 574 586 /* Prepare fallback pixmap: */ … … 579 591 580 592 /* Redirect to general icon-pool: */ 581 return m_pIconPool->guestOSTypePixmap(strOSTypeID, physicalSize); 582 } 583 584 QPixmap VBoxGlobal::vmGuestOSTypePixmapHiDPI(const QString &strOSTypeID, const QSize &physicalSize) const 585 { 586 /* Prepare fallback pixmap: */ 587 static QPixmap nullPixmap; 588 589 /* Make sure general icon-pool initialized: */ 590 AssertReturn(m_pIconPool, nullPixmap); 591 592 /* Redirect to general icon-pool: */ 593 return m_pIconPool->guestOSTypePixmapHiDPI(strOSTypeID, physicalSize); 593 return m_pIconPool->guestOSTypePixmapDefault(strOSTypeID, pLogicalSize); 594 594 } 595 595 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r66593 r66657 222 222 QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const; 223 223 224 /** Returns pixmap corresponding to passed @a strOSTypeID. */ 225 QIcon vmGuestOSTypeIcon(const QString &strOSTypeID) const; 226 /** Returns pixmap corresponding to passed @a strOSTypeID and @a size. */ 227 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &size) const; 224 228 /** Returns pixmap corresponding to passed @a strOSTypeID. 225 229 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */ 226 QPixmap vmGuestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize = 0) const; 227 228 /** Returns pixmap corresponding to passed @a strOSTypeID and @a physicalSize. */ 229 QPixmap vmGuestOSTypePixmap(const QString &strOSTypeID, const QSize &physicalSize) const; 230 /** Returns HiDPI pixmap corresponding to passed @a strOSTypeID and @a physicalSize. */ 231 QPixmap vmGuestOSTypePixmapHiDPI(const QString &strOSTypeID, const QSize &physicalSize) const; 230 QPixmap vmGuestOSTypePixmapDefault(const QString &strOSTypeID, QSize *pLogicalSize = 0) const; 232 231 233 232 CGuestOSType vmGuestOSType (const QString &aTypeId, -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r66628 r66657 1276 1276 # endif /* QT_VERSION >= 0x050000 */ 1277 1277 1278 /* Now the dock icon preview */1279 QString osTypeId = guest().GetOSTypeId();1280 m_pDockIconPreview = new UIDockIconPreview(uisession(), vboxGlobal().vmGuestOSTypePixmapHiDPI(osTypeId, QSize(42, 42)));1278 /* Now the dock icon preview: */ 1279 const QPixmap pixmap = vboxGlobal().vmGuestOSTypePixmap(guest().GetOSTypeId(), QSize(42, 42)); 1280 m_pDockIconPreview = new UIDockIconPreview(uisession(), pixmap); 1281 1281 1282 1282 /* Should the dock-icon be updated at runtime? */ … … 1554 1554 1555 1555 /* Assign corresponding icon: */ 1556 QString strTypeId = machine().GetOSTypeId();1557 pDlg->mLbIcon->setPixmap( vboxGlobal().vmGuestOSTypeIcon(strTypeId));1556 const QPixmap pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(guest().GetOSTypeId()); 1557 pDlg->mLbIcon->setPixmap(pixmap); 1558 1558 1559 1559 /* Search for the max available filter index: */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp
r66656 r66657 318 318 319 319 /* Assign pixmap: */ 320 setPixmap(vboxGlobal().vmGuestOSType Icon(m_machine.GetOSTypeId()));320 setPixmap(vboxGlobal().vmGuestOSTypePixmapDefault(m_machine.GetOSTypeId())); 321 321 322 322 /* Check which close-actions are resticted: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r65232 r66657 903 903 904 904 // TODO: Assign corresponding icon through sub-dialog API: */ 905 pDlg->mLbIcon->setPixmap(vboxGlobal().vmGuestOSTypeIcon(m_comMachine.GetOSTypeId())); 905 const QPixmap pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(m_comMachine.GetOSTypeId()); 906 pDlg->mLbIcon->setPixmap(pixmap); 906 907 907 908 /* Search for the max available snapshot index: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.cpp
r63321 r66657 155 155 QPixmap UIVMItem::osPixmap(QSize *pLogicalSize /* = 0 */) const 156 156 { 157 return m_fAccessible ? vboxGlobal().vmGuestOSType Icon(m_strOSTypeId, pLogicalSize) :158 vboxGlobal().vmGuestOSType Icon("Other", pLogicalSize);157 return m_fAccessible ? vboxGlobal().vmGuestOSTypePixmapDefault(m_strOSTypeId, pLogicalSize) : 158 vboxGlobal().vmGuestOSTypePixmapDefault("Other", pLogicalSize); 159 159 } 160 160 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceEditorWidget.cpp
r66532 r66657 522 522 const QStyle *pStyle = QApplication::style(); 523 523 const int iIconMetric = pStyle->pixelMetric(QStyle::PM_SmallIconSize); 524 value = vboxGlobal().vmGuestOSType Icon(m_strConfigValue).scaledToHeight(iIconMetric, Qt::SmoothTransformation);524 value = vboxGlobal().vmGuestOSTypePixmapDefault(m_strConfigValue).scaledToHeight(iIconMetric, Qt::SmoothTransformation); 525 525 } 526 526 break; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp
r60878 r66657 354 354 m_type = vboxGlobal().vmGuestOSType(m_pComboType->itemData(iIndex, TypeID).toString(), 355 355 m_pComboFamily->itemData(m_pComboFamily->currentIndex(), TypeID).toString()); 356 m_pIconType->setPixmap(vboxGlobal().vmGuestOSType Icon(m_type.GetId()));356 m_pIconType->setPixmap(vboxGlobal().vmGuestOSTypePixmapDefault(m_type.GetId())); 357 357 358 358 /* Save the most recently used item: */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxOSTypeSelectorButton.cpp
r62493 r66657 58 58 /* Looks ugly on the Mac */ 59 59 #ifndef VBOX_WS_MAC 60 setIcon (vboxGlobal().vmGuestOSType Icon(type.GetId()));60 setIcon (vboxGlobal().vmGuestOSTypePixmapDefault (type.GetId())); 61 61 #endif /* VBOX_WS_MAC */ 62 62 setText (type.GetDescription()); … … 84 84 foreach (const CGuestOSType& type, types) 85 85 { 86 QAction *a = subMenu->addAction (vboxGlobal().vmGuestOSType Icon(type.GetId()), type.GetDescription());86 QAction *a = subMenu->addAction (vboxGlobal().vmGuestOSTypePixmapDefault (type.GetId()), type.GetDescription()); 87 87 connect(a, SIGNAL (triggered()), 88 88 mSignalMapper, SLOT(map())); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp
r62493 r66657 56 56 if (machine.GetAccessible()) 57 57 { 58 pixIcon = vboxGlobal().vmGuestOSType Icon(machine.GetOSTypeId()).scaled(iIconMetric, iIconMetric, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);58 pixIcon = vboxGlobal().vmGuestOSTypePixmapDefault(machine.GetOSTypeId()).scaled(iIconMetric, iIconMetric, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 59 59 strName = machine.GetName(); 60 60 strUuid = machine.GetId();
Note:
See TracChangeset
for help on using the changeset viewer.