• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaCore

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • core
iconitem.h
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Marco Martin <mart@kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef ICONITEM_H
21 #define ICONITEM_H
22 
23 #include <QDeclarativeItem>
24 #include <QPixmap>
25 #include <QVariant>
26 
27 class QPropertyAnimation;
28 
29 namespace Plasma {
30  class Svg;
31 }
32 
33 class IconItem : public QDeclarativeItem
34 {
35  Q_OBJECT
36 
37  Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged)
38  Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
39  Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged)
40  Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged)
41  Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
42  Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
43 
44 public:
45 
46  IconItem(QDeclarativeItem *parent=0);
47  ~IconItem();
48 
49  void setSource(const QVariant &source);
50  QVariant source() const;
51 
52  bool isActive() const;
53  void setActive(bool active);
54 
55  void setImplicitWidth(qreal width);
56  qreal implicitWidth() const;
57 
58  void setImplicitHeight(qreal height);
59  qreal implicitHeight() const;
60 
61  void setSmooth(const bool smooth);
62  bool smooth() const;
63 
64  bool isValid() const;
65 
66  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
67 
68  void geometryChanged(const QRectF &newGeometry,
69  const QRectF &oldGeometry);
70 
71 Q_SIGNALS:
72  void activeChanged();
73  void sourceChanged();
74  void smoothChanged();
75  void validChanged();
76  void implicitWidthChanged();
77  void implicitHeightChanged();
78 
79 private Q_SLOTS:
80  void loadPixmap();
81  void animationFinished();
82  void valueChanged(const QVariant &value);
83 
84 private:
85  //all the ways we can set an source. Only one of them will be valid
86  QIcon m_icon;
87  Plasma::Svg *m_svgIcon;
88  QPixmap m_pixmapIcon;
89  QImage m_imageIcon;
90  //this contains the raw variant it was passed
91  QVariant m_source;
92 
93  QSizeF m_implicitSize;
94 
95  bool m_smooth;
96  bool m_active;
97 
98  //This list contains at most 2 sources, when a pixmap transition is due,
99  //a new pixmap is queued, the old one is removed when the animation finishes
100  QList<QPixmap> m_iconPixmaps;
101 
102  //animation on pixmap change
103  QPropertyAnimation *m_animation;
104  qreal m_animValue;
105 };
106 
107 #endif
IconItem::geometryChanged
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
Definition: iconitem.cpp:327
QWidget
IconItem::implicitWidthChanged
void implicitWidthChanged()
IconItem::validChanged
void validChanged()
IconItem::smooth
bool smooth() const
IconItem::active
bool active
Definition: iconitem.h:41
IconItem::setSource
void setSource(const QVariant &source)
Definition: iconitem.cpp:69
IconItem::setImplicitHeight
void setImplicitHeight(qreal height)
Definition: iconitem.cpp:179
IconItem::implicitHeightChanged
void implicitHeightChanged()
QPropertyAnimation
IconItem::isValid
bool isValid() const
Definition: iconitem.cpp:209
QPainter
IconItem::sourceChanged
void sourceChanged()
QList
QPixmap
QImage
IconItem::implicitHeight
qreal implicitHeight() const
IconItem::activeChanged
void activeChanged()
IconItem::isActive
bool isActive() const
Definition: iconitem.cpp:147
IconItem::implicitWidth
qreal implicitWidth() const
QSizeF
QRectF
IconItem::source
QVariant source() const
QStyleOptionGraphicsItem
IconItem::setSmooth
void setSmooth(const bool smooth)
Definition: iconitem.cpp:195
IconItem::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: iconitem.cpp:214
QDeclarativeItem
QObject::parent
QObject * parent() const
IconItem::smoothChanged
void smoothChanged()
IconItem::setActive
void setActive(bool active)
Definition: iconitem.cpp:152
IconItem::valid
bool valid
Definition: iconitem.h:42
IconItem
Definition: iconitem.h:33
QIcon
IconItem::setImplicitWidth
void setImplicitWidth(qreal width)
Definition: iconitem.cpp:163
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaCore

Skip menu "PlasmaCore"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal