From ed5e2e198104485e14351a97dc3dcccb452ed3d0 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 20 Feb 2012 11:20:51 +0100 Subject: [PATCH] bind kiconloader groups used for implicitWidth/height, will be used for kiconeffects --- .../qtextracomponents/qiconitem.cpp | 31 ++++++++++++++++++- .../qtextracomponents/qiconitem.h | 29 +++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/declarativeimports/qtextracomponents/qiconitem.cpp b/declarativeimports/qtextracomponents/qiconitem.cpp index 378a0eac7..6efbb3f07 100644 --- a/declarativeimports/qtextracomponents/qiconitem.cpp +++ b/declarativeimports/qtextracomponents/qiconitem.cpp @@ -20,12 +20,14 @@ #include "qiconitem.h" #include +#include #include 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) { diff --git a/declarativeimports/qtextracomponents/qiconitem.h b/declarativeimports/qtextracomponents/qiconitem.h index fa89057e8..2f5542510 100644 --- a/declarativeimports/qtextracomponents/qiconitem.h +++ b/declarativeimports/qtextracomponents/qiconitem.h @@ -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