diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2013-08-26 19:29:33 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-29 12:44:24 +0200 |
commit | df7944e7d7dd8b2bbccbd639eff0ab09745d6cc3 (patch) | |
tree | c59f5ed9f7f74ad6a2bca10225af56e98bf00b14 /src/plugins | |
parent | e4b2a0b4bab2a17a65fedafe9bae50af1fe019f6 (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/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoacolordialoghelper.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | 20 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm | 4 |
3 files changed, 26 insertions, 0 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]; } |