VirtualBox

Ignore:
Timestamp:
Oct 20, 2015 4:24:35 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Mac OS X: Runtime UI: First try to make sure OS type overlay takes 1/4 of the dock icon area.

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  
    394394}
    395395
     396QPixmap 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
     422QPixmap 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  
    107107    QPixmap guestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
    108108
     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
    109114private:
    110115
     
    113118    /** Guest OS type icons cache. */
    114119    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;
    115124};
    116125
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r58310 r58346  
    658658    /* Redirect to general icon-pool: */
    659659    return m_pIconPool->guestOSTypeIcon(strOSTypeID, pLogicalSize);
     660}
     661
     662QPixmap 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
     674QPixmap 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);
    660684}
    661685
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r58310 r58346  
    256256    QPixmap vmGuestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
    257257
     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
    258263    CGuestOSType vmGuestOSType (const QString &aTypeId,
    259264                                const QString &aFamilyId = QString::null) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r57998 r58346  
    12221222    /* Now the dock icon preview */
    12231223    QString osTypeId = guest().GetOSTypeId();
    1224     m_pDockIconPreview = new UIDockIconPreview(uisession(), vboxGlobal().vmGuestOSTypeIcon(osTypeId));
     1224    m_pDockIconPreview = new UIDockIconPreview(uisession(), vboxGlobal().vmGuestOSTypePixmapHiDPI(osTypeId, QSize(64, 64)));
    12251225
    12261226    /* Should the dock-icon be updated at runtime? */
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