VirtualBox

Changeset 51579 in vbox


Ignore:
Timestamp:
Jun 9, 2014 1:01:49 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94275
Message:

FE/Qt: 6278: Mac OS X: HiDPI: Integrate hi-dpi-aware icons for VM states and snapshot items.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverter.h

    r51531 r51579  
    4343    }
    4444
    45     /* QPixmap <= template class: */
    46     template<class T> QPixmap toPixmap(const T &data) const
     45    /* QIcon <= template class: */
     46    template<class T> QIcon toIcon(const T &data) const
    4747    {
    4848        if (canConvert<T>())
    49             return ::toPixmap(data);
    50         Assert(0); return QPixmap();
     49            return ::toIcon(data);
     50        Assert(0); return QIcon();
    5151    }
    5252    /* QPixmap <= template class: */
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r51531 r51579  
    2323#include <QString>
    2424#include <QColor>
     25#include <QIcon>
    2526#include <QPixmap>
    2627
     
    3738template<class X> QColor toColor(const X & /* xobject */) { Assert(0); return QColor(); }
    3839
    39 /* Converts passed 'Object X' to QPixmap.
    40  * This function returns null QPixmap for any object type until re-determined for specific one. */
    41 template<class X> QPixmap toPixmap(const X & /* xobject */) { Assert(0); return QPixmap(); }
     40/* Converts passed 'Object X' to QIcon.
     41 * This function returns null QIcon for any object type until re-determined for specific one. */
     42template<class X> QIcon toIcon(const X & /* xobject */) { Assert(0); return QIcon(); }
     43
    4244/* Converts passed 'Object X' to QPixmap.
    4345 * This function returns null QPixmap for any object type until re-determined for specific one. */
     
    165167/* Declare COM conversion specializations: */
    166168template<> QColor toColor(const KMachineState &state);
    167 template<> QPixmap toPixmap(const KMachineState &state);
     169template<> QIcon toIcon(const KMachineState &state);
    168170template<> QString toString(const KMachineState &state);
    169171template<> QString toString(const KSessionState &state);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp

    r51476 r51579  
    2424/* GUI includes: */
    2525#include "UIConverterBackend.h"
     26#include "UIIconPool.h"
    2627
    2728/* COM includes: */
     
    8788}
    8889
    89 /* QPixmap <= KMachineState: */
    90 template<> QPixmap toPixmap(const KMachineState &state)
     90/* QIcon <= KMachineState: */
     91template<> QIcon toIcon(const KMachineState &state)
    9192{
    9293    switch (state)
    9394    {
    94         case KMachineState_PoweredOff:             return QPixmap(":/state_powered_off_16px.png");
    95         case KMachineState_Saved:                  return QPixmap(":/state_saved_16px.png");
    96         case KMachineState_Aborted:                return QPixmap(":/state_aborted_16px.png");
    97         case KMachineState_Teleported:             return QPixmap(":/state_saved_16px.png");
    98         case KMachineState_Running:                return QPixmap(":/state_running_16px.png");
    99         case KMachineState_Paused:                 return QPixmap(":/state_paused_16px.png");
    100         case KMachineState_Stuck:                  return QPixmap(":/state_stuck_16px.png");
    101         case KMachineState_Teleporting:            return QPixmap(":/state_running_16px.png");
    102         case KMachineState_LiveSnapshotting:       return QPixmap(":/state_running_16px.png");
    103         case KMachineState_Starting:               return QPixmap(":/state_running_16px.png");
    104         case KMachineState_Stopping:               return QPixmap(":/state_running_16px.png");
    105         case KMachineState_Saving:                 return QPixmap(":/state_saving_16px.png");
    106         case KMachineState_Restoring:              return QPixmap(":/state_restoring_16px.png");
    107         case KMachineState_TeleportingPausedVM:    return QPixmap(":/state_saving_16px.png");
    108         case KMachineState_TeleportingIn:          return QPixmap(":/state_restoring_16px.png");
     95        case KMachineState_PoweredOff:             return UIIconPool::iconSet(":/state_powered_off_16px.png");
     96        case KMachineState_Saved:                  return UIIconPool::iconSet(":/state_saved_16px.png");
     97        case KMachineState_Aborted:                return UIIconPool::iconSet(":/state_aborted_16px.png");
     98        case KMachineState_Teleported:             return UIIconPool::iconSet(":/state_saved_16px.png");
     99        case KMachineState_Running:                return UIIconPool::iconSet(":/state_running_16px.png");
     100        case KMachineState_Paused:                 return UIIconPool::iconSet(":/state_paused_16px.png");
     101        case KMachineState_Stuck:                  return UIIconPool::iconSet(":/state_stuck_16px.png");
     102        case KMachineState_Teleporting:            return UIIconPool::iconSet(":/state_running_16px.png");
     103        case KMachineState_LiveSnapshotting:       return UIIconPool::iconSet(":/state_running_16px.png");
     104        case KMachineState_Starting:               return UIIconPool::iconSet(":/state_running_16px.png");
     105        case KMachineState_Stopping:               return UIIconPool::iconSet(":/state_running_16px.png");
     106        case KMachineState_Saving:                 return UIIconPool::iconSet(":/state_saving_16px.png");
     107        case KMachineState_Restoring:              return UIIconPool::iconSet(":/state_restoring_16px.png");
     108        case KMachineState_TeleportingPausedVM:    return UIIconPool::iconSet(":/state_saving_16px.png");
     109        case KMachineState_TeleportingIn:          return UIIconPool::iconSet(":/state_restoring_16px.png");
    109110        // case KMachineState_FaultTolerantSyncing:
    110         case KMachineState_DeletingSnapshotOnline: return QPixmap(":/state_discarding_16px.png");
    111         case KMachineState_DeletingSnapshotPaused: return QPixmap(":/state_discarding_16px.png");
    112         case KMachineState_RestoringSnapshot:      return QPixmap(":/state_discarding_16px.png");
    113         case KMachineState_DeletingSnapshot:       return QPixmap(":/state_discarding_16px.png");
    114         case KMachineState_SettingUp:              return QPixmap(":/vm_settings_16px.png"); // TODO: Change icon!
     111        case KMachineState_DeletingSnapshotOnline: return UIIconPool::iconSet(":/state_discarding_16px.png");
     112        case KMachineState_DeletingSnapshotPaused: return UIIconPool::iconSet(":/state_discarding_16px.png");
     113        case KMachineState_RestoringSnapshot:      return UIIconPool::iconSet(":/state_discarding_16px.png");
     114        case KMachineState_DeletingSnapshot:       return UIIconPool::iconSet(":/state_discarding_16px.png");
     115        case KMachineState_SettingUp:              return UIIconPool::iconSet(":/vm_settings_16px.png"); // TODO: Change icon!
    115116        // case KMachineState_FirstOnline:
    116117        // case KMachineState_LastOnline:
    117118        // case KMachineState_FirstTransient:
    118119        // case KMachineState_LastTransient:
    119         default: AssertMsgFailed(("No pixmap for %d", state)); break;
    120     }
    121     return QPixmap();
     120        default: AssertMsgFailed(("No icon for %d", state)); break;
     121    }
     122    return QIcon();
    122123}
    123124
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r51565 r51579  
    40134013    m_pIconPool = new UIIconPoolGeneral;
    40144014
    4015     /* online/offline snapshot icons */
    4016     mOfflineSnapshotIcon = QPixmap (":/snapshot_offline_16px.png");
    4017     mOnlineSnapshotIcon = QPixmap (":/snapshot_online_16px.png");
    4018 
    40194015    qApp->installEventFilter (this);
    40204016
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r51401 r51579  
    213213    QString toLPTPortName (ulong aIRQ, ulong aIOBase) const;
    214214    bool toLPTPortNumbers (const QString &aName, ulong &aIRQ, ulong &aIOBase) const;
    215 
    216     QPixmap snapshotIcon (bool online) const
    217     {
    218         return online ? mOnlineSnapshotIcon : mOfflineSnapshotIcon;
    219     }
    220215
    221216    static bool hasAllowedExtension(const QString &strExt, const QStringList &extList)
     
    485480    QList <QList <CGuestOSType> > mTypes;
    486481
    487     QPixmap mOfflineSnapshotIcon, mOnlineSnapshotIcon;
    488 
    489482    QString mDiskTypes_Differencing;
    490483
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIVMItem.cpp

    r51054 r51579  
    168168QIcon UIVMItem::machineStateIcon() const
    169169{
    170     return m_fAccessible ? gpConverter->toPixmap(m_machineState) :
    171                            QPixmap(":/state_aborted_16px.png");
     170    return m_fAccessible ? gpConverter->toIcon(m_machineState) :
     171                           gpConverter->toIcon(KMachineState_Aborted);
    172172}
    173173
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.cpp

    r51267 r51579  
    5959
    6060    /* Normal snapshot item (child of tree-widget) */
    61     SnapshotWgtItem (QTreeWidget *aTreeWidget, const CSnapshot &aSnapshot)
     61    SnapshotWgtItem (VBoxSnapshotsWgt *pSnapshotWidget, QTreeWidget *aTreeWidget, const CSnapshot &aSnapshot)
    6262        : QTreeWidgetItem (aTreeWidget, ItemType)
     63        , m_pSnapshotWidget(pSnapshotWidget)
    6364        , mIsCurrentState (false)
    6465        , mSnapshot (aSnapshot)
     
    6768
    6869    /* Normal snapshot item (child of tree-widget-item) */
    69     SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CSnapshot &aSnapshot)
     70    SnapshotWgtItem (VBoxSnapshotsWgt *pSnapshotWidget, QTreeWidgetItem *aRootItem, const CSnapshot &aSnapshot)
    7071        : QTreeWidgetItem (aRootItem, ItemType)
     72        , m_pSnapshotWidget(pSnapshotWidget)
    7173        , mIsCurrentState (false)
    7274        , mSnapshot (aSnapshot)
     
    7577
    7678    /* Current state item (child of tree-widget) */
    77     SnapshotWgtItem (QTreeWidget *aTreeWidget, const CMachine &aMachine)
     79    SnapshotWgtItem (VBoxSnapshotsWgt *pSnapshotWidget, QTreeWidget *aTreeWidget, const CMachine &aMachine)
    7880        : QTreeWidgetItem (aTreeWidget, ItemType)
     81        , m_pSnapshotWidget(pSnapshotWidget)
    7982        , mIsCurrentState (true)
    8083        , mMachine (aMachine)
     
    8487
    8588    /* Current state item (child of tree-widget-item) */
    86     SnapshotWgtItem (QTreeWidgetItem *aRootItem, const CMachine &aMachine)
     89    SnapshotWgtItem (VBoxSnapshotsWgt *pSnapshotWidget, QTreeWidgetItem *aRootItem, const CMachine &aMachine)
    8790        : QTreeWidgetItem (aRootItem, ItemType)
     91        , m_pSnapshotWidget(pSnapshotWidget)
    8892        , mIsCurrentState (true)
    8993        , mMachine (aMachine)
     
    171175            setText (0, mSnapshot.GetName());
    172176            mOnline = mSnapshot.GetOnline();
    173             setIcon (0, vboxGlobal().snapshotIcon (mOnline));
     177            setIcon(0, m_pSnapshotWidget->snapshotItemIcon(mOnline));
    174178            mDesc = mSnapshot.GetDescription();
    175179            mTimestamp.setTime_t (mSnapshot.GetTimeStamp() / 1000);
     
    193197            return;
    194198
    195         setIcon (0, gpConverter->toPixmap (aState));
     199        setIcon(0, gpConverter->toIcon(aState));
    196200        mMachineState = aState;
    197201        mTimestamp.setTime_t (mMachine.GetLastStateChange() / 1000);
     
    291295        setToolTip (0, toolTip);
    292296    }
     297
     298    /** Holds pointer to snapshot-widget 'this' item belongs to. */
     299    QPointer<VBoxSnapshotsWgt> m_pSnapshotWidget;
    293300
    294301    bool mIsCurrentState;
     
    361368    connect (mTreeWidget, SIGNAL (destroyed (QObject *)), treeWidgetStyle, SLOT (deleteLater()));
    362369// #endif
     370
     371    /* Cache pixmaps: */
     372    m_offlineSnapshotIcon = UIIconPool::iconSet(":/snapshot_offline_16px.png");
     373    m_onlineSnapshotIcon = UIIconPool::iconSet(":/snapshot_online_16px.png");
    363374
    364375    /* ToolBar creation */
     
    953964
    954965        /* Add the "current state" item */
    955         SnapshotWgtItem *csi = new SnapshotWgtItem (mCurSnapshotItem, mMachine);
     966        SnapshotWgtItem *csi = new SnapshotWgtItem(this, mCurSnapshotItem, mMachine);
    956967        csi->setBold (true);
    957968        csi->recache();
     
    972983
    973984        /* Add the "current state" item */
    974         SnapshotWgtItem *csi = new SnapshotWgtItem (mTreeWidget, mMachine);
     985        SnapshotWgtItem *csi = new SnapshotWgtItem(this, mTreeWidget, mMachine);
    975986        csi->setBold (true);
    976987        csi->recache();
     
    10101021void VBoxSnapshotsWgt::populateSnapshots (const CSnapshot &aSnapshot, QTreeWidgetItem *aItem)
    10111022{
    1012     SnapshotWgtItem *item = aItem ? new SnapshotWgtItem (aItem, aSnapshot) :
    1013                                     new SnapshotWgtItem (mTreeWidget, aSnapshot);
     1023    SnapshotWgtItem *item = aItem ? new SnapshotWgtItem(this, aItem, aSnapshot) :
     1024                                    new SnapshotWgtItem(this, mTreeWidget, aSnapshot);
    10141025    item->recache();
    10151026
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSnapshotsWgt.h

    r47222 r51579  
    2222/* Qt includes: */
    2323#include <QTimer>
     24#include <QIcon>
    2425
    2526/* GUI includes: */
     
    5354
    5455    void setMachine (const CMachine &aMachine);
     56
     57    /** Returns cached snapshot-item icon depending on @a fOnline flag. */
     58    const QIcon& snapshotItemIcon(bool fOnline) { return !fOnline ? m_offlineSnapshotIcon : m_onlineSnapshotIcon; }
    5559
    5660protected:
     
    112116
    113117    bool            m_fShapshotOperationsAllowed;
     118
     119    /** Pointer to cached snapshot-item pixmap for 'offline' state. */
     120    QIcon           m_offlineSnapshotIcon;
     121    /** Pointer to cached snapshot-item pixmap for 'online' state. */
     122    QIcon           m_onlineSnapshotIcon;
    114123};
    115124
    116125#endif // __VBoxSnapshotsWgt_h__
    117 
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.cpp

    r50934 r51579  
    235235{
    236236    /* Get new state-pixmap and state-pixmap size: */
    237     QIcon stateIcon = machineStateIcon();
    238     QSize stateIconSize = stateIcon.availableSizes().first();
    239     QPixmap statePixmap = stateIcon.pixmap(stateIconSize);
     237    const QIcon stateIcon = machineStateIcon();
     238    const QSize statePixmapSize = stateIcon.availableSizes().first();
     239    const QPixmap statePixmap = stateIcon.pixmap(statePixmapSize);
    240240    /* Update linked values: */
    241     if (m_statePixmapSize != stateIconSize)
    242     {
    243         m_statePixmapSize = stateIconSize;
     241    if (m_statePixmapSize != statePixmapSize)
     242    {
     243        m_statePixmapSize = statePixmapSize;
    244244        updateGeometry();
    245245    }
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