diff options
author | Morten Sorvig <morten.sorvig@nokia.com> | 2011-09-28 09:52:15 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-27 11:12:38 +0200 |
commit | 8f912c5c0f3f89e6f3042c0a948ccd155e57e216 (patch) | |
tree | 8b0ebe25160243e43ef1dc83bc669714779ffb68 /src/widgets/dialogs/qdialog.cpp | |
parent | a94c960b75453ef2eb9dca0be1db426de7a1091d (diff) |
Native file dialog support for Mac
* New API: QPlatformDialogHelper to support native dialog on QPA.
(Currently, It supports only file dialog.)
* Modify QDialog* and QFileDialog* to support native dialog.
* Add native file dialog support to cocoa platform plugin.
Change-Id: I957f046748a27a33fd9f8af3c525feabd1b0f582
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/widgets/dialogs/qdialog.cpp')
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index de71e451a7..38609a97ed 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -52,6 +52,7 @@ #include "qmenu.h" #include "qcursor.h" #include "private/qdialog_p.h" +#include "private/qguiapplication_p.h" #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif @@ -251,6 +252,10 @@ QDialog::QDialog(QWidget *parent, Qt::WindowFlags f) : QWidget(*new QDialogPrivate, parent, f | ((f & Qt::WindowType_Mask) == 0 ? Qt::Dialog : Qt::WindowType(0))) { + Q_D(QDialog); + d->platformHelper = QGuiApplicationPrivate::platformIntegration()->createPlatformDialogHelper(this); + if (d->platformHelper) + d->platformHelper->d_ptr = d_func(); #ifdef Q_WS_WINCE if (!qt_wince_is_smartphone()) setWindowFlags(windowFlags() | Qt::WindowOkButtonHint | QFlag(qt_wince_is_mobile() ? 0 : Qt::WindowCancelButtonHint)); @@ -265,7 +270,6 @@ QDialog::QDialog(QWidget *parent, Qt::WindowFlags f) #endif } - /*! \overload \internal @@ -361,7 +365,7 @@ void QDialogPrivate::resetModalitySetByOpen() // open() changed the window modality and the user didn't touch it afterwards; restore it q->setWindowModality(Qt::WindowModality(resetModalityTo)); q->setAttribute(Qt::WA_SetWindowModality, wasModalitySet); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC Q_ASSERT(resetModalityTo != Qt::WindowModal); q->setParent(q->parentWidget(), Qt::Dialog); #endif @@ -449,7 +453,7 @@ void QDialog::open() d->wasModalitySet = testAttribute(Qt::WA_SetWindowModality); setWindowModality(Qt::WindowModal); setAttribute(Qt::WA_SetWindowModality, false); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC setParent(parentWidget(), Qt::Sheet); #endif } @@ -511,9 +515,8 @@ int QDialog::exec() } show(); -#ifdef Q_WS_MAC - d->mac_nativeDialogModalHelp(); -#endif + if (d->platformHelper) + d->platformHelper->platformNativeDialogModalHelp(); QEventLoop eventLoop; d->eventLoop = &eventLoop; @@ -635,7 +638,7 @@ void QDialog::keyPressEvent(QKeyEvent *e) // Calls reject() if Escape is pressed. Simulates a button // click for the default button if Enter is pressed. Move focus // for the arrow keys. Ignore the rest. -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC if(e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period) { reject(); } else |