src/hbcore/gui/hbpopup.h
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbCore module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #ifndef HBPOPUP_H
       
    27 #define HBPOPUP_H
       
    28 
       
    29 //
       
    30 //  N O T E
       
    31 //  -------
       
    32 //
       
    33 // This class is to be called HbPopup, the base class of all popups.
       
    34 // It's merely a popup frame whose stacking order is handled by the
       
    35 // popup manager. It doesn't have heading/content widgets nor actions.
       
    36 // This functionality will be provided by the upcoming HbDialog class.
       
    37 //
       
    38 
       
    39 #include <hbglobal.h>
       
    40 #include <hbwidget.h>
       
    41 
       
    42 class HbPopupPrivate;
       
    43 
       
    44 class HB_CORE_EXPORT HbPopup : public HbWidget
       
    45 {
       
    46     Q_OBJECT
       
    47     Q_ENUMS( DefaultTimeout DismissPolicy FrameType )
       
    48     Q_PROPERTY( int timeout READ timeout WRITE setTimeout )
       
    49     Q_PROPERTY( bool modal READ isModal WRITE setModal )
       
    50     Q_PROPERTY( bool backgroundFaded 
       
    51                 READ isBackgroundFaded WRITE setBackgroundFaded )
       
    52     Q_PROPERTY( DismissPolicy dismissPolicy READ dismissPolicy WRITE setDismissPolicy )
       
    53     Q_PROPERTY( FrameType frameType READ frameType WRITE setFrameType )
       
    54                
       
    55 public:
       
    56 
       
    57     enum DefaultTimeout
       
    58     {
       
    59         NoTimeout,
       
    60         ConfirmationNoteTimeout,
       
    61         StandardTimeout,
       
    62         ContextMenuTimeout
       
    63     };
       
    64 
       
    65     enum DismissPolicy
       
    66     {
       
    67         NoDismiss   = 0,
       
    68         TapInside   = 1,
       
    69         TapOutside  = 2,
       
    70         TapAnywhere = TapInside | TapOutside
       
    71     };
       
    72 
       
    73     enum FrameType
       
    74     {
       
    75         Strong = 0,
       
    76         Weak   = 1 
       
    77     };
       
    78     
       
    79     enum Placement
       
    80     {
       
    81         TopLeftCorner     = Qt::TopLeftCorner,
       
    82         TopRightCorner    = Qt::TopRightCorner,
       
    83         BottomLeftCorner  = Qt::BottomLeftCorner,
       
    84         BottomRightCorner = Qt::BottomRightCorner,
       
    85         TopEdgeCenter,
       
    86         RightEdgeCenter,
       
    87         BottomEdgeCenter,
       
    88         LeftEdgeCenter,
       
    89         Center
       
    90     };
       
    91 
       
    92     explicit HbPopup(QGraphicsItem *parent = 0);
       
    93     virtual ~HbPopup();
       
    94 
       
    95     int timeout() const;
       
    96     void setTimeout(int timeout);
       
    97     void setTimeout(HbPopup::DefaultTimeout timeout);
       
    98 
       
    99     bool isModal() const;
       
   100     void setModal(bool enabled);
       
   101 
       
   102     void setBackgroundFaded(bool fadeBackground);
       
   103     bool isBackgroundFaded() const;
       
   104 
       
   105     DismissPolicy dismissPolicy() const;
       
   106     void setDismissPolicy(HbPopup::DismissPolicy dismissPolicy);
       
   107 
       
   108     FrameType frameType() const;
       
   109     void setFrameType(HbPopup::FrameType frameType);
       
   110 
       
   111     enum { Type = Hb::ItemType_Popup };
       
   112     int type() const { return Type; }
       
   113 
       
   114     void setPreferredPos(const QPointF& position,
       
   115                           HbPopup::Placement placement = HbPopup::TopLeftCorner);
       
   116 
       
   117 public slots:
       
   118     void open( QObject *receiver = 0, const char *member = 0);
       
   119     void exec();
       
   120     void handlePopupPos();
       
   121 
       
   122 signals:
       
   123     void aboutToShow();
       
   124     void aboutToHide();
       
   125     void aboutToClose();
       
   126 
       
   127 protected:
       
   128     HbPopup(HbPopupPrivate &dd, QGraphicsItem *parent);
       
   129     QVariant itemChange(GraphicsItemChange change, const QVariant & value);
       
   130 
       
   131     void mousePressEvent(QGraphicsSceneMouseEvent *event );
       
   132     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event );
       
   133     void keyPressEvent(QKeyEvent *event);
       
   134 
       
   135     void showEvent(QShowEvent *event);
       
   136     void hideEvent(QHideEvent *event);
       
   137     void resizeEvent(QGraphicsSceneResizeEvent *event);
       
   138     void closeEvent(QCloseEvent *event);
       
   139     bool event(QEvent *event);
       
   140 
       
   141 private:
       
   142     Q_DECLARE_PRIVATE_D(d_ptr, HbPopup)
       
   143     Q_DISABLE_COPY(HbPopup)
       
   144 #ifdef HB_EFFECTS
       
   145     Q_PRIVATE_SLOT(d_func(), void _q_delayedHide(HbEffect::EffectStatus status))
       
   146     Q_PRIVATE_SLOT(d_func(), void _q_orientationChange(Qt::Orientation orient, bool animate))
       
   147 #endif // HB_EFFECTS
       
   148     Q_PRIVATE_SLOT(d_func(), void _q_timeoutFinished())
       
   149 };
       
   150 
       
   151 #endif // HbPopup_H