337void QQuickAbstractDialog::open()
339 qCDebug(lcDialogs) <<
"open called";
340 if (m_visible || !create())
343 onShow(m_handle.get());
345 m_visible = m_handle->show(m_flags, m_modality, windowForOpen());
346 if (!m_visible && useNativeDialog()) {
349 if (!create(CreateOptions::DontTryNativeDialog))
352 onShow(m_handle.get());
353 m_visible = m_handle->show(m_flags, m_modality, windowForOpen());
359 QObject::connect(
this, &QQuickAbstractDialog::visibleChanged,
360 m_handle.get(), [
this]{
if (!isVisible()) destroy(); });
365 emit visibleChanged();
377void QQuickAbstractDialog::close()
379 if (!m_handle || !m_visible)
382 onHide(m_handle.get());
385 if (!m_parentWindowExplicitlySet)
386 m_parentWindow =
nullptr;
387 emit visibleChanged();
389 if (dialogCode() == Accepted)
391 else if (dialogCode() == Rejected)
436void QQuickAbstractDialog::componentComplete()
438 qCDebug(lcDialogs) <<
"componentComplete";
441 if (!m_visibleRequested)
444 m_visibleRequested =
false;
446 if (windowForOpen()) {
455 if (
const auto parentItem = findParentItem())
456 connect(parentItem, &QQuickItem::windowChanged,
this, &QQuickAbstractDialog::deferredOpen, Qt::SingleShotConnection);
470bool QQuickAbstractDialog::create(CreateOptions createOptions)
472 qCDebug(lcDialogs) << qmlTypeName(
this) <<
"attempting to create dialog backend of type"
473 <<
int(m_type) <<
"with parent window" << m_parentWindow;
475 return m_handle.get();
477 if ((createOptions != CreateOptions::DontTryNativeDialog) && useNativeDialog()) {
478 qCDebug(lcDialogs) <<
"- attempting to create a native dialog";
479 m_handle.reset(QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(
480 toPlatformDialogType(m_type)));
484 qCDebug(lcDialogs) <<
"- attempting to create a quick dialog";
485 m_handle = QQuickDialogImplFactory::createPlatformDialogHelper(m_type,
this);
488 qCDebug(lcDialogs) << qmlTypeName(
this) <<
"created ->" << m_handle.get();
490 onCreate(m_handle.get());
491 connect(m_handle.get(), &QPlatformDialogHelper::accept,
this, &QQuickAbstractDialog::accept);
492 connect(m_handle.get(), &QPlatformDialogHelper::reject,
this, &QQuickAbstractDialog::reject);
494 return m_handle.get();