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

libplasma

icon.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_ICON_H
00024 #define PLASMA_ICON_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 
00046 namespace Plasma
00047 {
00048 
00049 class IconPrivate;
00050 
00051 class PLASMA_EXPORT Icon : public QGraphicsWidget
00052 {
00053     Q_OBJECT
00054     Q_PROPERTY( QString text READ text WRITE setText )
00055     Q_PROPERTY( QString infoText READ infoText WRITE setInfoText )
00056     Q_PROPERTY( QIcon icon READ icon WRITE setIcon )
00057     Q_PROPERTY( QSizeF iconSize READ iconSize )
00058     Q_PROPERTY( QString svg WRITE setSvg )
00059 //    Q_PROPERTY( QAction action READ action WRITE setAction )
00060 public:
00065     explicit Icon(QGraphicsItem *parent = 0);
00066 
00072     explicit Icon(const QString &text, QGraphicsItem *parent = 0);
00073 
00080     Icon(const QIcon &icon, const QString &text, QGraphicsItem *parent = 0);
00081 
00085     virtual ~Icon();
00086 
00090     QString text() const;
00091 
00096     void setText(const QString &text);
00097 
00103     void setSvg(const QString &svgFilePath, const QString &svgIconElement = QString());
00104 
00108     QString infoText() const;
00109 
00115     void setInfoText(const QString &text);
00116 
00120     QIcon icon() const;
00121 
00126     void setIcon(const QIcon& icon);
00127 
00133     Q_INVOKABLE void setIcon(const QString& icon);
00134 
00138     QSizeF iconSize() const;
00139 
00146     void addIconAction(QAction* action);
00147 
00154     void setAction(QAction *action);
00155 
00159     QAction* action() const;
00160 
00168     void setOrientation(Qt::Orientation orientation);
00169 
00175     void invertLayout(bool invert);
00176 
00180     bool invertedLayout() const;
00181 
00186     QSizeF sizeFromIconSize(const qreal iconWidth) const;
00187 
00191     int numDisplayLines();
00192 
00196     void setNumDisplayLines(int numLines);
00197 
00203     void setDrawBackground(bool draw);
00204 
00208     bool drawBackground() const;
00209 
00213     QPainterPath shape() const;
00214 
00215 public Q_SLOTS:
00221     void setPressed(bool pressed = true);
00222 
00226     void setUnpressed();
00227 
00228 protected:
00229     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
00230 
00231 Q_SIGNALS:
00235     void pressed(bool down);
00236 
00240     void clicked();
00241 
00245     void doubleClicked();
00246 
00251     void activated();
00252 
00257     void changed();
00258 
00259 protected:
00260     bool isDown();
00261     void mousePressEvent(QGraphicsSceneMouseEvent *event);
00262     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00263     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00264     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
00265 
00266     void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00267     void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00268 
00269 public:
00273     void drawActionButtonBase(QPainter* painter, const QSize &size, int element);
00274 
00275 private:
00276     Q_PRIVATE_SLOT(d, void syncToAction())
00277     void init();
00278     void layoutIcons(const QStyleOptionGraphicsItem *option);
00279     void hoverEffect(bool);
00280 
00281     IconPrivate * const d;
00282 
00283     friend class IconPrivate;
00284 private Q_SLOTS:
00285     void actionDestroyed(QObject* obj);
00286     void readColors();
00287     void hoverAnimationUpdate(qreal progress);
00288 
00289 };
00290 
00291 } // namespace Plasma
00292 
00293 
00294 /*
00295     // Add these to UrlIcon
00296     void setUrl(const KUrl& url);
00297     KUrl url() const;
00298 */
00299 
00300 #endif

libplasma

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

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
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