diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-11-10 13:07:01 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-11 10:58:10 +0100 |
commit | af914694d81317b4a7bf0804d9d34a1f3bf2cf48 (patch) | |
tree | 039dc97541bc51cdeddf21b5f8949d5e998b18de /src/widgets/dialogs/qdialog.cpp | |
parent | 9a8a70d8e42f7e8fee8398affa5680adb2ba24d6 (diff) |
QPlatformDialogHelper: Split class hierarchy, decouple from Dialog
- Introduce hierarchy of QPlatformDialogHelper-derived classes
for font, color and file dialogs.
- Start reducing dependencies on QDialog:
* Remove QDialog-specifics from interface, introduce enumeration
for DialogCode
* Make the helpers Q_OBJECTS to be able to add the signals
passed on to the QDialogs
* Remove QDialogPrivate pointer
- Split setVisible_sys() in show_sys() (factory method for native
dialogs) and hide_sys(). Pass parent window to show_sys(),
removing the necessity to query the QDialog for it
- Introduce a styleHint() similar to QGuiApplication's for
platform-specific
- Fix compile in cocoa/windows, reduce depency on QDialog
(-private) classes.
Change-Id: Ic1cb715e1edf767f2cb18b9780341d189339ef1d
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 | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 09c0127852..a0b0cdc564 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -64,16 +64,42 @@ QPlatformDialogHelper *QDialogPrivate::platformHelper() const // Delayed creation of the platform, ensuring that // that qobject_cast<> on the dialog works in the plugin. if (!m_platformHelperCreated) { + QDialogPrivate *ncThis = const_cast<QDialogPrivate *>(this); m_platformHelperCreated = true; - QDialog *dialog = const_cast<QDialog *>(q_func()); m_platformHelper = QGuiApplicationPrivate::platformIntegration() - ->createPlatformDialogHelper(dialog); + ->createPlatformDialogHelper(ncThis->q_func()); if (m_platformHelper) - m_platformHelper->d_ptr = const_cast<QDialogPrivate *>(this); + ncThis->initHelper(m_platformHelper); } return m_platformHelper; } +QWindow *QDialogPrivate::parentWindow() const +{ + if (const QWidget *parent = q_func()->nativeParentWidget()) + return parent->windowHandle(); + return 0; +} + +bool QDialogPrivate::setNativeDialogVisible(bool visible) +{ + if (QPlatformDialogHelper *helper = platformHelper()) { + if (visible) { + nativeDialogInUse = helper->show_sys(parentWindow()); + } else { + helper->hide_sys(); + } + } + return nativeDialogInUse; +} + +QVariant QDialogPrivate::styleHint(QPlatformDialogHelper::StyleHint hint) const +{ + if (const QPlatformDialogHelper *helper = platformHelper()) + return helper->styleHint(hint); + return QPlatformDialogHelper::defaultStyleHint(hint); +} + /*! \class QDialog \brief The QDialog class is the base class of dialog windows. @@ -705,15 +731,9 @@ void QDialog::setVisible(bool visible) if (d->eventLoop) d->eventLoop->exit(); } -#ifdef Q_WS_WIN - if (d->mainDef && isActiveWindow()) { - BOOL snapToDefault = false; - if (SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, &snapToDefault, 0)) { - if (snapToDefault) - QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center())); - } - } -#endif + if (d->mainDef && isActiveWindow() + && d->styleHint(QPlatformDialogHelper::SnapToDefaultButton).toBool()) + QCursor::setPos(d->mainDef->mapToGlobal(d->mainDef->rect().center())); } /*!\reimp */ |