Developer Documentation
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 #ifndef QT_SLIDE_WINDOW_
45 #define QT_SLIDE_WINDOW_
46 
47 //=============================================================================
48 //
49 // CLASS QtSlideWindow
50 //
51 //=============================================================================
52 
53 //== INCLUDES =================================================================
54 
55 #include <QSettings>
56 #include <QGraphicsProxyWidget>
57 #include <QPropertyAnimation>
58 #include <QTimer>
59 
61 
62 //== FORWARDDECLARATIONS ======================================================
63 
64 class QtGraphicsButton;
65 class QTimeLine;
66 class QGraphicsItemAnimation;
67 
68 //== CLASS DEFINITION =========================================================
69 
70 
77 class DLLEXPORT QtSlideWindow : public QGraphicsProxyWidget
78 {
79  Q_OBJECT
80 
81  public:
86  QtSlideWindow (QString _name = 0, QGraphicsItem *_parent = 0);
87 
89  void updateGeometry ();
90 
92  void attachWidget (QWidget *_m);
93 
95  void detachWidget ();
96 
97 
99  void saveState (QSettings &_settings);
100 
102  void restoreState (QSettings &_settings);
103 
105  void updateParentGeometry();
106 
107  private:
108 
110  virtual void paintWindowFrame(QPainter *_painter, const QStyleOptionGraphicsItem *_option, QWidget *_widget = 0);
111 
113  virtual bool windowFrameEvent(QEvent *_e);
114 
116  virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF &_pos) const;
117 
119  virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *_event);
120  virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *_event);
121 
123  virtual void resizeEvent (QGraphicsSceneResizeEvent *_event);
124  virtual void moveEvent (QGraphicsSceneMoveEvent *_event);
125 
126  private slots:
128  void detachPressed ();
129 
131  void dialogClosed ();
132 
134  void autohidePressed ();
135 
137  void slideUp();
138 
140  void slideDown();
141 
143  void animationFinished();
144 
146  void startSlideDownAnimation();
147 
148  private:
149 
151  QString name_;
152 
154  QWidget *mainWidget_;
155 
158  QtGraphicsButton *detachButton_;
159 
161  QDialog *dialog_;
162 
164  QPointF startP_;
165 
167  QPointF endP_;
168 
170  bool down_;
171 
173  QPropertyAnimation* animation_;
174 
177 
179  QTimer* timer_;
180 
182  const int fontHeight_;
183 };
184 
185 //=============================================================================
186 //=============================================================================
187 #endif // QT_SLIDE_WINDOW_ defined
188 //=============================================================================
189 
QPointF endP_
Ending position (for animation)
QDialog * dialog_
detached dialog
#define DLLEXPORT
bool down_
Track if widget is at bottom position.
QPointF startP_
Starting position (for animation)
const int fontHeight_
height of the default font
QtGraphicsButton * autohideButton_
buttons
QPropertyAnimation * animation_
Animation object.
QTimer * timer_
Wait some milliseconds before sliding widget down.
bool animating_
Is widget animating in this moment?
QString name_
name
QWidget * mainWidget_
child widget