2
* Copyright 2007 by Matt Broadstone <mbroadst@kde.org>
3
* Copyright 2007 by Robert Knight <robertknight@gmail.com>
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.
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 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.
20
#ifndef PLASMA_PANELVIEW_H
21
#define PLASMA_PANELVIEW_H
25
#include <KConfigGroup>
27
#include <Plasma/Plasma>
28
#include <Plasma/View>
53
class PanelController;
54
class PanelAppletOverlay;
57
class PanelView : public Plasma::View
70
* Constructs a new panelview.
71
* @arg parent the QWidget this panel is parented to
73
explicit PanelView(Plasma::Containment *panel, int id = 0, QWidget *parent = 0);
77
* @return the location (screen edge) where this panel is positioned.
79
Plasma::Location location() const;
82
* @return panel behaviour
84
VisibilityMode visibilityMode() const;
87
* @return the offset of the panel from the left screen edge
92
* @return the panel alignment
94
Qt::Alignment alignment() const;
97
* Pinches the min/max sizes of the containment to the current screen resolution
99
void pinchContainment(const QRect &screenGeometry);
102
* @return the unhide trigger window id, None if there is none
104
Window unhideTrigger() { return m_unhideTrigger; }
108
* Show a visual hint or perhaps even unhide, based on the position of the event
110
bool hintOrUnhide(const QPoint &point, bool dueToDnd = false);
113
* Returns the geometry of the current unhide hint window
115
QRect unhideHintGeometry() const;
118
* Hides any unhide hinting
124
* unhides the panel if it is hidden
126
void unhide(bool destroyTrigger);
129
* unhides the panel if it is hidden, always destroys the unhide trigger
130
* this is an overloaded function provided for convenience
135
* Decides whether to hide or not based on the status of the containment
137
void checkUnhide(Plasma::ItemStatus newStatus);
140
* Decides whether give focus to the panel
142
void statusUpdated(Plasma::ItemStatus newStatus);
145
* Pinches the min/max sizes of the containment to the current screen resolution
147
void pinchContainmentToCurrentScreen();
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
158
void setOffset(int newOffset);
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
165
void setAlignment(Qt::Alignment align);
168
* Sets the location (screen edge) where this panel is positioned.
169
* @param location the location to place the panel at
171
void setLocation(Plasma::Location location);
174
* Sets the panel behaviour
177
void setVisibilityMode(PanelView::VisibilityMode mode);
180
* Call when there has been a change that might require changes to the unhide
181
* trigger, such as compositing changing.
183
void recreateUnhideTrigger();
186
* Called when a new applet is added into the view's containment
188
void appletAdded(Plasma::Applet *applet);
191
* Sets the containment for this view, which will also cause the view
192
* to track the geometry of the containment.
194
* @arg containment the containment to center the view on
196
void setContainment(Plasma::Containment *containment);
200
bool migratedFrom(int screenId) const;
201
void migrateTo(int screenId);
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);
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);
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);
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);
240
void startAutoHide();
241
void checkAutounhide();
244
* update the appearance of the unhide hinter
245
* and get rid of it if the mouse has gone elsewhere
248
void resetTriggerEnteredSuppression();
251
* Updates the panel's position according to the screen and containment
254
void updatePanelGeometry();
257
void setPanelDragPosition(const QPoint &point);
260
PanelController *m_panelController;
261
QSet<PanelAppletOverlay*> m_appletOverlays;
263
QTimer *m_mousePollTimer;
264
QTimer *m_strutsTimer;
265
QTimer *m_rehideAfterAutounhideTimer;
266
QTimeLine *m_timeLine;
267
QGraphicsWidget *m_spacer;
271
Qt::Alignment m_alignment;
273
Window m_unhideTrigger;
275
QRect m_unhideTriggerGeom;
280
VisibilityMode m_visibilityMode;
282
bool m_lastHorizontal : 1;
285
bool m_triggerEntered : 1;
286
bool m_respectStatus : 1;
288
static const int STRUTSTIMERDELAY = 200;
289
static const int AUTOUNHIDE_CHECK_DELAY = 3000;