CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkBasePopupWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Library: CTK
4
5 Copyright (c) Kitware Inc.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.commontk.org/LICENSE
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19=========================================================================*/
20
21#ifndef __ctkBasePopupWidget_h
22#define __ctkBasePopupWidget_h
23
24// Qt includes
25#include <QEasingCurve>
26#include <QFrame>
27#include <QMetaType>
28
29// CTK includes
30#include "ctkWidgetsExport.h"
31
32class ctkBasePopupWidgetPrivate;
33
42class CTK_WIDGETS_EXPORT ctkBasePopupWidget : public QFrame
43{
44 Q_OBJECT
45
46 Q_ENUMS(AnimationEffect)
47 Q_ENUMS(VerticalDirection)
48
49
55 Q_PROPERTY( AnimationEffect animationEffect READ animationEffect WRITE setAnimationEffect)
56
57
63 Q_PROPERTY( int effectDuration READ effectDuration WRITE setEffectDuration);
64
69 Q_PROPERTY( QEasingCurve::Type easingCurve READ easingCurve WRITE setEasingCurve);
70
74 Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment);
75
79 Q_PROPERTY( Qt::Orientations orientation READ orientation WRITE setOrientation);
80
83 Q_PROPERTY( ctkBasePopupWidget::VerticalDirection verticalDirection READ verticalDirection WRITE setVerticalDirection);
84
87 Q_PROPERTY( Qt::LayoutDirection horizontalDirection READ horizontalDirection WRITE setHorizontalDirection);
88
89public:
90 typedef QFrame Superclass;
98 explicit ctkBasePopupWidget(QWidget* parent = 0);
100
106 QWidget* baseWidget()const;
107
109 {
110 WindowOpacityFadeEffect = 0,
112 FadeEffect
113 };
114
121
124 int effectDuration()const;
127 void setEffectDuration(int duration);
128
131 QEasingCurve::Type easingCurve()const;
134 void setEasingCurve(QEasingCurve::Type easingCurve);
135
138 Qt::Alignment alignment()const;
141 void setAlignment(Qt::Alignment alignment);
142
145 Qt::Orientations orientation()const;
148 void setOrientation(Qt::Orientations orientation);
149
151 TopToBottom = 1,
152 BottomToTop = 2
153 };
154
161
164 Qt::LayoutDirection horizontalDirection()const;
167 void setHorizontalDirection(Qt::LayoutDirection direction);
168
169public Q_SLOTS:
172 virtual void hidePopup();
175 virtual void showPopup();
178 inline void showPopup(bool show);
179
180Q_SIGNALS:
183 void popupOpened(bool open);
184
185protected:
186 explicit ctkBasePopupWidget(ctkBasePopupWidgetPrivate* pimpl, QWidget* parent = 0);
187 QScopedPointer<ctkBasePopupWidgetPrivate> d_ptr;
188 Q_PROPERTY(double effectAlpha READ effectAlpha WRITE setEffectAlpha DESIGNABLE false)
189 Q_PROPERTY(QRect effectGeometry READ effectGeometry WRITE setEffectGeometry DESIGNABLE false)
190
191 double effectAlpha()const;
192 QRect effectGeometry()const;
193
194 virtual void setBaseWidget(QWidget* baseWidget);
195 virtual bool event(QEvent* event);
196 virtual void paintEvent(QPaintEvent*);
197
198protected Q_SLOTS:
199 virtual void onEffectFinished();
200 void setEffectAlpha(double alpha);
201 void setEffectGeometry(QRect geometry);
202 void onBaseWidgetDestroyed();
203
204private:
205 Q_DECLARE_PRIVATE(ctkBasePopupWidget);
206 Q_DISABLE_COPY(ctkBasePopupWidget);
207};
208
211
212// -------------------------------------------------------------------------
213void ctkBasePopupWidget::showPopup(bool show)
214{
215 if (show)
216 {
217 this->showPopup();
218 }
219 else
220 {
221 this->hidePopup();
222 }
223}
224
225#endif
int effectDuration() const
QEasingCurve::Type easingCurve() const
virtual ~ctkBasePopupWidget()
void setHorizontalDirection(Qt::LayoutDirection direction)
void setVerticalDirection(VerticalDirection direction)
AnimationEffect animationEffect() const
virtual void showPopup()
Qt::Alignment alignment() const
Qt::LayoutDirection horizontalDirection() const
void setAlignment(Qt::Alignment alignment)
void setAnimationEffect(AnimationEffect effect)
virtual void hidePopup()
void setEasingCurve(QEasingCurve::Type easingCurve)
void popupOpened(bool open)
void setOrientation(Qt::Orientations orientation)
VerticalDirection verticalDirection() const
ctkBasePopupWidget(ctkBasePopupWidgetPrivate *pimpl, QWidget *parent=0)
void setEffectDuration(int duration)
ctkBasePopupWidget(QWidget *parent=0)
QScopedPointer< ctkBasePopupWidgetPrivate > d_ptr
QWidget * baseWidget() const
Qt::Orientations orientation() const
Q_DECLARE_METATYPE(ctkDICOMPersonName)