Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/dialogs/qwizard.cpp

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    7070#include <qdebug.h>
    7171
    72 #ifdef Q_OS_WINCE
     72#ifdef Q_WS_WINCE
    7373extern bool qt_wince_is_mobile();     //defined in qguifunctions_wce.cpp
    7474#endif
    7575
    7676#include <string.h>     // for memset()
     77
     78#ifdef QT_SOFTKEYS_ENABLED
     79#include "qaction.h"
     80#endif
    7781
    7882QT_BEGIN_NAMESPACE
     
    8488const int MacButtonTopMargin = 13;
    8589const int MacLayoutLeftMargin = 20;
    86 const int MacLayoutTopMargin = 14;
     90//const int MacLayoutTopMargin = 14; // Unused. Save some space and avoid warning.
    8791const int MacLayoutRightMargin = 20;
    8892const int MacLayoutBottomMargin = 17;
     
    245249           && topLevelMarginRight == other.topLevelMarginRight
    246250           && topLevelMarginTop == other.topLevelMarginTop
    247            && topLevelMarginBottom == other.topLevelMarginBottom 
     251           && topLevelMarginBottom == other.topLevelMarginBottom
    248252           && childMarginLeft == other.childMarginLeft
    249253           && childMarginRight == other.childMarginRight
     
    329333    QWizard *wiz = parentWidget() ? qobject_cast <QWizard *>(parentWidget()->parentWidget()) : 0;
    330334    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
    332336        // off the Vista style.
    333337        const QVariant v = wiz->property("_q_wizard_vista_off");
     
    344348    bool modern = ((info.wizStyle == QWizard::ModernStyle)
    345349#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())
    348352#endif
    349353    );
     
    378382            There is no widthForHeight() function, so we simulate it with a loop.
    379383        */
    380         int candidateSubTitleWidth = qMin(512, 2 * qApp->desktop()->width() / 3);
     384        int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3);
    381385        int delta = candidateSubTitleWidth >> 1;
    382386        while (delta > 0) {
     
    524528        , maximumHeight(QWIDGETSIZE_MAX)
    525529    {
    526         for (int i = 0; i < QWizard::NButtons; ++i)
     530        for (int i = 0; i < QWizard::NButtons; ++i) {
    527531            btns[i] = 0;
     532#ifdef QT_SOFTKEYS_ENABLED
     533            softKeys[i] = 0;
     534#endif
     535        }
    528536#if !defined(QT_NO_STYLE_WINDOWSVISTA)
    529537        if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
     
    561569    void _q_emitCustomButtonClicked();
    562570    void _q_updateButtonStates();
     571    void _q_handleFieldObjectDestroyed(QObject *);
    563572    void setStyle(QStyle *style);
    564573#ifdef Q_WS_MAC
     
    609618    QLabel *subTitleLabel;
    610619    QWizardRuler *bottomRuler;
     620#ifdef QT_SOFTKEYS_ENABLED
     621    mutable QAction *softKeys[QWizard::NButtons];
     622#endif
    611623
    612624    QVBoxLayout *pageVBoxLayout;
     
    634646    const bool macStyle = (wstyle == QWizard::MacStyle);
    635647    switch (which) {
    636     case QWizard::BackButton: 
     648    case QWizard::BackButton:
    637649        return macStyle ? QWizard::tr("Go Back") : QWizard::tr("< &Back");
    638     case QWizard::NextButton: 
     650    case QWizard::NextButton:
    639651        if (macStyle)
    640652            return QWizard::tr("Continue");
     
    732744void QWizardPrivate::addField(const QWizardField &field)
    733745{
     746    Q_Q(QWizard);
     747
    734748    QWizardField myField = field;
    735749    myField.resolve(defaultPropertyTable);
     
    745759        QObject::connect(myField.object, myField.changedSignal,
    746760                         myField.page, SLOT(_q_maybeEmitCompleteChanged()));
     761    QObject::connect(
     762        myField.object, SIGNAL(destroyed(QObject*)), q,
     763        SLOT(_q_handleFieldObjectDestroyed(QObject*)));
    747764}
    748765
    749766void QWizardPrivate::removeFieldAt(int index)
    750767{
     768    Q_Q(QWizard);
     769
    751770    const QWizardField &field = fields.at(index);
    752771    fieldIndexMap.remove(field.name);
     
    754773        QObject::disconnect(field.object, field.changedSignal,
    755774                            field.page, SLOT(_q_maybeEmitCompleteChanged()));
     775    QObject::disconnect(
     776        field.object, SIGNAL(destroyed(QObject*)), q,
     777        SLOT(_q_handleFieldObjectDestroyed(QObject*)));
    756778    fields.remove(index);
    757779}
     
    949971            mainLayout->setMargin(0);
    950972            mainLayout->setSpacing(0);
    951             pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop, 
     973            pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop,
    952974                                               deltaMarginRight, deltaMarginBottom);
    953             buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 
     975            buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
    954976                                             info.topLevelMarginRight, info.topLevelMarginBottom);
    955977        } else {
    956             mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop, 
     978            mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
    957979                                           info.topLevelMarginRight, info.topLevelMarginBottom);
    958980            mainLayout->setHorizontalSpacing(info.hspacing);
     
    12021224        Q_ASSERT(bottomSpacer);
    12031225        bottomSpacer->changeSize(0, 0, QSizePolicy::Ignored, expandPage ? QSizePolicy::Ignored : QSizePolicy::MinimumExpanding);
    1204         pageVBoxLayout->invalidate();       
     1226        pageVBoxLayout->invalidate();
    12051227    }
    12061228
     
    12411263#endif
    12421264    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();
    12481266    if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) {
    12491267        minimumSize.setWidth(headerWidget->maximumWidth());
     
    13211339        if (which < QWizard::NStandardButtons)
    13221340            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
    13231364        connectButton(which);
    13241365    }
     
    13341375        QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked()));
    13351376    }
     1377
     1378#ifdef QT_SOFTKEYS_ENABLED
     1379    QObject::connect(softKeys[which], SIGNAL(triggered()), btns[which], SIGNAL(clicked()));
     1380#endif
    13361381}
    13371382
     
    13471392            else if (i < QWizard::NStandardButtons)
    13481393                btns[i]->setText(buttonDefaultText(wizStyle, i, this));
     1394#ifdef QT_SOFTKEYS_ENABLED
     1395            softKeys[i]->setText(btns[i]->text());
     1396#endif
    13491397        }
    13501398    }
     
    14661514    inHandleAeroStyleChange = true;
    14671515
    1468     vistaHelper->backButton()->disconnect();
     1516    vistaHelper->disconnectBackButton();
    14691517    q->removeEventFilter(vistaHelper);
    14701518
     
    14901538    } else {
    14911539        q->setMouseTracking(true); // ### original value possibly different
     1540#ifndef QT_NO_CURSOR
    14921541        q->unsetCursor(); // ### ditto
     1542#endif
    14931543        antiFlickerWidget->move(0, 0);
    1494         vistaHelper->backButton()->hide();
     1544        vistaHelper->hideBackButton();
    14951545        vistaHelper->setTitleBarIconAndCaptionVisible(true);
    14961546    }
     
    15891639#endif
    15901640
     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
    15911654    enableUpdates();
     1655}
     1656
     1657void 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    }
    15921669}
    15931670
     
    16031680
    16041681#ifdef Q_WS_MAC
    1605 
    1606 #ifdef Q_WS_MAC32
    1607 QT_BEGIN_INCLUDE_NAMESPACE
    1608 #include <QuickTime/QuickTime.h>
    1609 QT_END_INCLUDE_NAMESPACE
    1610 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 != 0
    1631            && 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, (kGraphicsImporterDontDoGammaCorrection
    1650                                                     + 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_MAC32
    16651682
    16661683QPixmap QWizardPrivate::findDefaultBackgroundPixmap()
     
    16751692            url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("tif"), 0);
    16761693            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);
    16931701                }
    16941702            }
     
    21212129    Q_D(QWizard);
    21222130    d->init();
    2123 #ifdef Q_OS_WINCE
     2131#ifdef Q_WS_WINCE
    21242132    if (!qt_wince_is_mobile())
    21252133        setWindowFlags(windowFlags() & ~Qt::WindowOkButtonHint);
     
    28372845    Q_D(const QWizard);
    28382846    QSize result = d->mainLayout->totalSizeHint();
     2847#ifdef Q_WS_S60
     2848    QSize extra(QApplication::desktop()->availableGeometry(QCursor::pos()).size());
     2849#else
    28392850    QSize extra(500, 360);
     2851#endif
    28402852    if (d->wizStyle == MacStyle && d->current != -1) {
    28412853        QSize pixmap(currentPage()->pixmap(BackgroundPixmap).size());
     
    34373449    changes. This ensures that QWizard updates the enabled or disabled state of
    34383450    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}.
    34413453
    34423454    \sa completeChanged(), isFinalPage()
Note: See TracChangeset for help on using the changeset viewer.