From 04bf0ddaedb2de7be61b67b071314e6bbdf5f2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Thu, 27 Mar 2014 20:11:28 +0100 Subject: [PATCH] The icon dialog can now be closed on request --- src/declarativeimports/platformcomponents/icondialog.cpp | 8 ++++++++ src/declarativeimports/platformcomponents/icondialog.h | 1 + .../platformcomponents/utils/sharedsingleton.h | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/src/declarativeimports/platformcomponents/icondialog.cpp b/src/declarativeimports/platformcomponents/icondialog.cpp index 7a4fba090..fb42c39e7 100644 --- a/src/declarativeimports/platformcomponents/icondialog.cpp +++ b/src/declarativeimports/platformcomponents/icondialog.cpp @@ -57,6 +57,14 @@ QString IconDialog::openDialog() return dialog->openDialog(); } +void IconDialog::closeDialog() +{ + if (d->dialog) { + auto dialog = d->dialog.instance(); + dialog->close(); + } +} + IconDialog::~IconDialog() { } diff --git a/src/declarativeimports/platformcomponents/icondialog.h b/src/declarativeimports/platformcomponents/icondialog.h index d791eff48..e268a8a74 100644 --- a/src/declarativeimports/platformcomponents/icondialog.h +++ b/src/declarativeimports/platformcomponents/icondialog.h @@ -47,6 +47,7 @@ public: ~IconDialog(); Q_INVOKABLE QString openDialog(); + Q_INVOKABLE void closeDialog(); private: D_PTR; diff --git a/src/declarativeimports/platformcomponents/utils/sharedsingleton.h b/src/declarativeimports/platformcomponents/utils/sharedsingleton.h index 76248c0ef..96b34eaa6 100644 --- a/src/declarativeimports/platformcomponents/utils/sharedsingleton.h +++ b/src/declarativeimports/platformcomponents/utils/sharedsingleton.h @@ -41,6 +41,11 @@ public: return ptr; } + operator bool() const + { + return !s_instance.expired(); + } + private: static std::weak_ptr s_instance; };