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

Applets

windowtaskitem.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Robert Knight <robertknight@gmail.com>          *
00003  *   Copyright (C) 2008 by Alexis Ménard <darktears31@gmail.com>           *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
00019  ***************************************************************************/
00020 
00021 
00022 #ifndef WINDOWTASKITEM_H
00023 #define WINDOWTASKITEM_H
00024 
00025 // KDE
00026 #include <taskmanager/taskmanager.h>
00027 
00028 // Qt
00029 #include <QIcon>
00030 #include <QTextLayout>
00031 #include <QTime>
00032 #include <QGraphicsLinearLayout>
00033 #include <QGraphicsWidget>
00034 
00035 #include <KColorScheme>
00036 
00037 class QTimeLine;
00038 
00039 // Plasma
00040 #include <plasma/animator.h>
00041 
00042 namespace Plasma
00043 {
00044     class PanelSvg;
00045 }
00046 
00047 class Tasks;
00048 
00052 class WindowTaskItem : public QGraphicsWidget
00053 {
00054     Q_OBJECT
00055 
00056 public:
00058     WindowTaskItem(Tasks *parent, const bool showTooltip);
00059 
00061     void setStartupTask(TaskManager::StartupPtr task);
00062 
00064     void setWindowTask(TaskManager::TaskPtr task);
00066     TaskManager::TaskPtr windowTask() const;
00067 
00069     void publishIconGeometry();
00070 
00072     void setShowTooltip(const bool showit);
00073 
00075     void setText(const QString &text);
00076 
00078     void setIcon(const QIcon &icon);
00079 
00084     enum TaskFlag
00085     {
00090         TaskWantsAttention = 1,
00094         TaskHasFocus       = 2,
00098         TaskIsMinimized    = 4
00099     };
00100     Q_DECLARE_FLAGS(TaskFlags, TaskFlag)
00101 
00102     
00103     void setTaskFlags(TaskFlags flags);
00104 
00106     TaskFlags taskFlags() const;
00107 
00109     QString text() const;
00110 
00112     QIcon icon() const;
00113 
00114     virtual void close();
00115 
00117     void setGeometry(const QRectF& geometry);
00118 
00119 signals:
00121     void windowSelected(WindowTaskItem *);
00122 
00123     void activated(WindowTaskItem *);
00124 
00125 public slots:
00126     virtual void activate();
00127 
00128 protected:
00129     virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
00130     virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
00131     virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
00132     virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
00133 
00135     void queueUpdate();
00136 
00137     // reimplemented
00138     virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
00139     virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
00140     virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
00141     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
00142     virtual void timerEvent(QTimerEvent *event);
00143     virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
00144     virtual void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget);
00145 
00147     virtual void drawBackground(QPainter *painter,const QStyleOptionGraphicsItem *option,
00148                                 QWidget *widget);
00150     virtual void drawTask(QPainter *painter,const QStyleOptionGraphicsItem *option,
00151                           QWidget *widget);
00152 
00154     QTextOption textOption() const;
00155 
00163     QSize layoutText(QTextLayout &layout, const QString &text, const QSize &constraints) const;
00164 
00170     void drawTextLayout(QPainter *painter, const QTextLayout &layout, const QRect &rect) const;
00171 
00172 
00173 private slots:
00174     void updateTask();
00175     void animationUpdate(qreal progress);
00176 
00177 private:
00178     Tasks *m_applet;
00179     TaskManager::TaskPtr m_task;
00180     QTimer* m_activateTimer;
00181 
00182     bool m_showTooltip;
00183     // area of item occupied by task's icon
00184     QRectF iconRect(const QRectF &bounds) const;
00185     // area of item occupied by task's text
00186     QRectF textRect(const QRectF &bounds) const;
00187 
00188     TaskFlags m_flags;
00189 
00190     QIcon m_icon;
00191     QString m_text;
00192 
00193     int m_animId;
00194     qreal m_alpha;
00195     bool m_fadeIn;
00196 
00197     QPointF _dragOffset;
00198     QTime m_lastUpdate;
00199     int m_updateTimerId;
00200     int m_attentionTimerId;
00201     int m_attentionTicks;
00202 
00203     // distance (in pixels) between a task's icon and its text
00204     static const int IconTextSpacing = 4;
00205 
00206     static const int TaskItemHorizontalMargin = 4;
00207     static const int TaskItemVerticalMargin = 4;
00208 };
00209 
00210 #endif

Applets

Skip menu "Applets"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

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