Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwizard.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qwizard.h"
5#include <QtWidgets/private/qtwidgetsglobal_p.h>
6
7#if QT_CONFIG(spinbox)
8#include "qabstractspinbox.h"
9#endif
10#include "qalgorithms.h"
11#include "qapplication.h"
12#include "qboxlayout.h"
13#include "qlayoutitem.h"
14#include "qevent.h"
15#include "qframe.h"
16#include "qlabel.h"
17#if QT_CONFIG(lineedit)
18#include "qlineedit.h"
19#endif
20#include <qpointer.h>
21#include "qstylepainter.h"
22#include "qwindow.h"
23#include "qpushbutton.h"
24#include "qset.h"
25#if QT_CONFIG(shortcut)
26# include "qshortcut.h"
27#endif
28#include "qstyle.h"
29#include "qstyleoption.h"
30#include "qvarlengtharray.h"
31#if defined(Q_OS_MACOS)
32#include <AppKit/AppKit.h>
33#include <QtGui/private/qcoregraphics_p.h>
34#elif QT_CONFIG(style_windowsvista)
35#include "qwizard_win_p.h"
36#include "qtimer.h"
37#endif
38
39#include "private/qdialog_p.h"
40#include <qdebug.h>
41
42#include <string.h> // for memset()
43#include <algorithm>
44
46
47using namespace Qt::StringLiterals;
48
49// These fudge terms were needed a few places to obtain pixel-perfect results
52const int ClassicHMargin = 4;
53const int MacButtonTopMargin = 13;
54const int MacLayoutLeftMargin = 20;
55//const int MacLayoutTopMargin = 14; // Unused. Save some space and avoid warning.
56const int MacLayoutRightMargin = 20;
57const int MacLayoutBottomMargin = 17;
58
59static void changeSpacerSize(QLayout *layout, int index, int width, int height)
60{
62 if (!spacer)
63 return;
64 spacer->changeSize(width, height);
65}
66
67static QWidget *iWantTheFocus(QWidget *ancestor)
68{
69 const int MaxIterations = 100;
70
71 QWidget *candidate = ancestor;
72 for (int i = 0; i < MaxIterations; ++i) {
73 candidate = candidate->nextInFocusChain();
74 if (!candidate)
75 break;
76
77 if (candidate->focusPolicy() & Qt::TabFocus) {
78 if (candidate != ancestor && ancestor->isAncestorOf(candidate))
79 return candidate;
80 }
81 }
82 return nullptr;
83}
84
85static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX,
86 const QByteArray &classY)
87{
88 const QMetaObject *metaObject = object->metaObject();
89 while (metaObject) {
90 if (metaObject->className() == classX)
91 return true;
92 if (metaObject->className() == classY)
93 return false;
94 metaObject = metaObject->superClass();
95 }
96 return false;
97}
98
99const struct {
100 const char className[16];
101 const char property[13];
102} fallbackProperties[] = {
103 // If you modify this list, make sure to update the documentation (and the auto test)
104 { "QAbstractButton", "checked" },
105 { "QAbstractSlider", "value" },
106 { "QComboBox", "currentIndex" },
107 { "QDateTimeEdit", "dateTime" },
108 { "QLineEdit", "text" },
109 { "QListWidget", "currentRow" },
110 { "QSpinBox", "value" },
113
114static const char *changed_signal(int which)
115{
116 // since it might expand to a runtime function call (to
117 // qFlagLocations()), we cannot store the result of SIGNAL() in a
118 // character array and expect it to be statically initialized. To
119 // avoid the relocations caused by a char pointer table, use a
120 // switch statement:
121 switch (which) {
122 case 0: return SIGNAL(toggled(bool));
123 case 1: return SIGNAL(valueChanged(int));
124 case 2: return SIGNAL(currentIndexChanged(int));
125 case 3: return SIGNAL(dateTimeChanged(QDateTime));
126 case 4: return SIGNAL(textChanged(QString));
127 case 5: return SIGNAL(currentRowChanged(int));
128 case 6: return SIGNAL(valueChanged(int));
129 };
130 static_assert(7 == NFallbackDefaultProperties);
131 Q_UNREACHABLE_RETURN(nullptr);
132}
133
147
149{
150public:
151 inline QWizardField() {}
152 QWizardField(QWizardPage *page, const QString &spec, QObject *object, const char *property,
153 const char *changedSignal);
154
155 void resolve(const QList<QWizardDefaultProperty> &defaultPropertyTable);
156 void findProperty(const QWizardDefaultProperty *properties, int propertyCount);
157
165};
167
169 const char *property, const char *changedSignal)
170 : page(page), name(spec), mandatory(false), object(object), property(property),
171 changedSignal(changedSignal)
172{
173 if (name.endsWith(u'*')) {
174 name.chop(1);
175 mandatory = true;
176 }
177}
178
179void QWizardField::resolve(const QList<QWizardDefaultProperty> &defaultPropertyTable)
180{
181 if (property.isEmpty())
182 findProperty(defaultPropertyTable.constData(), defaultPropertyTable.size());
183 initialValue = object->property(property);
184}
185
187{
189
190 for (int i = 0; i < propertyCount; ++i) {
192 className = properties[i].className;
193 property = properties[i].property;
194 changedSignal = properties[i].changedSignal;
195 }
196 }
197}
198
200{
201public:
210 int hspacing = -1;
211 int vspacing = -1;
214 bool header = false;
215 bool watermark = false;
216 bool title = false;
217 bool subTitle = false;
218 bool extension = false;
219 bool sideWidget = false;
220
221 bool operator==(const QWizardLayoutInfo &other) const;
222 inline bool operator!=(const QWizardLayoutInfo &other) const { return !operator==(other); }
223};
224
226{
227 return topLevelMarginLeft == other.topLevelMarginLeft
228 && topLevelMarginRight == other.topLevelMarginRight
229 && topLevelMarginTop == other.topLevelMarginTop
230 && topLevelMarginBottom == other.topLevelMarginBottom
231 && childMarginLeft == other.childMarginLeft
232 && childMarginRight == other.childMarginRight
233 && childMarginTop == other.childMarginTop
234 && childMarginBottom == other.childMarginBottom
235 && hspacing == other.hspacing
236 && vspacing == other.vspacing
237 && buttonSpacing == other.buttonSpacing
238 && wizStyle == other.wizStyle
239 && header == other.header
240 && watermark == other.watermark
241 && title == other.title
242 && subTitle == other.subTitle
243 && extension == other.extension
244 && sideWidget == other.sideWidget;
245}
246
247class QWizardHeader : public QWidget
248{
249public:
250 enum RulerType { Ruler };
251
252 inline QWizardHeader(RulerType /* ruler */, QWidget *parent = nullptr)
253 : QWidget(parent) { setFixedHeight(2); }
254 QWizardHeader(QWidget *parent = nullptr);
255
256 void setup(const QWizardLayoutInfo &info, const QString &title,
257 const QString &subTitle, const QPixmap &logo, const QPixmap &banner,
258 Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat);
259
260protected:
261 void paintEvent(QPaintEvent *event) override;
262#if QT_CONFIG(style_windowsvista)
263private:
264 bool vistaDisabled() const;
265#endif
266private:
267 QLabel *titleLabel;
268 QLabel *subTitleLabel;
269 QLabel *logoLabel;
270 QGridLayout *layout;
271 QPixmap bannerPixmap;
272};
273
275 : QWidget(parent)
276{
279
280 titleLabel = new QLabel(this);
282
283 subTitleLabel = new QLabel(this);
284 subTitleLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
285 subTitleLabel->setWordWrap(true);
286
287 logoLabel = new QLabel(this);
288
289 QFont font = titleLabel->font();
290 font.setBold(true);
291 titleLabel->setFont(font);
292
293 layout = new QGridLayout(this);
294 layout->setContentsMargins(QMargins());
295 layout->setSpacing(0);
296
297 layout->setRowMinimumHeight(3, 1);
298 layout->setRowStretch(4, 1);
299
300 layout->setColumnStretch(2, 1);
303
304 layout->addWidget(titleLabel, 2, 1, 1, 2);
305 layout->addWidget(subTitleLabel, 4, 2);
306 layout->addWidget(logoLabel, 1, 5, 5, 1);
307}
308
309#if QT_CONFIG(style_windowsvista)
310bool QWizardHeader::vistaDisabled() const
311{
312 bool styleDisabled = false;
313 QWizard *wiz = parentWidget() ? qobject_cast <QWizard *>(parentWidget()->parentWidget()) : 0;
314 if (wiz) {
315 // Designer doesn't support the Vista style for Wizards. This property is used to turn
316 // off the Vista style.
317 const QVariant v = wiz->property("_q_wizard_vista_off");
318 styleDisabled = v.isValid() && v.toBool();
319 }
320 return styleDisabled;
321}
322#endif
323
325 const QString &subTitle, const QPixmap &logo, const QPixmap &banner,
326 Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat)
327{
328 bool modern = ((info.wizStyle == QWizard::ModernStyle)
329#if QT_CONFIG(style_windowsvista)
330 || vistaDisabled()
331#endif
332 );
333
334 layout->setRowMinimumHeight(0, modern ? ModernHeaderTopMargin : 0);
335 layout->setRowMinimumHeight(1, modern ? info.topLevelMarginTop - ModernHeaderTopMargin - 1 : 0);
336 layout->setRowMinimumHeight(6, (modern ? 3 : GapBetweenLogoAndRightEdge) + 2);
337
338 int minColumnWidth0 = modern ? info.topLevelMarginLeft + info.topLevelMarginRight : 0;
339 int minColumnWidth1 = modern ? info.topLevelMarginLeft + info.topLevelMarginRight + 1
340 : info.topLevelMarginLeft + ClassicHMargin;
341 layout->setColumnMinimumWidth(0, minColumnWidth0);
342 layout->setColumnMinimumWidth(1, minColumnWidth1);
343
344 titleLabel->setTextFormat(titleFormat);
345 titleLabel->setText(title);
346 logoLabel->setPixmap(logo);
347
348 subTitleLabel->setTextFormat(subTitleFormat);
349 subTitleLabel->setText("Pq\nPq"_L1);
350 int desiredSubTitleHeight = subTitleLabel->sizeHint().height();
351 subTitleLabel->setText(subTitle);
352
353 if (modern) {
354 bannerPixmap = banner;
355 } else {
356 bannerPixmap = QPixmap();
357 }
358
359 if (bannerPixmap.isNull()) {
360 /*
361 There is no widthForHeight() function, so we simulate it with a loop.
362 */
363 int candidateSubTitleWidth = qMin(512, 2 * QGuiApplication::primaryScreen()->virtualGeometry().width() / 3);
364 int delta = candidateSubTitleWidth >> 1;
365 while (delta > 0) {
366 if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta)
367 <= desiredSubTitleHeight)
368 candidateSubTitleWidth -= delta;
369 delta >>= 1;
370 }
371
372 subTitleLabel->setMinimumSize(candidateSubTitleWidth, desiredSubTitleHeight);
373
374 QSize size = layout->totalMinimumSize();
377 } else {
378 subTitleLabel->setMinimumSize(0, 0);
379 setFixedSize(banner.size() + QSize(0, 2));
380 }
382}
383
385{
387 painter.drawPixmap(0, 0, bannerPixmap);
388
389 int x = width() - 2;
390 int y = height() - 2;
391 const QPalette &pal = palette();
392 painter.setPen(pal.mid().color());
393 painter.drawLine(0, y, x, y);
394 painter.setPen(pal.base().color());
395 painter.drawPoint(x + 1, y);
396 painter.drawLine(0, y + 1, x + 1, y + 1);
397}
398
399// We save one vtable by basing QWizardRuler on QWizardHeader
401{
402public:
403 inline QWizardRuler(QWidget *parent = nullptr)
405};
406
408{
409public:
411 m_layout = new QVBoxLayout(this);
412 if (m_sideWidget)
413 m_layout->addWidget(m_sideWidget);
414 }
415
416 QSize minimumSizeHint() const override {
417 if (!pixmap().isNull())
420 }
421
423 if (m_sideWidget == widget)
424 return;
425 if (m_sideWidget) {
426 m_layout->removeWidget(m_sideWidget);
427 m_sideWidget->hide();
428 }
429 m_sideWidget = widget;
430 if (m_sideWidget)
431 m_layout->addWidget(m_sideWidget);
432 }
434 return m_sideWidget;
435 }
436private:
437 QVBoxLayout *m_layout;
438 QWidget *m_sideWidget;
439};
440
442{
443 Q_DECLARE_PUBLIC(QWizardPage)
444
445public:
447
448 bool cachedIsComplete() const;
451
452 QWizard *wizard = nullptr;
456 QList<QWizardField> pendingFields;
458 bool explicitlyFinal = false;
459 bool commit = false;
460 bool initialized = false;
461 QMap<int, QString> buttonCustomTexts;
462};
463
465{
466 Q_Q(const QWizardPage);
468 completeState = q->isComplete() ? Tri_True : Tri_False;
469 return completeState == Tri_True;
470}
471
473{
474 Q_Q(QWizardPage);
475 TriState newState = q->isComplete() ? Tri_True : Tri_False;
476 if (newState != completeState)
477 emit q->completeChanged();
478}
479
485
487{
488public:
489#if QT_CONFIG(style_windowsvista)
490 QWizardPrivate *wizardPrivate;
491 QWizardAntiFlickerWidget(QWizard *wizard, QWizardPrivate *wizardPrivate)
492 : QWidget(wizard)
493 , wizardPrivate(wizardPrivate) {}
494protected:
495 void paintEvent(QPaintEvent *) override;
496#else
498 : QWidget(wizard)
499 {}
500#endif
501};
502
504{
505 Q_DECLARE_PUBLIC(QWizard)
506
507public:
508 typedef QMap<int, QWizardPage *> PageMap;
509
514
515 void init();
516 void reset();
518 void addField(const QWizardField &field);
519 void removeFieldAt(int index);
520 void switchToPage(int newId, Direction direction);
523 void updateLayout();
524 void updatePalette();
526 void updateCurrentPage();
527 bool ensureButton(QWizard::WizardButton which) const;
528 void connectButton(QWizard::WizardButton which) const;
529 void updateButtonTexts();
530 void updateButtonLayout();
534#if QT_CONFIG(style_windowsvista)
535 bool vistaDisabled() const;
536 bool handleAeroStyleChange();
537#endif
538 bool isVistaThemeEnabled() const;
539 void disableUpdates();
540 void enableUpdates();
544 void setStyle(QStyle *style);
545#ifdef Q_OS_MACOS
546 static QPixmap findDefaultBackgroundPixmap();
547#endif
548
550 QList<QWizardField> fields;
551 QMap<QString, int> fieldIndexMap;
552 QList<QWizardDefaultProperty> defaultPropertyTable;
553 QList<int> history;
554 int start = -1;
555 bool startSetByUser = false;
556 int current = -1;
557 bool canContinue = false;
558 bool canFinish = false;
561
563 QWizard::WizardOptions opts;
564 QMap<int, QString> buttonCustomTexts;
566 QList<QWizard::WizardButton> buttonsCustomLayout;
570
571 union {
572 // keep in sync with QWizard::WizardButton
573 mutable struct {
582 };
588 QWidget *sideWidget = nullptr;
589 QFrame *pageFrame = nullptr;
590 QLabel *titleLabel = nullptr;
593
597
598#if QT_CONFIG(style_windowsvista)
599 QVistaHelper *vistaHelper = nullptr;
600# if QT_CONFIG(shortcut)
601 QPointer<QShortcut> vistaNextShortcut;
602# endif
603 bool vistaInitPending = true;
604 bool vistaDirty = true;
605 bool vistaStateChanged = false;
606 bool inHandleAeroStyleChange = false;
607#endif
612};
613
614static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate)
615{
616#if !QT_CONFIG(style_windowsvista)
617 Q_UNUSED(wizardPrivate);
618#endif
619 const bool macStyle = (wstyle == QWizard::MacStyle);
620 switch (which) {
622 return macStyle ? QWizard::tr("Go Back") : QWizard::tr("< &Back");
624 if (macStyle)
625 return QWizard::tr("Continue");
626 else
627 return wizardPrivate->isVistaThemeEnabled()
628 ? QWizard::tr("&Next") : QWizard::tr("&Next >");
630 return QWizard::tr("Commit");
632 return macStyle ? QWizard::tr("Done") : QWizard::tr("&Finish");
634 return QWizard::tr("Cancel");
636 return macStyle ? QWizard::tr("Help") : QWizard::tr("&Help");
637 default:
638 return QString();
639 }
640}
641
643{
644 Q_Q(QWizard);
645
646 std::fill(btns, btns + QWizard::NButtons, nullptr);
647
649 wizStyle = QWizard::WizardStyle(q->style()->styleHint(QStyle::SH_WizardStyle, nullptr, q));
652 } else if (wizStyle == QWizard::ModernStyle) {
654 }
655
656#if QT_CONFIG(style_windowsvista)
657 vistaHelper = new QVistaHelper(q);
658#endif
659
660 // create these buttons right away; create the other buttons as necessary
665
668
673 pageVBoxLayout->addItem(spacerItem);
674
678
680
682 for (uint i = 0; i < NFallbackDefaultProperties; ++i)
685 changed_signal(i)));
686}
687
689{
690 Q_Q(QWizard);
691 if (current != -1) {
692 q->currentPage()->hide();
694 const auto end = history.crend();
695 for (auto it = history.crbegin(); it != end; ++it)
696 q->cleanupPage(*it);
697 history.clear();
698 for (QWizardPage *page : std::as_const(pageMap))
699 page->d_func()->initialized = false;
700
701 current = -1;
702 emit q->currentIdChanged(-1);
703 }
704}
705
707{
708 Q_Q(QWizard);
709
710 for (auto it = pageMap.begin(), end = pageMap.end(); it != end; ++it) {
711 const auto idx = it.key();
712 const auto page = it.value()->d_func();
713 if (page->initialized && !history.contains(idx)) {
714 q->cleanupPage(idx);
715 page->initialized = false;
716 }
717 }
718}
719
721{
722 Q_Q(QWizard);
723
724 QWizardField myField = field;
726
727 if (Q_UNLIKELY(fieldIndexMap.contains(myField.name))) {
728 qWarning("QWizardPage::addField: Duplicate field '%ls'", qUtf16Printable(myField.name));
729 return;
730 }
731
732 fieldIndexMap.insert(myField.name, fields.size());
733 fields += myField;
734 if (myField.mandatory && !myField.changedSignal.isEmpty())
735 QObject::connect(myField.object, myField.changedSignal,
736 myField.page, SLOT(_q_maybeEmitCompleteChanged()));
738 myField.object, SIGNAL(destroyed(QObject*)), q,
740}
741
743{
744 Q_Q(QWizard);
745
746 const QWizardField &field = fields.at(index);
748 if (field.mandatory && !field.changedSignal.isEmpty())
750 field.page, SLOT(_q_maybeEmitCompleteChanged()));
752 field.object, SIGNAL(destroyed(QObject*)), q,
755}
756
758{
759 Q_Q(QWizard);
760
762
763 int oldId = current;
764 if (QWizardPage *oldPage = q->currentPage()) {
765 oldPage->hide();
766
767 if (direction == Backward) {
769 q->cleanupPage(oldId);
770 oldPage->d_func()->initialized = false;
771 }
772 Q_ASSERT(history.constLast() == oldId);
774 Q_ASSERT(history.constLast() == newId);
775 }
776 }
777
778 current = newId;
779
780 QWizardPage *newPage = q->currentPage();
781 if (newPage) {
782 if (direction == Forward) {
783 if (!newPage->d_func()->initialized) {
784 newPage->d_func()->initialized = true;
786 }
788 }
789 newPage->show();
790 }
791
792 canContinue = (q->nextId() != -1);
793 canFinish = (newPage && newPage->isFinalPage());
794
797
798 const QWizard::WizardButton nextOrCommit =
800 QAbstractButton *nextOrFinishButton =
801 btns[canContinue ? nextOrCommit : QWizard::FinishButton];
802 QWidget *candidate = nullptr;
803
804 /*
805 If there is no default button and the Next or Finish button
806 is enabled, give focus directly to it as a convenience to the
807 user. This is the normal case on OS X.
808
809 Otherwise, give the focus to the new page's first child that
810 can handle it. If there is no such child, give the focus to
811 Next or Finish.
812 */
813 if ((opts & QWizard::NoDefaultButton) && nextOrFinishButton->isEnabled()) {
814 candidate = nextOrFinishButton;
815 } else if (newPage) {
816 candidate = iWantTheFocus(newPage);
817 }
818 if (!candidate)
819 candidate = nextOrFinishButton;
820 candidate->setFocus();
821
823 q->updateGeometry();
824
826 updateLayout();
828
829 emit q->currentIdChanged(current);
830}
831
832// keep in sync with QWizard::WizardButton
833static const char * buttonSlots(QWizard::WizardButton which)
834{
835 switch (which) {
837 return SLOT(back());
840 return SLOT(next());
842 return SLOT(accept());
844 return SLOT(reject());
846 return SIGNAL(helpRequested());
850 case QWizard::Stretch:
852 Q_UNREACHABLE();
853 };
854 return nullptr;
855};
856
858{
859 Q_Q(QWizard);
860 QStyle *style = q->style();
861
863
866 const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &option, q);
867 info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q);
868 info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q);
869 info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, q);
870 info.topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, q);
871 info.childMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, titleLabel);
872 info.childMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, titleLabel);
873 info.childMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, titleLabel);
874 info.childMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, titleLabel);
875 info.hspacing = (layoutHorizontalSpacing == -1)
877 : layoutHorizontalSpacing;
879 info.buttonSpacing = (layoutHorizontalSpacing == -1)
881 : layoutHorizontalSpacing;
882
884 info.buttonSpacing = 12;
885
886 info.wizStyle = wizStyle;
887 if (info.wizStyle == QWizard::AeroStyle
888#if QT_CONFIG(style_windowsvista)
889 && vistaDisabled()
890#endif
891 )
892 info.wizStyle = QWizard::ModernStyle;
893
894 QString titleText;
895 QString subTitleText;
896 QPixmap backgroundPixmap;
897 QPixmap watermarkPixmap;
898
899 if (QWizardPage *page = q->currentPage()) {
900 titleText = page->title();
901 subTitleText = page->subTitle();
902 backgroundPixmap = page->pixmap(QWizard::BackgroundPixmap);
903 watermarkPixmap = page->pixmap(QWizard::WatermarkPixmap);
904 }
905
906 info.header = (info.wizStyle == QWizard::ClassicStyle || info.wizStyle == QWizard::ModernStyle)
907 && !(opts & QWizard::IgnoreSubTitles) && !subTitleText.isEmpty();
908 info.sideWidget = sideWidget;
909 info.watermark = (info.wizStyle != QWizard::MacStyle) && (info.wizStyle != QWizard::AeroStyle)
910 && !watermarkPixmap.isNull();
911 info.title = !info.header && !titleText.isEmpty();
912 info.subTitle = !(opts & QWizard::IgnoreSubTitles) && !info.header && !subTitleText.isEmpty();
913 info.extension = (info.watermark || info.sideWidget) && (opts & QWizard::ExtendedWatermarkPixmap);
914
915 return info;
916}
917
919{
920 Q_Q(QWizard);
921
922 /*
923 Start by undoing the main layout.
924 */
925 for (int i = mainLayout->count() - 1; i >= 0; --i) {
927 if (item->layout()) {
928 item->layout()->setParent(nullptr);
929 } else {
930 delete item;
931 }
932 }
933 for (int i = mainLayout->columnCount() - 1; i >= 0; --i)
935 for (int i = mainLayout->rowCount() - 1; i >= 0; --i)
937
938 /*
939 Now, recreate it.
940 */
941
942 bool mac = (info.wizStyle == QWizard::MacStyle);
943 bool classic = (info.wizStyle == QWizard::ClassicStyle);
944 bool modern = (info.wizStyle == QWizard::ModernStyle);
945 bool aero = (info.wizStyle == QWizard::AeroStyle);
946 int deltaMarginLeft = info.topLevelMarginLeft - info.childMarginLeft;
947 int deltaMarginRight = info.topLevelMarginRight - info.childMarginRight;
948 int deltaMarginTop = info.topLevelMarginTop - info.childMarginTop;
949 int deltaMarginBottom = info.topLevelMarginBottom - info.childMarginBottom;
950 int deltaVSpacing = info.topLevelMarginBottom - info.vspacing;
951
952 int row = 0;
953 int numColumns;
954 if (mac) {
955 numColumns = 3;
956 } else if (info.watermark || info.sideWidget) {
957 numColumns = 2;
958 } else {
959 numColumns = 1;
960 }
961 int pageColumn = qMin(1, numColumns - 1);
962
963 if (mac) {
968 } else {
969 if (modern) {
972 pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop,
973 deltaMarginRight, deltaMarginBottom);
974 buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
975 info.topLevelMarginRight, info.topLevelMarginBottom);
976 } else {
977 mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
978 info.topLevelMarginRight, info.topLevelMarginBottom);
982 buttonLayout->setContentsMargins(0, 0, 0, 0);
983 }
984 }
985 buttonLayout->setSpacing(info.buttonSpacing);
986
987 if (info.header) {
988 if (!headerWidget)
991 mainLayout->addWidget(headerWidget, row++, 0, 1, numColumns);
992 }
993 if (headerWidget)
995
996 int watermarkStartRow = row;
997
998 if (mac)
1000
1001 if (info.title) {
1002 if (!titleLabel) {
1005 titleLabel->setWordWrap(true);
1006 }
1007
1008 QFont titleFont = q->font();
1009 titleFont.setPointSize(titleFont.pointSize() + (mac ? 3 : 4));
1010 titleFont.setBold(true);
1012
1013 if (aero) {
1014 // ### hardcoded for now:
1015 titleFont = QFont("Segoe UI"_L1, 12);
1016 QPalette pal(titleLabel->palette());
1017 pal.setColor(QPalette::Text, QColor(0x00, 0x33, 0x99));
1018 titleLabel->setPalette(pal);
1019 }
1020
1021 titleLabel->setFont(titleFont);
1022 const int aeroTitleIndent = 25; // ### hardcoded for now - should be calculated somehow
1023 if (aero)
1024 titleLabel->setIndent(aeroTitleIndent);
1025 else if (mac)
1027 else if (classic)
1028 titleLabel->setIndent(info.childMarginLeft);
1029 else
1030 titleLabel->setIndent(info.topLevelMarginLeft);
1031 if (modern) {
1032 if (!placeholderWidget1) {
1035 }
1036 placeholderWidget1->setFixedHeight(info.topLevelMarginLeft + 2);
1037 mainLayout->addWidget(placeholderWidget1, row++, pageColumn);
1038 }
1039 mainLayout->addWidget(titleLabel, row++, pageColumn);
1040 if (modern) {
1041 if (!placeholderWidget2) {
1044 }
1046 mainLayout->addWidget(placeholderWidget2, row++, pageColumn);
1047 }
1048 if (mac)
1050 }
1052 placeholderWidget1->setVisible(info.title && modern);
1054 placeholderWidget2->setVisible(info.title && modern);
1055
1056 if (info.subTitle) {
1057 if (!subTitleLabel) {
1060
1061 subTitleLabel->setContentsMargins(info.childMarginLeft , 0,
1062 info.childMarginRight , 0);
1063
1065 }
1066 }
1067
1068 // ### try to replace with margin.
1069 changeSpacerSize(pageVBoxLayout, 0, 0, info.subTitle ? info.childMarginLeft : 0);
1070
1071 int hMargin = mac ? 1 : 0;
1072 int vMargin = hMargin;
1073
1077
1078 if (info.header) {
1079 if (modern) {
1080 hMargin = info.topLevelMarginLeft;
1081 vMargin = deltaMarginBottom;
1082 } else if (classic) {
1083 hMargin = deltaMarginLeft + ClassicHMargin;
1084 vMargin = 0;
1085 }
1086 }
1087
1088 if (aero) {
1089 int leftMargin = 18; // ### hardcoded for now - should be calculated somehow
1090 int topMargin = vMargin;
1091 int rightMargin = hMargin; // ### for now
1092 int bottomMargin = vMargin;
1093 pageFrame->setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin);
1094 } else {
1096 }
1097
1098 if ((info.watermark || info.sideWidget) && !watermarkLabel) {
1104 }
1105
1106 //bool wasSemiTransparent = pageFrame->testAttribute(Qt::WA_SetPalette);
1107 const bool wasSemiTransparent =
1110 if (mac) {
1113 } else {
1114 if (wasSemiTransparent)
1116
1117 bool baseBackground = (modern && !info.header); // ### TAG1
1119
1120 if (titleLabel)
1121 titleLabel->setAutoFillBackground(baseBackground);
1122 pageFrame->setAutoFillBackground(baseBackground);
1123 if (watermarkLabel)
1124 watermarkLabel->setAutoFillBackground(baseBackground);
1129
1130 if (aero) {
1131 QPalette pal = pageFrame->palette();
1132 pal.setBrush(QPalette::Window, QColor(255, 255, 255));
1133 pageFrame->setPalette(pal);
1135 pal = antiFlickerWidget->palette();
1136 pal.setBrush(QPalette::Window, QColor(255, 255, 255));
1139 }
1140 }
1141
1142 mainLayout->addWidget(pageFrame, row++, pageColumn);
1143
1144 int watermarkEndRow = row;
1145 if (classic)
1146 mainLayout->setRowMinimumHeight(row++, deltaVSpacing);
1147
1148 if (aero) {
1149 buttonLayout->setContentsMargins(9, 9, 9, 9);
1150 mainLayout->setContentsMargins(0, 11, 0, 0);
1151 }
1152
1153 int buttonStartColumn = info.extension ? 1 : 0;
1154 int buttonNumColumns = info.extension ? 1 : numColumns;
1155
1156 if (classic || modern) {
1157 if (!bottomRuler)
1159 mainLayout->addWidget(bottomRuler, row++, buttonStartColumn, 1, buttonNumColumns);
1160 }
1161
1162 if (classic)
1163 mainLayout->setRowMinimumHeight(row++, deltaVSpacing);
1164
1165 mainLayout->addLayout(buttonLayout, row++, buttonStartColumn, 1, buttonNumColumns);
1166
1167 if (info.watermark || info.sideWidget) {
1168 if (info.extension)
1169 watermarkEndRow = row;
1170 mainLayout->addWidget(watermarkLabel, watermarkStartRow, 0,
1171 watermarkEndRow - watermarkStartRow, 1);
1172 }
1173
1174 mainLayout->setColumnMinimumWidth(0, mac && !info.watermark ? 181 : 0);
1175 if (mac)
1177
1178 if (headerWidget)
1179 headerWidget->setVisible(info.header);
1180 if (titleLabel)
1181 titleLabel->setVisible(info.title);
1182 if (subTitleLabel)
1183 subTitleLabel->setVisible(info.subTitle);
1184 if (bottomRuler)
1185 bottomRuler->setVisible(classic || modern);
1186 if (watermarkLabel)
1187 watermarkLabel->setVisible(info.watermark || info.sideWidget);
1188
1189 layoutInfo = info;
1190}
1191
1193{
1194 Q_Q(QWizard);
1195
1197
1199 if (layoutInfo != info)
1201 QWizardPage *page = q->currentPage();
1202
1203 // If the page can expand vertically, let it stretch "infinitely" more
1204 // than the QSpacerItem at the bottom. Otherwise, let the QSpacerItem
1205 // stretch "infinitely" more than the page. Change the bottom item's
1206 // policy accordingly. The case that the page has no layout is basically
1207 // for Designer, only.
1208 if (page) {
1209 bool expandPage = !page->layout();
1210 if (!expandPage) {
1212 expandPage = pageItem->expandingDirections() & Qt::Vertical;
1213 }
1214 QSpacerItem *bottomSpacer = pageVBoxLayout->itemAt(pageVBoxLayout->count() - 1)->spacerItem();
1215 Q_ASSERT(bottomSpacer);
1216 bottomSpacer->changeSize(0, 0, QSizePolicy::Ignored, expandPage ? QSizePolicy::Ignored : QSizePolicy::MinimumExpanding);
1218 }
1219
1220 if (info.header) {
1221 Q_ASSERT(page);
1222 headerWidget->setup(info, page->title(), page->subTitle(),
1225 }
1226
1227 if (info.watermark || info.sideWidget) {
1228 QPixmap pix;
1229 if (info.watermark) {
1230 if (page)
1232 else
1233 pix = q->pixmap(QWizard::WatermarkPixmap);
1234 }
1235 watermarkLabel->setPixmap(pix); // in case there is no watermark and we show the side widget we need to clear the watermark
1236 }
1237
1238 if (info.title) {
1239 Q_ASSERT(page);
1241 titleLabel->setText(page->title());
1242 }
1243 if (info.subTitle) {
1244 Q_ASSERT(page);
1246 subTitleLabel->setText(page->subTitle());
1247 }
1248
1249 enableUpdates();
1251}
1252
1254 if (wizStyle == QWizard::MacStyle) {
1255 // This is required to ensure visual semitransparency when
1256 // switching from ModernStyle to MacStyle.
1257 // See TAG1 in recreateLayout
1258 // This additionally ensures that the colors are correct
1259 // when the theme is changed.
1260
1261 // we should base the new palette on the default one
1262 // so theme colors will be correct
1264
1265 QColor windowColor = newPalette.brush(QPalette::Window).color();
1266 windowColor.setAlpha(153);
1267 newPalette.setBrush(QPalette::Window, windowColor);
1268
1269 QColor baseColor = newPalette.brush(QPalette::Base).color();
1270 baseColor.setAlpha(153);
1271 newPalette.setBrush(QPalette::Base, baseColor);
1272
1273 pageFrame->setPalette(newPalette);
1274 }
1275}
1276
1278{
1279 Q_Q(QWizard);
1280
1281 int extraHeight = 0;
1282#if QT_CONFIG(style_windowsvista)
1283 if (isVistaThemeEnabled())
1284 extraHeight = vistaHelper->titleBarSize() + vistaHelper->topOffset(q);
1285#endif
1286 QSize minimumSize = mainLayout->totalMinimumSize() + QSize(0, extraHeight);
1287 QSize maximumSize = mainLayout->totalMaximumSize();
1288 if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) {
1289 minimumSize.setWidth(headerWidget->maximumWidth());
1290 maximumSize.setWidth(headerWidget->maximumWidth());
1291 }
1292 if (info.watermark && !info.sideWidget) {
1293 minimumSize.setHeight(mainLayout->totalSizeHint().height());
1294 }
1295 if (q->minimumWidth() == minimumWidth) {
1296 minimumWidth = minimumSize.width();
1297 q->setMinimumWidth(minimumWidth);
1298 }
1299 if (q->minimumHeight() == minimumHeight) {
1300 minimumHeight = minimumSize.height();
1301 q->setMinimumHeight(minimumHeight);
1302 }
1303 if (q->maximumWidth() == maximumWidth) {
1304 maximumWidth = maximumSize.width();
1305 q->setMaximumWidth(maximumWidth);
1306 }
1307 if (q->maximumHeight() == maximumHeight) {
1308 maximumHeight = maximumSize.height();
1309 q->setMaximumHeight(maximumHeight);
1310 }
1311}
1312
1314{
1315 Q_Q(QWizard);
1316 if (q->currentPage()) {
1317 canContinue = (q->nextId() != -1);
1318 canFinish = q->currentPage()->isFinalPage();
1319 } else {
1320 canContinue = false;
1321 canFinish = false;
1322 }
1325}
1326
1328{
1329 switch (which) {
1331 return u"qt_wizard_commit"_s;
1333 return u"qt_wizard_finish"_s;
1335 return u"qt_wizard_cancel"_s;
1342 // Make navigation buttons detectable as passive interactor in designer
1343 return "__qt__passive_wizardbutton"_L1 + QString::number(which);
1344 case QWizard::Stretch:
1345 case QWizard::NoButton:
1346 //case QWizard::NStandardButtons:
1347 //case QWizard::NButtons:
1348 ;
1349 }
1350 Q_UNREACHABLE_RETURN(QString());
1351}
1352
1354{
1355 Q_Q(const QWizard);
1356 if (uint(which) >= QWizard::NButtons)
1357 return false;
1358
1359 if (!btns[which]) {
1361 QStyle *style = q->style();
1362 if (style != QApplication::style()) // Propagate style
1363 pushButton->setStyle(style);
1365#ifdef Q_OS_MACOS
1366 pushButton->setAutoDefault(false);
1367#endif
1368 pushButton->hide();
1369#ifdef Q_CC_HPACC
1370 const_cast<QWizardPrivate *>(this)->btns[which] = pushButton;
1371#else
1372 btns[which] = pushButton;
1373#endif
1374 if (which < QWizard::NStandardButtons)
1376
1377 connectButton(which);
1378 }
1379 return true;
1380}
1381
1383{
1384 Q_Q(const QWizard);
1385 if (which < QWizard::NStandardButtons) {
1386 QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots(which));
1387 } else {
1389 }
1390}
1391
1393{
1394 Q_Q(QWizard);
1395 for (int i = 0; i < QWizard::NButtons; ++i) {
1396 if (btns[i]) {
1397 if (q->currentPage() && (q->currentPage()->d_func()->buttonCustomTexts.contains(i)))
1398 btns[i]->setText(q->currentPage()->d_func()->buttonCustomTexts.value(i));
1399 else if (buttonCustomTexts.contains(i))
1401 else if (i < QWizard::NStandardButtons)
1403 }
1404 }
1405 // Vista: Add shortcut for 'next'. Note: native dialogs use ALT-Right
1406 // even in RTL mode, so do the same, even if it might be counter-intuitive.
1407 // The shortcut for 'back' is set in class QVistaBackButton.
1408#if QT_CONFIG(shortcut) && QT_CONFIG(style_windowsvista)
1410 if (vistaNextShortcut.isNull()) {
1411 vistaNextShortcut =
1414 }
1415 } else {
1416 delete vistaNextShortcut;
1417 }
1418#endif // shortcut && style_windowsvista
1419}
1420
1422{
1424 QVarLengthArray<QWizard::WizardButton, QWizard::NButtons> array{
1426 setButtonLayout(array.constData(), int(array.size()));
1427 } else {
1428 // Positions:
1429 // Help Stretch Custom1 Custom2 Custom3 Cancel Back Next Commit Finish Cancel Help
1430
1431 const int ArraySize = 12;
1432 QWizard::WizardButton array[ArraySize];
1433 memset(array, -1, sizeof(array));
1435
1437 int i = (opts & QWizard::HelpButtonOnRight) ? 11 : 0;
1439 }
1447
1448 if (!(opts & QWizard::NoCancelButton)) {
1449 int i = (opts & QWizard::CancelButtonOnLeft) ? 5 : 10;
1451 }
1456
1457 setButtonLayout(array, ArraySize);
1458 }
1459}
1460
1462{
1463 QWidget *prev = pageFrame;
1464
1465 for (int i = buttonLayout->count() - 1; i >= 0; --i) {
1467 if (QWidget *widget = item->widget())
1468 widget->hide();
1469 delete item;
1470 }
1471
1472 for (int i = 0; i < size; ++i) {
1473 QWizard::WizardButton which = array[i];
1474 if (which == QWizard::Stretch) {
1476 } else if (which != QWizard::NoButton) {
1477 ensureButton(which);
1478 buttonLayout->addWidget(btns[which]);
1479
1480 // Back, Next, Commit, and Finish are handled in _q_updateButtonStates()
1481 if (which != QWizard::BackButton && which != QWizard::NextButton
1482 && which != QWizard::CommitButton && which != QWizard::FinishButton)
1483 btns[which]->show();
1484
1485 if (prev)
1486 QWidget::setTabOrder(prev, btns[which]);
1487 prev = btns[which];
1488 }
1489 }
1490
1492}
1493
1498
1500{
1501 Q_Q(QWizard);
1502 if (which == QWizard::BackgroundPixmap) {
1503 if (wizStyle == QWizard::MacStyle) {
1504 q->update();
1505 q->updateGeometry();
1506 }
1507 } else {
1508 updateLayout();
1509 }
1510}
1511
1512#if QT_CONFIG(style_windowsvista)
1513bool QWizardPrivate::vistaDisabled() const
1514{
1515 Q_Q(const QWizard);
1516 const QVariant v = q->property("_q_wizard_vista_off");
1517 return v.isValid() && v.toBool();
1518}
1519
1520bool QWizardPrivate::handleAeroStyleChange()
1521{
1522 Q_Q(QWizard);
1523
1524 if (inHandleAeroStyleChange)
1525 return false; // prevent recursion
1526 // For top-level wizards, we need the platform window handle for the
1527 // DWM changes. Delay aero initialization to the show event handling if
1528 // it does not exist. If we are a child, skip DWM and just make room by
1529 // moving the antiFlickerWidget.
1530 const bool isWindow = q->isWindow();
1531 if (isWindow && (!q->windowHandle() || !q->windowHandle()->handle()))
1532 return false;
1533 inHandleAeroStyleChange = true;
1534
1535 vistaHelper->disconnectBackButton();
1536 q->removeEventFilter(vistaHelper);
1537
1538 bool vistaMargins = false;
1539
1540 if (isVistaThemeEnabled()) {
1541 const int topOffset = vistaHelper->topOffset(q);
1542 const int topPadding = vistaHelper->topPadding(q);
1543 if (isWindow) {
1544 vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar);
1545 q->installEventFilter(vistaHelper);
1546 }
1547 q->setMouseTracking(true);
1548 antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset);
1549 vistaHelper->backButton()->move(
1550 0, topOffset // ### should ideally work without the '+ 1'
1551 - qMin(topOffset, topPadding + 1));
1552 vistaMargins = true;
1553 vistaHelper->backButton()->show();
1554 if (isWindow)
1555 vistaHelper->setTitleBarIconAndCaptionVisible(false);
1557 vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots(QWizard::BackButton));
1558 vistaHelper->backButton()->show();
1559 } else {
1560 q->setMouseTracking(true); // ### original value possibly different
1561#ifndef QT_NO_CURSOR
1562 q->unsetCursor(); // ### ditto
1563#endif
1564 antiFlickerWidget->move(0, 0);
1565 vistaHelper->hideBackButton();
1566 if (isWindow)
1567 vistaHelper->setTitleBarIconAndCaptionVisible(true);
1568 }
1569
1571
1572 vistaHelper->updateCustomMargins(vistaMargins);
1573
1574 inHandleAeroStyleChange = false;
1575 return true;
1576}
1577#endif
1578
1580{
1581#if QT_CONFIG(style_windowsvista)
1582 return wizStyle == QWizard::AeroStyle && !vistaDisabled();
1583#else
1584 return false;
1585#endif
1586}
1587
1589{
1590 Q_Q(QWizard);
1591 if (disableUpdatesCount++ == 0) {
1592 q->setUpdatesEnabled(false);
1594 }
1595}
1596
1598{
1599 Q_Q(QWizard);
1600 if (--disableUpdatesCount == 0) {
1602 q->setUpdatesEnabled(true);
1603 }
1604}
1605
1607{
1608 Q_Q(QWizard);
1609 QObject *button = q->sender();
1610 for (int i = QWizard::NStandardButtons; i < QWizard::NButtons; ++i) {
1611 if (btns[i] == button) {
1612 emit q->customButtonClicked(QWizard::WizardButton(i));
1613 break;
1614 }
1615 }
1616}
1617
1619{
1620 Q_Q(QWizard);
1621
1623
1624 const QWizardPage *page = q->currentPage();
1625 bool complete = page && page->isComplete();
1626
1627 btn.back->setEnabled(history.size() > 1
1628 && !q->page(history.at(history.size() - 2))->isCommitPage()
1630 btn.next->setEnabled(canContinue && complete);
1631 btn.commit->setEnabled(canContinue && complete);
1632 btn.finish->setEnabled(canFinish && complete);
1633
1634 const bool backButtonVisible = buttonLayoutContains(QWizard::BackButton)
1637 bool commitPage = page && page->isCommitPage();
1638 btn.back->setVisible(backButtonVisible);
1639 btn.next->setVisible(buttonLayoutContains(QWizard::NextButton) && !commitPage
1641 btn.commit->setVisible(buttonLayoutContains(QWizard::CommitButton) && commitPage
1642 && canContinue);
1645
1649
1650 bool useDefault = !(opts & QWizard::NoDefaultButton);
1651 if (QPushButton *nextPush = qobject_cast<QPushButton *>(btn.next))
1652 nextPush->setDefault(canContinue && useDefault && !commitPage);
1653 if (QPushButton *commitPush = qobject_cast<QPushButton *>(btn.commit))
1654 commitPush->setDefault(canContinue && useDefault && commitPage);
1655 if (QPushButton *finishPush = qobject_cast<QPushButton *>(btn.finish))
1656 finishPush->setDefault(!canContinue && useDefault);
1657
1658#if QT_CONFIG(style_windowsvista)
1659 if (isVistaThemeEnabled()) {
1660 vistaHelper->backButton()->setEnabled(btn.back->isEnabled());
1661 vistaHelper->backButton()->setVisible(backButtonVisible);
1662 btn.back->setVisible(false);
1663 }
1664#endif
1665
1666 enableUpdates();
1667}
1668
1670{
1671 int destroyed_index = -1;
1673 while (it != fields.end()) {
1674 const QWizardField &field = *it;
1675 if (field.object == object) {
1676 destroyed_index = fieldIndexMap.value(field.name, -1);
1677 fieldIndexMap.remove(field.name);
1678 it = fields.erase(it);
1679 } else {
1680 ++it;
1681 }
1682 }
1683 if (destroyed_index != -1) {
1685 while (it2 != fieldIndexMap.end()) {
1686 int index = it2.value();
1687 if (index > destroyed_index) {
1688 QString field_name = it2.key();
1689 fieldIndexMap.insert(field_name, index-1);
1690 }
1691 ++it2;
1692 }
1693 }
1694}
1695
1697{
1698 for (int i = 0; i < QWizard::NButtons; i++)
1699 if (btns[i])
1700 btns[i]->setStyle(style);
1701 const PageMap::const_iterator pcend = pageMap.constEnd();
1702 for (PageMap::const_iterator it = pageMap.constBegin(); it != pcend; ++it)
1703 it.value()->setStyle(style);
1704}
1705
1706#ifdef Q_OS_MACOS
1707QPixmap QWizardPrivate::findDefaultBackgroundPixmap()
1708{
1709 auto *keyboardAssistantURL = [NSWorkspace.sharedWorkspace
1710 URLForApplicationWithBundleIdentifier:@"com.apple.KeyboardSetupAssistant"];
1711 auto *keyboardAssistantBundle = [NSBundle bundleWithURL:keyboardAssistantURL];
1712 auto *assistantBackground = [keyboardAssistantBundle imageForResource:@"Background"];
1713 auto size = QSizeF::fromCGSize(assistantBackground.size);
1714 static const QSizeF expectedSize(242, 414);
1715 if (size == expectedSize)
1716 return qt_mac_toQPixmap(assistantBackground, size);
1717
1718 return QPixmap();
1719}
1720#endif
1721
1722#if QT_CONFIG(style_windowsvista)
1724{
1725 if (wizardPrivate->isVistaThemeEnabled()) {
1726 int leftMargin, topMargin, rightMargin, bottomMargin;
1727 wizardPrivate->buttonLayout->getContentsMargins(
1728 &leftMargin, &topMargin, &rightMargin, &bottomMargin);
1729 const int buttonLayoutTop = wizardPrivate->buttonLayout->contentsRect().top() - topMargin;
1730 QPainter painter(this);
1731 const QBrush brush(QColor(240, 240, 240)); // ### hardcoded for now
1732 painter.fillRect(0, buttonLayoutTop, width(), height() - buttonLayoutTop, brush);
1733 painter.setPen(QPen(QBrush(QColor(223, 223, 223)), 0)); // ### hardcoded for now
1734 painter.drawLine(0, buttonLayoutTop, width(), buttonLayoutTop);
1735 }
1736}
1737#endif
1738
2125QWizard::QWizard(QWidget *parent, Qt::WindowFlags flags)
2126 : QDialog(*new QWizardPrivate, parent, flags)
2127{
2128 Q_D(QWizard);
2129 d->init();
2130}
2131
2136{
2137 Q_D(QWizard);
2138 delete d->buttonLayout;
2139}
2140
2150{
2151 Q_D(QWizard);
2152 int theid = 0;
2153 if (!d->pageMap.isEmpty())
2154 theid = d->pageMap.lastKey() + 1;
2155 setPage(theid, page);
2156 return theid;
2157}
2158
2170{
2171 Q_D(QWizard);
2172
2173 if (Q_UNLIKELY(!page)) {
2174 qWarning("QWizard::setPage: Cannot insert null page");
2175 return;
2176 }
2177
2178 if (Q_UNLIKELY(theid == -1)) {
2179 qWarning("QWizard::setPage: Cannot insert page with ID -1");
2180 return;
2181 }
2182
2183 if (Q_UNLIKELY(d->pageMap.contains(theid))) {
2184 qWarning("QWizard::setPage: Page with duplicate ID %d ignored", theid);
2185 return;
2186 }
2187
2188 page->setParent(d->pageFrame);
2189
2190 QList<QWizardField> &pendingFields = page->d_func()->pendingFields;
2191 for (const auto &field : std::as_const(pendingFields))
2192 d->addField(field);
2193 pendingFields.clear();
2194
2195 connect(page, SIGNAL(completeChanged()), this, SLOT(_q_updateButtonStates()));
2196
2197 d->pageMap.insert(theid, page);
2198 page->d_func()->wizard = this;
2199
2200 int n = d->pageVBoxLayout->count();
2201
2202 // disable layout to prevent layout updates while adding
2203 bool pageVBoxLayoutEnabled = d->pageVBoxLayout->isEnabled();
2204 d->pageVBoxLayout->setEnabled(false);
2205
2206 d->pageVBoxLayout->insertWidget(n - 1, page);
2207
2208 // hide new page and reset layout to old status
2209 page->hide();
2210 d->pageVBoxLayout->setEnabled(pageVBoxLayoutEnabled);
2211
2212 if (!d->startSetByUser && d->pageMap.constBegin().key() == theid)
2213 d->start = theid;
2214 emit pageAdded(theid);
2215}
2216
2226{
2227 Q_D(QWizard);
2228
2229 QWizardPage *removedPage = nullptr;
2230
2231 // update startItem accordingly
2232 if (d->pageMap.size() > 0) { // only if we have any pages
2233 if (d->start == id) {
2234 const int firstId = d->pageMap.constBegin().key();
2235 if (firstId == id) {
2236 if (d->pageMap.size() > 1)
2237 d->start = (++d->pageMap.constBegin()).key(); // secondId
2238 else
2239 d->start = -1; // removing the last page
2240 } else { // startSetByUser has to be "true" here
2241 d->start = firstId;
2242 }
2243 d->startSetByUser = false;
2244 }
2245 }
2246
2247 if (d->pageMap.contains(id))
2248 emit pageRemoved(id);
2249
2250 if (!d->history.contains(id)) {
2251 // Case 1: removing a page not in the history
2252 removedPage = d->pageMap.take(id);
2253 d->updateCurrentPage();
2254 } else if (id != d->current) {
2255 // Case 2: removing a page in the history before the current page
2256 removedPage = d->pageMap.take(id);
2257 d->history.removeOne(id);
2258 d->_q_updateButtonStates();
2259 } else if (d->history.size() == 1) {
2260 // Case 3: removing the current page which is the first (and only) one in the history
2261 d->reset();
2262 removedPage = d->pageMap.take(id);
2263 if (d->pageMap.isEmpty())
2264 d->updateCurrentPage();
2265 else
2266 restart();
2267 } else {
2268 // Case 4: removing the current page which is not the first one in the history
2269 back();
2270 removedPage = d->pageMap.take(id);
2271 d->updateCurrentPage();
2272 }
2273
2274 if (removedPage) {
2275 if (removedPage->d_func()->initialized) {
2276 cleanupPage(id);
2277 removedPage->d_func()->initialized = false;
2278 }
2279
2280 d->pageVBoxLayout->removeWidget(removedPage);
2281
2282 for (int i = d->fields.size() - 1; i >= 0; --i) {
2283 if (d->fields.at(i).page == removedPage) {
2284 removedPage->d_func()->pendingFields += d->fields.at(i);
2285 d->removeFieldAt(i);
2286 }
2287 }
2288 }
2289}
2290
2300{
2301 Q_D(const QWizard);
2302 return d->pageMap.value(theid);
2303}
2304
2315bool QWizard::hasVisitedPage(int theid) const
2316{
2317 Q_D(const QWizard);
2318 return d->history.contains(theid);
2319}
2320
2329QList<int> QWizard::visitedIds() const
2330{
2331 Q_D(const QWizard);
2332 return d->history;
2333}
2334
2339QList<int> QWizard::pageIds() const
2340{
2341 Q_D(const QWizard);
2342 return d->pageMap.keys();
2343}
2344
2355void QWizard::setStartId(int theid)
2356{
2357 Q_D(QWizard);
2358 int newStart = theid;
2359 if (theid == -1)
2360 newStart = d->pageMap.size() ? d->pageMap.constBegin().key() : -1;
2361
2362 if (d->start == newStart) {
2363 d->startSetByUser = theid != -1;
2364 return;
2365 }
2366
2367 if (Q_UNLIKELY(!d->pageMap.contains(newStart))) {
2368 qWarning("QWizard::setStartId: Invalid page ID %d", newStart);
2369 return;
2370 }
2371 d->start = newStart;
2372 d->startSetByUser = theid != -1;
2373}
2374
2376{
2377 Q_D(const QWizard);
2378 return d->start;
2379}
2380
2390{
2391 Q_D(const QWizard);
2392 return page(d->current);
2393}
2394
2408{
2409 Q_D(const QWizard);
2410 return d->current;
2411}
2412
2421{
2422 Q_D(QWizard);
2423
2424 int index = d->fieldIndexMap.value(name, -1);
2425 if (Q_UNLIKELY(index == -1)) {
2426 qWarning("QWizard::setField: No such field '%ls'", qUtf16Printable(name));
2427 return;
2428 }
2429
2430 const QWizardField &field = d->fields.at(index);
2431 if (Q_UNLIKELY(!field.object->setProperty(field.property, value)))
2432 qWarning("QWizard::setField: Couldn't write to property '%s'",
2433 field.property.constData());
2434}
2435
2444{
2445 Q_D(const QWizard);
2446
2447 int index = d->fieldIndexMap.value(name, -1);
2448 if (Q_UNLIKELY(index == -1)) {
2449 qWarning("QWizard::field: No such field '%ls'", qUtf16Printable(name));
2450 return QVariant();
2451 }
2452
2453 const QWizardField &field = d->fields.at(index);
2454 return field.object->property(field.property);
2455}
2456
2470{
2471 Q_D(QWizard);
2472
2473 const bool styleChange = style != d->wizStyle;
2474
2475#if QT_CONFIG(style_windowsvista)
2476 const bool aeroStyleChange =
2477 d->vistaInitPending || d->vistaStateChanged || (styleChange && (style == AeroStyle || d->wizStyle == AeroStyle));
2478 d->vistaStateChanged = false;
2479 d->vistaInitPending = false;
2480#endif
2481
2482 if (styleChange
2483#if QT_CONFIG(style_windowsvista)
2484 || aeroStyleChange
2485#endif
2486 ) {
2487 d->disableUpdates();
2488 d->wizStyle = style;
2489 d->updateButtonTexts();
2490#if QT_CONFIG(style_windowsvista)
2491 if (aeroStyleChange) {
2492 //Send a resizeevent since the antiflicker widget probably needs a new size
2493 //because of the backbutton in the window title
2494 QResizeEvent ev(geometry().size(), geometry().size());
2495 QCoreApplication::sendEvent(this, &ev);
2496 }
2497#endif
2498 d->updateLayout();
2500 d->enableUpdates();
2501#if QT_CONFIG(style_windowsvista)
2502 // Delay initialization when activating Aero style fails due to missing native window.
2503 if (aeroStyleChange && !d->handleAeroStyleChange() && d->wizStyle == AeroStyle)
2504 d->vistaInitPending = true;
2505#endif
2506 }
2507}
2508
2510{
2511 Q_D(const QWizard);
2512 return d->wizStyle;
2513}
2514
2522{
2523 Q_D(QWizard);
2524 if (!(d->opts & option) != !on)
2525 setOptions(d->opts ^ option);
2526}
2527
2535{
2536 Q_D(const QWizard);
2537 return (d->opts & option) != 0;
2538}
2539
2554void QWizard::setOptions(WizardOptions options)
2555{
2556 Q_D(QWizard);
2557
2558 WizardOptions changed = (options ^ d->opts);
2559 if (!changed)
2560 return;
2561
2562 d->disableUpdates();
2563
2564 d->opts = options;
2565 if ((changed & IndependentPages) && !(d->opts & IndependentPages))
2566 d->cleanupPagesNotInHistory();
2567
2570 | HaveCustomButton3)) {
2571 d->updateButtonLayout();
2572 } else if (changed & (NoBackButtonOnStartPage | NoBackButtonOnLastPage
2575 d->_q_updateButtonStates();
2576 }
2577
2578 d->enableUpdates();
2579 d->updateLayout();
2580}
2581
2582QWizard::WizardOptions QWizard::options() const
2583{
2584 Q_D(const QWizard);
2585 return d->opts;
2586}
2587
2606{
2607 Q_D(QWizard);
2608
2609 if (!d->ensureButton(which))
2610 return;
2611
2612 d->buttonCustomTexts.insert(which, text);
2613
2614 if (!currentPage() || !currentPage()->d_func()->buttonCustomTexts.contains(which))
2615 d->btns[which]->setText(text);
2616}
2617
2631{
2632 Q_D(const QWizard);
2633
2634 if (!d->ensureButton(which))
2635 return QString();
2636
2637 if (d->buttonCustomTexts.contains(which))
2638 return d->buttonCustomTexts.value(which);
2639
2640 const QString defText = buttonDefaultText(d->wizStyle, which, d);
2641 if (!defText.isNull())
2642 return defText;
2643
2644 return d->btns[which]->text();
2645}
2646
2665void QWizard::setButtonLayout(const QList<WizardButton> &layout)
2666{
2667 Q_D(QWizard);
2668
2669 for (int i = 0; i < layout.size(); ++i) {
2670 WizardButton button1 = layout.at(i);
2671
2672 if (button1 == NoButton || button1 == Stretch)
2673 continue;
2674 if (!d->ensureButton(button1))
2675 return;
2676
2677 // O(n^2), but n is very small
2678 for (int j = 0; j < i; ++j) {
2679 WizardButton button2 = layout.at(j);
2680 if (Q_UNLIKELY(button2 == button1)) {
2681 qWarning("QWizard::setButtonLayout: Duplicate button in layout");
2682 return;
2683 }
2684 }
2685 }
2686
2687 d->buttonsHaveCustomLayout = true;
2688 d->buttonsCustomLayout = layout;
2689 d->updateButtonLayout();
2690}
2691
2703{
2704 Q_D(QWizard);
2705
2706 if (uint(which) >= NButtons || d->btns[which] == button)
2707 return;
2708
2709 if (QAbstractButton *oldButton = d->btns[which]) {
2710 d->buttonLayout->removeWidget(oldButton);
2711 delete oldButton;
2712 }
2713
2714 d->btns[which] = button;
2715 if (button) {
2716 button->setParent(d->antiFlickerWidget);
2717 d->buttonCustomTexts.insert(which, button->text());
2718 d->connectButton(which);
2719 } else {
2720 d->buttonCustomTexts.remove(which); // ### what about page-specific texts set for 'which'
2721 d->ensureButton(which); // (QWizardPage::setButtonText())? Clear them as well?
2722 }
2723
2724 d->updateButtonLayout();
2725}
2726
2733{
2734 Q_D(const QWizard);
2735#if QT_CONFIG(style_windowsvista)
2736 if (d->wizStyle == AeroStyle && which == BackButton)
2737 return d->vistaHelper->backButton();
2738#endif
2739 if (!d->ensureButton(which))
2740 return nullptr;
2741 return d->btns[which];
2742}
2743
2753{
2754 Q_D(QWizard);
2755 d->titleFmt = format;
2756 d->updateLayout();
2757}
2758
2760{
2761 Q_D(const QWizard);
2762 return d->titleFmt;
2763}
2764
2774{
2775 Q_D(QWizard);
2776 d->subTitleFmt = format;
2777 d->updateLayout();
2778}
2779
2781{
2782 Q_D(const QWizard);
2783 return d->subTitleFmt;
2784}
2785
2799{
2800 Q_D(QWizard);
2801 Q_ASSERT(uint(which) < NPixmaps);
2802 d->defaultPixmaps[which] = pixmap;
2803 d->updatePixmap(which);
2804}
2805
2815{
2816 Q_D(const QWizard);
2817 Q_ASSERT(uint(which) < NPixmaps);
2818#ifdef Q_OS_MACOS
2819 if (which == BackgroundPixmap && d->defaultPixmaps[BackgroundPixmap].isNull())
2820 d->defaultPixmaps[BackgroundPixmap] = d->findDefaultBackgroundPixmap();
2821#endif
2822 return d->defaultPixmaps[which];
2823}
2824
2850void QWizard::setDefaultProperty(const char *className, const char *property,
2851 const char *changedSignal)
2852{
2853 Q_D(QWizard);
2854 for (int i = d->defaultPropertyTable.size() - 1; i >= 0; --i) {
2855 if (qstrcmp(d->defaultPropertyTable.at(i).className, className) == 0) {
2856 d->defaultPropertyTable.remove(i);
2857 break;
2858 }
2859 }
2860 d->defaultPropertyTable.append(QWizardDefaultProperty(className, property, changedSignal));
2861}
2862
2888{
2889 Q_D(QWizard);
2890
2891 d->sideWidget = widget;
2892 if (d->watermarkLabel) {
2893 d->watermarkLabel->setSideWidget(widget);
2894 d->updateLayout();
2895 }
2896}
2897
2906{
2907 Q_D(const QWizard);
2908
2909 return d->sideWidget;
2910}
2911
2915void QWizard::setVisible(bool visible)
2916{
2917 Q_D(QWizard);
2918 if (visible) {
2919 if (d->current == -1)
2920 restart();
2921 }
2923}
2924
2929{
2930 Q_D(const QWizard);
2931 QSize result = d->mainLayout->totalSizeHint();
2932 QSize extra(500, 360);
2933 if (d->wizStyle == MacStyle && d->current != -1) {
2935 extra.setWidth(616);
2936 if (!pixmap.isNull()) {
2937 extra.setHeight(pixmap.height());
2938
2939 /*
2940 The width isn't always reliable as a size hint, as
2941 some wizard backgrounds just cover the leftmost area.
2942 Use a rule of thumb to determine if the width is
2943 reliable or not.
2944 */
2945 if (pixmap.width() >= pixmap.height())
2946 extra.setWidth(pixmap.width());
2947 }
2948 }
2949 return result.expandedTo(extra);
2950}
2951
3032{
3033 Q_D(QWizard);
3034 int n = d->history.size() - 2;
3035 if (n < 0)
3036 return;
3037 d->switchToPage(d->history.at(n), QWizardPrivate::Backward);
3038}
3039
3048{
3049 Q_D(QWizard);
3050
3051 if (d->current == -1)
3052 return;
3053
3054 if (validateCurrentPage()) {
3055 int next = nextId();
3056 if (next != -1) {
3057 if (Q_UNLIKELY(d->history.contains(next))) {
3058 qWarning("QWizard::next: Page %d already met", next);
3059 return;
3060 }
3061 if (Q_UNLIKELY(!d->pageMap.contains(next))) {
3062 qWarning("QWizard::next: No such page %d", next);
3063 return;
3064 }
3065 d->switchToPage(next, QWizardPrivate::Forward);
3066 }
3067 }
3068}
3069
3086{
3087 Q_D(QWizard);
3088
3089 if (d->current == -1)
3090 return;
3091
3092 if (currentId() == id)
3093 return;
3094
3095 if (!validateCurrentPage())
3096 return;
3097
3098 if (id < 0 || Q_UNLIKELY(!d->pageMap.contains(id))) {
3099 qWarning("QWizard::setCurrentId: No such page: %d", id);
3100 return;
3101 }
3102
3103 d->switchToPage(id, (id < currentId()) ? QWizardPrivate::Backward : QWizardPrivate::Forward);
3104}
3105
3113{
3114 Q_D(QWizard);
3115 d->disableUpdates();
3116 d->reset();
3117 d->switchToPage(startId(), QWizardPrivate::Forward);
3118 d->enableUpdates();
3119}
3120
3125{
3126 Q_D(QWizard);
3127 if (event->type() == QEvent::StyleChange) { // Propagate style
3128 d->setStyle(style());
3129 d->updateLayout();
3130 } else if (event->type() == QEvent::PaletteChange) { // Emitted on theme change
3131 d->updatePalette();
3132 }
3133#if QT_CONFIG(style_windowsvista)
3134 else if (event->type() == QEvent::Show && d->vistaInitPending) {
3135 d->vistaInitPending = false;
3136 d->wizStyle = AeroStyle;
3137 d->handleAeroStyleChange();
3138 }
3139 else if (d->isVistaThemeEnabled()) {
3140 if (event->type() == QEvent::Resize
3141 || event->type() == QEvent::LayoutDirectionChange) {
3142 const int buttonLeft = (layoutDirection() == Qt::RightToLeft
3143 ? width() - d->vistaHelper->backButton()->sizeHint().width()
3144 : 0);
3145
3146 d->vistaHelper->backButton()->move(buttonLeft,
3147 d->vistaHelper->backButton()->y());
3148 }
3149
3150 d->vistaHelper->mouseEvent(event);
3151 }
3152#endif
3153 return QDialog::event(event);
3154}
3155
3160{
3161 Q_D(QWizard);
3162 int heightOffset = 0;
3163#if QT_CONFIG(style_windowsvista)
3164 if (d->isVistaThemeEnabled()) {
3165 heightOffset = d->vistaHelper->topOffset(this);
3166 heightOffset += d->vistaHelper->titleBarSize();
3167 }
3168#endif
3169 d->antiFlickerWidget->resize(event->size().width(), event->size().height() - heightOffset);
3170#if QT_CONFIG(style_windowsvista)
3171 if (d->isVistaThemeEnabled())
3172 d->vistaHelper->resizeEvent(event);
3173#endif
3175}
3176
3181{
3182 Q_D(QWizard);
3183 if (d->wizStyle == MacStyle && currentPage()) {
3184 QPixmap backgroundPixmap = currentPage()->pixmap(BackgroundPixmap);
3185 if (backgroundPixmap.isNull())
3186 return;
3187
3188 QStylePainter painter(this);
3189 painter.drawPixmap(0, (height() - backgroundPixmap.height()) / 2, backgroundPixmap);
3190 }
3191#if QT_CONFIG(style_windowsvista)
3192 else if (d->isVistaThemeEnabled()) {
3193 d->vistaHelper->paintEvent(event);
3194 }
3195#else
3196 Q_UNUSED(event);
3197#endif
3198}
3199
3200#if defined(Q_OS_WIN) || defined(Q_QDOC)
3204bool QWizard::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
3205{
3206#if QT_CONFIG(style_windowsvista)
3207 Q_D(QWizard);
3208 if (d->isVistaThemeEnabled() && eventType == "windows_generic_MSG") {
3209 MSG *windowsMessage = static_cast<MSG *>(message);
3210 const bool winEventResult = d->vistaHelper->handleWinEvent(windowsMessage, result);
3211 if (d->vistaDirty) {
3212 // QTBUG-78300: When Qt::AA_NativeWindows is set, delay further
3213 // window creation until after the platform window creation events.
3214 if (windowsMessage->message == WM_GETICON) {
3215 d->vistaStateChanged = true;
3216 d->vistaDirty = false;
3218 }
3219 }
3220 return winEventResult;
3221 } else {
3222 return QDialog::nativeEvent(eventType, message, result);
3223 }
3224#else
3225 return QDialog::nativeEvent(eventType, message, result);
3226#endif
3227}
3228#endif
3229
3234{
3235 Q_D(QWizard);
3236 // canceling leaves the wizard in a known state
3237 if (result == Rejected) {
3238 d->reset();
3239 } else {
3240 if (!validateCurrentPage())
3241 return;
3242 }
3244}
3245
3265{
3266 QWizardPage *page = this->page(theid);
3267 if (page)
3268 page->initializePage();
3269}
3270
3283{
3284 QWizardPage *page = this->page(theid);
3285 if (page)
3286 page->cleanupPage();
3287}
3288
3306{
3308 if (!page)
3309 return true;
3310
3311 return page->validatePage();
3312}
3313
3329{
3330 const QWizardPage *page = currentPage();
3331 if (!page)
3332 return -1;
3333
3334 return page->nextId();
3335}
3336
3415 : QWidget(*new QWizardPagePrivate, parent, { })
3416{
3417 connect(this, SIGNAL(completeChanged()), this, SLOT(_q_updateCachedCompleteState()));
3418}
3419
3426
3442{
3443 Q_D(QWizardPage);
3444 d->title = title;
3445 if (d->wizard && d->wizard->currentPage() == this)
3446 d->wizard->d_func()->updateLayout();
3447}
3448
3450{
3451 Q_D(const QWizardPage);
3452 return d->title;
3453}
3454
3475{
3476 Q_D(QWizardPage);
3477 d->subTitle = subTitle;
3478 if (d->wizard && d->wizard->currentPage() == this)
3479 d->wizard->d_func()->updateLayout();
3480}
3481
3483{
3484 Q_D(const QWizardPage);
3485 return d->subTitle;
3486}
3487
3502{
3503 Q_D(QWizardPage);
3505 d->pixmaps[which] = pixmap;
3506 if (d->wizard && d->wizard->currentPage() == this)
3507 d->wizard->d_func()->updatePixmap(which);
3508}
3509
3520{
3521 Q_D(const QWizardPage);
3523
3524 const QPixmap &pixmap = d->pixmaps[which];
3525 if (!pixmap.isNull())
3526 return pixmap;
3527
3528 if (wizard())
3529 return wizard()->pixmap(which);
3530
3531 return pixmap;
3532}
3533
3554
3567{
3568 Q_D(QWizardPage);
3569 if (d->wizard) {
3570 const QList<QWizardField> &fields = d->wizard->d_func()->fields;
3571 for (const auto &field : fields) {
3572 if (field.page == this)
3573 field.object->setProperty(field.property, field.initialValue);
3574 }
3575 }
3576}
3577
3593{
3594 return true;
3595}
3596
3615{
3616 Q_D(const QWizardPage);
3617
3618 if (!d->wizard)
3619 return true;
3620
3621 const QList<QWizardField> &wizardFields = d->wizard->d_func()->fields;
3622 const auto end = wizardFields.crend();
3623 for (auto it = wizardFields.crbegin(); it != end; ++it) {
3624 const QWizardField &field = *it;
3625 if (field.page == this && field.mandatory) {
3626 QVariant value = field.object->property(field.property);
3627 if (value == field.initialValue)
3628 return false;
3629
3630#if QT_CONFIG(lineedit)
3631 if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(field.object)) {
3633 return false;
3634 }
3635#endif
3636#if QT_CONFIG(spinbox)
3637 if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(field.object)) {
3639 return false;
3640 }
3641#endif
3642 }
3643 }
3644 return true;
3645}
3646
3659void QWizardPage::setFinalPage(bool finalPage)
3660{
3661 Q_D(QWizardPage);
3662 d->explicitlyFinal = finalPage;
3663 QWizard *wizard = this->wizard();
3664 if (wizard && wizard->currentPage() == this)
3665 wizard->d_func()->updateCurrentPage();
3666}
3667
3681{
3682 Q_D(const QWizardPage);
3683 if (d->explicitlyFinal)
3684 return true;
3685
3686 QWizard *wizard = this->wizard();
3687 if (wizard && wizard->currentPage() == this) {
3688 // try to use the QWizard implementation if possible
3689 return wizard->nextId() == -1;
3690 } else {
3691 return nextId() == -1;
3692 }
3693}
3694
3709void QWizardPage::setCommitPage(bool commitPage)
3710{
3711 Q_D(QWizardPage);
3712 d->commit = commitPage;
3713 QWizard *wizard = this->wizard();
3714 if (wizard && wizard->currentPage() == this)
3715 wizard->d_func()->updateCurrentPage();
3716}
3717
3724{
3725 Q_D(const QWizardPage);
3726 return d->commit;
3727}
3728
3738{
3739 Q_D(QWizardPage);
3740 d->buttonCustomTexts.insert(which, text);
3741 if (wizard() && wizard()->currentPage() == this && wizard()->d_func()->btns[which])
3742 wizard()->d_func()->btns[which]->setText(text);
3743}
3744
3759{
3760 Q_D(const QWizardPage);
3761
3762 if (d->buttonCustomTexts.contains(which))
3763 return d->buttonCustomTexts.value(which);
3764
3765 if (wizard())
3766 return wizard()->buttonText(which);
3767
3768 return QString();
3769}
3770
3788{
3789 Q_D(const QWizardPage);
3790
3791 if (!d->wizard)
3792 return -1;
3793
3794 bool foundCurrentPage = false;
3795
3796 const QWizardPrivate::PageMap &pageMap = d->wizard->d_func()->pageMap;
3797 QWizardPrivate::PageMap::const_iterator i = pageMap.constBegin();
3798 QWizardPrivate::PageMap::const_iterator end = pageMap.constEnd();
3799
3800 for (; i != end; ++i) {
3801 if (i.value() == this) {
3802 foundCurrentPage = true;
3803 } else if (foundCurrentPage) {
3804 return i.key();
3805 }
3806 }
3807 return -1;
3808}
3809
3834{
3835 Q_D(QWizardPage);
3836 if (!d->wizard)
3837 return;
3838 d->wizard->setField(name, value);
3839}
3840
3855{
3856 Q_D(const QWizardPage);
3857 if (!d->wizard)
3858 return QVariant();
3859 return d->wizard->field(name);
3860}
3861
3909 const char *changedSignal)
3910{
3911 Q_D(QWizardPage);
3912 QWizardField field(this, name, widget, property, changedSignal);
3913 if (d->wizard) {
3914 d->wizard->d_func()->addField(field);
3915 } else {
3916 d->pendingFields += field;
3917 }
3918}
3919
3927{
3928 Q_D(const QWizardPage);
3929 return d->wizard;
3930}
3931
3933
3934#include "moc_qwizard.cpp"
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
void setText(const QString &text)
QString text
the text shown on the button
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
bool hasAcceptableInput() const
static QStyle * style()
Returns the application's style object.
static QPalette palette()
Returns the current application palette.
void invalidate() override
Resets cached information.
int count() const override
\reimp
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
QLayoutItem * takeAt(int) override
\reimp
void addItem(QLayoutItem *) override
\reimp
void addSpacing(int size)
Adds a non-stretchable space (a QSpacerItem) with size size to the end of this box layout.
void addStretch(int stretch=0)
Adds a stretchable space (a QSpacerItem) with zero minimum size and stretch factor stretch to the end...
QLayoutItem * itemAt(int) const override
\reimp
void insertWidget(int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Inserts widget at position index, with stretch factor stretch and alignment alignment.
void setSpacing(int spacing) override
Reimplements QLayout::setSpacing().
\inmodule QtGui
Definition qbrush.h:30
const QColor & color() const
Returns the brush color.
Definition qbrush.h:121
\inmodule QtCore
Definition qbytearray.h:57
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:107
qsizetype count(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
int alpha() const noexcept
Returns the alpha color component of this color.
Definition qcolor.cpp:1466
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition qcolor.cpp:1481
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
\inmodule QtCore\reentrant
Definition qdatetime.h:283
The QDialog class is the base class of dialog windows.
Definition qdialog.h:19
@ Rejected
Definition qdialog.h:30
void resizeEvent(QResizeEvent *) override
\reimp
Definition qdialog.cpp:1054
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition qdialog.cpp:602
void setVisible(bool visible) override
\reimp
Definition qdialog.cpp:744
\inmodule QtCore
Definition qcoreevent.h:45
@ LayoutDirectionChange
Definition qcoreevent.h:124
@ StyleChange
Definition qcoreevent.h:136
@ PaletteChange
Definition qcoreevent.h:94
\reentrant
Definition qfont.h:22
void setPointSize(int)
Sets the point size to pointSize.
Definition qfont.cpp:985
int pointSize() const
Returns the point size of the font.
Definition qfont.cpp:884
void setBold(bool)
If enable is true sets the font's weight to \l{Weight}{QFont::Bold}; otherwise sets the weight to \l{...
Definition qfont.h:373
The QFrame class is the base class of widgets that can have a frame.
Definition qframe.h:17
@ Raised
Definition qframe.h:50
void setFrameStyle(int)
Sets the frame style to style.
Definition qframe.cpp:300
void setLineWidth(int)
Definition qframe.cpp:336
@ NoFrame
Definition qframe.h:39
@ Box
Definition qframe.h:40
void setMidLineWidth(int)
Definition qframe.cpp:360
The QGridLayout class lays out widgets in a grid.
Definition qgridlayout.h:21
void setHorizontalSpacing(int spacing)
void addWidget(QWidget *w)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qgridlayout.h:64
void addLayout(QLayout *, int row, int column, Qt::Alignment=Qt::Alignment())
Places the layout at position (row, column) in the grid.
void setRowMinimumHeight(int row, int minSize)
Sets the minimum height of row row to minSize pixels.
int count() const override
\reimp
void setColumnMinimumWidth(int column, int minSize)
Sets the minimum width of column column to minSize pixels.
void setSpacing(int spacing) override
This function sets both the vertical and horizontal spacing to spacing.
int rowCount() const
Returns the number of rows in this grid.
void setVerticalSpacing(int spacing)
void setRowStretch(int row, int stretch)
Sets the stretch factor of row row to stretch.
int columnCount() const
Returns the number of columns in this grid.
QLayoutItem * takeAt(int index) override
\reimp
void setColumnStretch(int column, int stretch)
Sets the stretch factor of column column to stretch.
QScreen * primaryScreen
the primary (or default) screen of the application.
The QHBoxLayout class lines up widgets horizontally.
Definition qboxlayout.h:78
The QKeySequence class encapsulates a key sequence as used by shortcuts.
The QLabel widget provides a text or image display.
Definition qlabel.h:20
int heightForWidth(int) const override
\reimp
Definition qlabel.cpp:650
void setText(const QString &)
Definition qlabel.cpp:263
void setTextFormat(Qt::TextFormat)
Definition qlabel.cpp:1376
QPixmap pixmap
the label's pixmap.
Definition qlabel.h:24
void setIndent(int)
Definition qlabel.cpp:510
void setPixmap(const QPixmap &)
Definition qlabel.cpp:339
void setAlignment(Qt::Alignment)
Definition qlabel.cpp:442
void setWordWrap(bool on)
Definition qlabel.cpp:472
QSize sizeHint() const override
\reimp
Definition qlabel.cpp:820
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition qlayoutitem.h:25
virtual Qt::Orientations expandingDirections() const =0
Returns whether this layout item can make use of more space than sizeHint().
virtual QSpacerItem * spacerItem()
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise \nullptr is returned.
The QLayout class is the base class of geometry managers.
Definition qlayout.h:26
QSize totalSizeHint() const
Definition qlayout.cpp:644
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
Definition qlayout.cpp:1323
void setSizeConstraint(SizeConstraint)
Definition qlayout.cpp:1241
QSize totalMaximumSize() const
Definition qlayout.cpp:669
QSize totalMinimumSize() const
Definition qlayout.cpp:621
@ SetNoConstraint
Definition qlayout.h:37
virtual int indexOf(const QWidget *) const
Searches for widget widget in this layout (not including child layouts).
Definition qlayout.cpp:1177
void setContentsMargins(int left, int top, int right, int bottom)
Definition qlayout.cpp:288
The QLineEdit widget is a one-line text editor.
Definition qlineedit.h:28
bool hasAcceptableInput() const
qsizetype size() const noexcept
Definition qlist.h:397
const T & constLast() const noexcept
Definition qlist.h:650
iterator erase(const_iterator begin, const_iterator end)
Definition qlist.h:889
iterator end()
Definition qlist.h:626
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
const_reverse_iterator crbegin() const noexcept
Definition qlist.h:638
void remove(qsizetype i, qsizetype n=1)
Definition qlist.h:794
iterator begin()
Definition qlist.h:625
void reserve(qsizetype size)
Definition qlist.h:753
void removeLast() noexcept
Definition qlist.h:815
const_iterator cend() const noexcept
Definition qlist.h:631
void append(parameter_type t)
Definition qlist.h:458
const_iterator cbegin() const noexcept
Definition qlist.h:630
void clear()
Definition qlist.h:434
const_reverse_iterator crend() const noexcept
Definition qlist.h:639
iterator insert(const Key &key, const T &value)
Definition qmap.h:688
T value(const Key &key, const T &defaultValue=T()) const
Definition qmap.h:357
bool contains(const Key &key) const
Definition qmap.h:341
size_type remove(const Key &key)
Definition qmap.h:300
iterator begin()
Definition qmap.h:598
iterator end()
Definition qmap.h:602
const_iterator constBegin() const
Definition qmap.h:600
const_iterator constEnd() const
Definition qmap.h:604
\inmodule QtCore
Definition qmargins.h:24
uint isWindow
Definition qobject.h:82
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition qobject.cpp:2658
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition qobject.cpp:1389
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
friend class QWidget
Definition qobject.h:382
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:127
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen's color.
Definition qpainter.h:545
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition qpainter.h:442
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
Definition qpalette.cpp:748
const QBrush & mid() const
Returns the mid brush of the current color group.
Definition qpalette.h:87
void setBrush(ColorRole cr, const QBrush &brush)
Sets the brush for the given color role to the specified brush for all groups in the palette.
Definition qpalette.h:151
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition qpalette.h:146
const QBrush & base() const
Returns the base brush of the current color group.
Definition qpalette.h:89
\inmodule QtGui
Definition qpen.h:28
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
int height() const
Returns the height of the pixmap.
Definition qpixmap.cpp:480
QSizeF deviceIndependentSize() const
Returns the size of the pixmap in device independent pixels.
Definition qpixmap.cpp:626
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition qpixmap.cpp:456
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
void setAutoDefault(bool)
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QShortcut class is used to create keyboard shortcuts.
Definition qshortcut.h:19
\inmodule QtCore
Definition qsize.h:208
constexpr QSize toSize() const noexcept
Returns an integer based copy of this size.
Definition qsize.h:401
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
constexpr void setWidth(int w) noexcept
Sets the width to the given width.
Definition qsize.h:136
constexpr void setHeight(int h) noexcept
Sets the height to the given height.
Definition qsize.h:139
The QSpacerItem class provides blank space in a layout.
Definition qlayoutitem.h:57
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
The QStyleOption class stores the parameters used by QStyle functions.
void initFrom(const QWidget *w)
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
@ SH_WizardStyle
Definition qstyle.h:663
virtual int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
@ PM_LayoutBottomMargin
Definition qstyle.h:515
@ PM_LayoutLeftMargin
Definition qstyle.h:512
@ PM_LayoutVerticalSpacing
Definition qstyle.h:517
@ PM_LayoutHorizontalSpacing
Definition qstyle.h:516
@ PM_LayoutTopMargin
Definition qstyle.h:513
@ PM_LayoutRightMargin
Definition qstyle.h:514
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
\inmodule QtCore
Definition qvariant.h:65
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:714
const void * constData() const
Definition qvariant.h:451
QSize minimumSizeHint() const override
\reimp
Definition qwizard.cpp:416
void setSideWidget(QWidget *widget)
Definition qwizard.cpp:422
QWatermarkLabel(QWidget *parent, QWidget *sideWidget)
Definition qwizard.cpp:410
QWidget * sideWidget() const
Definition qwizard.cpp:433
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setAutoFillBackground(bool enabled)
Definition qwidget.cpp:330
virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
This special event handler can be reimplemented in a subclass to receive native platform events ident...
Qt::LayoutDirection layoutDirection
the layout direction for this widget.
Definition qwidget.h:170
void setBackgroundRole(QPalette::ColorRole)
Sets the background role of the widget to role.
Definition qwidget.cpp:4391
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right,...
Definition qwidget.cpp:7590
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
void setMinimumSize(const QSize &)
Definition qwidget.h:832
void updateGeometry()
Notifies the layout system that this widget has changed and may need to change geometry.
void setSizePolicy(QSizePolicy)
void setStyle(QStyle *)
Sets the widget's GUI style to style.
Definition qwidget.cpp:2630
QWidget * nextInFocusChain() const
Returns the next widget in this widget's focus chain.
Definition qwidget.cpp:6845
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
static void setTabOrder(QWidget *, QWidget *)
Puts the second widget after the first widget in the focus order.
Definition qwidget.cpp:6981
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition qwidget.h:106
QLayout * layout() const
Returns the layout manager that is installed on this widget, or \nullptr if no layout manager is inst...
void setPalette(const QPalette &)
Definition qwidget.cpp:4530
QPalette palette
the widget's palette
Definition qwidget.h:132
int width
the width of the widget excluding any window frame
Definition qwidget.h:114
void move(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:880
QSize minimumSizeHint
the recommended minimum size for the widget
Definition qwidget.h:149
void hide()
Hides the widget.
Definition qwidget.cpp:8135
void setMinimumHeight(int minh)
Definition qwidget.cpp:4121
int height
the height of the widget excluding any window frame
Definition qwidget.h:115
void setFocus()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:423
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
virtual void setVisible(bool visible)
Definition qwidget.cpp:8255
void setMaximumSize(const QSize &)
Definition qwidget.h:835
void setFixedHeight(int h)
Sets both the minimum and maximum heights of the widget to h without changing the widths.
Definition qwidget.cpp:4175
friend class QPixmap
Definition qwidget.h:748
QStyle * style() const
Definition qwidget.cpp:2600
int maximumWidth
the widget's maximum width in pixels
Definition qwidget.h:127
void setFont(const QFont &)
Definition qwidget.cpp:4667
QFont font
the font currently set for the widget
Definition qwidget.h:133
Qt::FocusPolicy focusPolicy
the way the widget accepts keyboard focus
Definition qwidget.h:140
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
bool isAncestorOf(const QWidget *child) const
Returns true if this widget is a parent, (or grandparent and so on to any level), of the given child,...
Definition qwidget.cpp:8822
void setFixedSize(const QSize &)
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing o...
Definition qwidget.cpp:4082
virtual void paintEvent(QPaintEvent *event)
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Definition qwidget.cpp:9783
bool visible
whether the widget is visible
Definition qwidget.h:144
QWizardAntiFlickerWidget(QWizard *wizard, QWizardPrivate *)
Definition qwizard.cpp:497
QWizardDefaultProperty(const char *className, const char *property, const char *changedSignal)
Definition qwizard.cpp:142
QByteArray changedSignal
Definition qwizard.cpp:139
QString name
Definition qwizard.cpp:159
void resolve(const QList< QWizardDefaultProperty > &defaultPropertyTable)
Definition qwizard.cpp:179
void findProperty(const QWizardDefaultProperty *properties, int propertyCount)
Definition qwizard.cpp:186
QWizardPage * page
Definition qwizard.cpp:158
QObject * object
Definition qwizard.cpp:161
QByteArray property
Definition qwizard.cpp:162
QByteArray changedSignal
Definition qwizard.cpp:163
QVariant initialValue
Definition qwizard.cpp:164
void paintEvent(QPaintEvent *event) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Definition qwizard.cpp:384
QWizardHeader(RulerType, QWidget *parent=nullptr)
Definition qwizard.cpp:252
void setup(const QWizardLayoutInfo &info, const QString &title, const QString &subTitle, const QPixmap &logo, const QPixmap &banner, Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat)
Definition qwizard.cpp:324
QWizard::WizardStyle wizStyle
Definition qwizard.cpp:213
bool operator!=(const QWizardLayoutInfo &other) const
Definition qwizard.cpp:222
bool operator==(const QWizardLayoutInfo &other) const
Definition qwizard.cpp:225
TriState completeState
Definition qwizard.cpp:457
QPixmap pixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:455
void _q_maybeEmitCompleteChanged()
Definition qwizard.cpp:472
QList< QWizardField > pendingFields
Definition qwizard.cpp:456
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:461
void _q_updateCachedCompleteState()
Definition qwizard.cpp:480
bool cachedIsComplete() const
Definition qwizard.cpp:464
The QWizardPage class is the base class for wizard pages.
Definition qwizard.h:177
QString title
the title of the page
Definition qwizard.h:179
void setFinalPage(bool finalPage)
Explicitly sets this page to be final if finalPage is true.
Definition qwizard.cpp:3659
QVariant field(const QString &name) const
Returns the value of the field called name.
Definition qwizard.cpp:3854
void setButtonText(QWizard::WizardButton which, const QString &text)
Sets the text on button which to be text on this page.
Definition qwizard.cpp:3737
bool isCommitPage() const
Returns true if this page is a commit page; otherwise returns false.
Definition qwizard.cpp:3723
virtual void initializePage()
This virtual function is called by QWizard::initializePage() to prepare the page just before it is sh...
Definition qwizard.cpp:3551
void registerField(const QString &name, QWidget *widget, const char *property=nullptr, const char *changedSignal=nullptr)
Creates a field called name associated with the given property of the given widget.
Definition qwizard.cpp:3908
virtual void cleanupPage()
This virtual function is called by QWizard::cleanupPage() when the user leaves the page by clicking \...
Definition qwizard.cpp:3566
void setTitle(const QString &title)
Definition qwizard.cpp:3441
void setField(const QString &name, const QVariant &value)
Sets the value of the field called name to value.
Definition qwizard.cpp:3833
virtual bool validatePage()
This virtual function is called by QWizard::validateCurrentPage() when the user clicks \uicontrol Nex...
Definition qwizard.cpp:3592
QWizard * wizard() const
Returns the wizard associated with this page, or \nullptr if this page hasn't been inserted into a QW...
Definition qwizard.cpp:3926
virtual int nextId() const
This virtual function is called by QWizard::nextId() to find out which page to show when the user cli...
Definition qwizard.cpp:3787
void setSubTitle(const QString &subTitle)
Definition qwizard.cpp:3474
~QWizardPage()
Destructor.
Definition qwizard.cpp:3423
bool isFinalPage() const
This function is called by QWizard to determine whether the \uicontrol Finish button should be shown ...
Definition qwizard.cpp:3680
virtual bool isComplete() const
This virtual function is called by QWizard to determine whether the \uicontrol Next or \uicontrol Fin...
Definition qwizard.cpp:3614
QString buttonText(QWizard::WizardButton which) const
Returns the text on button which on this page.
Definition qwizard.cpp:3758
QWizardPage(QWidget *parent=nullptr)
Constructs a wizard page with the given parent.
Definition qwizard.cpp:3414
QPixmap pixmap(QWizard::WizardPixmap which) const
Returns the pixmap set for role which.
Definition qwizard.cpp:3519
void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap)
Sets the pixmap for role which to pixmap.
Definition qwizard.cpp:3501
QString subTitle
the subtitle of the page
Definition qwizard.h:180
void setCommitPage(bool commitPage)
Sets this page to be a commit page if commitPage is true; otherwise, sets it to be a normal page.
Definition qwizard.cpp:3709
struct QWizardPrivate::@495::@497 btn
QWizardAntiFlickerWidget * antiFlickerWidget
Definition qwizard.cpp:583
void setStyle(QStyle *style)
Definition qwizard.cpp:1696
PageMap pageMap
Definition qwizard.cpp:549
QAbstractButton * commit
Definition qwizard.cpp:576
bool buttonLayoutContains(QWizard::WizardButton which)
Definition qwizard.cpp:1494
QWizard::WizardOptions opts
Definition qwizard.cpp:563
void updateCurrentPage()
Definition qwizard.cpp:1313
QList< QWizardField > fields
Definition qwizard.cpp:550
QLabel * subTitleLabel
Definition qwizard.cpp:591
void _q_updateButtonStates()
Definition qwizard.cpp:1618
QAbstractButton * cancel
Definition qwizard.cpp:578
QWizardHeader * headerWidget
Definition qwizard.cpp:586
QWizardLayoutInfo layoutInfoForCurrentPage()
Definition qwizard.cpp:857
bool startSetByUser
Definition qwizard.cpp:555
QWidget * sideWidget
Definition qwizard.cpp:588
QMap< QString, int > fieldIndexMap
Definition qwizard.cpp:551
void connectButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1382
QFrame * pageFrame
Definition qwizard.cpp:589
void removeFieldAt(int index)
Definition qwizard.cpp:742
QAbstractButton * next
Definition qwizard.cpp:575
QAbstractButton * help
Definition qwizard.cpp:579
QAbstractButton * back
Definition qwizard.cpp:574
QWatermarkLabel * watermarkLabel
Definition qwizard.cpp:587
QHBoxLayout * buttonLayout
Definition qwizard.cpp:595
void recreateLayout(const QWizardLayoutInfo &info)
Definition qwizard.cpp:918
QList< QWizard::WizardButton > buttonsCustomLayout
Definition qwizard.cpp:566
QAbstractButton * finish
Definition qwizard.cpp:577
void updateLayout()
Definition qwizard.cpp:1192
QList< QWizardDefaultProperty > defaultPropertyTable
Definition qwizard.cpp:552
void updateMinMaxSizes(const QWizardLayoutInfo &info)
Definition qwizard.cpp:1277
QGridLayout * mainLayout
Definition qwizard.cpp:596
void _q_emitCustomButtonClicked()
Definition qwizard.cpp:1606
void setButtonLayout(const QWizard::WizardButton *array, int size)
Definition qwizard.cpp:1461
QList< int > history
Definition qwizard.cpp:553
bool isVistaThemeEnabled() const
Definition qwizard.cpp:1579
QPixmap defaultPixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:569
QMap< int, QWizardPage * > PageMap
Definition qwizard.cpp:508
void updatePixmap(QWizard::WizardPixmap which)
Definition qwizard.cpp:1499
void _q_handleFieldObjectDestroyed(QObject *)
Definition qwizard.cpp:1669
void switchToPage(int newId, Direction direction)
Definition qwizard.cpp:757
void enableUpdates()
Definition qwizard.cpp:1597
int disableUpdatesCount
Definition qwizard.cpp:560
Qt::TextFormat subTitleFmt
Definition qwizard.cpp:568
void updateButtonTexts()
Definition qwizard.cpp:1392
void updateButtonLayout()
Definition qwizard.cpp:1421
QVBoxLayout * pageVBoxLayout
Definition qwizard.cpp:594
QLabel * titleLabel
Definition qwizard.cpp:590
bool ensureButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1353
QWizard::WizardStyle wizStyle
Definition qwizard.cpp:562
void updatePalette()
Definition qwizard.cpp:1253
QWidget * placeholderWidget1
Definition qwizard.cpp:584
QWizardRuler * bottomRuler
Definition qwizard.cpp:592
QWidget * placeholderWidget2
Definition qwizard.cpp:585
bool buttonsHaveCustomLayout
Definition qwizard.cpp:565
void cleanupPagesNotInHistory()
Definition qwizard.cpp:706
QAbstractButton * btns[QWizard::NButtons]
Definition qwizard.cpp:581
Qt::TextFormat titleFmt
Definition qwizard.cpp:567
void disableUpdates()
Definition qwizard.cpp:1588
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:564
void addField(const QWizardField &field)
Definition qwizard.cpp:720
QWizardLayoutInfo layoutInfo
Definition qwizard.cpp:559
QWizardRuler(QWidget *parent=nullptr)
Definition qwizard.cpp:403
The QWizard class provides a framework for wizards.
Definition qwizard.h:19
WizardOptions options
the various options that affect the look and feel of the wizard
Definition qwizard.h:22
void resizeEvent(QResizeEvent *event) override
\reimp
Definition qwizard.cpp:3159
void setWizardStyle(WizardStyle style)
Definition qwizard.cpp:2469
void paintEvent(QPaintEvent *event) override
\reimp
Definition qwizard.cpp:3180
void setPage(int id, QWizardPage *page)
Adds the given page to the wizard with the given id.
Definition qwizard.cpp:2169
int currentId
the ID of the current page
Definition qwizard.h:26
QAbstractButton * button(WizardButton which) const
Returns the button corresponding to role which.
Definition qwizard.cpp:2732
QWidget * sideWidget() const
Definition qwizard.cpp:2905
virtual int nextId() const
This virtual function is called by QWizard to find out which page to show when the user clicks the \u...
Definition qwizard.cpp:3328
void setButtonText(WizardButton which, const QString &text)
Sets the text on button which to be text.
Definition qwizard.cpp:2605
void setSubTitleFormat(Qt::TextFormat format)
Definition qwizard.cpp:2773
QList< int > pageIds() const
Returns the list of page IDs.
Definition qwizard.cpp:2339
QVariant field(const QString &name) const
Returns the value of the field called name.
Definition qwizard.cpp:2443
void setStartId(int id)
Definition qwizard.cpp:2355
WizardOption
This enum specifies various options that affect the look and feel of a wizard.
Definition qwizard.h:63
@ NoCancelButtonOnLastPage
Definition qwizard.h:80
@ DisabledBackButtonOnLastPage
Definition qwizard.h:70
@ NoDefaultButton
Definition qwizard.h:67
@ CancelButtonOnLeft
Definition qwizard.h:74
@ IndependentPages
Definition qwizard.h:64
@ NoBackButtonOnLastPage
Definition qwizard.h:69
@ HelpButtonOnRight
Definition qwizard.h:76
@ HaveCustomButton1
Definition qwizard.h:77
@ HaveCustomButton2
Definition qwizard.h:78
@ HaveFinishButtonOnEarlyPages
Definition qwizard.h:72
@ IgnoreSubTitles
Definition qwizard.h:65
@ HaveCustomButton3
Definition qwizard.h:79
@ NoCancelButton
Definition qwizard.h:73
@ NoBackButtonOnStartPage
Definition qwizard.h:68
@ ExtendedWatermarkPixmap
Definition qwizard.h:66
@ HaveNextButtonOnLastPage
Definition qwizard.h:71
@ HaveHelpButton
Definition qwizard.h:75
void setButtonLayout(const QList< WizardButton > &layout)
Sets the order in which buttons are displayed to layout, where layout is a list of \l{WizardButton}s.
Definition qwizard.cpp:2665
Qt::TextFormat subTitleFormat
the text format used by page subtitles
Definition qwizard.h:24
virtual void initializePage(int id)
This virtual function is called by QWizard to prepare page id just before it is shown either as a res...
Definition qwizard.cpp:3264
QWizardPage * page(int id) const
Returns the page with the given id, or \nullptr if there is no such page.
Definition qwizard.cpp:2299
QSize sizeHint() const override
\reimp
Definition qwizard.cpp:2928
void setOptions(WizardOptions options)
Definition qwizard.cpp:2554
void next()
Advances to the next page.
Definition qwizard.cpp:3047
void pageAdded(int id)
void setOption(WizardOption option, bool on=true)
Sets the given option to be enabled if on is true; otherwise, clears the given option.
Definition qwizard.cpp:2521
WizardPixmap
This enum specifies the pixmaps that can be associated with a page.
Definition qwizard.h:46
@ BackgroundPixmap
Definition qwizard.h:50
@ BannerPixmap
Definition qwizard.h:49
@ WatermarkPixmap
Definition qwizard.h:47
@ NPixmaps
Definition qwizard.h:51
@ LogoPixmap
Definition qwizard.h:48
WizardStyle wizardStyle
the look and feel of the wizard
Definition qwizard.h:21
virtual bool validateCurrentPage()
This virtual function is called by QWizard when the user clicks \uicontrol Next or \uicontrol Finish ...
Definition qwizard.cpp:3305
WizardStyle
This enum specifies the different looks supported by QWizard.
Definition qwizard.h:54
@ AeroStyle
Definition qwizard.h:58
@ ModernStyle
Definition qwizard.h:56
@ ClassicStyle
Definition qwizard.h:55
@ MacStyle
Definition qwizard.h:57
void pageRemoved(int id)
void setCurrentId(int id)
Sets currentId to id, without visiting the pages between currentId and id.
Definition qwizard.cpp:3085
QWizardPage * currentPage() const
Returns a pointer to the current page, or \nullptr if there is no current page (e....
Definition qwizard.cpp:2389
bool hasVisitedPage(int id) const
Returns true if the page history contains page id; otherwise, returns false.
Definition qwizard.cpp:2315
~QWizard()
Destroys the wizard and its pages, releasing any allocated resources.
Definition qwizard.cpp:2135
void setPixmap(WizardPixmap which, const QPixmap &pixmap)
Sets the pixmap for role which to pixmap.
Definition qwizard.cpp:2798
void setSideWidget(QWidget *widget)
Definition qwizard.cpp:2887
void done(int result) override
\reimp
Definition qwizard.cpp:3233
void setDefaultProperty(const char *className, const char *property, const char *changedSignal)
Sets the default property for className to be property, and the associated change signal to be change...
Definition qwizard.cpp:2850
virtual void cleanupPage(int id)
This virtual function is called by QWizard to clean up page id just before the user leaves it by clic...
Definition qwizard.cpp:3282
QWizard(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
Constructs a wizard with the given parent and window flags.
Definition qwizard.cpp:2125
int addPage(QWizardPage *page)
Adds the given page to the wizard, and returns the page's ID.
Definition qwizard.cpp:2149
bool testOption(WizardOption option) const
Returns true if the given option is enabled; otherwise, returns false.
Definition qwizard.cpp:2534
QString buttonText(WizardButton which) const
Returns the text on button which.
Definition qwizard.cpp:2630
Qt::TextFormat titleFormat
the text format used by page titles
Definition qwizard.h:23
void setField(const QString &name, const QVariant &value)
Sets the value of the field called name to value.
Definition qwizard.cpp:2420
QList< int > visitedIds() const
Definition qwizard.cpp:2329
void setVisible(bool visible) override
\reimp
Definition qwizard.cpp:2915
void back()
Goes back to the previous page.
Definition qwizard.cpp:3031
void setButton(WizardButton which, QAbstractButton *button)
Sets the button corresponding to role which to button.
Definition qwizard.cpp:2702
void removePage(int id)
Removes the page with the given id.
Definition qwizard.cpp:2225
QPixmap pixmap(WizardPixmap which) const
Returns the pixmap set for role which.
Definition qwizard.cpp:2814
WizardButton
This enum specifies the buttons in a wizard.
Definition qwizard.h:29
@ NButtons
Definition qwizard.h:43
@ CommitButton
Definition qwizard.h:32
@ BackButton
Definition qwizard.h:30
@ NoButton
Definition qwizard.h:41
@ HelpButton
Definition qwizard.h:35
@ FinishButton
Definition qwizard.h:33
@ Stretch
Definition qwizard.h:39
@ CustomButton3
Definition qwizard.h:38
@ NextButton
Definition qwizard.h:31
@ NStandardButtons
Definition qwizard.h:42
@ CustomButton1
Definition qwizard.h:36
@ CancelButton
Definition qwizard.h:34
@ CustomButton2
Definition qwizard.h:37
void setTitleFormat(Qt::TextFormat format)
Definition qwizard.cpp:2752
bool event(QEvent *event) override
\reimp
Definition qwizard.cpp:3124
void restart()
Restarts the wizard at the start page.
Definition qwizard.cpp:3112
int startId
the ID of the first page
Definition qwizard.h:25
QPushButton
[1]
QOpenGLWidget * widget
[1]
QString text
QPushButton * button
[2]
void textChanged(const QString &newText)
QSet< QString >::iterator it
box animateClick()
QPixmap pix
direction
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
@ AlignTop
Definition qnamespace.h:153
@ AlignLeft
Definition qnamespace.h:144
@ ALT
TextFormat
@ AutoText
@ RightToLeft
@ TabFocus
Definition qnamespace.h:108
@ Horizontal
Definition qnamespace.h:99
@ Vertical
Definition qnamespace.h:100
@ Key_Right
Definition qnamespace.h:679
Definition brush.cpp:5
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
#define Q_UNLIKELY(x)
static const QCssKnownValue properties[NumProperties - 1]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:166
static int oldButton(int button)
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLuint64 key
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint GLuint end
GLint GLint GLint GLint GLsizei GLsizei GLsizei GLboolean commit
GLuint object
[3]
GLint GLsizei width
GLbitfield flags
GLuint GLsizei const GLchar * message
GLuint start
GLuint name
GLfloat n
GLint GLsizei GLsizei GLenum format
GLint y
struct _cl_event * event
GLenum array
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLenum GLenum GLsizei void * row
GLuint64EXT * result
[6]
GLuint GLenum option
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define qUtf16Printable(string)
Definition qstring.h:1543
#define QT_CONFIG(feature)
#define emit
#define Q_UNUSED(x)
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
unsigned int uint
Definition qtypes.h:34
ptrdiff_t qintptr
Definition qtypes.h:166
static const int hMargin
static const int vMargin
#define QWIDGETSIZE_MAX
Definition qwidget.h:917
struct tagMSG MSG
static const char * buttonSlots(QWizard::WizardButton which)
Definition qwizard.cpp:833
static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate)
Definition qwizard.cpp:614
static QString object_name_for_button(QWizard::WizardButton which)
Definition qwizard.cpp:1327
const int ModernHeaderTopMargin
Definition qwizard.cpp:51
static void changeSpacerSize(QLayout *layout, int index, int width, int height)
Definition qwizard.cpp:59
const int MacLayoutLeftMargin
Definition qwizard.cpp:54
const int GapBetweenLogoAndRightEdge
Definition qwizard.cpp:50
const char property[13]
Definition qwizard.cpp:101
static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX, const QByteArray &classY)
Definition qwizard.cpp:85
static QWidget * iWantTheFocus(QWidget *ancestor)
Definition qwizard.cpp:67
const int MacLayoutBottomMargin
Definition qwizard.cpp:57
const struct @494 fallbackProperties[]
const int MacLayoutRightMargin
Definition qwizard.cpp:56
static const char * changed_signal(int which)
Definition qwizard.cpp:114
const size_t NFallbackDefaultProperties
Definition qwizard.cpp:112
const int ClassicHMargin
Definition qwizard.cpp:52
const int MacButtonTopMargin
Definition qwizard.cpp:53
const char className[16]
[1]
Definition qwizard.cpp:100
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QPushButton * pushButton
obj metaObject() -> className()
QVBoxLayout * layout
QLineEdit * lineEdit
QString title
[35]
QByteArray page
[45]
QSharedPointer< T > other(t)
[5]
QPushButton * connectButton
QGraphicsItem * item
widget render & pixmap
QPainter painter(this)
[7]
QSpinBox * spinBox
[0]
QHostInfo info
[0]
bool contains(const AT &t) const noexcept
Definition qlist.h:45
\inmodule QtCore