summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-19 13:50:45 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-07 08:58:49 (GMT)
commitee383b89f16a9a75a934076255bddbef5a075fa3 (patch)
tree22118d8368e89aae2ebf09e41b79f3d69d811cae /src/gui/dialogs
parentc14455b78904f25e724cd928652c49f9583c6aa0 (diff)
downloadQt-ee383b89f16a9a75a934076255bddbef5a075fa3.zip
Qt-ee383b89f16a9a75a934076255bddbef5a075fa3.tar.gz
Qt-ee383b89f16a9a75a934076255bddbef5a075fa3.tar.bz2
Integrate the GuiPlatformPlugin interface
This is an internal interface for plugins that can be provided by the platform to give platform-specific features by platforms built on top of Qt. We can easlily integrate Qt on Windows, Mac, Gnome, ... without any plugin because we can link to their respective library (dynamically if we don't want to depend on it). On Gnome, we can dynamically resolve Gtk+ symbols. This is however not possible for KDE or other platform built on top of Qt: we can't link against their library because they depend on us and we can't dynamically resolve the symbols because they are mangled (C++) So this plugin provides hooks inside Qt to be able to do things like native File or Color dialog, native icons, accurate reading of the config file, and so on. This is currently private API. Task-number: QT-406 Reviewed-by: Jens Bache-Wiig Reviewed-by: Oswald Buddenhagen
Diffstat (limited to 'src/gui/dialogs')
-rw-r--r--src/gui/dialogs/qcolordialog.cpp21
-rw-r--r--src/gui/dialogs/qcolordialog_p.h1
-rw-r--r--src/gui/dialogs/qfiledialog_p.h24
3 files changed, 34 insertions, 12 deletions
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index a7df999..44a82ef 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -62,6 +62,7 @@
#include "qmime.h"
#include "qspinbox.h"
#include "qdialogbuttonbox.h"
+#include "private/qguiplatformplugin_p.h"
#ifdef Q_WS_S60
#include "private/qt_s60_p.h"
@@ -1454,6 +1455,8 @@ void QColorDialogPrivate::init(const QColor &initial)
q->setSizeGripEnabled(false);
q->setWindowTitle(QColorDialog::tr("Select Color"));
+ nativeDialogInUse = false;
+
nextCust = 0;
QVBoxLayout *mainLay = new QVBoxLayout(q);
// there's nothing in this dialog that benefits from sizing up
@@ -1719,6 +1722,8 @@ void QColorDialog::setCurrentColor(const QColor &color)
d->setCurrentQColor(color);
d->setCocoaPanelColor(color);
#endif
+ if (d->nativeDialogInUse)
+ qt_guiPlatformPlugin()->colorDialogSetCurrentColor(this, color);
}
QColor QColorDialog::currentColor() const
@@ -1871,6 +1876,17 @@ void QColorDialog::setVisible(bool visible)
setAttribute(Qt::WA_DontShowOnScreen, false);
}
}
+#else
+
+ if (!(d->opts & DontUseNativeDialog) && qt_guiPlatformPlugin()->colorDialogSetVisible(this, visible)) {
+ d->nativeDialogInUse = true;
+ // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
+ // updates the state correctly, but skips showing the non-native version:
+ setAttribute(Qt::WA_DontShowOnScreen);
+ } else {
+ d->nativeDialogInUse = false;
+ setAttribute(Qt::WA_DontShowOnScreen, false);
+ }
#endif
QDialog::setVisible(visible);
@@ -1970,8 +1986,8 @@ QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent)
QColorDialog::~QColorDialog()
{
-#if defined(Q_WS_MAC)
Q_D(QColorDialog);
+#if defined(Q_WS_MAC)
if (d->delegate) {
d->releaseCocoaColorPanelDelegate();
QColorDialogPrivate::sharedColorPanelAvailable = true;
@@ -1985,6 +2001,9 @@ QColorDialog::~QColorDialog()
settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), cusrgb[i]);
}
#endif
+ if (d->nativeDialogInUse)
+ qt_guiPlatformPlugin()->colorDialogDelete(this);
+
}
diff --git a/src/gui/dialogs/qcolordialog_p.h b/src/gui/dialogs/qcolordialog_p.h
index c7cabfb..81df503 100644
--- a/src/gui/dialogs/qcolordialog_p.h
+++ b/src/gui/dialogs/qcolordialog_p.h
@@ -114,6 +114,7 @@ public:
QColorDialog::ColorDialogOptions opts;
QPointer<QObject> receiverToDisconnectOnClose;
QByteArray memberToDisconnectOnClose;
+ bool nativeDialogInUse;
#ifdef Q_WS_MAC
void openCocoaColorPanel(const QColor &initial,
diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/gui/dialogs/qfiledialog_p.h
index 54fc0e0..44289d9 100644
--- a/src/gui/dialogs/qfiledialog_p.h
+++ b/src/gui/dialogs/qfiledialog_p.h
@@ -76,6 +76,8 @@
#include <qdebug.h>
#include "qsidebar_p.h"
#include "qfscompleter_p.h"
+#include "../kernel/qguiplatformplugin_p.h"
+
#if defined (Q_OS_UNIX)
#include <unistd.h>
@@ -405,17 +407,17 @@ inline QString QFileDialogPrivate::rootPath() const {
#ifndef Q_WS_MAC
// Dummies for platforms that don't use native dialogs:
- inline void QFileDialogPrivate::deleteNativeDialog_sys() {}
- inline bool QFileDialogPrivate::setVisible_sys(bool) { return false; }
- inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys(){ return QDialog::Rejected; }
- inline void QFileDialogPrivate::setDirectory_sys(const QString &) {}
- inline QString QFileDialogPrivate::directory_sys() const { return QString(); }
- inline void QFileDialogPrivate::selectFile_sys(const QString &) {}
- inline QStringList QFileDialogPrivate::selectedFiles_sys() const { return QStringList(); }
- inline void QFileDialogPrivate::setFilter_sys() {}
- inline void QFileDialogPrivate::setNameFilters_sys(const QStringList &) {}
- inline void QFileDialogPrivate::selectNameFilter_sys(const QString &) {}
- inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return QString(); }
+ inline void QFileDialogPrivate::deleteNativeDialog_sys() { qt_guiPlatformPlugin()->fileDialogDelete(q_func()); }
+ inline bool QFileDialogPrivate::setVisible_sys(bool visible) { return qt_guiPlatformPlugin()->fileDialogSetVisible(q_func(), visible); }
+ inline QDialog::DialogCode QFileDialogPrivate::dialogResultCode_sys(){ return qt_guiPlatformPlugin()->fileDialogResultCode(q_func()); }
+ inline void QFileDialogPrivate::setDirectory_sys(const QString &directory) { qt_guiPlatformPlugin()->fileDialogSetDirectory(q_func(), directory); }
+ inline QString QFileDialogPrivate::directory_sys() const { return qt_guiPlatformPlugin()->fileDialogDirectory(q_func()); }
+ inline void QFileDialogPrivate::selectFile_sys(const QString &filename) { qt_guiPlatformPlugin()->fileDialogSelectFile(q_func(), filename); }
+ inline QStringList QFileDialogPrivate::selectedFiles_sys() const { return qt_guiPlatformPlugin()->fileDialogSelectedFiles(q_func()); }
+ inline void QFileDialogPrivate::setFilter_sys() { qt_guiPlatformPlugin()->fileDialogSetFilter(q_func()); }
+ inline void QFileDialogPrivate::setNameFilters_sys(const QStringList &filters) { qt_guiPlatformPlugin()->fileDialogSetNameFilters(q_func(), filters); }
+ inline void QFileDialogPrivate::selectNameFilter_sys(const QString &filter) { qt_guiPlatformPlugin()->fileDialogSelectNameFilter(q_func(), filter); }
+ inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return qt_guiPlatformPlugin()->fileDialogSelectedNameFilter(q_func()); }
#endif
QT_END_NAMESPACE