diff options
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qcolordialog.cpp | 4 | ||||
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 5 | ||||
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 2 | ||||
-rw-r--r-- | src/widgets/dialogs/qfontdialog.cpp | 6 | ||||
-rw-r--r-- | src/widgets/dialogs/qinputdialog.cpp | 9 | ||||
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 4 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 85 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.h | 3 |
8 files changed, 79 insertions, 39 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 2e6518dd17..4c5fb18766 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -907,10 +907,8 @@ public: QColSpinBox(QWidget *parent) : QSpinBox(parent) { setRange(0, 255); } void setValue(int i) { - bool block = signalsBlocked(); - blockSignals(true); + const QSignalBlocker blocker(this); QSpinBox::setValue(i); - blockSignals(block); } }; diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index cd95b824a6..804331b1cd 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1727,7 +1727,7 @@ int QFileDialogPrivate::maxNameLength(const QString &path) { #if defined(Q_OS_UNIX) return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX); -#elif defined(Q_OS_WINCE) +#elif defined(Q_OS_WINCE) || defined(Q_OS_WINRT) Q_UNUSED(path); return MAX_PATH; #elif defined(Q_OS_WIN) @@ -2625,9 +2625,8 @@ void QFileDialog::accept() // special case for ".." if (lineEditText == QLatin1String("..")) { d->_q_navigateToParent(); - bool block = d->qFileDialogUi->fileNameEdit->blockSignals(true); + const QSignalBlocker blocker(d->qFileDialogUi->fileNameEdit); d->lineEdit()->selectAll(); - d->qFileDialogUi->fileNameEdit->blockSignals(block); return; } diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index fa6306005b..bda448bde3 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1715,7 +1715,7 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile #ifndef QT_NO_FILESYSTEMWATCHER node->populate(info); #endif -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) //The parentNode is "" so we are listing the drives if (parentNode->fileName.isEmpty()) { wchar_t name[MAX_PATH + 1]; diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index d908a683a9..94e96a52c5 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -632,12 +632,11 @@ void QFontDialogPrivate::updateSizes() } sizeList->setCurrentItem(current); - sizeEdit->blockSignals(true); + const QSignalBlocker blocker(sizeEdit); sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText())); if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q) && sizeList->hasFocus()) sizeEdit->selectAll(); - sizeEdit->blockSignals(false); } else { sizeEdit->clear(); } @@ -750,9 +749,8 @@ void QFontDialogPrivate::_q_sizeChanged(const QString &s) if (sizeList->text(i).toInt() >= this->size) break; } - sizeList->blockSignals(true); + const QSignalBlocker blocker(sizeList); sizeList->setCurrentItem(i); - sizeList->blockSignals(false); } _q_updateSample(); } diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index 4eec2eb3e2..10d693b4a3 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -771,10 +771,11 @@ void QInputDialog::setComboBoxItems(const QStringList &items) Q_D(QInputDialog); d->ensureComboBox(); - d->comboBox->blockSignals(true); - d->comboBox->clear(); - d->comboBox->addItems(items); - d->comboBox->blockSignals(false); + { + const QSignalBlocker blocker(d->comboBox); + d->comboBox->clear(); + d->comboBox->addItems(items); + } if (inputMode() == TextInput) d->chooseRightTextInputWidget(); diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index ee2ef409d8..1b64b0ba67 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) HMENU qt_getWindowsSystemMenu(const QWidget *w) { if (QWindow *window = QApplicationPrivate::windowForWidget(w)) @@ -1620,7 +1620,7 @@ void QMessageBox::showEvent(QShowEvent *e) QAccessibleEvent event(this, QAccessible::Alert); QAccessible::updateAccessibility(&event); #endif -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) if (const HMENU systemMenu = qt_getWindowsSystemMenu(this)) { EnableMenuItem(systemMenu, SC_CLOSE, d->detectedEscapeButton ? MF_BYCOMMAND|MF_ENABLED : MF_BYCOMMAND|MF_GRAYED); diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index a667f299e8..1cd294e5ea 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -129,22 +129,41 @@ static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteA return false; } -const int NFallbackDefaultProperties = 7; - const struct { - const char *className; - const char *property; - const char *changedSignal; -} fallbackProperties[NFallbackDefaultProperties] = { + const char className[16]; + const char property[13]; +} fallbackProperties[] = { // If you modify this list, make sure to update the documentation (and the auto test) - { "QAbstractButton", "checked", SIGNAL(toggled(bool)) }, - { "QAbstractSlider", "value", SIGNAL(valueChanged(int)) }, - { "QComboBox", "currentIndex", SIGNAL(currentIndexChanged(int)) }, - { "QDateTimeEdit", "dateTime", SIGNAL(dateTimeChanged(QDateTime)) }, - { "QLineEdit", "text", SIGNAL(textChanged(QString)) }, - { "QListWidget", "currentRow", SIGNAL(currentRowChanged(int)) }, - { "QSpinBox", "value", SIGNAL(valueChanged(int)) } + { "QAbstractButton", "checked" }, + { "QAbstractSlider", "value" }, + { "QComboBox", "currentIndex" }, + { "QDateTimeEdit", "dateTime" }, + { "QLineEdit", "text" }, + { "QListWidget", "currentRow" }, + { "QSpinBox", "value" }, }; +const size_t NFallbackDefaultProperties = sizeof fallbackProperties / sizeof *fallbackProperties; + +static const char *changed_signal(int which) +{ + // since it might expand to a runtime function call (to + // qFlagLocations()), we cannot store the result of SIGNAL() in a + // character array and expect it to be statically initialized. To + // avoid the relocations caused by a char pointer table, use a + // switch statement: + switch (which) { + case 0: return SIGNAL(toggled(bool)); + case 1: return SIGNAL(valueChanged(int)); + case 2: return SIGNAL(currentIndexChanged(int)); + case 3: return SIGNAL(dateTimeChanged(QDateTime)); + case 4: return SIGNAL(textChanged(QString)); + case 5: return SIGNAL(currentRowChanged(int)); + case 6: return SIGNAL(valueChanged(int)); + }; + Q_STATIC_ASSERT(7 == NFallbackDefaultProperties); + Q_UNREACHABLE(); + return 0; +} class QWizardDefaultProperty { @@ -737,10 +756,10 @@ void QWizardPrivate::init() updateButtonLayout(); - for (int i = 0; i < NFallbackDefaultProperties; ++i) + for (uint i = 0; i < NFallbackDefaultProperties; ++i) defaultPropertyTable.append(QWizardDefaultProperty(fallbackProperties[i].className, fallbackProperties[i].property, - fallbackProperties[i].changedSignal)); + changed_signal(i))); } void QWizardPrivate::reset() @@ -887,9 +906,28 @@ void QWizardPrivate::switchToPage(int newId, Direction direction) } // keep in sync with QWizard::WizardButton -static const char * const buttonSlots[QWizard::NStandardButtons] = { - SLOT(back()), SLOT(next()), SLOT(next()), SLOT(accept()), SLOT(reject()), - SIGNAL(helpRequested()) +static const char * buttonSlots(QWizard::WizardButton which) +{ + switch (which) { + case QWizard::BackButton: + return SLOT(back()); + case QWizard::NextButton: + case QWizard::CommitButton: + return SLOT(next()); + case QWizard::FinishButton: + return SLOT(accept()); + case QWizard::CancelButton: + return SLOT(reject()); + case QWizard::HelpButton: + return SIGNAL(helpRequested()); + case QWizard::CustomButton1: + case QWizard::CustomButton2: + case QWizard::CustomButton3: + case QWizard::Stretch: + case QWizard::NoButton: + Q_UNREACHABLE(); + }; + return 0; }; QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage() @@ -1405,7 +1443,7 @@ void QWizardPrivate::connectButton(QWizard::WizardButton which) const { Q_Q(const QWizard); if (which < QWizard::NStandardButtons) { - QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots[which]); + QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots(which)); } else { QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked())); } @@ -1576,7 +1614,7 @@ bool QWizardPrivate::handleAeroStyleChange() if (isWindow) vistaHelper->setTitleBarIconAndCaptionVisible(false); QObject::connect( - vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots[QWizard::BackButton]); + vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots(QWizard::BackButton)); vistaHelper->backButton()->show(); } else { q->setMouseTracking(true); // ### original value possibly different @@ -1666,6 +1704,10 @@ void QWizardPrivate::_q_updateButtonStates() btn.finish->setVisible(buttonLayoutContains(QWizard::FinishButton) && (canFinish || (opts & QWizard::HaveFinishButtonOnEarlyPages))); + if (!(opts & QWizard::NoCancelButton)) + btn.cancel->setVisible(buttonLayoutContains(QWizard::CancelButton) + && (canContinue || !(opts & QWizard::NoCancelButtonOnLastPage))); + bool useDefault = !(opts & QWizard::NoDefaultButton); if (QPushButton *nextPush = qobject_cast<QPushButton *>(btn.next)) nextPush->setDefault(canContinue && useDefault && !commitPage); @@ -2150,6 +2192,7 @@ void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *) \value HaveCustomButton1 Show the first user-defined button (CustomButton1). \value HaveCustomButton2 Show the second user-defined button (CustomButton2). \value HaveCustomButton3 Show the third user-defined button (CustomButton3). + \value NoCancelButtonOnLastPage Don't show the \uicontrol Cancel button on the last page. \sa setOptions(), setOption(), testOption() */ @@ -2604,7 +2647,7 @@ void QWizard::setOptions(WizardOptions options) d->updateButtonLayout(); } else if (changed & (NoBackButtonOnStartPage | NoBackButtonOnLastPage | HaveNextButtonOnLastPage | HaveFinishButtonOnEarlyPages - | DisabledBackButtonOnLastPage)) { + | DisabledBackButtonOnLastPage | NoCancelButtonOnLastPage)) { d->_q_updateButtonStates(); } diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index 9dea9a8e6f..51b18e0e8f 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -115,7 +115,8 @@ public: HelpButtonOnRight = 0x00001000, HaveCustomButton1 = 0x00002000, HaveCustomButton2 = 0x00004000, - HaveCustomButton3 = 0x00008000 + HaveCustomButton3 = 0x00008000, + NoCancelButtonOnLastPage = 0x00010000 }; Q_DECLARE_FLAGS(WizardOptions, WizardOption) |