VirtualBox

Changeset 66647 in vbox for trunk


Ignore:
Timestamp:
Apr 21, 2017 6:08:55 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:6911: Runtime UI: IMachine::icon support.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r63567 r66647  
    188188
    189189    /* Set redefined machine-window icon if any: */
    190     QIcon *pMachineWidnowIcon = uisession()->machineWindowIcon();
    191     if (pMachineWidnowIcon)
    192         setWindowIcon(*pMachineWidnowIcon);
     190    const QIcon *pMachineWindowIcon = uisession()->machineWindowIcon();
     191    if (pMachineWindowIcon)
     192        setWindowIcon(*pMachineWindowIcon);
    193193    /* Or set default machine-window icon: */
    194194    else
     
    346346                                                                  console().GetGuestEnteredACPIMode(),
    347347                                                                  restrictedCloseActions);
     348        /* Configure close-dialog: */
     349        const QIcon *pMachineWindowIcon = uisession()->machineWindowIcon();
     350        if (pMachineWindowIcon)
     351            pCloseDlg->setPixmap(pMachineWindowIcon->pixmap(QSize(32, 32)));
    348352
    349353        /* Make sure close-dialog is valid: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r66579 r66647  
    12901290
    12911291#ifndef VBOX_WS_MAC
    1292         /* Load/prepare user's machine-window icon: */
    1293         QIcon icon;
    1294         foreach (const QString &strIconName, gEDataManager->machineWindowIconNames(strMachineID))
    1295             if (!strIconName.isEmpty() && QFile::exists(strIconName))
    1296                 icon.addFile(strIconName);
    1297         if (!icon.isNull())
    1298             m_pMachineWindowIcon = new QIcon(icon);
     1292        /* Check whether we have overriding machine-window icon: */
     1293        {
     1294            /* Prepare null icon: */
     1295            QIcon icon;
     1296
     1297            /* 1. Load icon from IMachine extra-data: */
     1298            if (icon.isNull())
     1299                foreach (const QString &strIconName, gEDataManager->machineWindowIconNames(strMachineID))
     1300                    if (!strIconName.isEmpty() && QFile::exists(strIconName))
     1301                        icon.addFile(strIconName);
     1302
     1303            /* 2. Load icon from IMachine interface: */
     1304            if (icon.isNull())
     1305            {
     1306                const QVector<BYTE> byteVector = machine().GetIcon();
     1307                const QByteArray byteArray = QByteArray::fromRawData(reinterpret_cast<const char*>(byteVector.constData()), byteVector.size());
     1308                const QImage image = QImage::fromData(byteArray);
     1309                if (!image.isNull())
     1310                {
     1311                    QPixmap pixmap = QPixmap::fromImage(image);
     1312                    const int iMinimumLength = qMin(pixmap.width(), pixmap.height());
     1313                    pixmap = pixmap.scaled(QSize(iMinimumLength, iMinimumLength), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
     1314                    icon.addPixmap(pixmap);
     1315                }
     1316            }
     1317
     1318            /* Finally, store the icon dynamically if overriden: */
     1319            if (!icon.isNull())
     1320                m_pMachineWindowIcon = new QIcon(icon);
     1321        }
    12991322
    13001323        /* Load user's machine-window name postfix: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r62493 r66647  
    7070}
    7171
     72void UIVMCloseDialog::setPixmap(const QPixmap &pixmap)
     73{
     74    /* Make sure pixmap is valid: */
     75    if (pixmap.isNull())
     76        return;
     77
     78    /* Assign new pixmap: */
     79    m_pIcon->setPixmap(pixmap);
     80}
     81
    7282void UIVMCloseDialog::sltUpdateWidgetAvailability()
    7383{
     
    103113    /* Hide the dialog: */
    104114    hide();
    105 }
    106 
    107 void UIVMCloseDialog::setPixmap(const QPixmap &pixmap)
    108 {
    109     /* Make sure pixmap is valid: */
    110     if (pixmap.isNull())
    111         return;
    112 
    113     /* Assign new pixmap: */
    114     m_pIcon->setPixmap(pixmap);
    115115}
    116116
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r62493 r66647  
    4444    bool isValid() const { return m_fValid; }
    4545
     46    /* API: Pixmap stuff: */
     47    void setPixmap(const QPixmap &pixmap);
     48
    4649private slots:
    4750
     
    5356
    5457private:
    55 
    56     /* API: Pixmap stuff: */
    57     void setPixmap(const QPixmap &pixmap);
    5858
    5959    /* API: Detach-button stuff: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette