23 #ifndef PLASMA_ICONWIDGET_H
24 #define PLASMA_ICONWIDGET_H
26 #include <QtCore/QObject>
27 #include <QtCore/QWeakPointer>
28 #include <QtGui/QGraphicsTextItem>
29 #include <QtGui/QIcon>
30 #include <QtGui/QGraphicsWidget>
37 class QPropertyAnimation;
54 class IconWidgetPrivate;
59 Q_PROPERTY(QString text READ text WRITE setText)
60 Q_PROPERTY(QString infoText READ infoText WRITE setInfoText)
61 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
62 Q_PROPERTY(QColor textBackgroundColor READ textBackgroundColor WRITE setTextBackgroundColor)
63 Q_PROPERTY(QSizeF iconSize READ iconSize)
64 Q_PROPERTY(QString svg READ svg WRITE setSvg)
65 Q_PROPERTY(
bool drawBackground READ drawBackground WRITE setDrawBackground)
66 Q_PROPERTY(QAction *action READ action WRITE setAction)
67 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
68 Q_PROPERTY(
int numDisplayLines READ numDisplayLines WRITE setNumDisplayLines)
69 Q_PROPERTY(QSizeF preferredIconSize READ preferredIconSize WRITE setPreferredIconSize)
70 Q_PROPERTY(QSizeF minimumIconSize READ minimumIconSize WRITE setMinimumIconSize)
71 Q_PROPERTY(QSizeF maximumIconSize READ maximumIconSize WRITE setMaximumIconSize)
78 explicit
IconWidget(QGraphicsItem *parent = 0);
85 explicit
IconWidget(const QString &text, QGraphicsItem *parent = 0);
93 IconWidget(const QIcon &icon, const QString &text, QGraphicsItem *parent = 0);
103 QString text() const;
109 void setText(const QString &text);
116 void setSvg(const QString &svgFilePath, const QString &svgIconElement = QString());
126 QString infoText() const;
133 void setInfoText(const QString &text);
144 void setIcon(const QIcon &icon);
150 QColor textBackgroundColor() const;
157 void setTextBackgroundColor(const QColor &color);
164 Q_INVOKABLE
void setIcon(const QString &icon);
169 QSizeF iconSize() const;
177 void setPreferredIconSize(const QSizeF &size);
186 QSizeF preferredIconSize() const;
195 void setMinimumIconSize(const QSizeF &size);
205 QSizeF minimumIconSize() const;
214 void setMaximumIconSize(const QSizeF &size);
224 QSizeF maximumIconSize() const;
232 void addIconAction(QAction *action);
240 void removeIconAction(QAction *action);
248 void setAction(QAction *action);
253 QAction *action() const;
262 void setOrientation(Qt::Orientation orientation);
267 Qt::Orientation orientation() const;
274 void invertLayout(
bool invert);
279 bool invertedLayout() const;
285 Q_INVOKABLE QSizeF sizeFromIconSize(const qreal iconWidth) const;
290 int numDisplayLines();
295 void setNumDisplayLines(
int numLines);
302 void setDrawBackground(
bool draw);
307 bool drawBackground() const;
312 QPainterPath shape() const;
320 void setPressed(
bool pressed = true);
329 QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
335 void pressed(
bool down);
345 void doubleClicked();
361 void mousePressEvent(QGraphicsSceneMouseEvent *event);
362 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
363 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
364 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
366 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
367 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
369 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
370 void changeEvent(QEvent *event);
376 void drawActionButtonBase(QPainter *painter, const QSize &size,
int element);
379 Q_PRIVATE_SLOT(d,
void syncToAction())
380 Q_PRIVATE_SLOT(d,
void clearAction())
381 Q_PRIVATE_SLOT(d,
void svgChanged())
382 Q_PRIVATE_SLOT(d,
void actionDestroyed(
QObject *obj))
383 Q_PRIVATE_SLOT(d,
void hoverAnimationFinished())
384 Q_PRIVATE_SLOT(d,
void colorConfigChanged())
385 Q_PRIVATE_SLOT(d,
void iconConfigChanged())
386 Q_PRIVATE_SLOT(d,
void setPalette())
388 IconWidgetPrivate * const d;
389 friend class IconWidgetPrivate;
390 friend class PopupAppletPrivate;