fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/** @file
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * VBox Qt GUI - UIIconPool class declaration.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright (C) 2010-2014 Oracle Corporation
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file is part of VirtualBox Open Source Edition (OSE), as
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * available from http://www.virtualbox.org. This file is free software;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * you can redistribute it and/or modify it under the terms of the GNU
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * General Public License (GPL) as published by the Free Software
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Foundation, in version 2 as it comes in the "COPYING" file of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef ___UIIconPool_h___
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define ___UIIconPool_h___
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Qt includes: */
a1e9eea083a8f257157edb8a1efb5bbd300eb4bfSrikanth, Ramana#include <QIcon>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <QPixmap>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <QHash>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/** Interface which provides GUI with static API
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allowing to dynamically compose icons at runtime. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteclass UIIconPool
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortepublic:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Default icon types. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte enum UIDefaultIconType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Message-box related stuff: */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UIDefaultIconType_MessageBoxInformation,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UIDefaultIconType_MessageBoxQuestion,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UIDefaultIconType_MessageBoxWarning,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UIDefaultIconType_MessageBoxCritical,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Dialog related stuff: */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UIDefaultIconType_DialogCancel,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UIDefaultIconType_DialogHelp,
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe UIDefaultIconType_ArrowBack,
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe UIDefaultIconType_ArrowForward
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe };
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe /** Creates pixmap from passed pixmap @a strName. */
494f7e12a62129ef191a15f9dfde6b7abe3bf510Keith M Wesolowski static QPixmap pixmap(const QString &strName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Creates icon from passed pixmap names for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @a strNormal, @a strDisabled and @a strActive icon states. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static QIcon iconSet(const QString &strNormal,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const QString &strDisabled = QString(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const QString &strActive = QString());
a1e9eea083a8f257157edb8a1efb5bbd300eb4bfSrikanth, Ramana
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Creates icon from passed pixmap names for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @a strNormal, @a strDisabled, @a strActive icon states and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * their analogs for toggled-off case. Used for toggle actions. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static QIcon iconSetOnOff(const QString &strNormal, const QString strNormalOff,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const QString &strDisabled = QString(), const QString &strDisabledOff = QString(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const QString &strActive = QString(), const QString &strActiveOff = QString());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Creates icon from passed pixmap names for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @a strNormal, @a strDisabled, @a strActive icon states and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * their analogs for small-icon case. Used for setting pages. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static QIcon iconSetFull(const QString &strNormal, const QString &strSmall,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const QString &strNormalDisabled = QString(), const QString &strSmallDisabled = QString(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const QString &strNormalActive = QString(), const QString &strSmallActive = QString());
a1e9eea083a8f257157edb8a1efb5bbd300eb4bfSrikanth, Ramana
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Creates icon from passed pixmaps for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @a normal, @a disabled and @a active icon states. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static QIcon iconSet(const QPixmap &normal,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const QPixmap &disabled = QPixmap(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const QPixmap &active = QPixmap());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Creates icon of passed @a defaultIconType
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * based on passed @a pWidget style (if any) or application style (otherwise). */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static QIcon defaultIcon(UIDefaultIconType defaultIconType, const QWidget *pWidget = 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteprotected:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Icon-pool constructor. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte UIIconPool() {};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Icon-pool destructor. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte virtual ~UIIconPool() {};
a1e9eea083a8f257157edb8a1efb5bbd300eb4bfSrikanth, Ramana
a1e9eea083a8f257157edb8a1efb5bbd300eb4bfSrikanth, Ramanaprivate:
a1e9eea083a8f257157edb8a1efb5bbd300eb4bfSrikanth, Ramana
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /** Adds resource named @a strName to passed @a icon
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for @a mode (QIcon::Normal by default) and @a state (QIcon::Off by default). */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte static void addName(QIcon &icon, const QString &strName,
QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off);
};
/** UIIconPool interface extension used as general GUI icon-pool.
* Provides GUI with guest OS types pixmap cache. */
class UIIconPoolGeneral : public UIIconPool
{
public:
/** General icon-pool constructor. */
UIIconPoolGeneral();
/** Returns pixmap corresponding to passed @a strOSTypeID.
* In case if non-null @a pLogicalSize pointer provided, it will be updated properly. */
QPixmap guestOSTypeIcon(const QString &strOSTypeID, QSize *pLogicalSize = 0) const;
private:
/** Guest OS type icon-names cache. */
QHash<QString, QString> m_guestOSTypeIconNames;
/** Guest OS type icons cache. */
mutable QHash<QString, QIcon> m_guestOSTypeIcons;
};
#endif /* !___UIIconPool_h___ */