• Skip to content
  • Skip to link menu
KDE 4.2 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(QSizeF iconSize READ iconSize)
00061     Q_PROPERTY(QString svg WRITE setSvg)
00062 //    Q_PROPERTY(QAction action READ action WRITE setAction)
00063 
00064 public:
00069     explicit IconWidget(QGraphicsItem *parent = 0);
00070 
00076     explicit IconWidget(const QString &text, QGraphicsItem *parent = 0);
00077 
00084     IconWidget(const QIcon &icon, const QString &text, QGraphicsItem *parent = 0);
00085 
00089     virtual ~IconWidget();
00090 
00094     QString text() const;
00095 
00100     void setText(const QString &text);
00101 
00107     void setSvg(const QString &svgFilePath, const QString &svgIconElement = QString());
00108 
00112     QString infoText() const;
00113 
00119     void setInfoText(const QString &text);
00120 
00124     QIcon icon() const;
00125 
00130     void setIcon(const QIcon &icon);
00131 
00137     Q_INVOKABLE void setIcon(const QString &icon);
00138 
00142     QSizeF iconSize() const;
00143 
00150     void addIconAction(QAction *action);
00151 
00158     void setAction(QAction *action);
00159 
00163     QAction *action() const;
00164 
00172     void setOrientation(Qt::Orientation orientation);
00173 
00179     void invertLayout(bool invert);
00180 
00184     bool invertedLayout() const;
00185 
00190     QSizeF sizeFromIconSize(const qreal iconWidth) const;
00191 
00195     int numDisplayLines();
00196 
00200     void setNumDisplayLines(int numLines);
00201 
00207     void setDrawBackground(bool draw);
00208 
00212     bool drawBackground() const;
00213 
00217     QPainterPath shape() const;
00218 
00219 public Q_SLOTS:
00225     void setPressed(bool pressed = true);
00226 
00230     void setUnpressed();
00231 
00232 protected:
00233     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
00234 
00235 Q_SIGNALS:
00239     void pressed(bool down);
00240 
00244     void clicked();
00245 
00249     void doubleClicked();
00250 
00255     void activated();
00256 
00261     void changed();
00262 
00263 protected:
00264     bool isDown();
00265     void mousePressEvent(QGraphicsSceneMouseEvent *event);
00266     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00267     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00268     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
00269 
00270     void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00271     void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00272 
00273 public:
00277     void drawActionButtonBase(QPainter *painter, const QSize &size, int element);
00278 
00279 private:
00280     Q_PRIVATE_SLOT(d, void syncToAction())
00281     Q_PRIVATE_SLOT(d, void clearAction())
00282     Q_PRIVATE_SLOT(d, void svgChanged())
00283     Q_PRIVATE_SLOT(d, void actionDestroyed(QObject *obj))
00284     Q_PRIVATE_SLOT(d, void readColors())
00285     Q_PRIVATE_SLOT(d, void hoverAnimationUpdate(qreal progress))
00286 
00287     IconWidgetPrivate * const d;
00288     friend class IconWidgetPrivate;
00289 };
00290 
00291 } // namespace Plasma
00292 
00293 #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
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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