Respect the DontUseNativeDialog flag.

QFontDialog and QColorDialog were ignoring the DontUseNativeDialog. This
lead to a native (Cocoa) dialog created all the time.

Fix the testcase for QFontDialog. It needs the DontUseNativeDialog flag
set.

Task-number: QTBUG-24321

Change-Id: I159c1ad057bac38226f1e01a56b15f142650bfd8
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
bb10
Christoph Schleifenbaum 2012-04-10 17:17:41 +02:00 committed by Qt by Nokia
parent 551fd20c19
commit 1c9a4093a5
4 changed files with 14 additions and 19 deletions

View File

@ -1247,7 +1247,7 @@ inline bool QColorDialogPrivate::isAlphaVisible() const { return cs->isAlphaVisi
QColor QColorDialogPrivate::currentQColor() const
{
if (nativeDialogInUse)
if (!options->testOption(QColorDialogOptions::DontUseNativeDialog) && nativeDialogInUse)
return platformColorDialogHelper()->currentColor_sys();
return cs->currentQColor();
}
@ -1706,8 +1706,7 @@ void QColorDialog::setCurrentColor(const QColor &color)
d->selectColor(color);
d->setCurrentAlpha(color.alpha());
// ### fixme: Call helper
if (d->nativeDialogInUse)
if (!testOption(QColorDialog::DontUseNativeDialog) && d->nativeDialogInUse)
d->platformColorDialogHelper()->setCurrentColor_sys(color);
}

View File

@ -171,11 +171,6 @@ void QFontDialogPrivate::init()
{
Q_Q(QFontDialog);
#ifdef Q_WS_MAC
nativeDialogInUse = false;
delegate = 0;
#endif
q->setSizeGripEnabled(true);
q->setWindowTitle(QFontDialog::tr("Select Font"));
@ -805,8 +800,10 @@ void QFontDialog::setCurrentFont(const QFont &font)
d->strikeout->setChecked(font.strikeOut());
d->underline->setChecked(font.underline());
d->updateFamilies();
if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
helper->setCurrentFont_sys(font);
if (d->canBeNativeDialog()) {
if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
helper->setCurrentFont_sys(font);
}
#ifdef Q_WS_MAC
if (d->delegate)
@ -824,8 +821,10 @@ void QFontDialog::setCurrentFont(const QFont &font)
QFont QFontDialog::currentFont() const
{
Q_D(const QFontDialog);
if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
return helper->currentFont_sys();
if (d->canBeNativeDialog()) {
if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
return helper->currentFont_sys();
}
return d->sampleEdit->font();
}
@ -1013,9 +1012,9 @@ void QFontDialog::done(int result)
d->memberToDisconnectOnClose.clear();
}
bool QFontDialogPrivate::canBeNativeDialog()
bool QFontDialogPrivate::canBeNativeDialog() const
{
Q_Q(QFontDialog);
Q_Q(const QFontDialog);
if (nativeDialogInUse)
return true;
if (q->testAttribute(Qt::WA_DontShowOnScreen))

View File

@ -143,7 +143,7 @@ public:
QPointer<QObject> receiverToDisconnectOnClose;
QByteArray memberToDisconnectOnClose;
bool canBeNativeDialog();
bool canBeNativeDialog() const;
void _q_runNativeAppModalPanel();
#ifdef Q_WS_MAC
static void setFont(void *delegate, const QFont &font);

View File

@ -160,12 +160,9 @@ class FriendlyFontDialog : public QFontDialog
void tst_QFontDialog::task256466_wrongStyle()
{
#ifdef Q_OS_MAC
QSKIP("Test crashes on Mac OS X, see QTBUG-24321");
#endif
QFontDatabase fdb;
FriendlyFontDialog dialog;
dialog.setOption(QFontDialog::DontUseNativeDialog);
QListView *familyList = reinterpret_cast<QListView*>(dialog.d_func()->familyList);
QListView *styleList = reinterpret_cast<QListView*>(dialog.d_func()->styleList);
QListView *sizeList = reinterpret_cast<QListView*>(dialog.d_func()->sizeList);