itom 2.2.1
K:/git-itom/sources/itom/itomWidgets/basePopupWidget.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2016, Institut fuer Technische Optik (ITO),
00005     Universitaet Stuttgart, Germany
00006 
00007     This file is part of itom and its software development toolkit (SDK).
00008 
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013    
00014     In addition, as a special exception, the Institut fuer Technische
00015     Optik (ITO) gives you certain additional rights.
00016     These rights are described in the ITO LGPL Exception version 1.0,
00017     which can be found in the file LGPL_EXCEPTION.txt in this package.
00018 
00019     itom is distributed in the hope that it will be useful, but
00020     WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00022     General Public Licence for more details.
00023 
00024     You should have received a copy of the GNU Library General Public License
00025     along with itom. If not, see <http://www.gnu.org/licenses/>.
00026 
00027     This file is a port and modified version of the 
00028     CTK Common Toolkit (http://www.commontk.org)
00029 *********************************************************************** */
00030 
00031 #ifndef BASEPOPUPWIDGET_H
00032 #define BASEPOPUPWIDGET_H
00033 
00034 // Qt includes
00035 #include <QEasingCurve>
00036 #include <QFrame>
00037 #include <QMetaType>
00038 
00039 #include "commonWidgets.h"
00040 
00041 class BasePopupWidgetPrivate;
00042 
00045 class ITOMWIDGETS_EXPORT BasePopupWidget : public QFrame
00046 {
00047   Q_OBJECT
00048 
00049   Q_ENUMS(AnimationEffect)
00050   Q_ENUMS(VerticalDirection)
00051 
00052   
00053   Q_PROPERTY( AnimationEffect animationEffect READ animationEffect WRITE setAnimationEffect)
00054 
00057   Q_PROPERTY( int effectDuration READ effectDuration WRITE setEffectDuration);
00058 
00061   Q_PROPERTY( QEasingCurve::Type easingCurve READ easingCurve WRITE setEasingCurve);
00062 
00066   Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment);
00067   
00071   Q_PROPERTY( Qt::Orientations orientation READ orientation WRITE setOrientation);
00072   
00075   Q_PROPERTY( BasePopupWidget::VerticalDirection verticalDirection READ verticalDirection WRITE setVerticalDirection);
00076 
00079   Q_PROPERTY( Qt::LayoutDirection horizontalDirection READ horizontalDirection WRITE setHorizontalDirection);
00080 
00081 public:
00082   typedef QFrame Superclass;
00090   explicit BasePopupWidget(QWidget* parent = 0);
00091   virtual ~BasePopupWidget();
00092 
00097   QWidget* baseWidget()const;
00098 
00099   enum AnimationEffect
00100   {
00101     WindowOpacityFadeEffect = 0,
00102     ScrollEffect,
00103     FadeEffect
00104   };
00105 
00106   AnimationEffect animationEffect()const;
00107   void setAnimationEffect(AnimationEffect effect);
00108 
00109   int effectDuration()const;
00110   void setEffectDuration(int duration);
00111 
00112   QEasingCurve::Type easingCurve()const;
00113   void setEasingCurve(QEasingCurve::Type easingCurve);
00114 
00115   Qt::Alignment alignment()const;
00116   void setAlignment(Qt::Alignment alignment);
00117   
00118   Qt::Orientations orientation()const;
00119   void setOrientation(Qt::Orientations orientation);
00120   
00121   enum VerticalDirection{
00122     TopToBottom = 1,
00123     BottomToTop = 2
00124   };
00125   
00126   VerticalDirection verticalDirection()const;
00127   void setVerticalDirection(VerticalDirection direction);
00128   
00129   Qt::LayoutDirection horizontalDirection()const;
00130   void setHorizontalDirection(Qt::LayoutDirection direction);
00131 
00132 public Q_SLOTS:
00135   virtual void hidePopup();
00138   virtual void showPopup();
00141   inline void showPopup(bool show);
00142 
00143 Q_SIGNALS:
00144   void popupOpened(bool open);
00145 
00146 protected:
00147   explicit BasePopupWidget(BasePopupWidgetPrivate* pimpl, QWidget* parent = 0);
00148   QScopedPointer<BasePopupWidgetPrivate> d_ptr;
00149   Q_PROPERTY(double effectAlpha READ effectAlpha WRITE setEffectAlpha DESIGNABLE false)
00150   Q_PROPERTY(QRect effectGeometry READ effectGeometry WRITE setEffectGeometry DESIGNABLE false)
00151 
00152   double effectAlpha()const;
00153   QRect effectGeometry()const;
00154 
00155   virtual void setBaseWidget(QWidget* baseWidget);
00156 
00157   virtual bool event(QEvent* event);
00158   virtual void paintEvent(QPaintEvent*);
00159 
00160 protected Q_SLOTS:
00161   virtual void onEffectFinished();
00162   void setEffectAlpha(double alpha);
00163   void setEffectGeometry(QRect geometry);
00164   void onBaseWidgetDestroyed();
00165 
00166 private:
00167   Q_DECLARE_PRIVATE(BasePopupWidget);
00168   Q_DISABLE_COPY(BasePopupWidget);
00169 };
00170 
00171 Q_DECLARE_METATYPE(BasePopupWidget::AnimationEffect)
00172 Q_DECLARE_METATYPE(BasePopupWidget::VerticalDirection)
00173 
00174 // -------------------------------------------------------------------------
00175 void BasePopupWidget::showPopup(bool show)
00176 {
00177   if (show)
00178     {
00179     this->showPopup();
00180     }
00181   else
00182     {
00183     this->hidePopup();
00184     }
00185 }
00186 
00187 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends