|
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 HbWidgets 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 HBMESSAGEBOX_H |
|
27 #define HBMESSAGEBOX_H |
|
28 |
|
29 #include <hbglobal.h> |
|
30 #include <hbdialog.h> |
|
31 #include <hbicon.h> |
|
32 |
|
33 class HbMessageBoxPrivate; |
|
34 class HbStyleOptionMessageBox; |
|
35 |
|
36 class HB_WIDGETS_EXPORT HbMessageBox : public HbDialog |
|
37 { |
|
38 Q_OBJECT |
|
39 Q_PROPERTY( QString text READ text WRITE setText ) |
|
40 Q_PROPERTY( HbIcon icon READ icon WRITE setIcon ) |
|
41 Q_PROPERTY( Qt::Alignment iconAlignment READ iconAlignment WRITE setIconAlignment ) |
|
42 Q_PROPERTY( bool iconVisible READ iconVisible WRITE setIconVisible ) |
|
43 public: |
|
44 enum MessageBoxType { |
|
45 MessageTypeInformation, |
|
46 MessageTypeQuestion, |
|
47 MessageTypeWarning |
|
48 }; |
|
49 explicit HbMessageBox(MessageBoxType type=MessageTypeInformation,QGraphicsItem *parent = 0); |
|
50 explicit HbMessageBox(const QString &text,MessageBoxType type =MessageTypeInformation, QGraphicsItem *parent = 0); |
|
51 virtual ~HbMessageBox(); |
|
52 |
|
53 void setText(const QString &text); |
|
54 QString text() const; |
|
55 |
|
56 void setIcon(const HbIcon &icon); |
|
57 HbIcon icon() const; |
|
58 |
|
59 void setIconAlignment(Qt::Alignment align); |
|
60 Qt::Alignment iconAlignment() const; |
|
61 |
|
62 void setIconVisible(bool visible); |
|
63 bool iconVisible() const; |
|
64 |
|
65 QGraphicsItem *primitive(HbStyle::Primitive primitive) const; |
|
66 enum { Type = Hb::ItemType_MessageBox }; |
|
67 int type() const { return Type; } |
|
68 |
|
69 public: |
|
70 static bool launchQuestionMessageBox(const QString &questionText, |
|
71 const QString &primaryButtonText = tr("Yes"), |
|
72 const QString &secondaryButtonText = tr("No"), |
|
73 QGraphicsWidget *headWidget = 0, |
|
74 QGraphicsScene *scene = 0, |
|
75 QGraphicsItem *parent = 0 ); |
|
76 |
|
77 static void launchInformationMessageBox(const QString &informationText, |
|
78 QGraphicsWidget *headWidget = 0, |
|
79 QGraphicsScene *scene = 0, |
|
80 QGraphicsItem *parent = 0 ); |
|
81 |
|
82 static void launchWarningMessageBox(const QString &warningText, |
|
83 QGraphicsWidget *headWidget = 0, |
|
84 QGraphicsScene *scene = 0, |
|
85 QGraphicsItem *parent = 0 ); |
|
86 |
|
87 static bool question(const QString &questionText, |
|
88 const QString &primaryButtonText = tr("Yes"), |
|
89 const QString &secondaryButtonText = tr("No"), |
|
90 QGraphicsWidget *headWidget = 0, |
|
91 QGraphicsScene *scene = 0, |
|
92 QGraphicsItem *parent = 0 ); |
|
93 |
|
94 static void information(const QString &informationText, |
|
95 QGraphicsWidget *headWidget = 0, |
|
96 QGraphicsScene *scene = 0, |
|
97 QGraphicsItem *parent = 0 ); |
|
98 |
|
99 static void warning(const QString &warningText, |
|
100 QGraphicsWidget *headWidget = 0, |
|
101 QGraphicsScene *scene = 0, |
|
102 QGraphicsItem *parent = 0 ); |
|
103 |
|
104 static void question(const QString &questionText, |
|
105 QObject *receiver, |
|
106 const char *member, |
|
107 const QString &primaryButtonText = tr("Yes"), |
|
108 const QString &secondaryButtonText = tr("No"), |
|
109 QGraphicsWidget *headWidget = 0, |
|
110 QGraphicsScene *scene = 0, |
|
111 QGraphicsItem *parent = 0 ); |
|
112 |
|
113 static void information(const QString &informationText, |
|
114 QObject *receiver, |
|
115 const char *member, |
|
116 QGraphicsWidget *headWidget = 0, |
|
117 QGraphicsScene *scene = 0, |
|
118 QGraphicsItem *parent = 0 ); |
|
119 |
|
120 static void warning(const QString &warningText, |
|
121 QObject *receiver, |
|
122 const char *member, |
|
123 QGraphicsWidget *headWidget = 0, |
|
124 QGraphicsScene *scene = 0, |
|
125 QGraphicsItem *parent = 0 ); |
|
126 |
|
127 public slots: |
|
128 void updatePrimitives(); |
|
129 |
|
130 protected: |
|
131 HbMessageBox(HbMessageBoxPrivate &dd, QGraphicsItem *parent); |
|
132 void initStyleOption(HbStyleOptionMessageBox *option) const; |
|
133 void mousePressEvent(QGraphicsSceneMouseEvent *event ); |
|
134 private: |
|
135 Q_PRIVATE_SLOT(d_func(), void _q_closeOnGesture()) |
|
136 Q_DECLARE_PRIVATE_D(d_ptr, HbMessageBox) |
|
137 Q_DISABLE_COPY(HbMessageBox) |
|
138 |
|
139 }; |
|
140 |
|
141 #endif // HB_MESSAGEBOX_H |
|
142 |