~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/desktopchangeosd.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
 
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 DESKTOPCHANGEOSD_H
 
22
#define DESKTOPCHANGEOSD_H
 
23
 
 
24
#include <QGraphicsView>
 
25
#include <QGraphicsItem>
 
26
#include <QTimer>
 
27
#include <KDE/Plasma/FrameSvg>
 
28
#include <KDE/Plasma/Theme>
 
29
#include <KDE/Plasma/WindowEffects>
 
30
#include <QWeakPointer>
 
31
 
 
32
class QGraphicsScene;
 
33
class QPropertyAnimation;
 
34
 
 
35
namespace KWin
 
36
{
 
37
class Workspace;
 
38
 
 
39
class DesktopChangeText : public QGraphicsItem
 
40
{
 
41
public:
 
42
    DesktopChangeText(Workspace* ws);
 
43
    ~DesktopChangeText();
 
44
 
 
45
    enum { Type = UserType + 2 };
 
46
 
 
47
    inline void setWidth(float width) {
 
48
        m_width = width;
 
49
    };
 
50
    inline void setHeight(float height) {
 
51
        m_height = height;
 
52
    };
 
53
 
 
54
    virtual QRectF boundingRect() const;
 
55
    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
 
56
    inline virtual int type() const {
 
57
        return Type;
 
58
    };
 
59
 
 
60
private:
 
61
    Workspace* m_wspace;
 
62
    float m_width;
 
63
    float m_height;
 
64
};
 
65
 
 
66
class DesktopChangeOSD : public QGraphicsView
 
67
{
 
68
public:
 
69
    DesktopChangeOSD(Workspace* ws);
 
70
    ~DesktopChangeOSD();
 
71
 
 
72
    void reconfigure();
 
73
    void desktopChanged(int old);
 
74
    void numberDesktopsChanged();
 
75
 
 
76
    inline Plasma::FrameSvg* itemFrame() {
 
77
        return &m_item_frame;
 
78
    };
 
79
    inline int& getDelayTime() {
 
80
        return m_delayTime;
 
81
    };
 
82
 
 
83
protected:
 
84
    virtual void hideEvent(QHideEvent*);
 
85
    virtual void drawBackground(QPainter* painter, const QRectF& rect);
 
86
 
 
87
private:
 
88
    void resize();
 
89
    Workspace* m_wspace;
 
90
    Plasma::FrameSvg m_frame;
 
91
    Plasma::FrameSvg m_item_frame;
 
92
    QGraphicsScene* m_scene;
 
93
    bool m_active;
 
94
    QTimer m_delayedHideTimer;
 
95
    bool m_show;
 
96
    int m_delayTime;
 
97
    bool m_textOnly;
 
98
};
 
99
 
 
100
class DesktopChangeItem : public QObject, public QGraphicsItem
 
101
{
 
102
    Q_OBJECT
 
103
    Q_PROPERTY(qreal arrowValue READ arrowValue WRITE setArrowValue)
 
104
    Q_PROPERTY(qreal highLightValue READ highLightValue WRITE setHighLightValue)
 
105
 
 
106
    Q_INTERFACES(QGraphicsItem)
 
107
public:
 
108
    DesktopChangeItem(Workspace* ws, DesktopChangeOSD* parent, int desktop);
 
109
    ~DesktopChangeItem();
 
110
    enum { Type = UserType + 1 };
 
111
    void startDesktopHighLightAnimation(int time);
 
112
    void stopDesktopHighLightAnimation();
 
113
 
 
114
    inline void setWidth(float width) {
 
115
        m_width = width;
 
116
    };
 
117
    inline void setHeight(float height) {
 
118
        m_height = height;
 
119
    };
 
120
    inline int desktop() const {
 
121
        return m_desktop;
 
122
    };
 
123
 
 
124
    virtual QRectF boundingRect() const;
 
125
    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*);
 
126
    inline virtual int type() const {
 
127
        return Type;
 
128
    };
 
129
 
 
130
    enum Arrow {
 
131
        NONE,
 
132
        LEFT,
 
133
        RIGHT,
 
134
        UP,
 
135
        DOWN
 
136
    };
 
137
    void setArrow(Arrow arrow, int start_delay, int hide_delay);
 
138
 
 
139
    qreal arrowValue() const;
 
140
    qreal highLightValue() const;
 
141
 
 
142
protected slots:
 
143
    void setArrowValue(qreal value);
 
144
    void setHighLightValue(qreal value);
 
145
 
 
146
private slots:
 
147
    void showArrow();
 
148
    void hideArrow();
 
149
    void arrowAnimationFinished();
 
150
 
 
151
private:
 
152
    Workspace* m_wspace;
 
153
    DesktopChangeOSD* m_parent;
 
154
    int m_desktop;
 
155
    float m_width;
 
156
    float m_height;
 
157
    QTimer m_delayed_show_arrow_timer;
 
158
    QTimer m_delayed_hide_arrow_timer;
 
159
 
 
160
    Arrow m_arrow;
 
161
    bool m_arrowShown;
 
162
    bool m_fadeInArrow;
 
163
    bool m_fadeInHighLight;
 
164
 
 
165
    qreal m_arrowValue;
 
166
    qreal m_highLightValue;
 
167
 
 
168
    QWeakPointer<QPropertyAnimation> m_arrowAnimation;
 
169
    QWeakPointer<QPropertyAnimation> m_highLightAnimation;
 
170
};
 
171
 
 
172
}
 
173
 
 
174
#endif // DESKTOPCHANGEOSD_H