|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QDIALOGBUTTONBOX_H |
|
43 #define QDIALOGBUTTONBOX_H |
|
44 |
|
45 #include <QtGui/qwidget.h> |
|
46 |
|
47 QT_BEGIN_HEADER |
|
48 |
|
49 QT_BEGIN_NAMESPACE |
|
50 |
|
51 QT_MODULE(Gui) |
|
52 |
|
53 class QAbstractButton; |
|
54 class QPushButton; |
|
55 class QDialogButtonBoxPrivate; |
|
56 |
|
57 class Q_GUI_EXPORT QDialogButtonBox : public QWidget |
|
58 { |
|
59 Q_OBJECT |
|
60 Q_FLAGS(StandardButtons) |
|
61 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) |
|
62 Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons) |
|
63 Q_PROPERTY(bool centerButtons READ centerButtons WRITE setCenterButtons) |
|
64 |
|
65 public: |
|
66 enum ButtonRole { |
|
67 // keep this in sync with QMessageBox::ButtonRole |
|
68 InvalidRole = -1, |
|
69 AcceptRole, |
|
70 RejectRole, |
|
71 DestructiveRole, |
|
72 ActionRole, |
|
73 HelpRole, |
|
74 YesRole, |
|
75 NoRole, |
|
76 ResetRole, |
|
77 ApplyRole, |
|
78 |
|
79 NRoles |
|
80 }; |
|
81 |
|
82 enum StandardButton { |
|
83 // keep this in sync with QMessageBox::StandardButton |
|
84 NoButton = 0x00000000, |
|
85 Ok = 0x00000400, |
|
86 Save = 0x00000800, |
|
87 SaveAll = 0x00001000, |
|
88 Open = 0x00002000, |
|
89 Yes = 0x00004000, |
|
90 YesToAll = 0x00008000, |
|
91 No = 0x00010000, |
|
92 NoToAll = 0x00020000, |
|
93 Abort = 0x00040000, |
|
94 Retry = 0x00080000, |
|
95 Ignore = 0x00100000, |
|
96 Close = 0x00200000, |
|
97 Cancel = 0x00400000, |
|
98 Discard = 0x00800000, |
|
99 Help = 0x01000000, |
|
100 Apply = 0x02000000, |
|
101 Reset = 0x04000000, |
|
102 RestoreDefaults = 0x08000000, |
|
103 |
|
104 #ifndef Q_MOC_RUN |
|
105 FirstButton = Ok, |
|
106 LastButton = RestoreDefaults |
|
107 #endif |
|
108 }; |
|
109 |
|
110 Q_DECLARE_FLAGS(StandardButtons, StandardButton) |
|
111 |
|
112 enum ButtonLayout { |
|
113 WinLayout, |
|
114 MacLayout, |
|
115 KdeLayout, |
|
116 GnomeLayout |
|
117 }; |
|
118 |
|
119 QDialogButtonBox(QWidget *parent = 0); |
|
120 QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = 0); |
|
121 QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation = Qt::Horizontal, |
|
122 QWidget *parent = 0); |
|
123 ~QDialogButtonBox(); |
|
124 |
|
125 void setOrientation(Qt::Orientation orientation); |
|
126 Qt::Orientation orientation() const; |
|
127 |
|
128 void addButton(QAbstractButton *button, ButtonRole role); |
|
129 QPushButton *addButton(const QString &text, ButtonRole role); |
|
130 QPushButton *addButton(StandardButton button); |
|
131 void removeButton(QAbstractButton *button); |
|
132 void clear(); |
|
133 |
|
134 QList<QAbstractButton *> buttons() const; |
|
135 ButtonRole buttonRole(QAbstractButton *button) const; |
|
136 |
|
137 void setStandardButtons(StandardButtons buttons); |
|
138 StandardButtons standardButtons() const; |
|
139 StandardButton standardButton(QAbstractButton *button) const; |
|
140 QPushButton *button(StandardButton which) const; |
|
141 |
|
142 void setCenterButtons(bool center); |
|
143 bool centerButtons() const; |
|
144 |
|
145 Q_SIGNALS: |
|
146 void clicked(QAbstractButton *button); |
|
147 void accepted(); |
|
148 void helpRequested(); |
|
149 void rejected(); |
|
150 |
|
151 protected: |
|
152 void changeEvent(QEvent *event); |
|
153 bool event(QEvent *event); |
|
154 |
|
155 private: |
|
156 Q_DISABLE_COPY(QDialogButtonBox) |
|
157 Q_DECLARE_PRIVATE(QDialogButtonBox) |
|
158 Q_PRIVATE_SLOT(d_func(), void _q_handleButtonClicked()) |
|
159 Q_PRIVATE_SLOT(d_func(), void _q_handleButtonDestroyed()) |
|
160 }; |
|
161 |
|
162 Q_DECLARE_OPERATORS_FOR_FLAGS(QDialogButtonBox::StandardButtons) |
|
163 |
|
164 QT_END_NAMESPACE |
|
165 |
|
166 QT_END_HEADER |
|
167 |
|
168 #endif // QDIALOGBUTTONBOX_H |