add more spacing
[personal-kdebase.git] / workspace / plasma / applets / pager / pager.h
blob85ca38cd3b56a9bd4ecd45ee0c9e483e26b07f9c
1 /***************************************************************************
2 * Copyright (C) 2007 by Daniel Laidig <d.laidig@gmx.de> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18 ***************************************************************************/
20 #ifndef PAGER_H
21 #define PAGER_H
23 #include <QLabel>
24 #include <QGraphicsSceneHoverEvent>
25 #include <QList>
27 #include <Plasma/Applet>
28 #include <Plasma/DataEngine>
29 #include "ui_pagerConfig.h"
31 class KDialog;
32 class KSelectionOwner;
33 class KColorScheme;
34 class KWindowInfo;
36 namespace Plasma
38 class FrameSvg;
41 class Pager : public Plasma::Applet
43 Q_OBJECT
44 public:
45 Pager(QObject *parent, const QVariantList &args);
46 ~Pager();
47 void init();
48 void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
49 const QRect &contents);
50 void constraintsEvent(Plasma::Constraints);
51 virtual QList<QAction*> contextualActions();
53 public slots:
54 void recalculateGeometry();
55 void recalculateWindowRects();
56 void themeRefresh();
58 protected slots:
59 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
60 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
61 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
62 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
63 virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
64 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
65 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
66 virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
67 virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
68 virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
69 virtual void wheelEvent(QGraphicsSceneWheelEvent *);
71 void configAccepted();
72 void currentDesktopChanged(int desktop);
73 void desktopsSizeChanged();
74 void windowAdded(WId id);
75 void windowRemoved(WId id);
76 void activeWindowChanged(WId id);
77 void numberOfDesktopsChanged(int num);
78 void desktopNamesChanged();
79 void stackingOrderChanged();
80 void windowChanged(WId id, unsigned int properties);
81 void showingDesktopChanged(bool showing);
82 void slotConfigureDesktop();
83 void lostDesktopLayoutOwner();
84 void animationUpdate(qreal progress, int animId);
85 void dragSwitch();
87 protected:
88 void createMenu();
89 KColorScheme *colorScheme();
90 QRect fixViewportPosition( const QRect& r );
91 void createConfigurationInterface(KConfigDialog *parent);
92 void handleHoverMove(const QPointF& pos);
93 void handleHoverLeave();
94 void updateToolTip();
96 private:
97 QTimer* m_timer;
98 Ui::pagerConfig ui;
99 enum DisplayedText
101 Number,
102 Name,
103 None
106 struct AnimInfo
108 int animId;
109 qreal alpha;
110 bool fadeIn;
111 bool operator == (AnimInfo otherAnim) const { return otherAnim.animId == animId; }
114 DisplayedText m_displayedText;
115 bool m_showWindowIcons;
116 bool m_showOwnBackground;
117 int m_rows;
118 int m_columns;
119 int m_desktopCount;
120 int m_currentDesktop;
121 qreal m_widthScaleFactor;
122 qreal m_heightScaleFactor;
123 QSizeF m_size;
124 QList<QRectF> m_rects;
125 //list of info about animations for each desktop
126 QList<AnimInfo> m_animations;
127 QRectF m_hoverRect;
128 int m_hoverIndex;
129 QList<QList<QPair<WId, QRect> > > m_windowRects;
130 QList<QRect> m_activeWindows;
131 QList<QAction*> m_actions;
132 QList<KWindowInfo> m_windowInfo;
133 KSelectionOwner* m_desktopLayoutOwner;
134 Plasma::FrameSvg *m_background;
135 KColorScheme *m_colorScheme;
137 // dragging of windows
138 QRect m_dragOriginal;
139 QPointF m_dragOriginalPos;
140 QPointF m_dragCurrentPos;
141 WId m_dragId;
142 int m_dirtyDesktop;
143 int m_dragStartDesktop;
144 int m_dragHighlightedDesktop;
146 // desktop switching on drop event
147 int m_dragSwitchDesktop;
148 QTimer* m_dragSwitchTimer;
150 static const int s_FadeInDuration = 50;
151 static const int s_FadeOutDuration = 100;
154 K_EXPORT_PLASMA_APPLET(pager, Pager)
156 #endif