bind kiconloader groups
used for implicitWidth/height, will be used for kiconeffects
This commit is contained in:
parent
ffe2798e52
commit
ed5e2e1981
@ -20,12 +20,14 @@
|
||||
#include "qiconitem.h"
|
||||
|
||||
#include <kicon.h>
|
||||
#include <kiconloader.h>
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
|
||||
QIconItem::QIconItem(QDeclarativeItem *parent)
|
||||
: QDeclarativeItem(parent),
|
||||
m_smooth(false)
|
||||
m_smooth(false),
|
||||
m_group(NoGroup)
|
||||
{
|
||||
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
||||
}
|
||||
@ -51,6 +53,33 @@ QIcon QIconItem::icon() const
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
void QIconItem::setGroup(QIconItem::Group group)
|
||||
{
|
||||
if (m_group == group) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_group = group;
|
||||
emit groupChanged(group);
|
||||
emit implicitWidthChanged(implicitWidth());
|
||||
emit implicitHeightChanged(implicitHeight());
|
||||
}
|
||||
|
||||
QIconItem::Group QIconItem::group() const
|
||||
{
|
||||
return m_group;
|
||||
}
|
||||
|
||||
int QIconItem::implicitWidth() const
|
||||
{
|
||||
return KIconLoader::global()->currentSize((KIconLoader::Group)m_group);
|
||||
}
|
||||
|
||||
int QIconItem::implicitHeight() const
|
||||
{
|
||||
return KIconLoader::global()->currentSize((KIconLoader::Group)m_group);
|
||||
}
|
||||
|
||||
void QIconItem::setSmooth(const bool smooth)
|
||||
{
|
||||
if (smooth == m_smooth) {
|
||||
|
@ -29,22 +29,51 @@ class QIconItem : public QDeclarativeItem
|
||||
|
||||
Q_PROPERTY(QVariant icon READ icon WRITE setIcon)
|
||||
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
|
||||
Q_PROPERTY(int implicitWidth READ implicitWidth NOTIFY implicitWidthChanged)
|
||||
Q_PROPERTY(int implicitHeight READ implicitHeight NOTIFY implicitHeightChanged)
|
||||
Q_PROPERTY(Group group READ group WRITE setGroup NOTIFY groupChanged)
|
||||
Q_ENUMS(Group)
|
||||
|
||||
public:
|
||||
enum Group {
|
||||
NoGroup, ///No group.
|
||||
Desktop, ///Desktop icons.
|
||||
FirstGroup, ///First group.
|
||||
Toolbar, ///Toolbar icons.
|
||||
MainToolbar, ///Main toolbar icons.
|
||||
Small, ///Small icons, e.g. for buttons.
|
||||
Panel, ///Panel (Plasma Taskbar) icons.
|
||||
Dialog, ///Icons for use in dialog titles, page lists, etc.
|
||||
LastGroup, ///Last group.
|
||||
User ///User icons.
|
||||
};
|
||||
|
||||
QIconItem(QDeclarativeItem *parent=0);
|
||||
~QIconItem();
|
||||
|
||||
void setIcon(const QVariant &icon);
|
||||
QIcon icon() const;
|
||||
|
||||
void setGroup(Group group);
|
||||
Group group() const;
|
||||
|
||||
int implicitWidth() const;
|
||||
int implicitHeight() const;
|
||||
|
||||
void setSmooth(const bool smooth);
|
||||
bool smooth() const;
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
Q_SIGNALS:
|
||||
void implicitWidthChanged(int implicitWidth);
|
||||
void implicitHeightChanged(int implicitHeight);
|
||||
void groupChanged(Group group);
|
||||
|
||||
private:
|
||||
QIcon m_icon;
|
||||
bool m_smooth;
|
||||
Group m_group;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user