1/********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.org>
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>.
19*********************************************************************/
20
21#ifndef KWIN_THUMBNAILITEM_H
22#define KWIN_THUMBNAILITEM_H
23
24#include <QWeakPointer>
25#include <QtDeclarative/QDeclarativeItem>
26
27namespace KWin
28{
29
30class Client;
31class EffectWindow;
32class EffectWindowImpl;
33
34class AbstractThumbnailItem : public QDeclarativeItem
35{
36 Q_OBJECT
37 Q_PROPERTY(bool clip READ isClip WRITE setClip NOTIFY clipChanged SCRIPTABLE true)
38 Q_PROPERTY(qulonglong parentWindow READ parentWindow WRITE setParentWindow)
39 Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
40 Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged)
41public:
42 virtual ~AbstractThumbnailItem();
43 bool isClip() const {
44 return m_clip;
45 }
46 void setClip(bool clip);
47 qulonglong parentWindow() const {
48 return m_parentWindow;
49 }
50 void setParentWindow(qulonglong parentWindow);
51 qreal brightness() const;
52 qreal saturation() const;
53
54public Q_SLOTS:
55 void setBrightness(qreal brightness);
56 void setSaturation(qreal saturation);
57
58Q_SIGNALS:
59 void clipChanged(bool clipped);
60 void brightnessChanged();
61 void saturationChanged();
62
63protected:
64 explicit AbstractThumbnailItem(QDeclarativeItem *parent = 0);
65
66protected Q_SLOTS:
67 virtual void repaint(KWin::EffectWindow* w) = 0;
68
69private Q_SLOTS:
70 void init();
71 void effectWindowAdded();
72 void compositingToggled();
73
74private:
75 void findParentEffectWindow();
76 bool m_clip;
77 QWeakPointer<EffectWindowImpl> m_parent;
78 qulonglong m_parentWindow;
79 qreal m_brightness;
80 qreal m_saturation;
81};
82
83class WindowThumbnailItem : public AbstractThumbnailItem
84{
85 Q_OBJECT
86 Q_PROPERTY(qulonglong wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true)
87 Q_PROPERTY(KWin::Client *client READ client WRITE setClient NOTIFY clientChanged)
88public:
89 explicit WindowThumbnailItem(QDeclarativeItem *parent = 0);
90 virtual ~WindowThumbnailItem();
91
92 qulonglong wId() const {
93 return m_wId;
94 }
95 void setWId(qulonglong wId);
96 Client *client() const;
97 void setClient(Client *client);
98 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
99Q_SIGNALS:
100 void wIdChanged(qulonglong wid);
101 void clientChanged();
102protected Q_SLOTS:
103 virtual void repaint(KWin::EffectWindow* w);
104private:
105 qulonglong m_wId;
106 Client *m_client;
107};
108
109class DesktopThumbnailItem : public AbstractThumbnailItem
110{
111 Q_OBJECT
112 Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged)
113public:
114 DesktopThumbnailItem(QDeclarativeItem *parent = 0);
115 virtual ~DesktopThumbnailItem();
116
117 int desktop() const {
118 return m_desktop;
119 }
120 void setDesktop(int desktop);
121 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
122Q_SIGNALS:
123 void desktopChanged(int desktop);
124protected Q_SLOTS:
125 virtual void repaint(KWin::EffectWindow* w);
126private:
127 int m_desktop;
128};
129
130inline
131qreal AbstractThumbnailItem::brightness() const
132{
133 return m_brightness;
134}
135
136inline
137qreal AbstractThumbnailItem::saturation() const
138{
139 return m_saturation;
140}
141
142inline
143Client *WindowThumbnailItem::client() const
144{
145 return m_client;
146}
147
148} // KWin
149
150#endif // KWIN_THUMBNAILITEM_H
151