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

« back to all changes in this revision

Viewing changes to plasma/desktop/shell/panelview.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
*   Copyright 2007 by Matt Broadstone <mbroadst@kde.org>
 
3
*   Copyright 2007 by Robert Knight <robertknight@gmail.com>
 
4
*
 
5
*   This program is free software; you can redistribute it and/or modify
 
6
*   it under the terms of the GNU Library General Public License version 2, 
 
7
*   or (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 Library General Public
 
15
*   License 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
*/
 
19
 
 
20
#ifndef PLASMA_PANELVIEW_H
 
21
#define PLASMA_PANELVIEW_H
 
22
 
 
23
#include <QSet>
 
24
 
 
25
#include <KConfigGroup>
 
26
 
 
27
#include <Plasma/Plasma>
 
28
#include <Plasma/View>
 
29
 
 
30
#ifdef Q_WS_X11
 
31
#include <X11/Xlib.h>
 
32
#include <fixx11h.h>
 
33
#endif
 
34
 
 
35
#ifdef Q_WS_WIN
 
36
#include <windows.h>
 
37
#include <shellapi.h>
 
38
#endif
 
39
 
 
40
class QWidget;
 
41
class QTimeLine;
 
42
class QTimer;
 
43
 
 
44
class GlowBar;
 
45
 
 
46
namespace Plasma
 
47
{
 
48
    class Containment;
 
49
    class Applet;
 
50
    class Svg;
 
51
}
 
52
 
 
53
class PanelController;
 
54
class PanelAppletOverlay;
 
55
class PanelShadows;
 
56
 
 
57
class PanelView : public Plasma::View
 
58
{
 
59
    Q_OBJECT
 
60
public:
 
61
 
 
62
    enum VisibilityMode {
 
63
        NormalPanel = 0,
 
64
        AutoHide,
 
65
        LetWindowsCover,
 
66
        WindowsGoBelow
 
67
    };
 
68
 
 
69
   /**
 
70
    * Constructs a new panelview.
 
71
    * @arg parent the QWidget this panel is parented to
 
72
    */
 
73
    explicit PanelView(Plasma::Containment *panel, int id = 0, QWidget *parent = 0);
 
74
    ~PanelView();
 
75
 
 
76
    /**
 
77
     * @return the location (screen edge) where this panel is positioned.
 
78
     */
 
79
    Plasma::Location location() const;
 
80
 
 
81
    /**
 
82
     * @return panel behaviour
 
83
     */
 
84
    VisibilityMode visibilityMode() const;
 
85
 
 
86
    /*
 
87
     * @return the offset of the panel from the left screen edge
 
88
     */
 
89
    int offset() const;
 
90
 
 
91
    /**
 
92
     * @return the panel alignment
 
93
     */
 
94
    Qt::Alignment alignment() const;
 
95
 
 
96
    /**
 
97
     * Pinches the min/max sizes of the containment to the current screen resolution
 
98
     */
 
99
    void pinchContainment(const QRect &screenGeometry);
 
100
#ifdef Q_WS_X11
 
101
    /**
 
102
     * @return the unhide trigger window id, None if there is none
 
103
     */
 
104
    Window unhideTrigger() { return m_unhideTrigger; }
 
105
#endif
 
106
 
 
107
    /**
 
108
     * Show a visual hint or perhaps even unhide, based on the position of the event
 
109
     */
 
110
    bool hintOrUnhide(const QPoint &point, bool dueToDnd = false);
 
111
 
 
112
    /**
 
113
     * Returns the geometry of the current unhide hint window
 
114
     */
 
115
    QRect unhideHintGeometry() const;
 
116
 
 
117
    /**
 
118
     * Hides any unhide hinting
 
119
     */
 
120
    void hideHinter();
 
121
 
 
122
public Q_SLOTS:
 
123
    /**
 
124
     * unhides the panel if it is hidden
 
125
     */
 
126
    void unhide(bool destroyTrigger);
 
127
 
 
128
    /**
 
129
     * unhides the panel if it is hidden, always destroys the unhide trigger
 
130
     * this is an overloaded function provided for convenience
 
131
     */
 
132
    void unhide();
 
133
 
 
134
    /**
 
135
     * Decides whether to hide or not based on the status of the containment
 
136
     */
 
137
    void checkUnhide(Plasma::ItemStatus newStatus);
 
138
 
 
139
    /**
 
140
     * Decides whether give focus to the panel
 
141
     */
 
142
    void statusUpdated(Plasma::ItemStatus newStatus);
 
143
 
 
144
    /**
 
145
     * Pinches the min/max sizes of the containment to the current screen resolution
 
146
     */
 
147
    void pinchContainmentToCurrentScreen();
 
148
 
 
149
    /**
 
150
     * Sets the offset the left border, the offset is the distance of the left
 
151
     * border of the panel from the left border of the screen when the alignment is
 
152
     * Qt::AlignLeft, right border and right edge if the alignment is Qt::alignRight
 
153
     * and the distance between the center of the panel and the center of the screen if
 
154
     * the alignment is Qt::AlignCenter.
 
155
     * Similar way for vertical panels.
 
156
     * @param newOffset the offset of the panel
 
157
     */
 
158
    void setOffset(int newOffset);
 
159
 
 
160
    /**
 
161
     * Sets the edge of the screen the panel will be aligned and will grow
 
162
     * @param align the direction (for instance Qt::AlignLeft) means the panel will start
 
163
     * from the left of the screen and grow to the right
 
164
     */
 
165
    void setAlignment(Qt::Alignment align);
 
166
 
 
167
    /**
 
168
     * Sets the location (screen edge) where this panel is positioned.
 
169
     * @param location the location to place the panel at
 
170
     */
 
171
    void setLocation(Plasma::Location location);
 
172
 
 
173
    /**
 
174
     * Sets the panel behaviour
 
175
     * @param mode
 
176
     */
 
177
    void setVisibilityMode(PanelView::VisibilityMode mode);
 
178
 
 
179
    /**
 
180
     * Call when there has been a change that might require changes to the unhide
 
181
     * trigger, such as compositing changing.
 
182
     */
 
183
    void recreateUnhideTrigger();
 
184
 
 
185
    /**
 
186
     * Called when a new applet is added into the view's containment
 
187
     */
 
188
    void appletAdded(Plasma::Applet *applet);
 
189
 
 
190
    /**
 
191
     * Sets the containment for this view, which will also cause the view
 
192
     * to track the geometry of the containment.
 
193
     *
 
194
     * @arg containment the containment to center the view on
 
195
     */
 
196
    void setContainment(Plasma::Containment *containment);
 
197
 
 
198
    void updateStruts();
 
199
 
 
200
    bool migratedFrom(int screenId) const;
 
201
    void migrateTo(int screenId);
 
202
 
 
203
protected:
 
204
    void moveEvent(QMoveEvent *event);
 
205
    void resizeEvent(QResizeEvent *event);
 
206
    void leaveEvent(QEvent *event);
 
207
    void drawBackground(QPainter * painter, const QRectF & rect);
 
208
    void paintEvent(QPaintEvent *event);
 
209
    bool event(QEvent *event);
 
210
    void dragLeaveEvent(QDragLeaveEvent *event);
 
211
    void dropEvent(QDropEvent *event);
 
212
 
 
213
private:
 
214
    void createUnhideTrigger();
 
215
    void destroyUnhideTrigger();
 
216
    bool shouldHintHide() const;
 
217
    Qt::Alignment alignmentFilter(Qt::Alignment align) const;
 
218
    bool isHorizontal() const;
 
219
    QTimeLine *timeLine();
 
220
    void positionSpacer(const QPoint pos);
 
221
    bool hasPopup();
 
222
 
 
223
#ifdef Q_WS_WIN
 
224
    bool registerAccessBar(bool fRegister);
 
225
    void appBarQuerySetPos(LPRECT lprc);
 
226
    void appBarCallback(WPARAM message, LPARAM lParam);
 
227
    void appBarPosChanged();
 
228
    bool winEvent(MSG *message, long *result);
 
229
    APPBARDATA abd;
 
230
#endif
 
231
 
 
232
private Q_SLOTS:
 
233
    void immutabilityChanged(Plasma::ImmutabilityType immutability);
 
234
    void togglePanelController();
 
235
    void showWidgetExplorer();
 
236
    void editingComplete();
 
237
    void overlayDestroyed(PanelAppletOverlay *overlay);
 
238
    void overlayMoved(PanelAppletOverlay *overlay);
 
239
    void panelDeleted();
 
240
    void startAutoHide();
 
241
    void checkAutounhide();
 
242
 
 
243
    /**
 
244
     * update the appearance of the unhide hinter
 
245
     * and get rid of it if the mouse has gone elsewhere
 
246
     */
 
247
    void updateHinter();
 
248
    void resetTriggerEnteredSuppression();
 
249
 
 
250
    /**
 
251
     * Updates the panel's position according to the screen and containment
 
252
     * dimensions
 
253
     */
 
254
    void updatePanelGeometry();
 
255
 
 
256
    void themeChanged();
 
257
    void setPanelDragPosition(const QPoint &point);
 
258
 
 
259
private:
 
260
    PanelController *m_panelController;
 
261
    QSet<PanelAppletOverlay*> m_appletOverlays;
 
262
    GlowBar *m_glowBar;
 
263
    QTimer *m_mousePollTimer;
 
264
    QTimer *m_strutsTimer;
 
265
    QTimer *m_rehideAfterAutounhideTimer;
 
266
    QTimeLine *m_timeLine;
 
267
    QGraphicsWidget *m_spacer;
 
268
    int m_spacerIndex;
 
269
 
 
270
    int m_offset;
 
271
    Qt::Alignment m_alignment;
 
272
#ifdef Q_WS_X11
 
273
    Window m_unhideTrigger;
 
274
    QRect m_triggerZone;
 
275
    QRect m_unhideTriggerGeom;
 
276
#endif
 
277
 
 
278
    QSizeF m_lastMin;
 
279
    QSizeF m_lastMax;
 
280
    VisibilityMode m_visibilityMode;
 
281
    int m_lastSeenSize;
 
282
    bool m_lastHorizontal : 1;
 
283
 
 
284
    bool m_editing : 1;
 
285
    bool m_triggerEntered : 1;
 
286
    bool m_respectStatus : 1;
 
287
 
 
288
    static const int STRUTSTIMERDELAY = 200;
 
289
    static const int AUTOUNHIDE_CHECK_DELAY = 3000;
 
290
};
 
291
 
 
292
#endif
 
293