33QQuickPlatformFontDialog::QQuickPlatformFontDialog(QObject *parent)
35 qCDebug(lcQuickPlatformFontDialog)
36 <<
"creating non-native Qt Quick FontDialog with parent" << parent;
42 auto qmlContext = ::qmlContext(parent);
44 qmlWarning(parent) <<
"No QQmlContext for QQuickPlatformFontDialog; can't create "
45 "non-native FontDialog implementation";
49 const auto dialogQmlUrl = QUrl(QStringLiteral(
50 "qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/qml/FontDialog.qml"));
52 QQmlComponent fontDialogComponent(qmlContext->engine(), dialogQmlUrl, parent);
53 if (!fontDialogComponent.isReady()) {
54 qmlWarning(parent) <<
"Failed to load non-native FontDialog implementation:\n"
55 << fontDialogComponent.errorString();
59 m_dialog = qobject_cast<QQuickFontDialogImpl *>(fontDialogComponent.create());
62 qmlWarning(parent) <<
"Failed to create an instance of the non-native FontDialog:\n"
63 << fontDialogComponent.errorString();
67 m_dialog->setParent(
this);
69 connect(m_dialog, &QQuickDialog::accepted,
this, &QPlatformDialogHelper::accept);
70 connect(m_dialog, &QQuickDialog::rejected,
this, &QPlatformDialogHelper::reject);
72 connect(m_dialog, &QQuickFontDialogImpl::currentFontChanged,
73 this, &QQuickPlatformFontDialog::currentFontChanged);
101bool QQuickPlatformFontDialog::show(Qt::WindowFlags flags, Qt::WindowModality modality,
104 qCDebug(lcQuickPlatformFontDialog)
105 <<
"show called with flags" << flags <<
"modality" << modality <<
"parent" << parent;
113 auto quickWindow = qobject_cast<QQuickWindow *>(parent);
115 qmlInfo(
this->parent()) <<
"Parent window (" << parent
116 <<
") of non-native dialog is not a QQuickWindow";
119 m_dialog->setParent(parent);
120 m_dialog->resetParentItem();
122 auto popupPrivate = QQuickPopupPrivate::get(m_dialog);
123 popupPrivate->getAnchors()->setCenterIn(m_dialog->parentItem());
125 QSharedPointer<QFontDialogOptions> options = QPlatformFontDialogHelper::options();
126 m_dialog->setTitle(options->windowTitle());
127 m_dialog->setOptions(options);
130 m_dialog->setWindowModality(modality);