216 public: |
216 public: |
217 inline QWizardLayoutInfo() |
217 inline QWizardLayoutInfo() |
218 : topLevelMarginLeft(-1), topLevelMarginRight(-1), topLevelMarginTop(-1), |
218 : topLevelMarginLeft(-1), topLevelMarginRight(-1), topLevelMarginTop(-1), |
219 topLevelMarginBottom(-1), childMarginLeft(-1), childMarginRight(-1), |
219 topLevelMarginBottom(-1), childMarginLeft(-1), childMarginRight(-1), |
220 childMarginTop(-1), childMarginBottom(-1), hspacing(-1), vspacing(-1), |
220 childMarginTop(-1), childMarginBottom(-1), hspacing(-1), vspacing(-1), |
221 wizStyle(QWizard::ClassicStyle), header(false), watermark(false), title(false), |
221 wizStyle(QWizard::ClassicStyle), header(false), watermark(false), title(false), |
222 subTitle(false), extension(false) {} |
222 subTitle(false), extension(false), sideWidget(false) {} |
223 |
223 |
224 int topLevelMarginLeft; |
224 int topLevelMarginLeft; |
225 int topLevelMarginRight; |
225 int topLevelMarginRight; |
226 int topLevelMarginTop; |
226 int topLevelMarginTop; |
227 int topLevelMarginBottom; |
227 int topLevelMarginBottom; |
259 && wizStyle == other.wizStyle |
260 && wizStyle == other.wizStyle |
260 && header == other.header |
261 && header == other.header |
261 && watermark == other.watermark |
262 && watermark == other.watermark |
262 && title == other.title |
263 && title == other.title |
263 && subTitle == other.subTitle |
264 && subTitle == other.subTitle |
264 && extension == other.extension; |
265 && extension == other.extension |
|
266 && sideWidget == other.sideWidget; |
265 } |
267 } |
266 |
268 |
267 class QWizardHeader : public QWidget |
269 class QWizardHeader : public QWidget |
268 { |
270 { |
269 public: |
271 public: |
423 public: |
425 public: |
424 inline QWizardRuler(QWidget *parent = 0) |
426 inline QWizardRuler(QWidget *parent = 0) |
425 : QWizardHeader(Ruler, parent) {} |
427 : QWizardHeader(Ruler, parent) {} |
426 }; |
428 }; |
427 |
429 |
|
430 class QWatermarkLabel : public QLabel |
|
431 { |
|
432 public: |
|
433 QWatermarkLabel(QWidget *parent, QWidget *sideWidget) : QLabel(parent), m_sideWidget(sideWidget) { |
|
434 m_layout = new QVBoxLayout(this); |
|
435 if (m_sideWidget) |
|
436 m_layout->addWidget(m_sideWidget); |
|
437 } |
|
438 |
|
439 QSize minimumSizeHint() const { |
|
440 if (!pixmap() && !pixmap()->isNull()) |
|
441 return pixmap()->size(); |
|
442 return QFrame::minimumSizeHint(); |
|
443 } |
|
444 |
|
445 void setSideWidget(QWidget *widget) { |
|
446 if (m_sideWidget == widget) |
|
447 return; |
|
448 if (m_sideWidget) { |
|
449 m_layout->removeWidget(m_sideWidget); |
|
450 m_sideWidget->hide(); |
|
451 } |
|
452 m_sideWidget = widget; |
|
453 if (m_sideWidget) |
|
454 m_layout->addWidget(m_sideWidget); |
|
455 } |
|
456 QWidget *sideWidget() const { |
|
457 return m_sideWidget; |
|
458 } |
|
459 private: |
|
460 QVBoxLayout *m_layout; |
|
461 QWidget *m_sideWidget; |
|
462 }; |
|
463 |
428 class QWizardPagePrivate : public QWidgetPrivate |
464 class QWizardPagePrivate : public QWidgetPrivate |
429 { |
465 { |
430 Q_DECLARE_PUBLIC(QWizardPage) |
466 Q_DECLARE_PUBLIC(QWizardPage) |
431 |
467 |
432 public: |
468 public: |
511 , subTitleFmt(Qt::AutoText) |
548 , subTitleFmt(Qt::AutoText) |
512 , placeholderWidget1(0) |
549 , placeholderWidget1(0) |
513 , placeholderWidget2(0) |
550 , placeholderWidget2(0) |
514 , headerWidget(0) |
551 , headerWidget(0) |
515 , watermarkLabel(0) |
552 , watermarkLabel(0) |
|
553 , sideWidget(0) |
516 , titleLabel(0) |
554 , titleLabel(0) |
517 , subTitleLabel(0) |
555 , subTitleLabel(0) |
518 , bottomRuler(0) |
556 , bottomRuler(0) |
519 #if !defined(QT_NO_STYLE_WINDOWSVISTA) |
557 #if !defined(QT_NO_STYLE_WINDOWSVISTA) |
520 , vistaInitPending(false) |
558 , vistaInitPending(false) |
579 QMap<QString, int> fieldIndexMap; |
617 QMap<QString, int> fieldIndexMap; |
580 QVector<QWizardDefaultProperty> defaultPropertyTable; |
618 QVector<QWizardDefaultProperty> defaultPropertyTable; |
581 QList<int> history; |
619 QList<int> history; |
582 QSet<int> initialized; // ### remove and move bit to QWizardPage? |
620 QSet<int> initialized; // ### remove and move bit to QWizardPage? |
583 int start; |
621 int start; |
|
622 bool startSetByUser; |
584 int current; |
623 int current; |
585 bool canContinue; |
624 bool canContinue; |
586 bool canFinish; |
625 bool canFinish; |
587 QWizardLayoutInfo layoutInfo; |
626 QWizardLayoutInfo layoutInfo; |
588 int disableUpdatesCount; |
627 int disableUpdatesCount; |
610 }; |
649 }; |
611 QWizardAntiFlickerWidget *antiFlickerWidget; |
650 QWizardAntiFlickerWidget *antiFlickerWidget; |
612 QWidget *placeholderWidget1; |
651 QWidget *placeholderWidget1; |
613 QWidget *placeholderWidget2; |
652 QWidget *placeholderWidget2; |
614 QWizardHeader *headerWidget; |
653 QWizardHeader *headerWidget; |
615 QLabel *watermarkLabel; |
654 QWatermarkLabel *watermarkLabel; |
|
655 QWidget *sideWidget; |
616 QFrame *pageFrame; |
656 QFrame *pageFrame; |
617 QLabel *titleLabel; |
657 QLabel *titleLabel; |
618 QLabel *subTitleLabel; |
658 QLabel *subTitleLabel; |
619 QWizardRuler *bottomRuler; |
659 QWizardRuler *bottomRuler; |
620 #ifdef QT_SOFTKEYS_ENABLED |
660 #ifdef QT_SOFTKEYS_ENABLED |
905 watermarkPixmap = page->pixmap(QWizard::WatermarkPixmap); |
945 watermarkPixmap = page->pixmap(QWizard::WatermarkPixmap); |
906 } |
946 } |
907 |
947 |
908 info.header = (info.wizStyle == QWizard::ClassicStyle || info.wizStyle == QWizard::ModernStyle) |
948 info.header = (info.wizStyle == QWizard::ClassicStyle || info.wizStyle == QWizard::ModernStyle) |
909 && !(opts & QWizard::IgnoreSubTitles) && !subTitleText.isEmpty(); |
949 && !(opts & QWizard::IgnoreSubTitles) && !subTitleText.isEmpty(); |
|
950 info.sideWidget = sideWidget; |
910 info.watermark = (info.wizStyle != QWizard::MacStyle) && (info.wizStyle != QWizard::AeroStyle) |
951 info.watermark = (info.wizStyle != QWizard::MacStyle) && (info.wizStyle != QWizard::AeroStyle) |
911 && !watermarkPixmap.isNull(); |
952 && !watermarkPixmap.isNull(); |
912 info.title = !info.header && !titleText.isEmpty(); |
953 info.title = !info.header && !titleText.isEmpty(); |
913 info.subTitle = !(opts & QWizard::IgnoreSubTitles) && !info.header && !subTitleText.isEmpty(); |
954 info.subTitle = !(opts & QWizard::IgnoreSubTitles) && !info.header && !subTitleText.isEmpty(); |
914 info.extension = info.watermark && (opts & QWizard::ExtendedWatermarkPixmap); |
955 info.extension = (info.watermark || info.sideWidget) && (opts & QWizard::ExtendedWatermarkPixmap); |
915 |
956 |
916 return info; |
957 return info; |
917 } |
958 } |
918 |
959 |
919 void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info) |
960 void QWizardPrivate::recreateLayout(const QWizardLayoutInfo &info) |
1094 pageFrame->setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin); |
1135 pageFrame->setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin); |
1095 } else { |
1136 } else { |
1096 pageFrame->setContentsMargins(hMargin, vMargin, hMargin, vMargin); |
1137 pageFrame->setContentsMargins(hMargin, vMargin, hMargin, vMargin); |
1097 } |
1138 } |
1098 |
1139 |
1099 if (info.watermark && !watermarkLabel) { |
1140 if ((info.watermark || info.sideWidget) && !watermarkLabel) { |
1100 watermarkLabel = new QLabel(antiFlickerWidget); |
1141 watermarkLabel = new QWatermarkLabel(antiFlickerWidget, sideWidget); |
1101 watermarkLabel->setBackgroundRole(QPalette::Base); |
1142 watermarkLabel->setBackgroundRole(QPalette::Base); |
1102 watermarkLabel->setMinimumHeight(1); |
1143 watermarkLabel->setMinimumHeight(1); |
1103 watermarkLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
1144 watermarkLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
1104 watermarkLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
1145 watermarkLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
1105 } |
1146 } |
1171 if (classic) |
1212 if (classic) |
1172 mainLayout->setRowMinimumHeight(row++, deltaVSpacing); |
1213 mainLayout->setRowMinimumHeight(row++, deltaVSpacing); |
1173 |
1214 |
1174 mainLayout->addLayout(buttonLayout, row++, buttonStartColumn, 1, buttonNumColumns); |
1215 mainLayout->addLayout(buttonLayout, row++, buttonStartColumn, 1, buttonNumColumns); |
1175 |
1216 |
1176 if (info.watermark) { |
1217 if (info.watermark || info.sideWidget) { |
1177 if (info.extension) |
1218 if (info.extension) |
1178 watermarkEndRow = row; |
1219 watermarkEndRow = row; |
1179 mainLayout->addWidget(watermarkLabel, watermarkStartRow, 0, |
1220 mainLayout->addWidget(watermarkLabel, watermarkStartRow, 0, |
1180 watermarkEndRow - watermarkStartRow, 1); |
1221 watermarkEndRow - watermarkStartRow, 1); |
1181 } |
1222 } |
1231 headerWidget->setup(info, page->title(), page->subTitle(), |
1272 headerWidget->setup(info, page->title(), page->subTitle(), |
1232 page->pixmap(QWizard::LogoPixmap), page->pixmap(QWizard::BannerPixmap), |
1273 page->pixmap(QWizard::LogoPixmap), page->pixmap(QWizard::BannerPixmap), |
1233 titleFmt, subTitleFmt); |
1274 titleFmt, subTitleFmt); |
1234 } |
1275 } |
1235 |
1276 |
1236 if (info.watermark) { |
1277 if (info.watermark || info.sideWidget) { |
1237 Q_ASSERT(page); |
1278 QPixmap pix; |
1238 watermarkLabel->setPixmap(page->pixmap(QWizard::WatermarkPixmap)); |
1279 if (info.watermark) { |
1239 } |
1280 if (page) |
|
1281 pix = page->pixmap(QWizard::WatermarkPixmap); |
|
1282 else |
|
1283 pix = q->pixmap(QWizard::WatermarkPixmap); |
|
1284 } |
|
1285 watermarkLabel->setPixmap(pix); // in case there is no watermark and we show the side widget we need to clear the watermark |
|
1286 } |
|
1287 |
1240 if (info.title) { |
1288 if (info.title) { |
1241 Q_ASSERT(page); |
1289 Q_ASSERT(page); |
1242 titleLabel->setTextFormat(titleFmt); |
1290 titleLabel->setTextFormat(titleFmt); |
1243 titleLabel->setText(page->title()); |
1291 titleLabel->setText(page->title()); |
1244 } |
1292 } |
1265 QSize maximumSize = mainLayout->totalMaximumSize(); |
1313 QSize maximumSize = mainLayout->totalMaximumSize(); |
1266 if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) { |
1314 if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) { |
1267 minimumSize.setWidth(headerWidget->maximumWidth()); |
1315 minimumSize.setWidth(headerWidget->maximumWidth()); |
1268 maximumSize.setWidth(headerWidget->maximumWidth()); |
1316 maximumSize.setWidth(headerWidget->maximumWidth()); |
1269 } |
1317 } |
1270 if (info.watermark) { |
1318 if (info.watermark && !info.sideWidget) { |
1271 minimumSize.setHeight(mainLayout->totalSizeHint().height()); |
1319 minimumSize.setHeight(mainLayout->totalSizeHint().height()); |
1272 maximumSize.setHeight(mainLayout->totalSizeHint().height()); |
1320 maximumSize.setHeight(mainLayout->totalSizeHint().height()); |
1273 } |
1321 } |
1274 if (q->minimumWidth() == minimumWidth) { |
1322 if (q->minimumWidth() == minimumWidth) { |
1275 minimumWidth = minimumSize.width(); |
1323 minimumWidth = minimumSize.width(); |
2147 Adds the given \a page to the wizard, and returns the page's ID. |
2195 Adds the given \a page to the wizard, and returns the page's ID. |
2148 |
2196 |
2149 The ID is guaranteed to be larger than any other ID in the |
2197 The ID is guaranteed to be larger than any other ID in the |
2150 QWizard so far. |
2198 QWizard so far. |
2151 |
2199 |
2152 \sa setPage(), page() |
2200 \sa setPage(), page(), pageAdded() |
2153 */ |
2201 */ |
2154 int QWizard::addPage(QWizardPage *page) |
2202 int QWizard::addPage(QWizardPage *page) |
2155 { |
2203 { |
2156 Q_D(QWizard); |
2204 Q_D(QWizard); |
2157 int theid = 0; |
2205 int theid = 0; |
2164 /*! |
2212 /*! |
2165 \fn void QWizard::setPage(int id, QWizardPage *page) |
2213 \fn void QWizard::setPage(int id, QWizardPage *page) |
2166 |
2214 |
2167 Adds the given \a page to the wizard with the given \a id. |
2215 Adds the given \a page to the wizard with the given \a id. |
2168 |
2216 |
2169 \sa addPage(), page() |
2217 \note Adding a page may influence the value of the startId property |
|
2218 in case it was not set explicitly. |
|
2219 |
|
2220 \sa addPage(), page(), pageAdded() |
2170 */ |
2221 */ |
2171 void QWizard::setPage(int theid, QWizardPage *page) |
2222 void QWizard::setPage(int theid, QWizardPage *page) |
2172 { |
2223 { |
2173 Q_D(QWizard); |
2224 Q_D(QWizard); |
2174 |
2225 |
2208 d->pageVBoxLayout->insertWidget(n - 1, page); |
2259 d->pageVBoxLayout->insertWidget(n - 1, page); |
2209 |
2260 |
2210 // hide new page and reset layout to old status |
2261 // hide new page and reset layout to old status |
2211 page->hide(); |
2262 page->hide(); |
2212 d->pageVBoxLayout->setEnabled(pageVBoxLayoutEnabled); |
2263 d->pageVBoxLayout->setEnabled(pageVBoxLayoutEnabled); |
|
2264 |
|
2265 if (!d->startSetByUser && d->pageMap.constBegin().key() == theid) |
|
2266 d->start = theid; |
|
2267 emit pageAdded(theid); |
2213 } |
2268 } |
2214 |
2269 |
2215 /*! |
2270 /*! |
2216 Removes the page with the given \a id. cleanupPage() will be called if necessary. |
2271 Removes the page with the given \a id. cleanupPage() will be called if necessary. |
|
2272 |
|
2273 \note Removing a page may influence the value of the startId property. |
|
2274 |
2217 \since 4.5 |
2275 \since 4.5 |
2218 \sa addPage(), setPage() |
2276 \sa addPage(), setPage(), pageRemoved(), startId() |
2219 */ |
2277 */ |
2220 void QWizard::removePage(int id) |
2278 void QWizard::removePage(int id) |
2221 { |
2279 { |
2222 Q_D(QWizard); |
2280 Q_D(QWizard); |
2223 |
2281 |
2224 QWizardPage *removedPage = 0; |
2282 QWizardPage *removedPage = 0; |
2225 |
2283 |
2226 if (d->start == id) |
2284 // update startItem accordingly |
2227 d->start = -1; |
2285 if (d->pageMap.count() > 0) { // only if we have any pages |
|
2286 if (d->start == id) { |
|
2287 const int firstId = d->pageMap.constBegin().key(); |
|
2288 if (firstId == id) { |
|
2289 if (d->pageMap.count() > 1) |
|
2290 d->start = (++d->pageMap.constBegin()).key(); // secondId |
|
2291 else |
|
2292 d->start = -1; // removing the last page |
|
2293 } else { // startSetByUser has to be "true" here |
|
2294 d->start = firstId; |
|
2295 } |
|
2296 d->startSetByUser = false; |
|
2297 } |
|
2298 } |
|
2299 |
|
2300 if (d->pageMap.contains(id)) |
|
2301 emit pageRemoved(id); |
2228 |
2302 |
2229 if (!d->history.contains(id)) { |
2303 if (!d->history.contains(id)) { |
2230 // Case 1: removing a page not in the history |
2304 // Case 1: removing a page not in the history |
2231 removedPage = d->pageMap.take(id); |
2305 removedPage = d->pageMap.take(id); |
2232 d->updateCurrentPage(); |
2306 d->updateCurrentPage(); |
2332 \sa restart(), nextId() |
2406 \sa restart(), nextId() |
2333 */ |
2407 */ |
2334 void QWizard::setStartId(int theid) |
2408 void QWizard::setStartId(int theid) |
2335 { |
2409 { |
2336 Q_D(QWizard); |
2410 Q_D(QWizard); |
2337 if (!d->pageMap.contains(theid)) { |
2411 int newStart = theid; |
2338 qWarning("QWizard::setStartId: Invalid page ID %d", theid); |
2412 if (theid == -1) |
|
2413 newStart = d->pageMap.count() ? d->pageMap.constBegin().key() : -1; |
|
2414 |
|
2415 if (d->start == newStart) { |
|
2416 d->startSetByUser = theid != -1; |
2339 return; |
2417 return; |
2340 } |
2418 } |
2341 d->start = theid; |
2419 |
|
2420 if (!d->pageMap.contains(newStart)) { |
|
2421 qWarning("QWizard::setStartId: Invalid page ID %d", newStart); |
|
2422 return; |
|
2423 } |
|
2424 d->start = newStart; |
|
2425 d->startSetByUser = theid != -1; |
2342 } |
2426 } |
2343 |
2427 |
2344 int QWizard::startId() const |
2428 int QWizard::startId() const |
2345 { |
2429 { |
2346 Q_D(const QWizard); |
2430 Q_D(const QWizard); |
2347 if (d->start != -1) |
2431 return d->start; |
2348 return d->start; |
|
2349 if (!d->pageMap.isEmpty()) |
|
2350 return d->pageMap.constBegin().key(); |
|
2351 return -1; |
|
2352 } |
2432 } |
2353 |
2433 |
2354 /*! |
2434 /*! |
2355 Returns a pointer to the current page, or 0 if there is no current |
2435 Returns a pointer to the current page, or 0 if there is no current |
2356 page (e.g., before the wizard is shown). |
2436 page (e.g., before the wizard is shown). |
2823 } |
2903 } |
2824 d->defaultPropertyTable.append(QWizardDefaultProperty(className, property, changedSignal)); |
2904 d->defaultPropertyTable.append(QWizardDefaultProperty(className, property, changedSignal)); |
2825 } |
2905 } |
2826 |
2906 |
2827 /*! |
2907 /*! |
|
2908 \since 4.7 |
|
2909 |
|
2910 Sets the given \a widget to be shown on the left side of the wizard. |
|
2911 For styles which use the WatermarkPixmap (ClassicStyle and ModernStyle) |
|
2912 the side widget is displayed on top of the watermark, for other styles |
|
2913 or when the watermark is not provided the side widget is displayed |
|
2914 on the left side of the wizard. |
|
2915 |
|
2916 Passing 0 shows no side widget. |
|
2917 |
|
2918 When the \a widget is not 0 the wizard reparents it. |
|
2919 |
|
2920 Any previous side widget is hidden. |
|
2921 |
|
2922 You may call setSideWidget() with the same widget at different |
|
2923 times. |
|
2924 |
|
2925 All widgets set here will be deleted by the wizard when it is |
|
2926 destroyed unless you separately reparent the widget after setting |
|
2927 some other side widget (or 0). |
|
2928 |
|
2929 By default, no side widget is present. |
|
2930 */ |
|
2931 void QWizard::setSideWidget(QWidget *widget) |
|
2932 { |
|
2933 Q_D(QWizard); |
|
2934 |
|
2935 d->sideWidget = widget; |
|
2936 if (d->watermarkLabel) { |
|
2937 d->watermarkLabel->setSideWidget(widget); |
|
2938 d->updateLayout(); |
|
2939 } |
|
2940 } |
|
2941 |
|
2942 /*! |
|
2943 \since 4.7 |
|
2944 |
|
2945 Returns the widget on the left side of the wizard or 0. |
|
2946 |
|
2947 By default, no side widget is present. |
|
2948 */ |
|
2949 QWidget *QWizard::sideWidget() const |
|
2950 { |
|
2951 Q_D(const QWizard); |
|
2952 |
|
2953 return d->sideWidget; |
|
2954 } |
|
2955 |
|
2956 /*! |
2828 \reimp |
2957 \reimp |
2829 */ |
2958 */ |
2830 void QWizard::setVisible(bool visible) |
2959 void QWizard::setVisible(bool visible) |
2831 { |
2960 { |
2832 Q_D(QWizard); |
2961 Q_D(QWizard); |
2873 |
3002 |
2874 This signal is emitted when the current page changes, with the new |
3003 This signal is emitted when the current page changes, with the new |
2875 current \a id. |
3004 current \a id. |
2876 |
3005 |
2877 \sa currentId(), currentPage() |
3006 \sa currentId(), currentPage() |
|
3007 */ |
|
3008 |
|
3009 /*! |
|
3010 \fn void QWizard::pageAdded(int id) |
|
3011 |
|
3012 \since 4.7 |
|
3013 |
|
3014 This signal is emitted whenever a page is added to the |
|
3015 wizard. The page's \a id is passed as parameter. |
|
3016 |
|
3017 \sa addPage(), setPage(), startId() |
|
3018 */ |
|
3019 |
|
3020 /*! |
|
3021 \fn void QWizard::pageRemoved(int id) |
|
3022 |
|
3023 \since 4.7 |
|
3024 |
|
3025 This signal is emitted whenever a page is removed from the |
|
3026 wizard. The page's \a id is passed as parameter. |
|
3027 |
|
3028 \sa removePage(), startId() |
2878 */ |
3029 */ |
2879 |
3030 |
2880 /*! |
3031 /*! |
2881 \fn void QWizard::helpRequested() |
3032 \fn void QWizard::helpRequested() |
2882 |
3033 |