339void QQuickAbstractDialog::open()
341 qCDebug(lcDialogs) <<
"open called";
342 if (m_visible || !create())
345 onShow(m_handle.get());
347 m_visible = m_handle->show(m_flags, m_modality, windowForOpen());
348 if (!m_visible && useNativeDialog()) {
351 if (!create(CreateOptions::DontTryNativeDialog))
354 onShow(m_handle.get());
355 m_visible = m_handle->show(m_flags, m_modality, windowForOpen());
361 QObject::connect(
this, &QQuickAbstractDialog::visibleChanged,
362 m_handle.get(), [
this]{
if (!isVisible()) destroy(); });
367 emit visibleChanged();
379void QQuickAbstractDialog::close()
381 if (!m_handle || !m_visible)
384 onHide(m_handle.get());
387 if (!m_parentWindowExplicitlySet)
388 m_parentWindow =
nullptr;
389 emit visibleChanged();
391 if (dialogCode() == Accepted)
393 else if (dialogCode() == Rejected)
438void QQuickAbstractDialog::componentComplete()
440 qCDebug(lcDialogs) <<
"componentComplete";
443 if (!m_visibleRequested)
446 m_visibleRequested =
false;
448 if (windowForOpen()) {
457 if (
const auto parentItem = findParentItem())
458 connect(parentItem, &QQuickItem::windowChanged,
this, &QQuickAbstractDialog::deferredOpen, Qt::SingleShotConnection);
472bool QQuickAbstractDialog::create(CreateOptions createOptions)
474 qCDebug(lcDialogs) << qmlTypeName(
this) <<
"attempting to create dialog backend of type"
475 <<
int(m_type) <<
"with parent window" << m_parentWindow;
477 return m_handle.get();
479 if ((createOptions != CreateOptions::DontTryNativeDialog) && useNativeDialog()) {
480 qCDebug(lcDialogs) <<
"- attempting to create a native dialog";
481 m_handle.reset(QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(
482 toPlatformDialogType(m_type)));
486 qCDebug(lcDialogs) <<
"- attempting to create a quick dialog";
487 m_handle = QQuickDialogImplFactory::createPlatformDialogHelper(m_type,
this);
490 qCDebug(lcDialogs) << qmlTypeName(
this) <<
"created ->" << m_handle.get();
492 onCreate(m_handle.get());
493 connect(m_handle.get(), &QPlatformDialogHelper::accept,
this, &QQuickAbstractDialog::accept);
494 connect(m_handle.get(), &QPlatformDialogHelper::reject,
this, &QQuickAbstractDialog::reject);
496 return m_handle.get();