44 #include "qabstractspinbox.h"
45 #include "qalgorithms.h"
46 #include "qapplication.h"
47 #include "qboxlayout.h"
48 #include "qlayoutitem.h"
49 #include "qdesktopwidget.h"
53 #include "qlineedit.h"
55 #include "qpushbutton.h"
58 #include "qvarlengtharray.h"
60 #include "private/qt_mac_p.h"
62 #elif !defined(QT_NO_STYLE_WINDOWSVISTA)
63 #include "qwizard_win_p.h"
67 #include "private/qdialog_p.h"
72 #ifdef QT_SOFTKEYS_ENABLED
88 QSpacerItem *spacer = layout->itemAt(index)->spacerItem();
91 spacer->changeSize(width, height);
96 const int MaxIterations = 100;
99 for (
int i = 0; i < MaxIterations; ++i) {
100 candidate = candidate->nextInFocusChain();
104 if (candidate->focusPolicy() & Qt::TabFocus) {
105 if (candidate != ancestor && ancestor->isAncestorOf(candidate))
113 const QByteArray &classY)
115 const QMetaObject *metaObject =
object->metaObject();
117 if (metaObject->className() == classX)
119 if (metaObject->className() == classY)
121 metaObject = metaObject->superClass();
134 {
"QAbstractButton",
"checked", SIGNAL(toggled(
bool)) },
135 {
"QAbstractSlider",
"value", SIGNAL(valueChanged(
int)) },
136 {
"QComboBox",
"currentIndex", SIGNAL(currentIndexChanged(
int)) },
137 {
"QDateTimeEdit",
"dateTime", SIGNAL(dateTimeChanged(QDateTime)) },
138 {
"QLineEdit",
"text", SIGNAL(textChanged(QString)) },
139 {
"QListWidget",
"currentRow", SIGNAL(currentRowChanged(
int)) },
140 {
"QSpinBox",
"value", SIGNAL(valueChanged(
int)) }
143 class QWizardDefaultProperty
150 inline QWizardDefaultProperty() {}
153 : className(className), property(property), changedSignal(changedSignal) {}
159 inline QWizardField() {}
160 QWizardField(
QWizardPage *page,
const QString &spec, QObject *
object,
const char *
property,
163 void resolve(
const QVector<QWizardDefaultProperty> &defaultPropertyTable);
164 void findProperty(
const QWizardDefaultProperty *properties,
int propertyCount);
172 QVariant initialValue;
175 QWizardField::QWizardField(
QWizardPage *page,
const QString &spec, QObject *
object,
177 : page(page),
name(spec), mandatory(false), object(object), property(property),
178 changedSignal(changedSignal)
180 if (
name.endsWith(QLatin1Char(
'*'))) {
188 if (property.isEmpty())
189 findProperty(defaultPropertyTable.constData(), defaultPropertyTable.count());
190 initialValue =
object->property(property);
193 void QWizardField::findProperty(
const QWizardDefaultProperty *properties,
int propertyCount)
197 for (
int i = 0; i < propertyCount; ++i) {
199 className = properties[i].className;
200 property = properties[i].property;
201 changedSignal = properties[i].changedSignal;
206 class QWizardLayoutInfo
209 inline QWizardLayoutInfo()
210 : topLevelMarginLeft(-1), topLevelMarginRight(-1), topLevelMarginTop(-1),
211 topLevelMarginBottom(-1), childMarginLeft(-1), childMarginRight(-1),
212 childMarginTop(-1), childMarginBottom(-1), hspacing(-1), vspacing(-1),
213 wizStyle(
QWizard::ClassicStyle), header(false), watermark(false), title(false),
214 subTitle(false),
extension(false), sideWidget(false) {}
216 int topLevelMarginLeft;
217 int topLevelMarginRight;
218 int topLevelMarginTop;
219 int topLevelMarginBottom;
221 int childMarginRight;
223 int childMarginBottom;
235 bool operator==(
const QWizardLayoutInfo &other);
241 return topLevelMarginLeft == other.topLevelMarginLeft
242 && topLevelMarginRight == other.topLevelMarginRight
243 && topLevelMarginTop == other.topLevelMarginTop
244 && topLevelMarginBottom == other.topLevelMarginBottom
245 && childMarginLeft == other.childMarginLeft
246 && childMarginRight == other.childMarginRight
247 && childMarginTop == other.childMarginTop
248 && childMarginBottom == other.childMarginBottom
249 && hspacing == other.hspacing
250 && vspacing == other.vspacing
251 && buttonSpacing == other.buttonSpacing
252 && wizStyle == other.wizStyle
253 && header == other.header
254 && watermark == other.watermark
255 && title == other.title
256 && subTitle == other.subTitle
258 && sideWidget == other.sideWidget;
261 class QWizardHeader :
public QWidget
264 enum RulerType { Ruler };
266 inline QWizardHeader(RulerType ,
QWidget *parent = 0)
267 :
QWidget(parent) { setFixedHeight(2); }
268 QWizardHeader(
QWidget *parent = 0);
270 void setup(
const QWizardLayoutInfo &info,
const QString &title,
271 const QString &subTitle,
const QPixmap &logo,
const QPixmap &banner,
272 Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat);
275 void paintEvent(QPaintEvent *event);
276 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
278 bool vistaDisabled()
const;
282 QLabel *subTitleLabel;
285 QPixmap bannerPixmap;
288 QWizardHeader::QWizardHeader(
QWidget *parent)
291 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
292 setBackgroundRole(QPalette::Base);
294 titleLabel =
new QLabel(
this);
295 titleLabel->setBackgroundRole(QPalette::Base);
297 subTitleLabel =
new QLabel(
this);
298 subTitleLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
299 subTitleLabel->setWordWrap(
true);
301 logoLabel =
new QLabel(
this);
303 QFont font = titleLabel->font();
305 titleLabel->setFont(font);
307 layout =
new QGridLayout(
this);
308 layout->setMargin(0);
309 layout->setSpacing(0);
311 layout->setRowMinimumHeight(3, 1);
312 layout->setRowStretch(4, 1);
314 layout->setColumnStretch(2, 1);
318 layout->addWidget(titleLabel, 2, 1, 1, 2);
319 layout->addWidget(subTitleLabel, 4, 2);
320 layout->addWidget(logoLabel, 1, 5, 5, 1);
323 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
324 bool QWizardHeader::vistaDisabled()
const
326 bool styleDisabled =
false;
327 QWizard *wiz = parentWidget() ? qobject_cast <
QWizard *>(parentWidget()->parentWidget()) : 0;
331 const QVariant v = wiz->property(
"_q_wizard_vista_off");
332 styleDisabled = v.isValid() && v.toBool();
334 return styleDisabled;
338 void QWizardHeader::setup(
const QWizardLayoutInfo &info,
const QString &title,
339 const QString &subTitle,
const QPixmap &logo,
const QPixmap &banner,
340 Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat)
343 #
if !defined(QT_NO_STYLE_WINDOWSVISTA)
345 && QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled())
350 layout->setRowMinimumHeight(1, modern ? info.topLevelMarginTop - ModernHeaderTopMargin - 1 : 0);
353 int minColumnWidth0 = modern ? info.topLevelMarginLeft + info.topLevelMarginRight : 0;
354 int minColumnWidth1 = modern ? info.topLevelMarginLeft + info.topLevelMarginRight + 1
356 layout->setColumnMinimumWidth(0, minColumnWidth0);
357 layout->setColumnMinimumWidth(1, minColumnWidth1);
359 titleLabel->setTextFormat(titleFormat);
360 titleLabel->setText(title);
361 logoLabel->setPixmap(logo);
363 subTitleLabel->setTextFormat(subTitleFormat);
364 subTitleLabel->setText(QLatin1String(
"Pq\nPq"));
365 int desiredSubTitleHeight = subTitleLabel->sizeHint().height();
366 subTitleLabel->setText(subTitle);
369 bannerPixmap = banner;
371 bannerPixmap = QPixmap();
374 if (bannerPixmap.isNull()) {
378 int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3);
379 int delta = candidateSubTitleWidth >> 1;
381 if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta)
382 <= desiredSubTitleHeight)
383 candidateSubTitleWidth -= delta;
387 subTitleLabel->setMinimumSize(candidateSubTitleWidth, desiredSubTitleHeight);
389 QSize size = layout->totalMinimumSize();
390 setMinimumSize(size);
391 setMaximumSize(QWIDGETSIZE_MAX, size.height());
393 subTitleLabel->setMinimumSize(0, 0);
394 setFixedSize(banner.size() + QSize(0, 2));
399 void QWizardHeader::paintEvent(QPaintEvent * )
401 QPainter painter(
this);
402 painter.drawPixmap(0, 0, bannerPixmap);
405 int y = height() - 2;
406 const QPalette &pal = palette();
407 painter.setPen(pal.mid().color());
408 painter.drawLine(0, y, x, y);
409 painter.setPen(pal.base().color());
410 painter.drawPoint(x + 1, y);
411 painter.drawLine(0, y + 1, x + 1, y + 1);
415 class QWizardRuler :
public QWizardHeader
418 inline QWizardRuler(
QWidget *parent = 0)
419 : QWizardHeader(Ruler, parent) {}
422 class QWatermarkLabel :
public QLabel
425 QWatermarkLabel(
QWidget *parent,
QWidget *sideWidget) : QLabel(parent), m_sideWidget(sideWidget) {
426 m_layout =
new QVBoxLayout(
this);
428 m_layout->addWidget(m_sideWidget);
431 QSize minimumSizeHint()
const {
432 if (!pixmap() && !pixmap()->isNull())
433 return pixmap()->size();
434 return QFrame::minimumSizeHint();
437 void setSideWidget(
QWidget *widget) {
438 if (m_sideWidget == widget)
441 m_layout->removeWidget(m_sideWidget);
442 m_sideWidget->hide();
444 m_sideWidget = widget;
446 m_layout->addWidget(m_sideWidget);
452 QVBoxLayout *m_layout;
456 class QWizardPagePrivate :
public QWidgetPrivate
461 enum TriState { Tri_Unknown = -1, Tri_False, Tri_True };
463 inline QWizardPagePrivate()
464 : wizard(0), completeState(Tri_Unknown), explicitlyFinal(false), commit(false) {}
466 bool cachedIsComplete()
const;
467 void _q_maybeEmitCompleteChanged();
468 void _q_updateCachedCompleteState();
474 QVector<QWizardField> pendingFields;
475 mutable TriState completeState;
476 bool explicitlyFinal;
481 bool QWizardPagePrivate::cachedIsComplete()
const
484 if (completeState == Tri_Unknown)
485 completeState =
q->isComplete() ? Tri_True : Tri_False;
486 return completeState == Tri_True;
489 void QWizardPagePrivate::_q_maybeEmitCompleteChanged()
492 TriState newState =
q->isComplete() ? Tri_True : Tri_False;
493 if (newState != completeState)
494 emit
q->completeChanged();
497 void QWizardPagePrivate::_q_updateCachedCompleteState()
500 completeState =
q->isComplete() ? Tri_True : Tri_False;
503 class QWizardAntiFlickerWidget :
public QWidget
506 QWizardPrivate *wizardPrivate;
508 QWizardAntiFlickerWidget(
QWidget *parent,
QWizard *wizard, QWizardPrivate *wizardPrivate)
511 , wizardPrivate(wizardPrivate) {}
512 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
514 void paintEvent(QPaintEvent *);
518 class QWizardPrivate :
public QDialogPrivate
530 inline QWizardPrivate()
532 , startSetByUser(false)
536 , disableUpdatesCount(0)
538 , buttonsHaveCustomLayout(false)
539 , titleFmt(Qt::AutoText)
540 , subTitleFmt(Qt::AutoText)
541 , placeholderWidget1(0)
542 , placeholderWidget2(0)
549 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
550 , vistaInitPending(false)
551 , vistaState(QVistaHelper::Dirty)
552 , vistaStateChanged(false)
553 , inHandleAeroStyleChange(false)
557 , maximumWidth(QWIDGETSIZE_MAX)
558 , maximumHeight(QWIDGETSIZE_MAX)
562 #ifdef QT_SOFTKEYS_ENABLED
566 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
567 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
568 && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based)
569 vistaInitPending =
true;
575 void cleanupPagesNotInHistory();
576 void addField(
const QWizardField &field);
577 void removeFieldAt(
int index);
578 void switchToPage(
int newId, Direction direction);
579 QWizardLayoutInfo layoutInfoForCurrentPage();
580 void recreateLayout(
const QWizardLayoutInfo &info);
582 void updateMinMaxSizes(
const QWizardLayoutInfo &info);
583 void updateCurrentPage();
586 void updateButtonTexts();
587 void updateButtonLayout();
591 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
592 bool vistaDisabled()
const;
593 bool isVistaThemeEnabled(QVistaHelper::VistaState state)
const;
594 void handleAeroStyleChange();
596 bool isVistaThemeEnabled()
const;
597 void disableUpdates();
598 void enableUpdates();
599 void _q_emitCustomButtonClicked();
600 void _q_updateButtonStates();
601 void _q_handleFieldObjectDestroyed(QObject *);
602 void setStyle(QStyle *style);
604 static QPixmap findDefaultBackgroundPixmap();
608 QVector<QWizardField> fields;
610 QVector<QWizardDefaultProperty> defaultPropertyTable;
612 QSet<int> initialized;
618 QWizardLayoutInfo layoutInfo;
619 int disableUpdatesCount;
622 QWizard::WizardOptions opts;
624 bool buttonsHaveCustomLayout;
626 Qt::TextFormat titleFmt;
627 Qt::TextFormat subTitleFmt;
633 QAbstractButton *back;
634 QAbstractButton *next;
635 QAbstractButton *commit;
636 QAbstractButton *finish;
637 QAbstractButton *cancel;
638 QAbstractButton *help;
643 QWizardAntiFlickerWidget *antiFlickerWidget;
646 QWizardHeader *headerWidget;
647 QWatermarkLabel *watermarkLabel;
651 QLabel *subTitleLabel;
652 QWizardRuler *bottomRuler;
653 #ifdef QT_SOFTKEYS_ENABLED
657 QVBoxLayout *pageVBoxLayout;
658 QHBoxLayout *buttonLayout;
659 QGridLayout *mainLayout;
661 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
662 QVistaHelper *vistaHelper;
663 bool vistaInitPending;
664 QVistaHelper::VistaState vistaState;
665 bool vistaStateChanged;
666 bool inHandleAeroStyleChange;
676 #if defined(QT_NO_STYLE_WINDOWSVISTA)
677 Q_UNUSED(wizardPrivate);
682 return macStyle ? QWizard::tr(
"Go Back") : QWizard::tr(
"< &Back");
685 return QWizard::tr(
"Continue");
687 return wizardPrivate->isVistaThemeEnabled()
688 ? QWizard::tr(
"&Next") : QWizard::tr(
"&Next >");
690 return QWizard::tr(
"Commit");
692 return macStyle ? QWizard::tr(
"Done") : QWizard::tr(
"&Finish");
694 return QWizard::tr(
"Cancel");
696 return macStyle ? QWizard::tr(
"Help") : QWizard::tr(
"&Help");
702 void QWizardPrivate::init()
707 antiFlickerWidget =
new QWizardAntiFlickerWidget(scrollArea,
q,
this);
708 scrollArea->setWidget(antiFlickerWidget);
709 scrollArea->setWidgetResizable(
true);
710 scrollArea->setFrameStyle(QFrame::NoFrame);
711 topWidget = scrollArea;
720 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
721 vistaHelper =
new QVistaHelper(
q);
730 pageFrame =
new QFrame(antiFlickerWidget);
731 pageFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
733 pageVBoxLayout =
new QVBoxLayout(pageFrame);
734 pageVBoxLayout->setSpacing(0);
735 pageVBoxLayout->addSpacing(0);
736 QSpacerItem *spacerItem =
new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding);
737 pageVBoxLayout->addItem(spacerItem);
739 buttonLayout =
new QHBoxLayout;
740 mainLayout =
new QGridLayout(antiFlickerWidget);
741 mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
743 updateButtonLayout();
751 void QWizardPrivate::reset()
755 q->currentPage()->hide();
756 cleanupPagesNotInHistory();
757 for (
int i = history.count() - 1; i >= 0; --i)
758 q->cleanupPage(history.at(i));
763 emit
q->currentIdChanged(-1);
767 void QWizardPrivate::cleanupPagesNotInHistory()
771 const QSet<int> original = initialized;
772 QSet<int>::const_iterator i = original.constBegin();
773 QSet<int>::const_iterator end = original.constEnd();
775 for (; i != end; ++i) {
776 if (!history.contains(*i)) {
778 initialized.remove(*i);
783 void QWizardPrivate::addField(
const QWizardField &field)
787 QWizardField myField = field;
788 myField.resolve(defaultPropertyTable);
790 if (fieldIndexMap.contains(myField.name)) {
791 kWarning() <<
"Duplicate field '" << qPrintable(myField.name) <<
"'";
795 fieldIndexMap.insert(myField.name, fields.count());
797 if (myField.mandatory && !myField.changedSignal.isEmpty())
798 QObject::connect(myField.object, myField.changedSignal,
799 myField.page, SLOT(_q_maybeEmitCompleteChanged()));
801 myField.object, SIGNAL(destroyed(QObject*)),
q,
802 SLOT(_q_handleFieldObjectDestroyed(QObject*)));
805 void QWizardPrivate::removeFieldAt(
int index)
809 const QWizardField &field = fields.at(index);
810 fieldIndexMap.remove(field.name);
811 if (field.mandatory && !field.changedSignal.isEmpty())
812 QObject::disconnect(field.object, field.changedSignal,
813 field.page, SLOT(_q_maybeEmitCompleteChanged()));
815 field.object, SIGNAL(destroyed(QObject*)),
q,
816 SLOT(_q_handleFieldObjectDestroyed(QObject*)));
817 fields.remove(index);
820 void QWizardPrivate::switchToPage(
int newId, Direction direction)
830 if (direction == Backward) {
832 q->cleanupPage(oldId);
833 initialized.remove(oldId);
835 Q_ASSERT(history.last() == oldId);
836 history.removeLast();
837 Q_ASSERT(history.last() == newId);
845 if (direction == Forward) {
846 if (!initialized.contains(current)) {
847 initialized.insert(current);
848 q->initializePage(current);
850 history.append(current);
855 canContinue = (
q->nextId() != -1);
858 _q_updateButtonStates();
863 QAbstractButton *nextOrFinishButton =
877 candidate = nextOrFinishButton;
878 }
else if (newPage) {
882 candidate = nextOrFinishButton;
883 candidate->setFocus();
891 emit
q->currentIdChanged(current);
896 SLOT(back()), SLOT(next()), SLOT(next()), SLOT(accept()), SLOT(reject()),
897 SIGNAL(helpRequested())
900 QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
903 QStyle *style =
q->style();
905 QWizardLayoutInfo info;
907 const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
908 info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0,
q);
909 info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0,
q);
910 info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0,
q);
911 info.topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0,
q);
912 info.childMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, titleLabel);
913 info.childMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, titleLabel);
914 info.childMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, titleLabel);
915 info.childMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, titleLabel);
916 info.hspacing = (layoutHorizontalSpacing == -1)
917 ? style->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal)
918 : layoutHorizontalSpacing;
919 info.vspacing = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing);
920 info.buttonSpacing = (layoutHorizontalSpacing == -1)
921 ? style->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal)
922 : layoutHorizontalSpacing;
925 info.buttonSpacing = 12;
927 info.wizStyle = wizStyle;
929 #
if !defined(QT_NO_STYLE_WINDOWSVISTA)
930 && (QVistaHelper::vistaState() == QVistaHelper::Classic || vistaDisabled())
936 QString subTitleText;
937 QPixmap backgroundPixmap;
938 QPixmap watermarkPixmap;
941 titleText = page->
title();
949 info.sideWidget = sideWidget;
951 && !watermarkPixmap.isNull();
952 info.title = !info.header && !titleText.isEmpty();
959 void QWizardPrivate::recreateLayout(
const QWizardLayoutInfo &info)
966 for (
int i = mainLayout->count() - 1; i >= 0; --i) {
967 QLayoutItem *item = mainLayout->takeAt(i);
968 if (item->layout()) {
969 item->layout()->setParent(0);
974 for (
int i = mainLayout->columnCount() - 1; i >= 0; --i)
975 mainLayout->setColumnMinimumWidth(i, 0);
976 for (
int i = mainLayout->rowCount() - 1; i >= 0; --i)
977 mainLayout->setRowMinimumHeight(i, 0);
987 int deltaMarginLeft = info.topLevelMarginLeft - info.childMarginLeft;
988 int deltaMarginRight = info.topLevelMarginRight - info.childMarginRight;
989 int deltaMarginTop = info.topLevelMarginTop - info.childMarginTop;
990 int deltaMarginBottom = info.topLevelMarginBottom - info.childMarginBottom;
991 int deltaVSpacing = info.topLevelMarginBottom - info.vspacing;
997 }
else if (info.watermark || info.sideWidget) {
1002 int pageColumn = qMin(1, numColumns - 1);
1005 mainLayout->setMargin(0);
1006 mainLayout->setSpacing(0);
1008 pageVBoxLayout->setMargin(7);
1011 mainLayout->setMargin(0);
1012 mainLayout->setSpacing(0);
1013 pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop,
1014 deltaMarginRight, deltaMarginBottom);
1015 buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
1016 info.topLevelMarginRight, info.topLevelMarginBottom);
1018 mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
1019 info.topLevelMarginRight, info.topLevelMarginBottom);
1020 mainLayout->setHorizontalSpacing(info.hspacing);
1021 mainLayout->setVerticalSpacing(info.vspacing);
1022 pageVBoxLayout->setContentsMargins(0, 0, 0, 0);
1023 buttonLayout->setContentsMargins(0, 0, 0, 0);
1026 buttonLayout->setSpacing(info.buttonSpacing);
1030 headerWidget =
new QWizardHeader(antiFlickerWidget);
1031 headerWidget->setAutoFillBackground(modern);
1032 mainLayout->addWidget(headerWidget, row++, 0, 1, numColumns);
1035 headerWidget->setVisible(info.header);
1037 int watermarkStartRow = row;
1040 mainLayout->setRowMinimumHeight(row++, 10);
1044 titleLabel =
new QLabel(antiFlickerWidget);
1045 titleLabel->setBackgroundRole(QPalette::Base);
1046 titleLabel->setWordWrap(
true);
1049 QFont titleFont =
q->font();
1050 titleFont.setPointSize(titleFont.pointSize() + (mac ? 3 : 4));
1051 titleFont.setBold(
true);
1052 titleLabel->setPalette(QPalette());
1056 titleFont = QFont(QLatin1String(
"Segoe UI"), 12);
1057 QPalette pal(titleLabel->palette());
1058 pal.setColor(QPalette::Text,
"#003399");
1059 titleLabel->setPalette(pal);
1062 titleLabel->setFont(titleFont);
1063 const int aeroTitleIndent = 25;
1065 titleLabel->setIndent(aeroTitleIndent);
1067 titleLabel->setIndent(2);
1069 titleLabel->setIndent(info.childMarginLeft);
1071 titleLabel->setIndent(info.topLevelMarginLeft);
1073 if (!placeholderWidget1) {
1074 placeholderWidget1 =
new QWidget(antiFlickerWidget);
1075 placeholderWidget1->setBackgroundRole(QPalette::Base);
1077 placeholderWidget1->setFixedHeight(info.topLevelMarginLeft + 2);
1078 mainLayout->addWidget(placeholderWidget1, row++, pageColumn);
1080 mainLayout->addWidget(titleLabel, row++, pageColumn);
1082 if (!placeholderWidget2) {
1083 placeholderWidget2 =
new QWidget(antiFlickerWidget);
1084 placeholderWidget2->setBackgroundRole(QPalette::Base);
1086 placeholderWidget2->setFixedHeight(5);
1087 mainLayout->addWidget(placeholderWidget2, row++, pageColumn);
1090 mainLayout->setRowMinimumHeight(row++, 7);
1092 if (placeholderWidget1)
1093 placeholderWidget1->setVisible(info.title && modern);
1094 if (placeholderWidget2)
1095 placeholderWidget2->setVisible(info.title && modern);
1097 if (info.subTitle) {
1098 if (!subTitleLabel) {
1099 subTitleLabel =
new QLabel(pageFrame);
1100 subTitleLabel->setWordWrap(
true);
1102 subTitleLabel->setContentsMargins(info.childMarginLeft , 0,
1103 info.childMarginRight , 0);
1105 pageVBoxLayout->insertWidget(1, subTitleLabel);
1110 changeSpacerSize(pageVBoxLayout, 0, 0, info.subTitle ? info.childMarginLeft : 0);
1112 int hMargin = mac ? 1 : 0;
1113 int vMargin = hMargin;
1115 pageFrame->setFrameStyle(mac ? (QFrame::Box | QFrame::Raised) : QFrame::NoFrame);
1116 pageFrame->setLineWidth(0);
1117 pageFrame->setMidLineWidth(hMargin);
1121 hMargin = info.topLevelMarginLeft;
1122 vMargin = deltaMarginBottom;
1123 }
else if (classic) {
1130 int leftMargin = 18;
1131 int topMargin = vMargin;
1132 int rightMargin = hMargin;
1133 int bottomMargin = vMargin;
1134 pageFrame->setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin);
1136 pageFrame->setContentsMargins(hMargin, vMargin, hMargin, vMargin);
1139 if ((info.watermark || info.sideWidget) && !watermarkLabel) {
1140 watermarkLabel =
new QWatermarkLabel(antiFlickerWidget, sideWidget);
1141 watermarkLabel->setBackgroundRole(QPalette::Base);
1142 watermarkLabel->setMinimumHeight(1);
1143 watermarkLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
1144 watermarkLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
1148 const bool wasSemiTransparent =
1149 pageFrame->palette().brush(QPalette::Window).color().alpha() < 255
1150 || pageFrame->palette().brush(QPalette::Base).color().alpha() < 255;
1152 if (!wasSemiTransparent) {
1153 QPalette pal = pageFrame->palette();
1154 pal.setBrush(QPalette::Window, QColor(255, 255, 255, 153));
1157 pal.setBrush(QPalette::Base, QColor(255, 255, 255, 153));
1158 pageFrame->setPalette(pal);
1159 pageFrame->setAutoFillBackground(
true);
1160 antiFlickerWidget->setAutoFillBackground(
false);
1163 if (wasSemiTransparent)
1164 pageFrame->setPalette(QPalette());
1166 bool baseBackground = (modern && !info.header);
1167 pageFrame->setBackgroundRole(baseBackground ? QPalette::Base : QPalette::Window);
1170 titleLabel->setAutoFillBackground(baseBackground);
1171 pageFrame->setAutoFillBackground(baseBackground);
1173 watermarkLabel->setAutoFillBackground(baseBackground);
1174 if (placeholderWidget1)
1175 placeholderWidget1->setAutoFillBackground(baseBackground);
1176 if (placeholderWidget2)
1177 placeholderWidget2->setAutoFillBackground(baseBackground);
1180 QPalette pal = pageFrame->palette();
1181 pal.setBrush(QPalette::Window, QColor(255, 255, 255));
1182 pageFrame->setPalette(pal);
1183 pageFrame->setAutoFillBackground(
true);
1184 pal = antiFlickerWidget->palette();
1185 pal.setBrush(QPalette::Window, QColor(255, 255, 255));
1186 antiFlickerWidget->setPalette(pal);
1187 antiFlickerWidget->setAutoFillBackground(
true);
1191 mainLayout->addWidget(pageFrame, row++, pageColumn);
1193 int watermarkEndRow = row;
1195 mainLayout->setRowMinimumHeight(row++, deltaVSpacing);
1198 buttonLayout->setContentsMargins(9, 9, 9, 9);
1199 mainLayout->setContentsMargins(0, 11, 0, 0);
1202 int buttonStartColumn = info.extension ? 1 : 0;
1203 int buttonNumColumns = info.extension ? 1 : numColumns;
1205 if (classic || modern) {
1207 bottomRuler =
new QWizardRuler(antiFlickerWidget);
1208 mainLayout->addWidget(bottomRuler, row++, buttonStartColumn, 1, buttonNumColumns);
1212 mainLayout->setRowMinimumHeight(row++, deltaVSpacing);
1214 mainLayout->addLayout(buttonLayout, row++, buttonStartColumn, 1, buttonNumColumns);
1216 if (info.watermark || info.sideWidget) {
1218 watermarkEndRow = row;
1219 mainLayout->addWidget(watermarkLabel, watermarkStartRow, 0,
1220 watermarkEndRow - watermarkStartRow, 1);
1223 mainLayout->setColumnMinimumWidth(0, mac && !info.watermark ? 181 : 0);
1225 mainLayout->setColumnMinimumWidth(2, 21);
1228 headerWidget->setVisible(info.header);
1230 titleLabel->setVisible(info.title);
1232 subTitleLabel->setVisible(info.subTitle);
1234 bottomRuler->setVisible(classic || modern);
1236 watermarkLabel->setVisible(info.watermark || info.sideWidget);
1241 void QWizardPrivate::updateLayout()
1247 QWizardLayoutInfo info = layoutInfoForCurrentPage();
1248 if (layoutInfo != info)
1249 recreateLayout(info);
1258 bool expandPage = !page->layout();
1260 const QLayoutItem *pageItem = pageVBoxLayout->itemAt(pageVBoxLayout->indexOf(page));
1261 expandPage = pageItem->expandingDirections() & Qt::Vertical;
1263 QSpacerItem *bottomSpacer = pageVBoxLayout->itemAt(pageVBoxLayout->count() - 1)->spacerItem();
1264 Q_ASSERT(bottomSpacer);
1265 bottomSpacer->changeSize(0, 0, QSizePolicy::Ignored, expandPage ? QSizePolicy::Ignored : QSizePolicy::MinimumExpanding);
1266 pageVBoxLayout->invalidate();
1273 titleFmt, subTitleFmt);
1276 if (info.watermark || info.sideWidget) {
1278 if (info.watermark) {
1284 watermarkLabel->setPixmap(pix);
1289 titleLabel->setTextFormat(titleFmt);
1290 titleLabel->setText(page->
title());
1292 if (info.subTitle) {
1294 subTitleLabel->setTextFormat(subTitleFmt);
1295 subTitleLabel->setText(page->
subTitle());
1299 updateMinMaxSizes(info);
1302 void QWizardPrivate::updateMinMaxSizes(
const QWizardLayoutInfo &info)
1306 int extraHeight = 0;
1307 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
1308 if (isVistaThemeEnabled())
1309 extraHeight = vistaHelper->titleBarSize() + vistaHelper->topOffset();
1311 QSize minimumSize = mainLayout->totalMinimumSize() + QSize(0, extraHeight);
1312 QSize maximumSize = mainLayout->totalMaximumSize();
1313 if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) {
1314 minimumSize.setWidth(headerWidget->maximumWidth());
1315 maximumSize.setWidth(headerWidget->maximumWidth());
1317 if (info.watermark && !info.sideWidget) {
1318 minimumSize.setHeight(mainLayout->totalSizeHint().height());
1319 maximumSize.setHeight(mainLayout->totalSizeHint().height());
1321 if (
q->minimumWidth() == minimumWidth) {
1322 minimumWidth = minimumSize.width();
1323 q->setMinimumWidth(minimumWidth);
1325 if (
q->minimumHeight() == minimumHeight) {
1326 minimumHeight = minimumSize.height();
1327 q->setMinimumHeight(minimumHeight);
1329 if (
q->maximumWidth() == maximumWidth) {
1330 maximumWidth = maximumSize.width();
1331 q->setMaximumWidth(maximumWidth);
1333 if (
q->maximumHeight() == maximumHeight) {
1334 maximumHeight = maximumSize.height();
1335 q->setMaximumHeight(maximumHeight);
1338 q->setFixedSize( QApplication::desktop()->screenGeometry().size() );
1341 void QWizardPrivate::updateCurrentPage()
1344 if (
q->currentPage()) {
1345 canContinue = (
q->nextId() != -1);
1346 canFinish =
q->currentPage()->isFinalPage();
1348 canContinue =
false;
1351 _q_updateButtonStates();
1352 updateButtonTexts();
1362 QPushButton *pushButton =
new QPushButton(antiFlickerWidget);
1363 QStyle *style =
q->style();
1364 if (style != QApplication::style())
1365 pushButton->setStyle(style);
1373 QString objectName = QLatin1String(
"__qt__passive_wizardbutton");
1374 objectName += QString::number(which);
1375 pushButton->setObjectName(objectName);
1380 pushButton->setAutoDefault(
false);
1384 const_cast<QWizardPrivate *
>(
this)->btns[which] = pushButton;
1386 btns[which] = pushButton;
1391 #ifdef QT_SOFTKEYS_ENABLED
1392 QAction *softKey =
new QAction(pushButton->text(), pushButton);
1393 QAction::SoftKeyRole softKeyRole;
1398 softKeyRole = QAction::NegativeSoftKey;
1407 softKeyRole = QAction::PositiveSoftKey;
1410 softKey->setSoftKeyRole(softKeyRole);
1411 softKeys[which] = softKey;
1413 connectButton(which);
1422 QObject::connect(btns[which], SIGNAL(clicked()),
q, buttonSlots[which]);
1424 QObject::connect(btns[which], SIGNAL(clicked()),
q, SLOT(_q_emitCustomButtonClicked()));
1427 #ifdef QT_SOFTKEYS_ENABLED
1428 QObject::connect(softKeys[which], SIGNAL(triggered()), btns[which], SIGNAL(clicked()));
1432 void QWizardPrivate::updateButtonTexts()
1437 if (
q->currentPage() && (
q->currentPage()->d_func()->buttonCustomTexts.contains(i)))
1438 btns[i]->setText(
q->currentPage()->d_func()->buttonCustomTexts.value(i));
1439 else if (buttonCustomTexts.contains(i))
1440 btns[i]->setText(buttonCustomTexts.value(i));
1443 #ifdef QT_SOFTKEYS_ENABLED
1444 softKeys[i]->setText(btns[i]->text());
1450 void QWizardPrivate::updateButtonLayout()
1452 if (buttonsHaveCustomLayout) {
1453 QVarLengthArray<QWizard::WizardButton> array(buttonsCustomLayout.count());
1454 for (
int i = 0; i < buttonsCustomLayout.count(); ++i)
1455 array[i] = buttonsCustomLayout.at(i);
1456 setButtonLayout(array.constData(), array.count());
1461 const int ArraySize = 12;
1463 memset(array, -1,
sizeof(array));
1487 setButtonLayout(array, ArraySize);
1495 for (
int i = buttonLayout->count() - 1; i >= 0; --i) {
1496 QLayoutItem *item = buttonLayout->takeAt(i);
1497 if (
QWidget *widget = item->widget())
1502 for (
int i = 0; i < size; ++i) {
1505 buttonLayout->addStretch(1);
1507 ensureButton(which);
1508 buttonLayout->addWidget(btns[which]);
1513 btns[which]->show();
1516 QWidget::setTabOrder(prev, btns[which]);
1521 _q_updateButtonStates();
1526 return !buttonsHaveCustomLayout || buttonsCustomLayout.contains(which);
1535 q->updateGeometry();
1542 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
1543 bool QWizardPrivate::vistaDisabled()
const
1546 const QVariant v =
q->property(
"_q_wizard_vista_off");
1547 return v.isValid() && v.toBool();
1550 bool QWizardPrivate::isVistaThemeEnabled(QVistaHelper::VistaState state)
const
1553 && QVistaHelper::vistaState() == state
1554 && !vistaDisabled();
1557 void QWizardPrivate::handleAeroStyleChange()
1561 if (inHandleAeroStyleChange)
1563 inHandleAeroStyleChange =
true;
1565 vistaHelper->disconnectBackButton();
1566 q->removeEventFilter(vistaHelper);
1568 if (isVistaThemeEnabled()) {
1569 if (isVistaThemeEnabled(QVistaHelper::VistaAero)) {
1570 vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar);
1571 q->installEventFilter(vistaHelper);
1572 q->setMouseTracking(
true);
1573 topWidget->move(0, vistaHelper->titleBarSize() + vistaHelper->topOffset());
1574 vistaHelper->backButton()->move(
1575 0, vistaHelper->topOffset()
1576 - qMin(vistaHelper->topOffset(), vistaHelper->topPadding() + 1));
1578 vistaHelper->setDWMTitleBar(QVistaHelper::NormalTitleBar);
1579 q->setMouseTracking(
true);
1580 topWidget->move(0, vistaHelper->topOffset());
1581 vistaHelper->backButton()->move(0, -1);
1583 vistaHelper->setTitleBarIconAndCaptionVisible(
false);
1586 vistaHelper->backButton()->show();
1588 q->setMouseTracking(
true);
1589 #ifndef QT_NO_CURSOR
1592 topWidget->move(0, 0);
1593 vistaHelper->hideBackButton();
1594 vistaHelper->setTitleBarIconAndCaptionVisible(
true);
1597 _q_updateButtonStates();
1600 vistaHelper->setWindowPosHack();
1602 inHandleAeroStyleChange =
false;
1606 bool QWizardPrivate::isVistaThemeEnabled()
const
1608 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
1609 return isVistaThemeEnabled(QVistaHelper::VistaAero)
1610 || isVistaThemeEnabled(QVistaHelper::VistaBasic);
1616 void QWizardPrivate::disableUpdates()
1619 if (disableUpdatesCount++ == 0) {
1620 q->setUpdatesEnabled(
false);
1625 void QWizardPrivate::enableUpdates()
1628 if (--disableUpdatesCount == 0) {
1630 q->setUpdatesEnabled(
true);
1634 void QWizardPrivate::_q_emitCustomButtonClicked()
1637 QObject *button =
q->sender();
1639 if (btns[i] == button) {
1646 void QWizardPrivate::_q_updateButtonStates()
1655 btn.back->setEnabled(history.count() > 1
1656 && !
q->page(history.at(history.count() - 2))->isCommitPage()
1658 btn.next->setEnabled(canContinue && complete);
1659 btn.commit->setEnabled(canContinue && complete);
1660 btn.finish->setEnabled(canFinish && complete);
1666 btn.back->setVisible(backButtonVisible);
1675 if (QPushButton *nextPush = qobject_cast<QPushButton *>(btn.next))
1676 nextPush->setDefault(canContinue && useDefault && !commitPage);
1677 if (QPushButton *commitPush = qobject_cast<QPushButton *>(btn.commit))
1678 commitPush->setDefault(canContinue && useDefault && commitPage);
1679 if (QPushButton *finishPush = qobject_cast<QPushButton *>(btn.finish))
1680 finishPush->setDefault(!canContinue && useDefault);
1682 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
1683 if (isVistaThemeEnabled()) {
1684 vistaHelper->backButton()->setEnabled(btn.back->isEnabled());
1685 vistaHelper->backButton()->setVisible(backButtonVisible);
1686 btn.back->setVisible(
false);
1690 #ifdef QT_SOFTKEYS_ENABLED
1691 QAbstractButton *wizardButton;
1693 wizardButton = btns[i];
1694 if (wizardButton && !wizardButton->testAttribute(Qt::WA_WState_Hidden)) {
1695 wizardButton->hide();
1696 q->addAction(softKeys[i]);
1698 q->removeAction(softKeys[i]);
1706 void QWizardPrivate::_q_handleFieldObjectDestroyed(QObject *
object)
1708 QVector<QWizardField>::iterator it = fields.begin();
1709 while (it != fields.end()) {
1710 const QWizardField &field = *it;
1711 if (field.object ==
object) {
1712 fieldIndexMap.remove(field.name);
1713 it = fields.erase(it);
1720 void QWizardPrivate::setStyle(QStyle *style)
1724 btns[i]->setStyle(style);
1725 const PageMap::const_iterator pcend = pageMap.constEnd();
1726 for (PageMap::const_iterator it = pageMap.constBegin(); it != pcend; ++it)
1727 it.value()->setStyle(style);
1732 QPixmap QWizardPrivate::findDefaultBackgroundPixmap()
1734 QCFType<CFURLRef> url;
1735 const int ExpectedImageWidth = 242;
1736 const int ExpectedImageHeight = 414;
1737 if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(
"com.apple.KeyboardSetupAssistant"),
1738 0, 0, &url) == noErr) {
1739 QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);
1741 url = CFBundleCopyResourceURL(bundle, CFSTR(
"Background"), CFSTR(
"tif"), 0);
1743 QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0);
1744 QCFType<CGImageRef>
image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0);
1746 int width = CGImageGetWidth(image);
1747 int height = CGImageGetHeight(image);
1748 if (width == ExpectedImageWidth && height == ExpectedImageHeight)
1749 return QPixmap::fromMacCGImageRef(image);
1760 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
1761 void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
1763 if (wizardPrivate->isVistaThemeEnabled()) {
1764 int leftMargin, topMargin, rightMargin, bottomMargin;
1765 wizardPrivate->buttonLayout->getContentsMargins(
1766 &leftMargin, &topMargin, &rightMargin, &bottomMargin);
1767 const int buttonLayoutTop = wizardPrivate->buttonLayout->contentsRect().top() - topMargin;
1768 QPainter painter(
this);
1769 const QBrush brush(QColor(240, 240, 240));
1770 painter.fillRect(0, buttonLayoutTop, width(), height() - buttonLayoutTop, brush);
1771 painter.setPen(QPen(QBrush(QColor(223, 223, 223)), 0));
1772 painter.drawLine(0, buttonLayoutTop, width(), buttonLayoutTop);
1773 if (wizardPrivate->isVistaThemeEnabled(QVistaHelper::VistaBasic)) {
1774 if (window()->isActiveWindow())
1775 painter.setPen(QPen(QBrush(QColor(169, 191, 214)), 0));
1777 painter.setPen(QPen(QBrush(QColor(182, 193, 204)), 0));
1778 painter.drawLine(0, 0, width(), 0);
2176 :
QDialog(*new QWizardPrivate, parent, flags)
2188 delete d->buttonLayout;
2203 if (!
d->pageMap.isEmpty())
2204 theid = (
d->pageMap.constEnd() - 1).key() + 1;
2224 kWarning() <<
"Cannot insert null page";
2229 kWarning() <<
"Cannot insert page with ID -1";
2233 if (
d->pageMap.contains(theid)) {
2234 kWarning() <<
"Page with duplicate ID " << theid <<
" ignored";
2238 page->setParent(
d->pageFrame);
2240 QVector<QWizardField> &pendingFields = page->d_func()->pendingFields;
2241 for (
int i = 0; i < pendingFields.count(); ++i)
2242 d->addField(pendingFields.at(i));
2243 pendingFields.clear();
2245 connect(page, SIGNAL(completeChanged()),
this, SLOT(_q_updateButtonStates()));
2247 d->pageMap.insert(theid, page);
2248 page->d_func()->
wizard =
this;
2250 int n =
d->pageVBoxLayout->count();
2253 bool pageVBoxLayoutEnabled =
d->pageVBoxLayout->isEnabled();
2254 d->pageVBoxLayout->setEnabled(
false);
2256 d->pageVBoxLayout->insertWidget(n - 1, page);
2260 d->pageVBoxLayout->setEnabled(pageVBoxLayoutEnabled);
2262 if (!
d->startSetByUser &&
d->pageMap.constBegin().key() == theid)
2282 if (
d->pageMap.count() > 0) {
2283 if (
d->start ==
id) {
2284 const int firstId =
d->pageMap.constBegin().key();
2285 if (firstId ==
id) {
2286 if (
d->pageMap.count() > 1)
2287 d->start = (++
d->pageMap.constBegin()).key();
2293 d->startSetByUser =
false;
2297 if (
d->pageMap.contains(
id))
2300 if (!
d->history.contains(
id)) {
2302 removedPage =
d->pageMap.take(
id);
2303 d->updateCurrentPage();
2304 }
else if (
id !=
d->current) {
2306 removedPage =
d->pageMap.take(
id);
2307 d->history.removeOne(
id);
2308 d->_q_updateButtonStates();
2309 }
else if (
d->history.count() == 1) {
2312 removedPage =
d->pageMap.take(
id);
2313 if (
d->pageMap.isEmpty())
2314 d->updateCurrentPage();
2320 removedPage =
d->pageMap.take(
id);
2321 d->updateCurrentPage();
2325 if (
d->initialized.contains(
id)) {
2327 d->initialized.remove(
id);
2330 d->pageVBoxLayout->removeWidget(removedPage);
2332 for (
int i =
d->fields.count() - 1; i >= 0; --i) {
2333 if (
d->fields.at(i).page == removedPage) {
2334 removedPage->d_func()->pendingFields +=
d->fields.at(i);
2335 d->removeFieldAt(i);
2352 return d->pageMap.value(theid);
2368 return d->history.contains(theid);
2392 return d->pageMap.keys();
2408 int newStart = theid;
2410 newStart =
d->pageMap.count() ?
d->pageMap.constBegin().key() : -1;
2412 if (
d->start == newStart) {
2413 d->startSetByUser = theid != -1;
2417 if (!
d->pageMap.contains(newStart)) {
2418 kWarning() <<
"Invalid page ID " << newStart;
2421 d->start = newStart;
2422 d->startSetByUser = theid != -1;
2442 return page(
d->current);
2474 int index =
d->fieldIndexMap.value(name, -1);
2476 const QWizardField &field =
d->fields.at(index);
2477 if (!field.object->setProperty(field.property, value))
2478 kWarning() <<
"Couldn't write to property '"
2479 << field.property.constData() <<
"'";
2483 kWarning() <<
"No such field '" << qPrintable(name) <<
"'";
2497 int index =
d->fieldIndexMap.value(name, -1);
2499 const QWizardField &field =
d->fields.at(index);
2500 return field.object->property(field.property);
2503 kWarning() <<
"No such field '" << qPrintable(name) <<
"'";
2523 const bool styleChange = style !=
d->wizStyle;
2525 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
2526 const bool aeroStyleChange =
2527 d->vistaInitPending ||
d->vistaStateChanged || (styleChange && (style ==
AeroStyle ||
d->wizStyle ==
AeroStyle));
2528 d->vistaStateChanged =
false;
2529 d->vistaInitPending =
false;
2533 #
if !defined(QT_NO_STYLE_WINDOWSVISTA)
2537 d->disableUpdates();
2538 d->wizStyle = style;
2539 d->updateButtonTexts();
2543 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
2544 if (aeroStyleChange)
2545 d->handleAeroStyleChange();
2565 if (!(
d->opts & option) != !on)
2578 return (
d->opts & option) != 0;
2599 WizardOptions changed = (options ^
d->opts);
2603 d->disableUpdates();
2607 d->cleanupPagesNotInHistory();
2612 d->updateButtonLayout();
2616 d->_q_updateButtonStates();
2650 if (!
d->ensureButton(which))
2653 d->buttonCustomTexts.insert(which, text);
2656 d->btns[which]->setText(text);
2675 if (!
d->ensureButton(which))
2678 if (
d->buttonCustomTexts.contains(which))
2679 return d->buttonCustomTexts.value(which);
2682 if(!defText.isNull())
2685 return d->btns[which]->text();
2710 for (
int i = 0; i < layout.count(); ++i) {
2715 if (!
d->ensureButton(button1))
2719 for (
int j = 0; j < i; ++j) {
2721 if (button2 == button1) {
2722 kWarning() <<
"Duplicate button in layout");
2728 d->buttonsHaveCustomLayout =
true;
2729 d->buttonsCustomLayout = layout;
2730 d->updateButtonLayout();
2747 if (uint(which) >=
NButtons ||
d->btns[which] == button)
2750 if (QAbstractButton *oldButton =
d->btns[which]) {
2751 d->buttonLayout->removeWidget(oldButton);
2757 button->setParent(
d->antiFlickerWidget);
2758 d->buttonCustomTexts.insert(which, button->text());
2759 d->connectButton(which);
2761 d->buttonCustomTexts.remove(which);
2762 d->ensureButton(which);
2765 d->updateButtonLayout();
2776 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
2778 return d->vistaHelper->backButton();
2780 if (!
d->ensureButton(which))
2782 return d->btns[which];
2796 d->titleFmt = format;
2817 d->subTitleFmt = format;
2824 return d->subTitleFmt;
2843 d->defaultPixmaps[which] =
pixmap;
2844 d->updatePixmap(which);
2863 return d->defaultPixmaps[which];
2892 const char *changedSignal)
2895 for (
int i =
d->defaultPropertyTable.count() - 1; i >= 0; --i) {
2896 if (qstrcmp(
d->defaultPropertyTable.at(i).className,
className) == 0) {
2897 d->defaultPropertyTable.remove(i);
2901 d->defaultPropertyTable.append(QWizardDefaultProperty(className, property, changedSignal));
2932 d->sideWidget = widget;
2933 if (
d->watermarkLabel) {
2934 d->watermarkLabel->setSideWidget(widget);
2950 return d->sideWidget;
2960 if (
d->current == -1)
2963 QDialog::setVisible(visible);
2972 QSize result =
d->mainLayout->totalSizeHint();
2974 QSize extra(QApplication::desktop()->availableGeometry(QCursor::pos()).size());
2976 QSize extra(500, 360);
2978 if (
d->wizStyle ==
MacStyle &&
d->current != -1) {
2980 extra.setWidth(616);
2981 if (!pixmap.isNull()) {
2982 extra.setHeight(pixmap.height());
2990 if (pixmap.width() >= pixmap.height())
2991 extra.setWidth(pixmap.width());
2994 return result.expandedTo(extra);
3079 int n =
d->history.count() - 2;
3082 d->switchToPage(
d->history.at(n), QWizardPrivate::Backward);
3096 if (
d->current == -1)
3102 if (
d->history.contains(next)) {
3103 kWarning() <<
"Page " << next <<
" already met";
3106 if (!
d->pageMap.contains(next)) {
3107 kWarning() <<
"No such page " <<
next;
3110 d->switchToPage(next, QWizardPrivate::Forward);
3124 d->disableUpdates();
3126 d->switchToPage(
startId(), QWizardPrivate::Forward);
3136 if (event->type() == QEvent::StyleChange) {
3137 d->setStyle(style());
3140 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
3141 else if (event->type() == QEvent::Show &&
d->vistaInitPending) {
3142 d->vistaInitPending =
false;
3144 d->handleAeroStyleChange();
3146 else if (
d->isVistaThemeEnabled()) {
3147 d->vistaHelper->mouseEvent(event);
3150 return QDialog::event(event);
3159 int heightOffset = 0;
3160 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
3161 if (
d->isVistaThemeEnabled()) {
3162 heightOffset =
d->vistaHelper->topOffset();
3163 if (
d->isVistaThemeEnabled(QVistaHelper::VistaAero))
3164 heightOffset +=
d->vistaHelper->titleBarSize();
3167 d->topWidget->resize(event->size().width(),
event->size().height() - heightOffset);
3168 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
3169 if (
d->isVistaThemeEnabled())
3170 d->vistaHelper->resizeEvent(event);
3172 QDialog::resizeEvent(event);
3183 if (backgroundPixmap.isNull())
3186 QPainter painter(
this);
3187 painter.drawPixmap(0, (height() - backgroundPixmap.height()) / 2, backgroundPixmap);
3189 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
3190 else if (
d->isVistaThemeEnabled()) {
3191 if (
d->isVistaThemeEnabled(QVistaHelper::VistaBasic)) {
3192 QPainter painter(
this);
3193 QColor color =
d->vistaHelper->basicWindowFrameColor();
3194 painter.fillRect(0, 0, width(), QVistaHelper::topOffset(), color);
3196 d->vistaHelper->paintEvent(event);
3203 #if defined(Q_WS_WIN)
3207 bool QWizard::winEvent(MSG *message,
long *result)
3209 #if !defined(QT_NO_STYLE_WINDOWSVISTA)
3211 if (
d->isVistaThemeEnabled()) {
3212 const bool winEventResult =
d->vistaHelper->handleWinEvent(message, result);
3213 if (QVistaHelper::vistaState() !=
d->vistaState) {
3214 d->vistaState = QVistaHelper::vistaState();
3215 d->vistaStateChanged =
true;
3218 return winEventResult;
3220 return QDialog::winEvent(message, result);
3223 return QDialog::winEvent(message, result);
3235 if (result == Rejected) {
3241 QDialog::done(result);
3411 :
QWidget(*new QWizardPagePrivate, parent, 0)
3413 connect(
this, SIGNAL(
completeChanged()),
this, SLOT(_q_updateCachedCompleteState()));
3434 if (
d->wizard &&
d->wizard->currentPage() ==
this)
3435 d->wizard->d_func()->updateLayout();
3467 if (
d->wizard &&
d->wizard->currentPage() ==
this)
3468 d->wizard->d_func()->updateLayout();
3495 if (
d->wizard &&
d->wizard->currentPage() ==
this)
3496 d->wizard->d_func()->updatePixmap(which);
3513 const QPixmap &
pixmap =
d->pixmaps[which];
3514 if (!pixmap.isNull())
3559 QVector<QWizardField> &fields =
d->wizard->d_func()->fields;
3560 for (
int i = 0; i < fields.count(); ++i) {
3561 const QWizardField &field = fields.at(i);
3562 if (field.page ==
this)
3563 field.object->setProperty(field.property, field.initialValue);
3611 const QVector<QWizardField> &wizardFields =
d->wizard->d_func()->fields;
3612 for (
int i = wizardFields.count() - 1; i >= 0; --i) {
3613 const QWizardField &field = wizardFields.at(i);
3614 if (field.page ==
this && field.mandatory) {
3615 QVariant value = field.object->property(field.property);
3616 if (value == field.initialValue)
3619 #ifndef QT_NO_LINEEDIT
3620 if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(field.object)) {
3621 if (!lineEdit->hasAcceptableInput())
3625 #ifndef QT_NO_SPINBOX
3626 if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(field.object)) {
3627 if (!spinBox->hasAcceptableInput())
3651 d->explicitlyFinal = finalPage;
3654 wizard->d_func()->updateCurrentPage();
3672 if (
d->explicitlyFinal)
3678 return wizard->
nextId() == -1;
3701 d->commit = commitPage;
3704 wizard->d_func()->updateCurrentPage();
3729 d->buttonCustomTexts.insert(which, text);
3731 wizard()->d_func()->btns[which]->setText(text);
3751 if (
d->buttonCustomTexts.contains(which))
3752 return d->buttonCustomTexts.value(which);
3783 bool foundCurrentPage =
false;
3786 QWizardPrivate::PageMap::const_iterator i = pageMap.constBegin();
3787 QWizardPrivate::PageMap::const_iterator end = pageMap.constEnd();
3789 for (; i != end; ++i) {
3790 if (i.value() ==
this) {
3791 foundCurrentPage =
true;
3792 }
else if (foundCurrentPage) {
3827 d->wizard->setField(name, value);
3848 return d->wizard->field(name);
3898 const char *changedSignal)
3901 QWizardField
field(
this, name, widget, property, changedSignal);
3903 d->wizard->d_func()->addField(field);
3905 d->pendingFields +=
field;
3921 #include "moc_qwizard.cpp"
virtual int nextId() const
void paintEvent(QPaintEvent *event)
static const char * flags[]
void setTitle(const QString &title)
bool hasVisitedPage(int id) const
void setButton(WizardButton which, QAbstractButton *button)
QVariant field(const QString &name) const
const int MacLayoutRightMargin
void resizeEvent(QResizeEvent *event)
void setWizardStyle(WizardStyle style)
void setDefaultProperty(const char *className, const char *property, const char *changedSignal)
static void changeSpacerSize(QLayout *layout, int index, int width, int height)
const char * changedSignal
void setField(const QString &name, const QVariant &value)
The QWizardPage class is the base class for wizard pages.
static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate)
const int NFallbackDefaultProperties
virtual bool validatePage()
QVariant field(const QString &name) const
static QWidget * iWantTheFocus(QWidget *ancestor)
void setOption(WizardOption option, bool on=true)
bool isCommitPage() const
virtual void cleanupPage(int id)
static QStringList resolve(const QStringList &paths, const QStringList &blacklist, const QStringList &whitelist)
virtual void cleanupPage()
static QString image(const char *img)
const struct @9 fallbackProperties[NFallbackDefaultProperties]
virtual bool validateCurrentPage()
const int MacLayoutBottomMargin
void setFinalPage(bool finalPage)
QAbstractButton * button(WizardButton which) const
void setSubTitleFormat(Qt::TextFormat format)
void setCommitPage(bool commitPage)
int addPage(QWizardPage *page)
QWizard(QWidget *parent=0, Qt::WindowFlags flags=0)
WizardStyle wizardStyle() const
QPixmap pixmap(WizardPixmap which) const
bool event(QEvent *event)
void setButtonText(WizardButton which, const QString &text)
QList< int > pageIds() const
void setButtonText(QWizard::WizardButton which, const QString &text)
Qt::TextFormat titleFormat() const
QString subTitle
the subtitle of the page
void setSideWidget(QWidget *widget)
const int ModernHeaderTopMargin
void setButtonLayout(const QList< WizardButton > &layout)
bool operator!=(const Recipient &lhs, const Recipient &rhs)
void setTitleFormat(Qt::TextFormat format)
const int MacLayoutLeftMargin
static bool operator==(const AddrSpec &lhs, const AddrSpec &rhs)
virtual void initializePage(int id)
void setField(const QString &name, const QVariant &value)
WizardOptions options() const
void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap)
QWizardPage * currentPage() const
void setOptions(WizardOptions options)
QPixmap pixmap(QWizard::WizardPixmap which) const
QWizardPage(QWidget *parent=0)
QString title
the title of the page
static const char *const buttonSlots[QWizard::NStandardButtons]
QString buttonText(QWizard::WizardButton which) const
virtual int nextId() const
void setPixmap(WizardPixmap which, const QPixmap &pixmap)
QWizardPage * page(int id) const
Qt::TextFormat subTitleFormat() const
QString buttonText(WizardButton which) const
static const char * extension(bool pgp, bool sign, bool encrypt, bool ascii, bool detached)
QList< int > visitedPages() const
bool testOption(WizardOption option) const
virtual void initializePage()
virtual bool isComplete() const
const int GapBetweenLogoAndRightEdge
static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX, const QByteArray &classY)
const int MacButtonTopMargin
void setPage(int id, QWizardPage *page)
QWidget * sideWidget() const
The QWizard class provides a framework for wizards.
void setVisible(bool visible)
void setSubTitle(const QString &subTitle)
void registerField(const QString &name, QWidget *widget, const char *property=0, const char *changedSignal=0)