VirtualBox

Ignore:
Timestamp:
Apr 24, 2017 5:37:48 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115033
Message:

FE/Qt: bugref:6911: UISession: Caching VM pixmap.

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

Legend:

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

    r66657 r66660  
    15541554
    15551555    /* Assign corresponding icon: */
    1556     const QPixmap pixmap = vboxGlobal().vmGuestOSTypePixmapDefault(guest().GetOSTypeId());
    1557     pDlg->mLbIcon->setPixmap(pixmap);
     1556    if (uisession() && uisession()->machineWindowIcon())
     1557        pDlg->mLbIcon->setPixmap(uisession()->machineWindowIcon()->pixmap(QSize(32, 32)));
    15581558
    15591559    /* Search for the max available filter index: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp

    r66656 r66660  
    182182{
    183183#ifndef VBOX_WS_MAC
    184     /* On Mac OS X window icon referenced in info.plist is used. */
    185 
    186     /* Set default window icon (will be changed to VM-specific icon little bit later): */
    187     setWindowIcon(QIcon(":/VirtualBox_48px.png"));
    188 
    189     /* Set redefined machine-window icon if any: */
    190     QIcon *pMachineWidnowIcon = uisession()->machineWindowIcon();
    191     if (pMachineWidnowIcon)
    192         setWindowIcon(*pMachineWidnowIcon);
    193     /* Or set default machine-window icon: */
    194     else
    195         setWindowIcon(vboxGlobal().vmGuestOSTypeIcon(machine().GetOSTypeId()));
     184    /* Set machine-window icon if any: */
     185    // On macOS window icon is referenced in info.plist.
     186    if (uisession() && uisession()->machineWindowIcon())
     187        setWindowIcon(*uisession()->machineWindowIcon());
    196188#endif /* !VBOX_WS_MAC */
    197189}
     
    346338                                                                  console().GetGuestEnteredACPIMode(),
    347339                                                                  restrictedCloseActions);
     340        /* Configure close-dialog: */
     341        if (uisession() && uisession()->machineWindowIcon())
     342            pCloseDlg->setPixmap(uisession()->machineWindowIcon()->pixmap(QSize(32, 32)));
    348343
    349344        /* Make sure close-dialog is valid: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r66656 r66660  
    957957    , m_machineStatePrevious(KMachineState_Null)
    958958    , m_machineState(KMachineState_Null)
    959 #ifndef VBOX_WS_MAC
    960959    , m_pMachineWindowIcon(0)
    961 #endif /* !VBOX_WS_MAC */
    962960    , m_requestedVisualStateType(UIVisualStateType_Invalid)
    963961#ifdef VBOX_WS_WIN
     
    12891287        const QString strMachineID = vboxGlobal().managedVMUuid();
    12901288
     1289        /* Prepare machine-window icon: */
     1290        {
     1291            QIcon icon;
    12911292#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())
     1293            /* Load user machine-window icon: */
     1294            foreach (const QString &strIconName, gEDataManager->machineWindowIconNames(strMachineID))
     1295                if (!strIconName.isEmpty() && QFile::exists(strIconName))
     1296                    icon.addFile(strIconName);
     1297#endif
     1298            /* Use the OS type icon if user one was not set: */
     1299            if (icon.isNull())
     1300                icon = vboxGlobal().vmGuestOSTypeIcon(machine().GetOSTypeId());
     1301            /* Use the default icon if nothing else works: */
     1302            if (icon.isNull())
     1303                icon = QIcon(":/VirtualBox_48px.png");
     1304            /* Store the icon dynamically: */
    12981305            m_pMachineWindowIcon = new QIcon(icon);
    1299 
     1306        }
     1307
     1308#ifndef VBOX_WS_MAC
    13001309        /* Load user's machine-window name postfix: */
    13011310        m_strMachineWindowNamePostfix = gEDataManager->machineWindowNamePostfix(strMachineID);
    1302 #endif /* !VBOX_WS_MAC */
     1311#endif
    13031312
    13041313        /* Is there should be First RUN Wizard? */
     
    13681377        }
    13691378
    1370 #ifndef VBOX_WS_MAC
    1371         /* Cleanup user's machine-window icon: */
     1379        /* Cleanup machine-window icon: */
    13721380        delete m_pMachineWindowIcon;
    13731381        m_pMachineWindowIcon = 0;
    1374 #endif /* !VBOX_WS_MAC */
    13751382    }
    13761383}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r64160 r66660  
    128128    QCursor cursor() const { return m_cursor; }
    129129
    130 #ifndef VBOX_WS_MAC
    131130    /** @name Branding stuff.
    132131     ** @{ */
    133     /** Returns redefined machine-window icon. */
    134     QIcon* machineWindowIcon() const { return m_pMachineWindowIcon; }
     132    /** Returns the cached machine-window icon. */
     133    QIcon *machineWindowIcon() const { return m_pMachineWindowIcon; }
     134#ifndef VBOX_WS_MAC
    135135    /** Returns redefined machine-window name postfix. */
    136136    QString machineWindowNamePostfix() const { return m_strMachineWindowNamePostfix; }
    137     /** @} */
    138 #endif /* !VBOX_WS_MAC */
     137#endif
     138    /** @} */
    139139
    140140    /** @name Host-screen configuration variables.
     
    459459    QCursor m_cursor;
    460460
    461 #ifndef VBOX_WS_MAC
    462461    /** @name Branding variables.
    463462     ** @{ */
    464     /** Holds redefined machine-window icon. */
     463    /** Holds the cached machine-window icon. */
    465464    QIcon *m_pMachineWindowIcon;
     465#ifndef VBOX_WS_MAC
    466466    /** Holds redefined machine-window name postfix. */
    467467    QString m_strMachineWindowNamePostfix;
    468     /** @} */
    469 #endif /* !VBOX_WS_MAC */
     468#endif
     469    /** @} */
    470470
    471471    /** @name Visual-state configuration variables.
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.cpp

    r66657 r66660  
    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
     
    317317    KMachineState machineState = m_machine.GetState();
    318318
    319     /* Assign pixmap: */
    320     setPixmap(vboxGlobal().vmGuestOSTypePixmapDefault(m_machine.GetOSTypeId()));
    321 
    322319    /* Check which close-actions are resticted: */
    323320    bool fIsDetachAllowed = vboxGlobal().isSeparateProcess() && !(m_restictedCloseActions & MachineCloseAction_Detach);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIVMCloseDialog.h

    r66656 r66660  
    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.

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