1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QWIZARD_H
41#define QWIZARD_H
42
43#include <QtWidgets/qtwidgetsglobal.h>
44#include <QtWidgets/qdialog.h>
45
46QT_REQUIRE_CONFIG(wizard);
47
48QT_BEGIN_NAMESPACE
49
50class QAbstractButton;
51class QWizardPage;
52class QWizardPrivate;
53
54class Q_WIDGETS_EXPORT QWizard : public QDialog
55{
56 Q_OBJECT
57 Q_PROPERTY(WizardStyle wizardStyle READ wizardStyle WRITE setWizardStyle)
58 Q_PROPERTY(WizardOptions options READ options WRITE setOptions)
59 Q_PROPERTY(Qt::TextFormat titleFormat READ titleFormat WRITE setTitleFormat)
60 Q_PROPERTY(Qt::TextFormat subTitleFormat READ subTitleFormat WRITE setSubTitleFormat)
61 Q_PROPERTY(int startId READ startId WRITE setStartId)
62 Q_PROPERTY(int currentId READ currentId NOTIFY currentIdChanged)
63
64public:
65 enum WizardButton {
66 BackButton,
67 NextButton,
68 CommitButton,
69 FinishButton,
70 CancelButton,
71 HelpButton,
72 CustomButton1,
73 CustomButton2,
74 CustomButton3,
75 Stretch,
76
77 NoButton = -1,
78 NStandardButtons = 6,
79 NButtons = 9
80 };
81
82 enum WizardPixmap {
83 WatermarkPixmap,
84 LogoPixmap,
85 BannerPixmap,
86 BackgroundPixmap,
87 NPixmaps
88 };
89
90 enum WizardStyle {
91 ClassicStyle,
92 ModernStyle,
93 MacStyle,
94 AeroStyle,
95 NStyles
96 };
97 Q_ENUM(WizardStyle)
98
99 enum WizardOption {
100 IndependentPages = 0x00000001,
101 IgnoreSubTitles = 0x00000002,
102 ExtendedWatermarkPixmap = 0x00000004,
103 NoDefaultButton = 0x00000008,
104 NoBackButtonOnStartPage = 0x00000010,
105 NoBackButtonOnLastPage = 0x00000020,
106 DisabledBackButtonOnLastPage = 0x00000040,
107 HaveNextButtonOnLastPage = 0x00000080,
108 HaveFinishButtonOnEarlyPages = 0x00000100,
109 NoCancelButton = 0x00000200,
110 CancelButtonOnLeft = 0x00000400,
111 HaveHelpButton = 0x00000800,
112 HelpButtonOnRight = 0x00001000,
113 HaveCustomButton1 = 0x00002000,
114 HaveCustomButton2 = 0x00004000,
115 HaveCustomButton3 = 0x00008000,
116 NoCancelButtonOnLastPage = 0x00010000
117 };
118 Q_ENUM(WizardOption)
119
120 Q_DECLARE_FLAGS(WizardOptions, WizardOption)
121 Q_FLAG(WizardOptions)
122
123 explicit QWizard(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
124 ~QWizard();
125
126 int addPage(QWizardPage *page);
127 void setPage(int id, QWizardPage *page);
128 void removePage(int id);
129 QWizardPage *page(int id) const;
130 bool hasVisitedPage(int id) const;
131#if QT_DEPRECATED_SINCE(5, 15)
132 QT_DEPRECATED_VERSION_X_5_15("Use visitedIds() instead") QList<int> visitedPages() const;
133#endif
134 QList<int> visitedIds() const;
135 QList<int> pageIds() const;
136 void setStartId(int id);
137 int startId() const;
138 QWizardPage *currentPage() const;
139 int currentId() const;
140
141 virtual bool validateCurrentPage();
142 virtual int nextId() const;
143
144 void setField(const QString &name, const QVariant &value);
145 QVariant field(const QString &name) const;
146
147 void setWizardStyle(WizardStyle style);
148 WizardStyle wizardStyle() const;
149
150 void setOption(WizardOption option, bool on = true);
151 bool testOption(WizardOption option) const;
152 void setOptions(WizardOptions options);
153 WizardOptions options() const;
154
155 void setButtonText(WizardButton which, const QString &text);
156 QString buttonText(WizardButton which) const;
157 void setButtonLayout(const QList<WizardButton> &layout);
158 void setButton(WizardButton which, QAbstractButton *button);
159 QAbstractButton *button(WizardButton which) const;
160
161 void setTitleFormat(Qt::TextFormat format);
162 Qt::TextFormat titleFormat() const;
163 void setSubTitleFormat(Qt::TextFormat format);
164 Qt::TextFormat subTitleFormat() const;
165 void setPixmap(WizardPixmap which, const QPixmap &pixmap);
166 QPixmap pixmap(WizardPixmap which) const;
167
168 void setSideWidget(QWidget *widget);
169 QWidget *sideWidget() const;
170
171 void setDefaultProperty(const char *className, const char *property,
172 const char *changedSignal);
173
174 void setVisible(bool visible) override;
175 QSize sizeHint() const override;
176
177Q_SIGNALS:
178 void currentIdChanged(int id);
179 void helpRequested();
180 void customButtonClicked(int which);
181 void pageAdded(int id);
182 void pageRemoved(int id);
183
184public Q_SLOTS:
185 void back();
186 void next();
187 void restart();
188
189protected:
190 bool event(QEvent *event) override;
191 void resizeEvent(QResizeEvent *event) override;
192 void paintEvent(QPaintEvent *event) override;
193#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
194# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
195 bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
196# else
197 bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
198# endif
199#endif
200 void done(int result) override;
201 virtual void initializePage(int id);
202 virtual void cleanupPage(int id);
203
204private:
205 Q_DISABLE_COPY(QWizard)
206 Q_DECLARE_PRIVATE(QWizard)
207 Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
208 Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
209 Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
210
211 friend class QWizardPage;
212};
213
214Q_DECLARE_OPERATORS_FOR_FLAGS(QWizard::WizardOptions)
215
216class QWizardPagePrivate;
217
218class Q_WIDGETS_EXPORT QWizardPage : public QWidget
219{
220 Q_OBJECT
221 Q_PROPERTY(QString title READ title WRITE setTitle)
222 Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
223
224public:
225 explicit QWizardPage(QWidget *parent = nullptr);
226 ~QWizardPage();
227
228 void setTitle(const QString &title);
229 QString title() const;
230 void setSubTitle(const QString &subTitle);
231 QString subTitle() const;
232 void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap);
233 QPixmap pixmap(QWizard::WizardPixmap which) const;
234 void setFinalPage(bool finalPage);
235 bool isFinalPage() const;
236 void setCommitPage(bool commitPage);
237 bool isCommitPage() const;
238 void setButtonText(QWizard::WizardButton which, const QString &text);
239 QString buttonText(QWizard::WizardButton which) const;
240
241 virtual void initializePage();
242 virtual void cleanupPage();
243 virtual bool validatePage();
244 virtual bool isComplete() const;
245 virtual int nextId() const;
246
247Q_SIGNALS:
248 void completeChanged();
249
250protected:
251 void setField(const QString &name, const QVariant &value);
252 QVariant field(const QString &name) const;
253 void registerField(const QString &name, QWidget *widget, const char *property = nullptr,
254 const char *changedSignal = nullptr);
255 QWizard *wizard() const;
256
257private:
258 Q_DISABLE_COPY(QWizardPage)
259 Q_DECLARE_PRIVATE(QWizardPage)
260 Q_PRIVATE_SLOT(d_func(), void _q_maybeEmitCompleteChanged())
261 Q_PRIVATE_SLOT(d_func(), void _q_updateCachedCompleteState())
262
263 friend class QWizard;
264 friend class QWizardPrivate;
265};
266
267QT_END_NAMESPACE
268
269#endif // QWIZARD_H
270

source code of qtbase/src/widgets/dialogs/qwizard.h