QFontDialog: Check if native dialog is in use before using
A call to platformFontDialogHelper() will lazily create the helper, and is not enough to distinguish whether the helper is actually in use. The explicit nativeDialogInUse flag also takes properties like DontUseNativeDialog into account, which may be set after the dialog is first constructed. Fixes: QTBUG-104696 Pick-to: 6.2 6.3 6.4 Change-Id: Ia00a39bba4aaae8c99ae0cdd6543c2e451f72ea6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
13868474f9
commit
efbcc80010
|
|
@ -426,10 +426,12 @@ bool QFontDialog::eventFilter(QObject *o , QEvent *e)
|
|||
|
||||
void QFontDialogPrivate::initHelper(QPlatformDialogHelper *h)
|
||||
{
|
||||
QFontDialog *d = q_func();
|
||||
QObject::connect(h, SIGNAL(currentFontChanged(QFont)), d, SIGNAL(currentFontChanged(QFont)));
|
||||
QObject::connect(h, SIGNAL(fontSelected(QFont)), d, SIGNAL(fontSelected(QFont)));
|
||||
static_cast<QPlatformFontDialogHelper *>(h)->setOptions(options);
|
||||
Q_Q(QFontDialog);
|
||||
auto *fontDialogHelper = static_cast<QPlatformFontDialogHelper *>(h);
|
||||
fontDialogHelper->setOptions(options);
|
||||
fontDialogHelper->setCurrentFont(q->currentFont());
|
||||
QObject::connect(h, SIGNAL(currentFontChanged(QFont)), q, SIGNAL(currentFontChanged(QFont)));
|
||||
QObject::connect(h, SIGNAL(fontSelected(QFont)), q, SIGNAL(fontSelected(QFont)));
|
||||
}
|
||||
|
||||
void QFontDialogPrivate::helperPrepareShow(QPlatformDialogHelper *)
|
||||
|
|
@ -788,8 +790,11 @@ 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(font);
|
||||
|
||||
if (d->nativeDialogInUse) {
|
||||
if (QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
|
||||
helper->setCurrentFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -802,8 +807,11 @@ void QFontDialog::setCurrentFont(const QFont &font)
|
|||
QFont QFontDialog::currentFont() const
|
||||
{
|
||||
Q_D(const QFontDialog);
|
||||
if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
|
||||
return helper->currentFont();
|
||||
|
||||
if (d->nativeDialogInUse) {
|
||||
if (const QPlatformFontDialogHelper *helper = d->platformFontDialogHelper())
|
||||
return helper->currentFont();
|
||||
}
|
||||
return d->sampleEdit->font();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue