• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • plasma
  • widgets
iconwidget.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 by Siraj Razick <siraj@kde.org>
3* Copyright (C) 2007 by Riccardo Iaconelli <riccardo@kde.org>
4* Copyright (C) 2007 by Matt Broadstone <mbroadst@gmail.com>
5* Copyright 2008 by Alexis Ménard <darktears31@gmail.com>
6*
7* This program is free software; you can redistribute it and/or modify
8* it under the terms of the GNU Library General Public License as
9* published by the Free Software Foundation; either version 2, or
10* (at your option) any later version.
11*
12* This program is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details
16*
17* You should have received a copy of the GNU Library General Public
18* License along with this program; if not, write to the
19* Free Software Foundation, Inc.,
20* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21*/
22
23#ifndef PLASMA_ICONWIDGET_H
24#define PLASMA_ICONWIDGET_H
25
26#include <QtCore/QObject>
27#include <QtCore/QWeakPointer>
28#include <QtGui/QGraphicsTextItem>
29#include <QtGui/QIcon>
30#include <QtGui/QGraphicsWidget>
31
32#include <plasma/dataengine.h>
33#include <plasma/animator.h>
34#include <plasma/plasma_export.h>
35
36class QAction;
37class QPropertyAnimation;
38
51namespace Plasma
52{
53
54class IconWidgetPrivate;
55
56class PLASMA_EXPORT IconWidget : public QGraphicsWidget
57{
58 Q_OBJECT
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)
72
73public:
78 explicit IconWidget(QGraphicsItem *parent = 0);
79
85 explicit IconWidget(const QString &text, QGraphicsItem *parent = 0);
86
93 IconWidget(const QIcon &icon, const QString &text, QGraphicsItem *parent = 0);
94
98 virtual ~IconWidget();
99
103 QString text() const;
104
109 void setText(const QString &text);
110
116 void setSvg(const QString &svgFilePath, const QString &svgIconElement = QString());
117
121 QString svg() const;
122
126 QString infoText() const;
127
133 void setInfoText(const QString &text);
134
138 QIcon icon() const;
139
144 void setIcon(const QIcon &icon);
145
150 QColor textBackgroundColor() const;
151
157 void setTextBackgroundColor(const QColor &color);
158
164 Q_INVOKABLE void setIcon(const QString &icon);
165
169 QSizeF iconSize() const;
170
177 void setPreferredIconSize(const QSizeF &size);
178
186 QSizeF preferredIconSize() const;
187
195 void setMinimumIconSize(const QSizeF &size);
196
205 QSizeF minimumIconSize() const;
206
214 void setMaximumIconSize(const QSizeF &size);
215
224 QSizeF maximumIconSize() const;
225
232 void addIconAction(QAction *action);
233
240 void removeIconAction(QAction *action);
241
248 void setAction(QAction *action);
249
253 QAction *action() const;
254
262 void setOrientation(Qt::Orientation orientation);
263
267 Qt::Orientation orientation() const;
268
274 void invertLayout(bool invert);
275
279 bool invertedLayout() const;
280
285 Q_INVOKABLE QSizeF sizeFromIconSize(const qreal iconWidth) const;
286
290 int numDisplayLines();
291
295 void setNumDisplayLines(int numLines);
296
302 void setDrawBackground(bool draw);
303
307 bool drawBackground() const;
308
312 QPainterPath shape() const;
313
314public Q_SLOTS:
320 void setPressed(bool pressed = true);
321
325 void setUnpressed();
326
327protected:
328 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
329 QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
330
331Q_SIGNALS:
335 void pressed(bool down);
336
340 void clicked();
341
345 void doubleClicked();
346
351 void activated();
352
357 void changed();
358
359protected:
360 bool isDown();
361 void mousePressEvent(QGraphicsSceneMouseEvent *event);
362 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
363 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
364 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
365
366 void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
367 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
368
369 bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
370 void changeEvent(QEvent *event);
371
372public:
376 void drawActionButtonBase(QPainter *painter, const QSize &size, int element);
377
378private:
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())
387
388 IconWidgetPrivate * const d;
389 friend class IconWidgetPrivate;
390 friend class PopupAppletPrivate;
391};
392
393} // namespace Plasma
394
395#endif
animator.h
Plasma::IconWidget
Definition iconwidget.h:57
QGraphicsWidget
QObject
QStyleOptionGraphicsItem
QWidget
dataengine.h
Plasma
Namespace for everything in libplasma.
Definition abstractdialogmanager.cpp:25
plasma_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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