⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qwizard.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    q->setMaximumSize(mainLayout->totalMaximumSize());    if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX)        q->setFixedWidth(headerWidget->maximumWidth());    if (info.watermark)        q->setFixedHeight(mainLayout->totalSizeHint().height());}bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const{    if (uint(which) >= QWizard::NButtons)        return false;    if (!btns[which]) {        QPushButton *pushButton = new QPushButton(antiFlickerWidget);#ifdef Q_WS_MAC        pushButton->setAutoDefault(false);#endif        pushButton->hide();#ifdef Q_CC_HPACC        const_cast<QWizardPrivate *>(this)->btns[which] = pushButton;#else        btns[which] = pushButton;#endif        if (which < QWizard::NStandardButtons)            pushButton->setText(buttonDefaultTexts.value(wizStyle).value(which));        connectButton(which);    }    return true;}void QWizardPrivate::connectButton(QWizard::WizardButton which) const{    Q_Q(const QWizard);    if (which < QWizard::NStandardButtons) {        QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots[which]);    } else {        QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked()));    }}void QWizardPrivate::updateButtonTexts(){    Q_Q(QWizard);    for (int i = 0; i < QWizard::NButtons; ++i) {        if (btns[i]) {            if (q->currentPage() && (q->currentPage()->d_func()->buttonCustomTexts.contains(i)))                btns[i]->setText(q->currentPage()->d_func()->buttonCustomTexts.value(i));            else if (buttonCustomTexts.contains(i))                btns[i]->setText(buttonCustomTexts.value(i));            else if (i < QWizard::NStandardButtons)                btns[i]->setText(buttonDefaultTexts.value(wizStyle).value(i));        }    }}void QWizardPrivate::updateButtons(){    if (buttonsHaveCustomLayout) {        QVarLengthArray<QWizard::WizardButton> array(buttonsCustomLayout.count());        for (int i = 0; i < buttonsCustomLayout.count(); ++i)            array[i] = buttonsCustomLayout.at(i);        setButtonLayout(array.constData(), array.count());    } else {        // Positions:        //     Help Stretch Custom1 Custom2 Custom3 Cancel Back Next Commit Finish Cancel Help        const int ArraySize = 12;        QWizard::WizardButton array[ArraySize];        memset(array, -1, sizeof(array));        Q_ASSERT(array[0] == QWizard::NoButton);        if (opts & QWizard::HaveHelpButton) {            int i = (opts & QWizard::HelpButtonOnRight) ? 11 : 0;            array[i] = QWizard::HelpButton;        }        array[1] = QWizard::Stretch;        if (opts & QWizard::HaveCustomButton1)            array[2] = QWizard::CustomButton1;        if (opts & QWizard::HaveCustomButton2)            array[3] = QWizard::CustomButton2;        if (opts & QWizard::HaveCustomButton3)            array[4] = QWizard::CustomButton3;        if (!(opts & QWizard::NoCancelButton)) {            int i = (opts & QWizard::CancelButtonOnLeft) ? 5 : 10;            array[i] = QWizard::CancelButton;        }        array[6] = QWizard::BackButton;        array[7] = QWizard::NextButton;        array[8] = QWizard::CommitButton;        array[9] = QWizard::FinishButton;        setButtonLayout(array, ArraySize);    }}void QWizardPrivate::setButtonLayout(const QWizard::WizardButton *array, int size){    QWidget *prev = pageFrame;    for (int i = buttonLayout->count() - 1; i >= 0; --i) {        QLayoutItem *item = buttonLayout->takeAt(i);        if (QWidget *widget = item->widget())            widget->hide();        delete item;    }    for (int i = 0; i < size; ++i) {        QWizard::WizardButton which = array[i];        if (which == QWizard::Stretch) {            buttonLayout->addStretch(1);        } else if (which != QWizard::NoButton) {            ensureButton(which);            buttonLayout->addWidget(btns[which]);            // Back, Next, Commit, and Finish are handled in _q_updateButtonStates()            if (which != QWizard::BackButton && which != QWizard::NextButton                && which != QWizard::CommitButton && which != QWizard::FinishButton)                btns[which]->show();            if (prev)                QWidget::setTabOrder(prev, btns[which]);            prev = btns[which];        }    }    _q_updateButtonStates();}bool QWizardPrivate::buttonLayoutContains(QWizard::WizardButton which){    return !buttonsHaveCustomLayout || buttonsCustomLayout.contains(which);}void QWizardPrivate::updatePixmap(QWizard::WizardPixmap which){    Q_Q(QWizard);    if (which == QWizard::BackgroundPixmap) {        if (wizStyle == QWizard::MacStyle) {            q->update();            q->updateGeometry();        }    } else {        updateLayout();    }}#if !defined(QT_NO_STYLE_WINDOWSVISTA)void QWizardPrivate::handleAeroStyleChange(){    Q_Q(QWizard);    if (wizStyle == QWizard::AeroStyle) {        vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar);        q->installEventFilter(vistaHelper);        q->setMouseTracking(true); // due to faked title bar        antiFlickerWidget->move(0, vistaHelper->titleBarSize() + vistaHelper->topOffset());        QObject::connect(            vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots[QWizard::BackButton]);        vistaHelper->backButton()->show();    } else {        vistaHelper->setDWMTitleBar(QVistaHelper::NormalTitleBar);        q->removeEventFilter(vistaHelper);        q->setMouseTracking(false); // ### reset to original value (which could be true!)        antiFlickerWidget->move(0, 0);        vistaHelper->backButton()->disconnect();        vistaHelper->backButton()->hide();    }    _q_updateButtonStates();    updateButtonTexts(); // ### assume this is required - 2 B TESTED!    if (q->isVisible())        vistaHelper->setWindowPosHack();}#endifvoid QWizardPrivate::disableUpdates(){    Q_Q(QWizard);    if (disableUpdatesCount++ == 0) {        q->setUpdatesEnabled(false);        antiFlickerWidget->hide();    }}void QWizardPrivate::enableUpdates(){    Q_Q(QWizard);    if (--disableUpdatesCount == 0) {        antiFlickerWidget->show();        q->setUpdatesEnabled(true);    }}void QWizardPrivate::_q_emitCustomButtonClicked(){    Q_Q(QWizard);    QObject *button = q->sender();    for (int i = QWizard::NStandardButtons; i < QWizard::NButtons; ++i) {        if (btns[i] == button) {            emit q->customButtonClicked(QWizard::WizardButton(i));            break;        }    }}void QWizardPrivate::_q_updateButtonStates(){    Q_Q(QWizard);    disableUpdates();    const QWizardPage *page = q->currentPage();    bool complete = page && page->isComplete();    btn.back->setEnabled(history.count() > 1                         && !q->page(history.at(history.count() - 2))->isCommitPage()                         && (!canFinish || !(opts & QWizard::DisabledBackButtonOnLastPage)));    btn.next->setEnabled(canContinue && complete);    btn.commit->setEnabled(canContinue && complete);    btn.finish->setEnabled(canFinish && complete);    const bool backButtonVisible = buttonLayoutContains(QWizard::BackButton)        && (history.count() > 1 || !(opts & QWizard::NoBackButtonOnStartPage))        && (canContinue || !(opts & QWizard::NoBackButtonOnLastPage));    bool commitPage = page && page->isCommitPage();    btn.back->setVisible(backButtonVisible);    btn.next->setVisible(buttonLayoutContains(QWizard::NextButton) && !commitPage                         && (canContinue || (opts & QWizard::HaveNextButtonOnLastPage)));    btn.commit->setVisible(buttonLayoutContains(QWizard::CommitButton) && commitPage                           && canContinue);    btn.finish->setVisible(buttonLayoutContains(QWizard::FinishButton)                           && (canFinish || (opts & QWizard::HaveFinishButtonOnEarlyPages)));    bool useDefault = !(opts & QWizard::NoDefaultButton);    if (QPushButton *nextPush = qobject_cast<QPushButton *>(btn.next))        nextPush->setDefault(canContinue && useDefault && !commitPage);    if (QPushButton *commitPush = qobject_cast<QPushButton *>(btn.commit))        commitPush->setDefault(canContinue && useDefault && commitPage);    if (QPushButton *finishPush = qobject_cast<QPushButton *>(btn.finish))        finishPush->setDefault(!canContinue && useDefault);#if !defined(QT_NO_STYLE_WINDOWSVISTA)    if (wizStyle == QWizard::AeroStyle) {        vistaHelper->backButton()->setEnabled(btn.back->isEnabled());        vistaHelper->backButton()->setVisible(backButtonVisible);        btn.back->setVisible(false);    }#endif    enableUpdates();}#ifdef Q_WS_MAC#ifdef Q_WS_MAC32#include <QuickTime/QuickTime.h>typedef OSErr (*PtrQTNewDataReferenceFromCFURL)(CFURLRef, UInt32, Handle*, OSType*);typedef OSErr (*PtrGetGraphicsImporterForDataRefWithFlags)(Handle, OSType, ComponentInstance*, long);typedef ComponentResult (*PtrGraphicsImportSetFlags)(GraphicsImportComponent, long);typedef ComponentResult (*PtrGraphicsImportCreateCGImage)(GraphicsImportComponent, CGImageRef*, UInt32);static PtrQTNewDataReferenceFromCFURL ptrQTNewDataReferenceFromCFURL = 0;static PtrGetGraphicsImporterForDataRefWithFlags ptrGetGraphicsImporterForDataRefWithFlags = 0;static PtrGraphicsImportSetFlags ptrGraphicsImportSetFlags = 0;static PtrGraphicsImportCreateCGImage ptrGraphicsImportCreateCGImage = 0;static bool resolveQuickTimeSymbols(){    if (ptrQTNewDataReferenceFromCFURL == 0) {        QLibrary library(QLatin1String("/System/Library/Frameworks/QuickTime.framework/QuickTime"));        ptrQTNewDataReferenceFromCFURL = reinterpret_cast<PtrQTNewDataReferenceFromCFURL>(library.resolve("QTNewDataReferenceFromCFURL"));        ptrGetGraphicsImporterForDataRefWithFlags = reinterpret_cast<PtrGetGraphicsImporterForDataRefWithFlags>(library.resolve("GetGraphicsImporterForDataRefWithFlags"));        ptrGraphicsImportSetFlags = reinterpret_cast<PtrGraphicsImportSetFlags>(library.resolve("GraphicsImportSetFlags"));        ptrGraphicsImportCreateCGImage = reinterpret_cast<PtrGraphicsImportCreateCGImage>(library.resolve("GraphicsImportCreateCGImage"));    }    return ptrQTNewDataReferenceFromCFURL != 0 && ptrGetGraphicsImporterForDataRefWithFlags != 0           && ptrGraphicsImportSetFlags != 0 && ptrGraphicsImportCreateCGImage != 0;}static QPixmap quicktimeTiff(const CFURLRef url){    if (!resolveQuickTimeSymbols())        return QPixmap();    QCFType <CGImageRef> imageRef = 0;    Handle dataRef;    OSType dataRefType;    GraphicsImportComponent gi;    ComponentResult result;    result = ptrQTNewDataReferenceFromCFURL(url, 0, &dataRef, &dataRefType);    if (dataRef != 0) {        OSStatus err = ptrGetGraphicsImporterForDataRefWithFlags(dataRef, dataRefType, &gi, 0);        if (err == noErr && gi) {            result = ptrGraphicsImportSetFlags(gi, (kGraphicsImporterDontDoGammaCorrection                                                    + kGraphicsImporterDontUseColorMatching));            if (!result)                result = ptrGraphicsImportCreateCGImage(gi, &imageRef, 0);            if (result)                qWarning("Qt: Problem reading TIFF image %ld(%s:%d)", result, __FILE__, __LINE__);            DisposeHandle(dataRef);            CloseComponent(gi);        }    }    if (imageRef)        return QPixmap::fromMacCGImageRef(imageRef);    return QPixmap();}#endif // Q_WS_MAC32QPixmap QWizardPrivate::findDefaultBackgroundPixmap(){    QCFType<CFURLRef> url;    const int ExpectedImageWidth = 242;    const int ExpectedImageHeight = 414;    if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"),                                 0, 0, &url) == noErr) {        QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);        if (bundle) {            url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("tif"), 0);            if (url) {#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4                if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {                    QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithURL(url, 0);                    QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0);                    if (image) {                        int width = CGImageGetWidth(image);                        int height = CGImageGetHeight(image);                        if (width == ExpectedImageWidth && height == ExpectedImageHeight)                            return QPixmap::fromMacCGImageRef(image);                    }                } else#endif                {#ifdef Q_WS_MAC32                    return quicktimeTiff(url);#endif                }            }        }    }    return QPixmap();}#endif#if !defined(QT_NO_STYLE_WINDOWSVISTA)void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *){    if (wizard->wizardStyle() == QWizard::AeroStyle) {        int leftMargin, topMargin, rightMargin, bottomMargin;        wizardPrivate->buttonLayout->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);        const int buttonLayoutTop = wizardPrivate->buttonLayout->contentsRect().top() - topMargin;        QPainter painter(this);        const QBrush brush(QColor(240, 240, 240)); // ### hardcoded for now        painter.fillRect(0, buttonLayoutTop, width(), height() - buttonLayoutTop, brush);        painter.setPen(QPen(QBrush(QColor(223, 223, 223)), 0)); // ### hardcoded for now        painter.drawLine(0, buttonLayoutTop, width(), buttonLayoutTop);    }}#endif/*!    \class QWizard    \since 4.3    \brief The QWizard class provides a framework for wizards.    A wizard (also called an assistant on Mac OS X) is a special type    of input dialog that consists of a sequence of pages. A wizard's    purpose is to guide the user through a process step by step.    Wizards are useful for complex or infrequent tasks that users may    find difficult to learn.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -