Changeset 66662 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 24, 2017 5:55:47 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 115035
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIIconPool.cpp
r66657 r66662 22 22 /* Qt includes: */ 23 23 # include <QApplication> 24 # include <QFile> 24 25 # include <QStyle> 25 26 # include <QWidget> … … 27 28 /* GUI includes: */ 28 29 # include "UIIconPool.h" 30 # include "UIExtraDataManager.h" 31 32 /* COM includes: */ 33 # include "COMEnums.h" 34 # include "CMachine.h" 29 35 30 36 /* Other VBox includes: */ … … 355 361 } 356 362 363 QIcon UIIconPoolGeneral::userMachineIcon(const CMachine &comMachine) const 364 { 365 /* Get machine ID: */ 366 const QString strMachineId = comMachine.GetId(); 367 AssertReturn(comMachine.isOk(), QPixmap()); 368 369 /* Prepare icon: */ 370 QIcon icon; 371 372 /* 1. First, load icon from IMachine extra-data: */ 373 if (icon.isNull()) 374 foreach (const QString &strIconName, gEDataManager->machineWindowIconNames(strMachineId)) 375 if (!strIconName.isEmpty() && QFile::exists(strIconName)) 376 icon.addFile(strIconName); 377 378 /* 2. Otherwise, load icon from IMachine interface itself: */ 379 if (icon.isNull()) 380 { 381 const QVector<BYTE> byteVector = comMachine.GetIcon(); 382 AssertReturn(comMachine.isOk(), QPixmap()); 383 const QByteArray byteArray = QByteArray::fromRawData(reinterpret_cast<const char*>(byteVector.constData()), byteVector.size()); 384 const QImage image = QImage::fromData(byteArray); 385 if (!image.isNull()) 386 { 387 QPixmap pixmap = QPixmap::fromImage(image); 388 const int iMinimumLength = qMin(pixmap.width(), pixmap.height()); 389 if (pixmap.width() != iMinimumLength || pixmap.height() != iMinimumLength) 390 pixmap = pixmap.scaled(QSize(iMinimumLength, iMinimumLength), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 391 icon.addPixmap(pixmap); 392 } 393 } 394 395 /* Return icon: */ 396 return icon; 397 } 398 399 QPixmap UIIconPoolGeneral::userMachinePixmap(const CMachine &comMachine, const QSize &size) const 400 { 401 /* Acquire icon: */ 402 const QIcon icon = userMachineIcon(comMachine); 403 404 /* Prepare pixmap: */ 405 QPixmap pixmap; 406 407 /* Check whether we have valid icon: */ 408 if (!icon.isNull()) 409 { 410 /* Get pixmap of requested size: */ 411 pixmap = icon.pixmap(size); 412 /* And even scale it if size is not valid: */ 413 if (pixmap.size() != size) 414 pixmap = pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 415 } 416 417 /* Return pixmap: */ 418 return pixmap; 419 } 420 421 QPixmap UIIconPoolGeneral::userMachinePixmapDefault(const CMachine &comMachine, QSize *pLogicalSize /* = 0 */) const 422 { 423 /* Acquire icon: */ 424 const QIcon icon = userMachineIcon(comMachine); 425 426 /* Prepare pixmap: */ 427 QPixmap pixmap; 428 429 /* Check whether we have valid icon: */ 430 if (!icon.isNull()) 431 { 432 /* Determine desired icon size: */ 433 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); 434 const QSize iconSize = QSize(iIconMetric, iIconMetric); 435 436 /* Pass up logical size if necessary: */ 437 if (pLogicalSize) 438 *pLogicalSize = iconSize; 439 440 /* Get pixmap of requested size: */ 441 pixmap = icon.pixmap(iconSize); 442 } 443 444 /* Return pixmap: */ 445 return pixmap; 446 } 447 357 448 QIcon UIIconPoolGeneral::guestOSTypeIcon(const QString &strOSTypeID) const 358 449 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIIconPool.h
r66657 r66662 23 23 #include <QPixmap> 24 24 #include <QHash> 25 26 /* Forward declarations: */ 27 class CMachine; 25 28 26 29 … … 104 107 UIIconPoolGeneral(); 105 108 109 /** Returns icon defined for a passed @a comMachine. */ 110 QIcon userMachineIcon(const CMachine &comMachine) const; 111 /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */ 112 QPixmap userMachinePixmap(const CMachine &comMachine, const QSize &size) const; 113 /** Returns pixmap defined for a passed @a comMachine. 114 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */ 115 QPixmap userMachinePixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const; 116 106 117 /** Returns icon corresponding to passed @a strOSTypeID. */ 107 118 QIcon guestOSTypeIcon(const QString &strOSTypeID) const; -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r66657 r66662 558 558 } 559 559 560 QIcon VBoxGlobal::vmUserIcon(const CMachine &comMachine) 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->userMachineIcon(comMachine); 570 } 571 572 QPixmap VBoxGlobal::vmUserPixmap(const CMachine &comMachine, const QSize &size) const 573 { 574 /* Prepare fallback pixmap: */ 575 static QPixmap nullPixmap; 576 577 /* Make sure general icon-pool initialized: */ 578 AssertReturn(m_pIconPool, nullPixmap); 579 580 /* Redirect to general icon-pool: */ 581 return m_pIconPool->userMachinePixmap(comMachine, size); 582 } 583 584 QPixmap VBoxGlobal::vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize /* = 0 */) 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->userMachinePixmapDefault(comMachine, pLogicalSize); 594 } 595 560 596 QIcon VBoxGlobal::vmGuestOSTypeIcon(const QString &strOSTypeID) const 561 597 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r66657 r66662 221 221 QList <CGuestOSType> vmGuestOSFamilyList() const; 222 222 QList <CGuestOSType> vmGuestOSTypeList (const QString &aFamilyId) const; 223 224 /** Returns icon defined for a passed @a comMachine. */ 225 QIcon vmUserIcon(const CMachine &comMachine) const; 226 /** Returns pixmap of a passed @a size defined for a passed @a comMachine. */ 227 QPixmap vmUserPixmap(const CMachine &comMachine, const QSize &size) const; 228 /** Returns pixmap defined for a passed @a comMachine. 229 * In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */ 230 QPixmap vmUserPixmapDefault(const CMachine &comMachine, QSize *pLogicalSize = 0) const; 223 231 224 232 /** Returns pixmap corresponding to passed @a strOSTypeID. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r66660 r66662 1277 1277 1278 1278 /* Now the dock icon preview: */ 1279 const QPixmap pixmap = vboxGlobal().vmGuestOSTypePixmap(guest().GetOSTypeId(), QSize(42, 42)); 1279 QPixmap pixmap = vboxGlobal().vmUserPixmap(machine(), QSize(42, 42)); 1280 if (pixmap.isNull()) 1281 pixmap = vboxGlobal().vmGuestOSTypePixmap(guest().GetOSTypeId(), QSize(42, 42)); 1280 1282 m_pDockIconPreview = new UIDockIconPreview(uisession(), pixmap); 1281 1283 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r66661 r66662 1289 1289 /* Prepare machine-window icon: */ 1290 1290 { 1291 QIcon icon; 1292 /* Load user machine-window icon: */ 1293 foreach (const QString &strIconName, gEDataManager->machineWindowIconNames(strMachineID)) 1294 if (!strIconName.isEmpty() && QFile::exists(strIconName)) 1295 icon.addFile(strIconName); 1291 /* Acquire user machine-window icon: */ 1292 QIcon icon = vboxGlobal().vmUserIcon(machine()); 1296 1293 /* Use the OS type icon if user one was not set: */ 1297 1294 if (icon.isNull()) -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UISnapshotPane.cpp
r66657 r66662 903 903 904 904 // TODO: Assign corresponding icon through sub-dialog API: */ 905 const QPixmap pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(m_comMachine.GetOSTypeId()); 905 QPixmap pixmap = vboxGlobal().vmUserPixmapDefault(m_comMachine); 906 if (pixmap.isNull()) 907 pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(m_comMachine.GetOSTypeId()); 906 908 pDlg->mLbIcon->setPixmap(pixmap); 907 909 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.cpp
r66659 r66662 237 237 m_cSnaphot = m_machine.GetSnapshotCount(); 238 238 239 m_pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(m_strOSTypeId, &m_logicalPixmapSize); 239 m_pixmap = vboxGlobal().vmUserPixmapDefault(m_machine, &m_logicalPixmapSize); 240 if (m_pixmap.isNull()) 241 m_pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(m_strOSTypeId, &m_logicalPixmapSize); 240 242 241 243 if ( m_machineState == KMachineState_PoweredOff -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp
r66658 r66662 56 56 if (machine.GetAccessible()) 57 57 { 58 pixIcon = vboxGlobal().vmGuestOSTypePixmapDefault(machine.GetOSTypeId()); 58 pixIcon = vboxGlobal().vmUserPixmapDefault(machine); 59 if (pixIcon.isNull()) 60 pixIcon = vboxGlobal().vmGuestOSTypePixmapDefault(machine.GetOSTypeId()); 59 61 strName = machine.GetName(); 60 62 strUuid = machine.GetId();
Note:
See TracChangeset
for help on using the changeset viewer.