diff options
author | Liang Qi <liang.qi@qt.io> | 2019-01-04 07:31:22 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-01-04 07:33:14 +0100 |
commit | 03039979b5a643f9def38a73e19835bb69384202 (patch) | |
tree | e8a9184d5963128f013247ac64ec768d1cbf6911 /src/widgets/dialogs | |
parent | 9682d217e21a2e88b6de799d79b843bbe0039df1 (diff) | |
parent | 4dc2bc323c985bdceb27f096dd6c8e7af657bb6b (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Also blacklist tst_QRawFont::unsupportedWritingSystem() and
tst_QGlyphRun::mixedScripts() on windows for now.
Conflicts:
qmake/generators/makefile.cpp
src/corelib/itemmodels/qstringlistmodel.cpp
src/platformsupport/fontdatabases/windows/qwindowsfontengine_p.h
tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
tests/auto/gui/text/qglyphrun/BLACKLIST
tests/auto/gui/text/qrawfont/BLACKLIST
Task-number: QTBUG-72836
Change-Id: I10fea1493f0ae1a5708e1e48d0a4d7d6b76258b9
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 57 | ||||
-rw-r--r-- | src/widgets/dialogs/qdialog_p.h | 5 | ||||
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 3 | ||||
-rw-r--r-- | src/widgets/dialogs/qmessagebox.cpp | 42 |
4 files changed, 86 insertions, 21 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index cadd7ef031..5e64503f27 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -145,10 +145,48 @@ bool QDialogPrivate::canBeNativeDialog() const return false; } -QWindow *QDialogPrivate::parentWindow() const +/*! + \internal + + Properly hides dialog and sets the \p resultCode + */ +void QDialogPrivate::hide(int resultCode) { - if (const QWidget *parent = q_func()->nativeParentWidget()) + Q_Q(QDialog); + + q->setResult(resultCode); + q->hide(); + + close_helper(QWidgetPrivate::CloseNoEvent); + resetModalitySetByOpen(); +} + +/*! + \internal + + Emits finished() signal with \p resultCode. If the \p dialogCode + is equal to 0 emits rejected(), if the \p dialogCode is equal to + 1 emits accepted(). + */ +void QDialogPrivate::finalize(int resultCode, int dialogCode) +{ + Q_Q(QDialog); + + if (dialogCode == QDialog::Accepted) + emit q->accepted(); + else if (dialogCode == QDialog::Rejected) + emit q->rejected(); + + emit q->finished(resultCode); +} + +QWindow *QDialogPrivate::transientParentWindow() const +{ + Q_Q(const QDialog); + if (const QWidget *parent = q->nativeParentWidget()) return parent->windowHandle(); + else if (q->windowHandle()) + return q->windowHandle()->transientParent(); return 0; } @@ -158,7 +196,7 @@ bool QDialogPrivate::setNativeDialogVisible(bool visible) if (visible) { Q_Q(QDialog); helperPrepareShow(helper); - nativeDialogInUse = helper->show(q->windowFlags(), q->windowModality(), parentWindow()); + nativeDialogInUse = helper->show(q->windowFlags(), q->windowModality(), transientParentWindow()); } else if (nativeDialogInUse) { helper->hide(); } @@ -590,17 +628,8 @@ int QDialog::exec() void QDialog::done(int r) { Q_D(QDialog); - setResult(r); - hide(); - - d->close_helper(QWidgetPrivate::CloseNoEvent); - d->resetModalitySetByOpen(); - - emit finished(r); - if (r == Accepted) - emit accepted(); - else if (r == Rejected) - emit rejected(); + d->hide(r); + d->finalize(r, r); } /*! diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 99fff08e65..92634f6793 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -87,7 +87,7 @@ public: {} ~QDialogPrivate(); - QWindow *parentWindow() const; + QWindow *transientParentWindow() const; bool setNativeDialogVisible(bool visible); QVariant styleHint(QPlatformDialogHelper::StyleHint hint) const; void deletePlatformHelper(); @@ -122,6 +122,9 @@ public: QPlatformDialogHelper *platformHelper() const; virtual bool canBeNativeDialog() const; + void hide(int resultCode); + void finalize(int resultCode, int dialogCode); + private: virtual void initHelper(QPlatformDialogHelper *) {} virtual void helperPrepareShow(QPlatformDialogHelper *) {} diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 8b3549c3f5..d29f74e93d 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -2032,8 +2032,7 @@ bool QFileSystemModelPrivate::passNameFilters(const QFileSystemNode *node) const : QRegularExpression::CaseInsensitiveOption; for (const auto &nameFilter : nameFilters) { - const QString wildcard = QRegularExpression::wildcardToRegularExpression(nameFilter); - QRegularExpression rx(QRegularExpression::anchoredPattern(wildcard), options); + QRegularExpression rx(QRegularExpression::wildcardToRegularExpression(nameFilter), options); QRegularExpressionMatch match = rx.match(node->fileName); if (match.hasMatch()) return true; diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index ffbbe82856..ce918b8a74 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -209,6 +209,7 @@ public: void setupLayout(); void _q_buttonClicked(QAbstractButton *); void _q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role); + void setClickedButton(QAbstractButton *button); QAbstractButton *findButton(int button0, int button1, int button2, int flags); void addOldButtons(int button0, int button1, int button2); @@ -216,6 +217,8 @@ public: QAbstractButton *abstractButtonForId(int id) const; int execReturnCode(QAbstractButton *button); + int dialogCodeForButton(QAbstractButton *button) const; + void detectEscapeButton(); void updateSize(); int layoutMinimumWidth(); @@ -466,6 +469,27 @@ int QMessageBoxPrivate::execReturnCode(QAbstractButton *button) return ret; } +/*! + \internal + + Returns 0 for RejectedRole and NoRole, 1 for AcceptedRole and YesRole, -1 otherwise + */ +int QMessageBoxPrivate::dialogCodeForButton(QAbstractButton *button) const +{ + Q_Q(const QMessageBox); + + switch (q->buttonRole(button)) { + case QMessageBox::AcceptRole: + case QMessageBox::YesRole: + return QDialog::Accepted; + case QMessageBox::RejectRole: + case QMessageBox::NoRole: + return QDialog::Rejected; + default: + return -1; + } +} + void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) { Q_Q(QMessageBox); @@ -477,20 +501,30 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button) } else #endif { - clickedButton = button; - q->done(execReturnCode(button)); // does not trigger closeEvent - emit q->buttonClicked(button); + setClickedButton(button); if (receiverToDisconnectOnClose) { QObject::disconnect(q, signalToDisconnectOnClose, receiverToDisconnectOnClose, memberToDisconnectOnClose); - receiverToDisconnectOnClose = 0; + receiverToDisconnectOnClose = nullptr; } signalToDisconnectOnClose.clear(); memberToDisconnectOnClose.clear(); } } +void QMessageBoxPrivate::setClickedButton(QAbstractButton *button) +{ + Q_Q(QMessageBox); + + clickedButton = button; + emit q->buttonClicked(clickedButton); + + auto resultCode = execReturnCode(button); + hide(resultCode); + finalize(resultCode, dialogCodeForButton(button)); +} + void QMessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role) { Q_Q(QMessageBox); |