1 | /******************************************************************** |
2 | KWin - the KDE window manager |
3 | This file is part of the KDE project. |
4 | |
5 | Copyright (C) 2011 Martin Gräßlin <mgraesslin@kde.org> |
6 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU General Public License |
18 | along 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 | |
27 | namespace KWin |
28 | { |
29 | |
30 | class Client; |
31 | class EffectWindow; |
32 | class EffectWindowImpl; |
33 | |
34 | class 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) |
41 | public: |
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 | |
54 | public Q_SLOTS: |
55 | void setBrightness(qreal brightness); |
56 | void setSaturation(qreal saturation); |
57 | |
58 | Q_SIGNALS: |
59 | void clipChanged(bool clipped); |
60 | void brightnessChanged(); |
61 | void saturationChanged(); |
62 | |
63 | protected: |
64 | explicit AbstractThumbnailItem(QDeclarativeItem *parent = 0); |
65 | |
66 | protected Q_SLOTS: |
67 | virtual void repaint(KWin::EffectWindow* w) = 0; |
68 | |
69 | private Q_SLOTS: |
70 | void init(); |
71 | void effectWindowAdded(); |
72 | void compositingToggled(); |
73 | |
74 | private: |
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 | |
83 | class 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) |
88 | public: |
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); |
99 | Q_SIGNALS: |
100 | void wIdChanged(qulonglong wid); |
101 | void clientChanged(); |
102 | protected Q_SLOTS: |
103 | virtual void repaint(KWin::EffectWindow* w); |
104 | private: |
105 | qulonglong m_wId; |
106 | Client *m_client; |
107 | }; |
108 | |
109 | class DesktopThumbnailItem : public AbstractThumbnailItem |
110 | { |
111 | Q_OBJECT |
112 | Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged) |
113 | public: |
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); |
122 | Q_SIGNALS: |
123 | void desktopChanged(int desktop); |
124 | protected Q_SLOTS: |
125 | virtual void repaint(KWin::EffectWindow* w); |
126 | private: |
127 | int m_desktop; |
128 | }; |
129 | |
130 | inline |
131 | qreal AbstractThumbnailItem::brightness() const |
132 | { |
133 | return m_brightness; |
134 | } |
135 | |
136 | inline |
137 | qreal AbstractThumbnailItem::saturation() const |
138 | { |
139 | return m_saturation; |
140 | } |
141 | |
142 | inline |
143 | Client *WindowThumbnailItem::client() const |
144 | { |
145 | return m_client; |
146 | } |
147 | |
148 | } // KWin |
149 | |
150 | #endif // KWIN_THUMBNAILITEM_H |
151 | |