Changeset 561 for trunk/src/gui/dialogs/qwizard.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/dialogs/qwizard.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 70 70 #include <qdebug.h> 71 71 72 #ifdef Q_ OS_WINCE72 #ifdef Q_WS_WINCE 73 73 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp 74 74 #endif 75 75 76 76 #include <string.h> // for memset() 77 78 #ifdef QT_SOFTKEYS_ENABLED 79 #include "qaction.h" 80 #endif 77 81 78 82 QT_BEGIN_NAMESPACE … … 84 88 const int MacButtonTopMargin = 13; 85 89 const int MacLayoutLeftMargin = 20; 86 const int MacLayoutTopMargin = 14; 90 //const int MacLayoutTopMargin = 14; // Unused. Save some space and avoid warning. 87 91 const int MacLayoutRightMargin = 20; 88 92 const int MacLayoutBottomMargin = 17; … … 245 249 && topLevelMarginRight == other.topLevelMarginRight 246 250 && topLevelMarginTop == other.topLevelMarginTop 247 && topLevelMarginBottom == other.topLevelMarginBottom 251 && topLevelMarginBottom == other.topLevelMarginBottom 248 252 && childMarginLeft == other.childMarginLeft 249 253 && childMarginRight == other.childMarginRight … … 329 333 QWizard *wiz = parentWidget() ? qobject_cast <QWizard *>(parentWidget()->parentWidget()) : 0; 330 334 if (wiz) { 331 // Designer dosen't support the Vista style for Wizards. This property is used to turn 335 // Designer dosen't support the Vista style for Wizards. This property is used to turn 332 336 // off the Vista style. 333 337 const QVariant v = wiz->property("_q_wizard_vista_off"); … … 344 348 bool modern = ((info.wizStyle == QWizard::ModernStyle) 345 349 #if !defined(QT_NO_STYLE_WINDOWSVISTA) 346 || ((info.wizStyle == QWizard::AeroStyle )347 && (QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled())350 || ((info.wizStyle == QWizard::AeroStyle 351 && QVistaHelper::vistaState() == QVistaHelper::Classic) || vistaDisabled()) 348 352 #endif 349 353 ); … … 378 382 There is no widthForHeight() function, so we simulate it with a loop. 379 383 */ 380 int candidateSubTitleWidth = qMin(512, 2 * qApp->desktop()->width() / 3);384 int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3); 381 385 int delta = candidateSubTitleWidth >> 1; 382 386 while (delta > 0) { … … 524 528 , maximumHeight(QWIDGETSIZE_MAX) 525 529 { 526 for (int i = 0; i < QWizard::NButtons; ++i) 530 for (int i = 0; i < QWizard::NButtons; ++i) { 527 531 btns[i] = 0; 532 #ifdef QT_SOFTKEYS_ENABLED 533 softKeys[i] = 0; 534 #endif 535 } 528 536 #if !defined(QT_NO_STYLE_WINDOWSVISTA) 529 537 if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA … … 561 569 void _q_emitCustomButtonClicked(); 562 570 void _q_updateButtonStates(); 571 void _q_handleFieldObjectDestroyed(QObject *); 563 572 void setStyle(QStyle *style); 564 573 #ifdef Q_WS_MAC … … 609 618 QLabel *subTitleLabel; 610 619 QWizardRuler *bottomRuler; 620 #ifdef QT_SOFTKEYS_ENABLED 621 mutable QAction *softKeys[QWizard::NButtons]; 622 #endif 611 623 612 624 QVBoxLayout *pageVBoxLayout; … … 634 646 const bool macStyle = (wstyle == QWizard::MacStyle); 635 647 switch (which) { 636 case QWizard::BackButton: 648 case QWizard::BackButton: 637 649 return macStyle ? QWizard::tr("Go Back") : QWizard::tr("< &Back"); 638 case QWizard::NextButton: 650 case QWizard::NextButton: 639 651 if (macStyle) 640 652 return QWizard::tr("Continue"); … … 732 744 void QWizardPrivate::addField(const QWizardField &field) 733 745 { 746 Q_Q(QWizard); 747 734 748 QWizardField myField = field; 735 749 myField.resolve(defaultPropertyTable); … … 745 759 QObject::connect(myField.object, myField.changedSignal, 746 760 myField.page, SLOT(_q_maybeEmitCompleteChanged())); 761 QObject::connect( 762 myField.object, SIGNAL(destroyed(QObject*)), q, 763 SLOT(_q_handleFieldObjectDestroyed(QObject*))); 747 764 } 748 765 749 766 void QWizardPrivate::removeFieldAt(int index) 750 767 { 768 Q_Q(QWizard); 769 751 770 const QWizardField &field = fields.at(index); 752 771 fieldIndexMap.remove(field.name); … … 754 773 QObject::disconnect(field.object, field.changedSignal, 755 774 field.page, SLOT(_q_maybeEmitCompleteChanged())); 775 QObject::disconnect( 776 field.object, SIGNAL(destroyed(QObject*)), q, 777 SLOT(_q_handleFieldObjectDestroyed(QObject*))); 756 778 fields.remove(index); 757 779 } … … 949 971 mainLayout->setMargin(0); 950 972 mainLayout->setSpacing(0); 951 pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop, 973 pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop, 952 974 deltaMarginRight, deltaMarginBottom); 953 buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 975 buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 954 976 info.topLevelMarginRight, info.topLevelMarginBottom); 955 977 } else { 956 mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 978 mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 957 979 info.topLevelMarginRight, info.topLevelMarginBottom); 958 980 mainLayout->setHorizontalSpacing(info.hspacing); … … 1202 1224 Q_ASSERT(bottomSpacer); 1203 1225 bottomSpacer->changeSize(0, 0, QSizePolicy::Ignored, expandPage ? QSizePolicy::Ignored : QSizePolicy::MinimumExpanding); 1204 pageVBoxLayout->invalidate(); 1226 pageVBoxLayout->invalidate(); 1205 1227 } 1206 1228 … … 1241 1263 #endif 1242 1264 QSize minimumSize = mainLayout->totalMinimumSize() + QSize(0, extraHeight); 1243 QSize maximumSize; 1244 #if defined(Q_WS_WIN) 1245 if (QSysInfo::WindowsVersion > QSysInfo::WV_Me) // ### See Tasks 164078 and 161660 1246 #endif 1247 maximumSize = mainLayout->totalMaximumSize(); 1265 QSize maximumSize = mainLayout->totalMaximumSize(); 1248 1266 if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) { 1249 1267 minimumSize.setWidth(headerWidget->maximumWidth()); … … 1321 1339 if (which < QWizard::NStandardButtons) 1322 1340 pushButton->setText(buttonDefaultText(wizStyle, which, this)); 1341 1342 #ifdef QT_SOFTKEYS_ENABLED 1343 QAction *softKey = new QAction(pushButton->text(), pushButton); 1344 QAction::SoftKeyRole softKeyRole; 1345 switch(which) { 1346 case QWizard::NextButton: 1347 case QWizard::FinishButton: 1348 case QWizard::CancelButton: 1349 softKeyRole = QAction::NegativeSoftKey; 1350 break; 1351 case QWizard::BackButton: 1352 case QWizard::CommitButton: 1353 case QWizard::HelpButton: 1354 case QWizard::CustomButton1: 1355 case QWizard::CustomButton2: 1356 case QWizard::CustomButton3: 1357 default: 1358 softKeyRole = QAction::PositiveSoftKey; 1359 break; 1360 } 1361 softKey->setSoftKeyRole(softKeyRole); 1362 softKeys[which] = softKey; 1363 #endif 1323 1364 connectButton(which); 1324 1365 } … … 1334 1375 QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked())); 1335 1376 } 1377 1378 #ifdef QT_SOFTKEYS_ENABLED 1379 QObject::connect(softKeys[which], SIGNAL(triggered()), btns[which], SIGNAL(clicked())); 1380 #endif 1336 1381 } 1337 1382 … … 1347 1392 else if (i < QWizard::NStandardButtons) 1348 1393 btns[i]->setText(buttonDefaultText(wizStyle, i, this)); 1394 #ifdef QT_SOFTKEYS_ENABLED 1395 softKeys[i]->setText(btns[i]->text()); 1396 #endif 1349 1397 } 1350 1398 } … … 1466 1514 inHandleAeroStyleChange = true; 1467 1515 1468 vistaHelper-> backButton()->disconnect();1516 vistaHelper->disconnectBackButton(); 1469 1517 q->removeEventFilter(vistaHelper); 1470 1518 … … 1490 1538 } else { 1491 1539 q->setMouseTracking(true); // ### original value possibly different 1540 #ifndef QT_NO_CURSOR 1492 1541 q->unsetCursor(); // ### ditto 1542 #endif 1493 1543 antiFlickerWidget->move(0, 0); 1494 vistaHelper-> backButton()->hide();1544 vistaHelper->hideBackButton(); 1495 1545 vistaHelper->setTitleBarIconAndCaptionVisible(true); 1496 1546 } … … 1589 1639 #endif 1590 1640 1641 #ifdef QT_SOFTKEYS_ENABLED 1642 QAbstractButton *wizardButton; 1643 for (int i = 0; i < QWizard::NButtons; ++i) { 1644 wizardButton = btns[i]; 1645 if (wizardButton && !wizardButton->testAttribute(Qt::WA_WState_Hidden)) { 1646 wizardButton->hide(); 1647 q->addAction(softKeys[i]); 1648 } else { 1649 q->removeAction(softKeys[i]); 1650 } 1651 } 1652 #endif 1653 1591 1654 enableUpdates(); 1655 } 1656 1657 void QWizardPrivate::_q_handleFieldObjectDestroyed(QObject *object) 1658 { 1659 QVector<QWizardField>::iterator it = fields.begin(); 1660 while (it != fields.end()) { 1661 const QWizardField &field = *it; 1662 if (field.object == object) { 1663 fieldIndexMap.remove(field.name); 1664 it = fields.erase(it); 1665 } else { 1666 ++it; 1667 } 1668 } 1592 1669 } 1593 1670 … … 1603 1680 1604 1681 #ifdef Q_WS_MAC 1605 1606 #ifdef Q_WS_MAC321607 QT_BEGIN_INCLUDE_NAMESPACE1608 #include <QuickTime/QuickTime.h>1609 QT_END_INCLUDE_NAMESPACE1610 typedef OSErr (*PtrQTNewDataReferenceFromCFURL)(CFURLRef, UInt32, Handle*, OSType*);1611 typedef OSErr (*PtrGetGraphicsImporterForDataRefWithFlags)(Handle, OSType, ComponentInstance*, long);1612 typedef ComponentResult (*PtrGraphicsImportSetFlags)(GraphicsImportComponent, long);1613 typedef ComponentResult (*PtrGraphicsImportCreateCGImage)(GraphicsImportComponent, CGImageRef*, UInt32);1614 1615 static PtrQTNewDataReferenceFromCFURL ptrQTNewDataReferenceFromCFURL = 0;1616 static PtrGetGraphicsImporterForDataRefWithFlags ptrGetGraphicsImporterForDataRefWithFlags = 0;1617 static PtrGraphicsImportSetFlags ptrGraphicsImportSetFlags = 0;1618 static PtrGraphicsImportCreateCGImage ptrGraphicsImportCreateCGImage = 0;1619 1620 static bool resolveQuickTimeSymbols()1621 {1622 if (ptrQTNewDataReferenceFromCFURL == 0) {1623 QLibrary library(QLatin1String("/System/Library/Frameworks/QuickTime.framework/QuickTime"));1624 ptrQTNewDataReferenceFromCFURL = reinterpret_cast<PtrQTNewDataReferenceFromCFURL>(library.resolve("QTNewDataReferenceFromCFURL"));1625 ptrGetGraphicsImporterForDataRefWithFlags = reinterpret_cast<PtrGetGraphicsImporterForDataRefWithFlags>(library.resolve("GetGraphicsImporterForDataRefWithFlags"));1626 ptrGraphicsImportSetFlags = reinterpret_cast<PtrGraphicsImportSetFlags>(library.resolve("GraphicsImportSetFlags"));1627 ptrGraphicsImportCreateCGImage = reinterpret_cast<PtrGraphicsImportCreateCGImage>(library.resolve("GraphicsImportCreateCGImage"));1628 }1629 1630 return ptrQTNewDataReferenceFromCFURL != 0 && ptrGetGraphicsImporterForDataRefWithFlags != 01631 && ptrGraphicsImportSetFlags != 0 && ptrGraphicsImportCreateCGImage != 0;1632 }1633 1634 1635 static QPixmap quicktimeTiff(const CFURLRef url)1636 {1637 if (!resolveQuickTimeSymbols())1638 return QPixmap();1639 1640 QCFType <CGImageRef> imageRef = 0;1641 Handle dataRef;1642 OSType dataRefType;1643 GraphicsImportComponent gi;1644 ComponentResult result;1645 result = ptrQTNewDataReferenceFromCFURL(url, 0, &dataRef, &dataRefType);1646 if (dataRef != 0) {1647 OSStatus err = ptrGetGraphicsImporterForDataRefWithFlags(dataRef, dataRefType, &gi, 0);1648 if (err == noErr && gi) {1649 result = ptrGraphicsImportSetFlags(gi, (kGraphicsImporterDontDoGammaCorrection1650 + kGraphicsImporterDontUseColorMatching));1651 if (!result)1652 result = ptrGraphicsImportCreateCGImage(gi, &imageRef, 0);1653 if (result)1654 qWarning("Qt: Problem reading TIFF image %ld(%s:%d)", result, __FILE__, __LINE__);1655 DisposeHandle(dataRef);1656 CloseComponent(gi);1657 }1658 }1659 1660 if (imageRef)1661 return QPixmap::fromMacCGImageRef(imageRef);1662 return QPixmap();1663 }1664 #endif // Q_WS_MAC321665 1682 1666 1683 QPixmap QWizardPrivate::findDefaultBackgroundPixmap() … … 1675 1692 url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("tif"), 0); 1676 1693 if (url) { 1677 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 1678 if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) { 1679 QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0); 1680 QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); 1681 if (image) { 1682 int width = CGImageGetWidth(image); 1683 int height = CGImageGetHeight(image); 1684 if (width == ExpectedImageWidth && height == ExpectedImageHeight) 1685 return QPixmap::fromMacCGImageRef(image); 1686 } 1687 } else 1688 #endif 1689 { 1690 #ifdef Q_WS_MAC32 1691 return quicktimeTiff(url); 1692 #endif 1694 QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0); 1695 QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0); 1696 if (image) { 1697 int width = CGImageGetWidth(image); 1698 int height = CGImageGetHeight(image); 1699 if (width == ExpectedImageWidth && height == ExpectedImageHeight) 1700 return QPixmap::fromMacCGImageRef(image); 1693 1701 } 1694 1702 } … … 2121 2129 Q_D(QWizard); 2122 2130 d->init(); 2123 #ifdef Q_ OS_WINCE2131 #ifdef Q_WS_WINCE 2124 2132 if (!qt_wince_is_mobile()) 2125 2133 setWindowFlags(windowFlags() & ~Qt::WindowOkButtonHint); … … 2837 2845 Q_D(const QWizard); 2838 2846 QSize result = d->mainLayout->totalSizeHint(); 2847 #ifdef Q_WS_S60 2848 QSize extra(QApplication::desktop()->availableGeometry(QCursor::pos()).size()); 2849 #else 2839 2850 QSize extra(500, 360); 2851 #endif 2840 2852 if (d->wizStyle == MacStyle && d->current != -1) { 2841 2853 QSize pixmap(currentPage()->pixmap(BackgroundPixmap).size()); … … 3437 3449 changes. This ensures that QWizard updates the enabled or disabled state of 3438 3450 its buttons. An example of the reimplementation is 3439 available \l{http:// doc.trolltech.com/qq/qq22-qwizard.html#validatebeforeitstoolate}3440 {here}. 3451 available \l{http://qt.nokia.com/doc/qq/qq22-qwizard.html#validatebeforeitstoolate} 3452 {here}. 3441 3453 3442 3454 \sa completeChanged(), isFinalPage()
Note:
See TracChangeset
for help on using the changeset viewer.