338void QQuickAbstractDialog::open()
340 qCDebug(lcDialogs) <<
"open called";
341 if (m_visible || !create())
344 onShow(m_handle.get());
346 m_visible = m_handle->show(m_flags, m_modality, windowForOpen());
347 if (!m_visible && useNativeDialog()) {
350 if (!create(CreateOptions::DontTryNativeDialog))
353 onShow(m_handle.get());
354 m_visible = m_handle->show(m_flags, m_modality, windowForOpen());
360 QObject::connect(
this, &QQuickAbstractDialog::visibleChanged,
361 m_handle.get(), [
this]{
if (!isVisible()) destroy(); });
366 emit visibleChanged();
378void QQuickAbstractDialog::close()
380 if (!m_handle || !m_visible)
383 onHide(m_handle.get());
386 if (!m_parentWindowExplicitlySet)
387 m_parentWindow =
nullptr;
388 emit visibleChanged();
390 if (dialogCode() == Accepted)
392 else if (dialogCode() == Rejected)
437void QQuickAbstractDialog::componentComplete()
439 qCDebug(lcDialogs) <<
"componentComplete";
442 if (!m_visibleRequested)
445 m_visibleRequested =
false;
447 if (windowForOpen()) {
456 if (
const auto parentItem = findParentItem())
457 connect(parentItem, &QQuickItem::windowChanged,
this, &QQuickAbstractDialog::deferredOpen, Qt::SingleShotConnection);
471bool QQuickAbstractDialog::create(CreateOptions createOptions)
473 qCDebug(lcDialogs) << qmlTypeName(
this) <<
"attempting to create dialog backend of type"
474 <<
int(m_type) <<
"with parent window" << m_parentWindow;
476 return m_handle.get();
478 if ((createOptions != CreateOptions::DontTryNativeDialog) && useNativeDialog()) {
479 qCDebug(lcDialogs) <<
"- attempting to create a native dialog";
480 m_handle.reset(QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(
481 toPlatformDialogType(m_type)));
485 qCDebug(lcDialogs) <<
"- attempting to create a quick dialog";
486 m_handle = QQuickDialogImplFactory::createPlatformDialogHelper(m_type,
this);
489 qCDebug(lcDialogs) << qmlTypeName(
this) <<
"created ->" << m_handle.get();
491 onCreate(m_handle.get());
492 connect(m_handle.get(), &QPlatformDialogHelper::accept,
this, &QQuickAbstractDialog::accept);
493 connect(m_handle.get(), &QPlatformDialogHelper::reject,
this, &QQuickAbstractDialog::reject);
495 return m_handle.get();