itom
Loading...
Searching...
No Matches
basePopupWidget.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom and its software development toolkit (SDK).
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 In addition, as a special exception, the Institut für Technische
15 Optik (ITO) gives you certain additional rights.
16 These rights are described in the ITO LGPL Exception version 1.0,
17 which can be found in the file LGPL_EXCEPTION.txt in this package.
18
19 itom is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22 General Public Licence for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with itom. If not, see <http://www.gnu.org/licenses/>.
26
27 This file is a port and modified version of the
28 CTK Common Toolkit (http://www.commontk.org)
29*********************************************************************** */
30
31#ifndef BASEPOPUPWIDGET_H
32#define BASEPOPUPWIDGET_H
33
34// Qt includes
35#include <QEasingCurve>
36#include <QFrame>
37#include <QMetaType>
38
39#include "commonWidgets.h"
40
42
45class ITOMWIDGETS_EXPORT BasePopupWidget : public QFrame
46{
47 Q_OBJECT
48
50 Q_PROPERTY( AnimationEffect animationEffect READ animationEffect WRITE setAnimationEffect)
51
52
54 Q_PROPERTY( int effectDuration READ effectDuration WRITE setEffectDuration);
55
58 Q_PROPERTY( QEasingCurve::Type easingCurve READ easingCurve WRITE setEasingCurve);
59
63 Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment);
64
68 Q_PROPERTY( Qt::Orientations orientation READ orientation WRITE setOrientation);
69
72 Q_PROPERTY( BasePopupWidget::VerticalDirection verticalDirection READ verticalDirection WRITE setVerticalDirection);
73
76 Q_PROPERTY( Qt::LayoutDirection horizontalDirection READ horizontalDirection WRITE setHorizontalDirection);
77
78public:
79 typedef QFrame Superclass;
87 explicit BasePopupWidget(QWidget* parent = 0);
88 virtual ~BasePopupWidget();
89
94 QWidget* baseWidget()const;
95
96 enum AnimationEffect
97 {
98 WindowOpacityFadeEffect = 0,
99 ScrollEffect,
100 FadeEffect
101 };
102
103 AnimationEffect animationEffect()const;
104 void setAnimationEffect(AnimationEffect effect);
105
106 int effectDuration()const;
107 void setEffectDuration(int duration);
108
109 QEasingCurve::Type easingCurve()const;
110 void setEasingCurve(QEasingCurve::Type easingCurve);
111
112 Qt::Alignment alignment()const;
113 void setAlignment(Qt::Alignment alignment);
114
115 Qt::Orientations orientation()const;
116 void setOrientation(Qt::Orientations orientation);
117
118 enum VerticalDirection{
119 TopToBottom = 1,
120 BottomToTop = 2
121 };
122
123 //Q_ENUM exposes a meta object to the enumeration types, such that the key names for the enumeration
124 //values are always accessible.
125 Q_ENUM(AnimationEffect);
126 Q_ENUM(VerticalDirection);
127
128 VerticalDirection verticalDirection()const;
129 void setVerticalDirection(VerticalDirection direction);
130
131 Qt::LayoutDirection horizontalDirection()const;
132 void setHorizontalDirection(Qt::LayoutDirection direction);
133
134public Q_SLOTS:
137 virtual void hidePopup();
140 virtual void showPopup();
143 inline void showPopup(bool show);
144
145Q_SIGNALS:
146 void popupOpened(bool open);
147
148protected:
149 explicit BasePopupWidget(BasePopupWidgetPrivate* pimpl, QWidget* parent = 0);
150 QScopedPointer<BasePopupWidgetPrivate> d_ptr;
151 Q_PROPERTY(double effectAlpha READ effectAlpha WRITE setEffectAlpha DESIGNABLE false)
152 Q_PROPERTY(QRect effectGeometry READ effectGeometry WRITE setEffectGeometry DESIGNABLE false)
153
154 double effectAlpha()const;
155 QRect effectGeometry()const;
156
157 virtual void setBaseWidget(QWidget* baseWidget);
158
159 virtual bool event(QEvent* event);
160 virtual void paintEvent(QPaintEvent*);
161
162protected Q_SLOTS:
163 virtual void onEffectFinished();
164 void setEffectAlpha(double alpha);
165 void setEffectGeometry(QRect geometry);
166 void onBaseWidgetDestroyed();
167
168private:
169 Q_DECLARE_PRIVATE(BasePopupWidget);
170 Q_DISABLE_COPY(BasePopupWidget);
171};
172
173Q_DECLARE_METATYPE(BasePopupWidget::AnimationEffect)
174Q_DECLARE_METATYPE(BasePopupWidget::VerticalDirection)
175
176// -------------------------------------------------------------------------
177void BasePopupWidget::showPopup(bool show)
178{
179 if (show)
180 {
181 this->showPopup();
182 }
183 else
184 {
185 this->hidePopup();
186 }
187}
188
189#endif
Definition basePopupWidget.h:46
Definition basePopupWidget_p.h:46