• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Plasma

iconwidget.h

Go to the documentation of this file.
00001 /*
00002 *   Copyright (C) 2007 by Siraj Razick <siraj@kde.org>
00003 *   Copyright (C) 2007 by Riccardo Iaconelli <riccardo@kde.org>
00004 *   Copyright (C) 2007 by Matt Broadstone <mbroadst@gmail.com>
00005 *   Copyright 2008 by Alexis Ménard <darktears31@gmail.com>
00006 *
00007 *   This program is free software; you can redistribute it and/or modify
00008 *   it under the terms of the GNU Library General Public License as
00009 *   published by the Free Software Foundation; either version 2, or
00010 *   (at your option) any later version.
00011 *
00012 *   This program is distributed in the hope that it will be useful,
00013 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 *   GNU General Public License for more details
00016 *
00017 *   You should have received a copy of the GNU Library General Public
00018 *   License along with this program; if not, write to the
00019 *   Free Software Foundation, Inc.,
00020 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021 */
00022 
00023 #ifndef PLASMA_ICONWIDGET_H
00024 #define PLASMA_ICONWIDGET_H
00025 
00026 #include <QtCore/QObject>
00027 #include <QtGui/QGraphicsTextItem>
00028 #include <QtGui/QIcon>
00029 #include <QtGui/QGraphicsWidget>
00030 
00031 #include <plasma/dataengine.h>
00032 #include <plasma/animator.h>
00033 #include <plasma/plasma_export.h>
00034 
00035 class QAction;
00036 
00049 namespace Plasma
00050 {
00051 
00052 class IconWidgetPrivate;
00053 
00054 class PLASMA_EXPORT IconWidget : public QGraphicsWidget
00055 {
00056     Q_OBJECT
00057     Q_PROPERTY(QString text READ text WRITE setText)
00058     Q_PROPERTY(QString infoText READ infoText WRITE setInfoText)
00059     Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
00060     Q_PROPERTY(QColor textBackgroundColor READ textBackgroundColor WRITE setTextBackgroundColor)
00061     Q_PROPERTY(QSizeF iconSize READ iconSize)
00062     Q_PROPERTY(QString svg READ svg WRITE setSvg)
00063     Q_PROPERTY(QAction *action READ action WRITE setAction)
00064     Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
00065     Q_PROPERTY(int numDisplayLines READ numDisplayLines WRITE setNumDisplayLines)
00066 
00067 public:
00072     explicit IconWidget(QGraphicsItem *parent = 0);
00073 
00079     explicit IconWidget(const QString &text, QGraphicsItem *parent = 0);
00080 
00087     IconWidget(const QIcon &icon, const QString &text, QGraphicsItem *parent = 0);
00088 
00092     virtual ~IconWidget();
00093 
00097     QString text() const;
00098 
00103     void setText(const QString &text);
00104 
00110     void setSvg(const QString &svgFilePath, const QString &svgIconElement = QString());
00111 
00115     QString svg() const;
00116 
00120     QString infoText() const;
00121 
00127     void setInfoText(const QString &text);
00128 
00132     QIcon icon() const;
00133 
00138     void setIcon(const QIcon &icon);
00139 
00144     QColor textBackgroundColor() const;
00145 
00151     void setTextBackgroundColor(const QColor &color);
00152 
00158     Q_INVOKABLE void setIcon(const QString &icon);
00159 
00163     QSizeF iconSize() const;
00164 
00171     void addIconAction(QAction *action);
00172 
00177     void removeIconAction(QAction *action);
00178 
00185     void setAction(QAction *action);
00186 
00190     QAction *action() const;
00191 
00199     void setOrientation(Qt::Orientation orientation);
00200 
00204     Qt::Orientation orientation() const;
00205 
00211     void invertLayout(bool invert);
00212 
00216     bool invertedLayout() const;
00217 
00222     QSizeF sizeFromIconSize(const qreal iconWidth) const;
00223 
00227     int numDisplayLines();
00228 
00232     void setNumDisplayLines(int numLines);
00233 
00239     void setDrawBackground(bool draw);
00240 
00244     bool drawBackground() const;
00245 
00249     QPainterPath shape() const;
00250 
00251 public Q_SLOTS:
00257     void setPressed(bool pressed = true);
00258 
00262     void setUnpressed();
00263 
00264 protected:
00265     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
00266 
00267 Q_SIGNALS:
00271     void pressed(bool down);
00272 
00276     void clicked();
00277 
00281     void doubleClicked();
00282 
00287     void activated();
00288 
00293     void changed();
00294 
00295 protected:
00296     bool isDown();
00297     void mousePressEvent(QGraphicsSceneMouseEvent *event);
00298     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00299     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00300     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
00301 
00302     void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00303     void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00304 
00305     bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
00306 
00307 public:
00311     void drawActionButtonBase(QPainter *painter, const QSize &size, int element);
00312 
00313 private:
00314     Q_PRIVATE_SLOT(d, void syncToAction())
00315     Q_PRIVATE_SLOT(d, void clearAction())
00316     Q_PRIVATE_SLOT(d, void svgChanged())
00317     Q_PRIVATE_SLOT(d, void actionDestroyed(QObject *obj))
00318     Q_PRIVATE_SLOT(d, void hoverAnimationUpdate(qreal progress))
00319     Q_PRIVATE_SLOT(d, void colorConfigChanged())
00320     Q_PRIVATE_SLOT(d, void iconConfigChanged())
00321 
00322     IconWidgetPrivate * const d;
00323     friend class IconWidgetPrivate;
00324 };
00325 
00326 } // namespace Plasma
00327 
00328 #endif

Plasma

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal