summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs/qfontdialog.cpp
diff options
context:
space:
mode:
authorCarlos Manuel Duclos Vergara <carlos.duclos@nokia.com>2010-02-22 13:58:41 (GMT)
committerCarlos Manuel Duclos Vergara <carlos.duclos@nokia.com>2010-02-22 14:01:48 (GMT)
commit976a2b6ad1f95175d8d0be2d1eb7603cf4e4026a (patch)
treed8413137eb7f1307c2a15c6eb9d2e253ba59a681 /src/gui/dialogs/qfontdialog.cpp
parent5e95e1bb510d24b9b7889191144a4842fd8569c1 (diff)
downloadQt-976a2b6ad1f95175d8d0be2d1eb7603cf4e4026a.zip
Qt-976a2b6ad1f95175d8d0be2d1eb7603cf4e4026a.tar.gz
Qt-976a2b6ad1f95175d8d0be2d1eb7603cf4e4026a.tar.bz2
QFontDialog::exec() never returns on OSX
The problem is the fact that this dialog is never meant to be used this way. Instead it should be called through the static function ::getFont(...). I reimplemented this code path and made sure that this works. Task-number: QTBUG-7769 Reviewed-by: Richard Moe Gustavsen
Diffstat (limited to 'src/gui/dialogs/qfontdialog.cpp')
-rw-r--r--src/gui/dialogs/qfontdialog.cpp58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp
index 56580a9..4358313 100644
--- a/src/gui/dialogs/qfontdialog.cpp
+++ b/src/gui/dialogs/qfontdialog.cpp
@@ -989,33 +989,23 @@ void QFontDialog::open(QObject *receiver, const char *member)
void QFontDialog::setVisible(bool visible)
{
Q_D(QFontDialog);
- if (visible)
- d->selectedFont = QFont();
-
-#if defined(Q_WS_MAC)
- bool isCurrentlyVisible = (isVisible() || d->delegate);
-
- if (!visible == !isCurrentlyVisible)
- return;
-
if (visible) {
- if (!(d->opts & DontUseNativeDialog) && QFontDialogPrivate::sharedFontPanelAvailable) {
- d->delegate = QFontDialogPrivate::openCocoaFontPanel(
- currentFont(), parentWidget(), windowTitle(), options(), d);
- QFontDialogPrivate::sharedFontPanelAvailable = false;
+ if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
return;
- }
+ } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
+ return;
- setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
- } else {
- if (d->delegate) {
- QFontDialogPrivate::closeCocoaFontPanel(d->delegate);
- d->delegate = 0;
- QFontDialogPrivate::sharedFontPanelAvailable = true;
- return;
+ if (d->canBeNativeDialog()){
+ if (d->setVisible_sys(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, true);
+ } else {
+ d->nativeDialogInUse = false;
+ setAttribute(Qt::WA_DontShowOnScreen, false);
}
}
-#endif
QDialog::setVisible(visible);
}
@@ -1032,11 +1022,14 @@ void QFontDialog::done(int result)
Q_D(QFontDialog);
QDialog::done(result);
if (result == Accepted) {
- d->selectedFont = currentFont();
+ // We check if this is the same font we had before, if so we emit currentFontChanged
+ QFont selectedFont = currentFont();
+ if(selectedFont != d->selectedFont)
+ emit(currentFontChanged(selectedFont));
+ d->selectedFont = selectedFont;
emit fontSelected(d->selectedFont);
- } else {
+ } else
d->selectedFont = QFont();
- }
if (d->receiverToDisconnectOnClose) {
disconnect(this, SIGNAL(fontSelected(QFont)),
d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
@@ -1045,6 +1038,21 @@ void QFontDialog::done(int result)
d->memberToDisconnectOnClose.clear();
}
+bool QFontDialogPrivate::canBeNativeDialog()
+{
+ Q_Q(QFontDialog);
+ if (nativeDialogInUse)
+ return true;
+ if (q->testAttribute(Qt::WA_DontShowOnScreen))
+ return false;
+ if (opts & QFontDialog::DontUseNativeDialog)
+ return false;
+
+ QLatin1String staticName(QFontDialog::staticMetaObject.className());
+ QLatin1String dynamicName(q->metaObject()->className());
+ return (staticName == dynamicName);
+}
+
/*!
\fn QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget* parent, const char* name)
\since 4.5