• Skip to content
  • Skip to link menu
KDE 4.0 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 *
00006 *   This program is free software; you can redistribute it and/or modify
00007 *   it under the terms of the GNU Library General Public License as
00008 *   published by the Free Software Foundation; either version 2, or
00009 *   (at your option) any later version.
00010 *
00011 *   This program is distributed in the hope that it will be useful,
00012 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 *   GNU General Public License for more details
00015 *
00016 *   You should have received a copy of the GNU Library General Public
00017 *   License along with this program; if not, write to the
00018 *   Free Software Foundation, Inc.,
00019 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020 */
00021 
00022 #ifndef ICON_H
00023 #define ICON_H
00024 
00025 #include <QtCore/QObject>
00026 #include <QtGui/QGraphicsTextItem>
00027 #include <QtGui/QIcon>
00028 
00029 #include <plasma/dataengine.h>
00030 #include <plasma/phase.h>
00031 #include <plasma/plasma_export.h>
00032 #include <plasma/widgets/widget.h>
00033 
00034 class QAction;
00035 
00045 namespace Plasma
00046 {
00047 
00048 class PLASMA_EXPORT Icon : public Plasma::Widget
00049 {
00050     Q_OBJECT
00051     Q_PROPERTY( QString text READ text WRITE setText )
00052     Q_PROPERTY( QString infoText READ infoText WRITE setInfoText )
00053     Q_PROPERTY( QIcon icon READ icon WRITE setIcon )
00054     Q_PROPERTY( QSizeF iconSize READ iconSize )
00055     Q_PROPERTY( QString svg WRITE setSvg )
00056 public:
00061     explicit Icon(QGraphicsItem *parent = 0);
00062 
00068     explicit Icon(const QString &text, QGraphicsItem *parent = 0);
00069 
00076     Icon(const QIcon &icon, const QString &text, QGraphicsItem *parent = 0);
00077 
00081     virtual ~Icon();
00082 
00086     QString text() const;
00087 
00092     void setText(const QString &text);
00093 
00099     void setSvg(const QString &svgFilePath, const QString &svgIconElement = QString());
00100 
00104     QString infoText() const;
00105 
00111     void setInfoText(const QString &text);
00112 
00116     QIcon icon() const;
00117 
00122     void setIcon(const QIcon& icon);
00123 
00129     Q_INVOKABLE void setIcon(const QString& icon);
00130 
00134     QSizeF iconSize() const;
00135 
00143     void addAction(QAction* action);
00144 
00152     void setOrientation(Qt::Orientation orientation);
00153 
00159     void invertLayout(bool invert);
00160 
00164     bool invertedLayout() const;
00165 
00170     QSizeF sizeFromIconSize(const qreal iconWidth) const;
00171 
00175     int numDisplayLines();
00176 
00180     void setNumDisplayLines(int numLines);
00181 
00187     void setDrawBackground(bool draw);
00188 
00192     bool drawBackground() const;
00193 
00194 public Q_SLOTS:
00200     void setPressed(bool pressed = true);
00201 
00205     void setUnpressed();
00206 
00207 protected:
00208     void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
00209 
00210 Q_SIGNALS:
00214     void pressed(bool down);
00215 
00219     void clicked();
00220 
00224     void doubleClicked();
00225 
00226 protected:
00227     bool isDown();
00228     void mousePressEvent(QGraphicsSceneMouseEvent *event);
00229     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
00230     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00231     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
00232 
00233     void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00234     void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00235 
00236 public:
00237     class Private;
00238 
00242     void drawActionButtonBase(QPainter* painter, const QSize &size, int element);
00243 
00244 private:
00245     void init();
00246     void layoutIcons(const QStyleOptionGraphicsItem *option);
00247 
00248     Private * const d;
00249 
00250 private Q_SLOTS:
00251     void actionDestroyed(QObject* obj);
00252 };
00253 
00254 } // namespace Plasma
00255 
00256 
00257 /*
00258     // Add these to UrlIcon
00259     void setUrl(const KUrl& url);
00260     KUrl url() const;
00261 */
00262 
00263 #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
  • 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