1 /***************************************************************************
2 * Copyright (C) 2007 by Daniel Laidig <d.laidig@gmx.de> *
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. *
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. *
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 ***************************************************************************/
24 #include <QGraphicsSceneHoverEvent>
27 #include <Plasma/Applet>
28 #include <Plasma/DataEngine>
29 #include "ui_pagerConfig.h"
32 class KSelectionOwner
;
41 class Pager
: public Plasma::Applet
45 Pager(QObject
*parent
, const QVariantList
&args
);
48 void paintInterface(QPainter
*painter
, const QStyleOptionGraphicsItem
*option
,
49 const QRect
&contents
);
50 void constraintsEvent(Plasma::Constraints
);
51 virtual QList
<QAction
*> contextualActions();
54 void recalculateGeometry();
55 void recalculateWindowRects();
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
);
89 KColorScheme
*colorScheme();
90 QRect
fixViewportPosition( const QRect
& r
);
91 void createConfigurationInterface(KConfigDialog
*parent
);
92 void handleHoverMove(const QPointF
& pos
);
93 void handleHoverLeave();
111 bool operator == (AnimInfo otherAnim
) const { return otherAnim
.animId
== animId
; }
114 DisplayedText m_displayedText
;
115 bool m_showWindowIcons
;
116 bool m_showOwnBackground
;
120 int m_currentDesktop
;
121 qreal m_widthScaleFactor
;
122 qreal m_heightScaleFactor
;
124 QList
<QRectF
> m_rects
;
125 //list of info about animations for each desktop
126 QList
<AnimInfo
> m_animations
;
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
;
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
)