Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QtSlideWindow.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef QT_SLIDE_WINDOW_
51 #define QT_SLIDE_WINDOW_
52 
53 //=============================================================================
54 //
55 // CLASS QtSlideWindow
56 //
57 //=============================================================================
58 
59 //== INCLUDES =================================================================
60 
61 #include <QSettings>
62 #include <QGraphicsProxyWidget>
63 #include <QPropertyAnimation>
64 #include <QTimer>
65 
67 
68 //== FORWARDDECLARATIONS ======================================================
69 
70 class QtGraphicsButton;
71 class QTimeLine;
72 class QGraphicsItemAnimation;
73 
74 //== CLASS DEFINITION =========================================================
75 
76 
83 class DLLEXPORT QtSlideWindow : public QGraphicsProxyWidget
84 {
85  Q_OBJECT
86 
87  public:
92  QtSlideWindow (QString _name = 0, QGraphicsItem *_parent = 0);
93 
95  void updateGeometry ();
96 
98  void attachWidget (QWidget *_m);
99 
101  void detachWidget ();
102 
103 
105  void saveState (QSettings &_settings);
106 
108  void restoreState (QSettings &_settings);
109 
111  void updateParentGeometry();
112 
113  private:
114 
116  virtual void paintWindowFrame(QPainter *_painter, const QStyleOptionGraphicsItem *_option, QWidget *_widget = 0);
117 
119  virtual bool windowFrameEvent(QEvent *_e);
120 
122  virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF &_pos) const;
123 
125  virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *_event);
126  virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *_event);
127 
129  virtual void resizeEvent (QGraphicsSceneResizeEvent *_event);
130  virtual void moveEvent (QGraphicsSceneMoveEvent *_event);
131 
132  private slots:
134  void detachPressed ();
135 
137  void dialogClosed ();
138 
140  void autohidePressed ();
141 
143  void slideUp();
144 
146  void slideDown();
147 
149  void animationFinished();
150 
152  void startSlideDownAnimation();
153 
154  private:
155 
156  // name
157  QString name_;
158 
159  // child widget
160  QWidget *mainWidget_;
161 
162  // buttons
163  QtGraphicsButton *autohideButton_;
164  QtGraphicsButton *detachButton_;
165 
166  // detached dialog
167  QDialog *dialog_;
168 
169  // Starting position (for animation)
170  QPointF startP_;
171 
172  // Ending position (for animation)
173  QPointF endP_;
174 
175  // Track if widget is at bottom position
176  bool down_;
177 
178  // Animation object
179  QPropertyAnimation* animation_;
180 
181  // Is widget animating in this moment?
182  bool animating_;
183 
184  // Wait some milliseconds before sliding widget down
185  QTimer* timer_;
186 };
187 
188 //=============================================================================
189 //=============================================================================
190 #endif // QT_SLIDE_WINDOW_ defined
191 //=============================================================================
192 
#define DLLEXPORT