summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2013-08-26 19:29:33 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-29 12:44:24 +0200
commitdf7944e7d7dd8b2bbccbd639eff0ab09745d6cc3 (patch)
treec59f5ed9f7f74ad6a2bca10225af56e98bf00b14 /src
parente4b2a0b4bab2a17a65fedafe9bae50af1fe019f6 (diff)
Cocoa: Fix QFontDialog, QColorDialog auto-tests
The new Cocoa event dispatcher made apparent some deficiencies in the way the dialog helpers were being hidden. In particular, we would not stop a dialog helper's modal loop when closing the dialog, resulting in the auto-tests hanging. Also, since the QApplication event loop is runnig with [NSApp run] in the stack, the previous workarounds are no longer needed. Task-number: QTBUG-24321 Change-Id: Ifba713c286638d78a699c319a15683d09714f06f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm20
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm4
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp2
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp11
5 files changed, 31 insertions, 8 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h
index 59e029769d..2b34f909d1 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h
@@ -59,6 +59,8 @@ public:
void setCurrentColor(const QColor&);
QColor currentColor() const;
+
+ bool event(QEvent *);
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index d90d77ec1d..ef2b4cbcfb 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -161,6 +161,10 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
- (void)closePanel
{
+ if (mDialogIsExecuting) {
+ mDialogIsExecuting = false;
+ [NSApp stopModal];
+ }
[mColorPanel close];
}
@@ -488,6 +492,22 @@ QColor QCocoaColorDialogHelper::currentColor() const
return sharedColorPanel()->currentColor();
}
+bool QCocoaColorDialogHelper::event(QEvent *e)
+{
+ if (e->type() == QEvent::KeyPress) {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(e);
+ if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return) {
+ emit accept();
+ return true;
+ } else if (ke->key() == Qt::Key_Escape) {
+ emit reject();
+ return true;
+ }
+ }
+
+ return false;
+}
+
QT_END_NAMESPACE
#endif // QT_NO_COLORDIALOG
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 91fb52eb6d..5bd0ad2a43 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -203,6 +203,10 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
- (void)closePanel
{
+ if (mDialogIsExecuting) {
+ mDialogIsExecuting = false;
+ [NSApp stopModal];
+ }
[mFontPanel close];
}
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 5da41aa0a5..c9f03c5a97 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -2166,6 +2166,8 @@ void QColorDialog::keyPressEvent(QKeyEvent *e)
}
e->accept();
return;
+ } else if (d->nativeDialogInUse && d->platformColorDialogHelper()->event(e)) {
+ return;
}
QDialog::keyPressEvent(e);
}
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index b989ea7c86..28afd91a09 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -983,14 +983,9 @@ void QFontDialog::setVisible(bool visible)
Q_D(QFontDialog);
if (d->canBeNativeDialog())
d->setNativeDialogVisible(visible);
- if (d->nativeDialogInUse) {
- // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
- // updates the state correctly, but skips showing the non-native version:
- setAttribute(Qt::WA_DontShowOnScreen, true);
- } else {
- d->nativeDialogInUse = false;
- setAttribute(Qt::WA_DontShowOnScreen, false);
- }
+ // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
+ // updates the state correctly, but skips showing the non-native version:
+ setAttribute(Qt::WA_DontShowOnScreen, d->nativeDialogInUse);
QDialog::setVisible(visible);
}