summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qcolordialog.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-19 15:50:45 +0200
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-07 10:58:49 +0200
commitee383b89f16a9a75a934076255bddbef5a075fa3 (patch)
tree22118d8368e89aae2ebf09e41b79f3d69d811cae /src/gui/dialogs/qcolordialog.cpp
parentc14455b78904f25e724cd928652c49f9583c6aa0 (diff)
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/qcolordialog.cpp')
-rw-r--r--src/gui/dialogs/qcolordialog.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index a7df999824..44a82ef96a 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);
+
}