Plasma
panelview.h
Go to the documentation of this file.00001 /* 00002 * Copyright 2007 by Matt Broadstone <mbroadst@kde.org> 00003 * Copyright 2007 by Robert Knight <robertknight@gmail.com> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Library General Public License version 2, 00007 * or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PLASMA_PANELVIEW_H 00021 #define PLASMA_PANELVIEW_H 00022 00023 #include <QList> 00024 00025 #include <KConfigGroup> 00026 00027 #include <Plasma/Plasma> 00028 #include <Plasma/View> 00029 00030 #ifdef Q_WS_X11 00031 #include <X11/Xlib.h> 00032 #include <fixx11h.h> 00033 #endif 00034 00035 #ifdef Q_WS_WIN 00036 #include <windows.h> 00037 #include <shellapi.h> 00038 #endif 00039 00040 class QWidget; 00041 class QTimeLine; 00042 class QTimer; 00043 00044 class GlowBar; 00045 00046 namespace Plasma 00047 { 00048 class Containment; 00049 class Corona; 00050 class Svg; 00051 } 00052 00053 class PanelController; 00054 00055 class PanelAppletOverlay; 00056 00057 class PanelView : public Plasma::View 00058 { 00059 Q_OBJECT 00060 public: 00061 00062 enum VisibilityMode { 00063 NormalPanel = 0, 00064 AutoHide, 00065 LetWindowsCover 00066 }; 00067 00072 explicit PanelView(Plasma::Containment *panel, int id = 0, QWidget *parent = 0); 00073 ~PanelView(); 00074 00078 Plasma::Location location() const; 00079 00083 VisibilityMode visibilityMode() const; 00084 00088 Plasma::Corona *corona() const; 00089 00090 /* 00091 * @return the offset of the panel from the left screen edge 00092 */ 00093 int offset() const; 00094 00098 Qt::Alignment alignment() const; 00099 00103 void pinchContainment(const QRect &screenGeometry); 00104 #ifdef Q_WS_X11 00105 00108 Window unhideTrigger() { return m_unhideTrigger; } 00109 #endif 00110 00114 bool hintOrUnhide(const QPoint &point, bool dueToDnd = false); 00115 00119 QRect unhideHintGeometry() const; 00120 00124 void unhintHide(); 00125 00126 public Q_SLOTS: 00130 void unhide(bool destroyTrigger); 00131 00135 void pinchContainmentToCurrentScreen(); 00136 00146 void setOffset(int newOffset); 00147 00153 void setAlignment(Qt::Alignment align); 00154 00159 void setLocation(Plasma::Location location); 00160 00165 void setVisibilityMode(PanelView::VisibilityMode mode); 00166 00171 void recreateUnhideTrigger(); 00172 00173 protected: 00174 void updateStruts(); 00175 void moveEvent(QMoveEvent *event); 00176 void resizeEvent(QResizeEvent *event); 00177 void leaveEvent(QEvent *event); 00178 void drawBackground(QPainter * painter, const QRectF & rect); 00179 void paintEvent(QPaintEvent *event); 00180 bool event(QEvent *event); 00181 void dragEnterEvent(QDragEnterEvent *event); 00182 void dragMoveEvent(QDragMoveEvent *event); 00183 void dragLeaveEvent(QDragLeaveEvent *event); 00184 void dropEvent(QDropEvent *event); 00185 00186 private: 00187 void createUnhideTrigger(); 00188 void destroyUnhideTrigger(); 00189 bool shouldHintHide() const; 00190 Qt::Alignment alignmentFilter(Qt::Alignment align) const; 00191 bool isHorizontal() const; 00192 QTimeLine *timeLine(); 00193 void positionSpacer(const QPoint pos); 00194 void startAutoHide(); 00195 bool hasPopup(); 00196 00197 #ifdef Q_WS_WIN 00198 bool registerAccessBar(bool fRegister); 00199 void appBarQuerySetPos(LPRECT lprc); 00200 void appBarCallback(WPARAM message, LPARAM lParam); 00201 void appBarPosChanged(); 00202 bool winEvent(MSG *message, long *result); 00203 APPBARDATA abd; 00204 #endif 00205 00206 private Q_SLOTS: 00207 void togglePanelController(); 00208 void edittingComplete(); 00209 void animateHide(qreal); 00210 void panelDeleted(); 00211 void hideMousePoll(); 00212 void unhideHintMousePoll(); 00213 void resetTriggerEnteredSuppression(); 00214 00219 void updatePanelGeometry(); 00220 00221 private: 00222 Plasma::Svg *m_background; 00223 PanelController *m_panelController; 00224 QList<PanelAppletOverlay*> m_moveOverlays; 00225 GlowBar *m_glowBar; 00226 QTimer *m_mousePollTimer; 00227 QTimeLine *m_timeLine; 00228 QGraphicsWidget *m_spacer; 00229 int m_spacerIndex; 00230 00231 int m_offset; 00232 Qt::Alignment m_alignment; 00233 #ifdef Q_WS_X11 00234 Window m_unhideTrigger; 00235 QRect m_triggerZone; 00236 QRect m_unhideTriggerGeom; 00237 #endif 00238 00239 QSizeF m_lastMin; 00240 QSizeF m_lastMax; 00241 VisibilityMode m_visibilityMode; 00242 int m_lastSeenSize; 00243 bool m_lastHorizontal : 1; 00244 00245 bool m_editting : 1; 00246 bool m_firstPaint : 1; 00247 bool m_triggerEntered : 1; 00248 }; 00249 00250 #endif 00251