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
60 #include <OpenFlipper/common/GlobalDefines.hh>
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
157 QtGraphicsButton *autohideButton_;
158 QtGraphicsButton *detachButton_;
159
161 QDialog *dialog_;
162
164 QPointF startP_;
165
167 QPointF endP_;
168
170 bool down_;
171
173 QPropertyAnimation* animation_;
174
176 bool animating_;
177
179 QTimer* timer_;
180
182 const int fontHeight_;
183 };
184
185 //=============================================================================
186 //=============================================================================
187 #endif // QT_SLIDE_WINDOW_ defined
188 //=============================================================================
189
QtSlideWindow::endP_
QPointF endP_
Ending position (for animation)
Definition: QtSlideWindow.hh:167
QtSlideWindow::dialog_
QDialog * dialog_
detached dialog
Definition: QtSlideWindow.hh:161
DLLEXPORT
#define DLLEXPORT
Definition: GlobalDefines.hh:95
QtGraphicsButton
Definition: QtGraphicsButton.hh:65
QtSlideWindow::down_
bool down_
Track if widget is at bottom position.
Definition: QtSlideWindow.hh:170
QtSlideWindow::startP_
QPointF startP_
Starting position (for animation)
Definition: QtSlideWindow.hh:164
QtSlideWindow::fontHeight_
const int fontHeight_
height of the default font
Definition: QtSlideWindow.hh:182
QtSlideWindow::autohideButton_
QtGraphicsButton * autohideButton_
buttons
Definition: QtSlideWindow.hh:157
QtSlideWindow::animation_
QPropertyAnimation * animation_
Animation object.
Definition: QtSlideWindow.hh:173
QtSlideWindow::timer_
QTimer * timer_
Wait some milliseconds before sliding widget down.
Definition: QtSlideWindow.hh:179
QtSlideWindow::animating_
bool animating_
Is widget animating in this moment?
Definition: QtSlideWindow.hh:176
GlobalDefines.hh
QtSlideWindow::name_
QString name_
name
Definition: QtSlideWindow.hh:151
QtSlideWindow
Definition: QtSlideWindow.hh:77
QtSlideWindow::mainWidget_
QWidget * mainWidget_
child widget
Definition: QtSlideWindow.hh:154