Changeset View
Changeset View
Standalone View
Standalone View
shell/shellcorona.cpp
Show All 32 Lines | |||||
33 | 33 | | |||
34 | #include <QJsonObject> | 34 | #include <QJsonObject> | ||
35 | #include <QJsonDocument> | 35 | #include <QJsonDocument> | ||
36 | 36 | | |||
37 | #include <kactioncollection.h> | 37 | #include <kactioncollection.h> | ||
38 | #include <klocalizedstring.h> | 38 | #include <klocalizedstring.h> | ||
39 | #include <Plasma/Package> | 39 | #include <Plasma/Package> | ||
40 | #include <Plasma/PluginLoader> | 40 | #include <Plasma/PluginLoader> | ||
41 | #include <PlasmaQuick/Dialog> | ||||
42 | | ||||
41 | #include <kactivities/controller.h> | 43 | #include <kactivities/controller.h> | ||
42 | #include <kactivities/consumer.h> | 44 | #include <kactivities/consumer.h> | ||
43 | #include <ksycoca.h> | 45 | #include <ksycoca.h> | ||
44 | #include <KGlobalAccel> | 46 | #include <KGlobalAccel> | ||
45 | #include <KAuthorized> | 47 | #include <KAuthorized> | ||
46 | #include <KWindowSystem> | 48 | #include <KWindowSystem> | ||
47 | #include <kdeclarative/kdeclarative.h> | 49 | #include <kdeclarative/kdeclarative.h> | ||
48 | #include <kdeclarative/qmlobject.h> | 50 | #include <kdeclarative/qmlobject.h> | ||
▲ Show 20 Lines • Show All 766 Lines • ▼ Show 20 Line(s) | 812 | { | |||
815 | 817 | | |||
816 | KDeclarative::QmlObject *qmlObj = new KDeclarative::QmlObject(this); | 818 | KDeclarative::QmlObject *qmlObj = new KDeclarative::QmlObject(this); | ||
817 | qmlObj->setInitializationDelayed(true); | 819 | qmlObj->setInitializationDelayed(true); | ||
818 | qmlObj->setSource(QUrl::fromLocalFile(alternativesQML)); | 820 | qmlObj->setSource(QUrl::fromLocalFile(alternativesQML)); | ||
819 | 821 | | |||
820 | AlternativesHelper *helper = new AlternativesHelper(applet, qmlObj); | 822 | AlternativesHelper *helper = new AlternativesHelper(applet, qmlObj); | ||
821 | qmlObj->rootContext()->setContextProperty(QStringLiteral("alternativesHelper"), helper); | 823 | qmlObj->rootContext()->setContextProperty(QStringLiteral("alternativesHelper"), helper); | ||
822 | 824 | | |||
823 | m_alternativesObjects << qmlObj; | | |||
824 | qmlObj->completeInitialization(); | 825 | qmlObj->completeInitialization(); | ||
825 | connect(qmlObj->rootObject(), SIGNAL(visibleChanged(bool)), | | |||
826 | this, SLOT(alternativesVisibilityChanged(bool))); | | |||
827 | 826 | | |||
828 | connect(applet, &Plasma::Applet::destroyedChanged, this, [this, qmlObj] (bool destroyed) { | 827 | auto dialog = qobject_cast<PlasmaQuick::Dialog*>(qmlObj->rootObject()); | ||
829 | if (!destroyed) { | 828 | if (!dialog) { | ||
829 | qWarning() << "Alternatives UI does not inherit from Dialog"; | ||||
830 | delete qmlObj; | ||||
830 | return; | 831 | return; | ||
831 | } | 832 | } | ||
832 | QMutableListIterator<KDeclarative::QmlObject *> it(m_alternativesObjects); | 833 | connect(applet, &Plasma::Applet::destroyedChanged, qmlObj, [qmlObj] (bool destroyed) { | ||
833 | while (it.hasNext()) { | 834 | if (!destroyed) { | ||
834 | KDeclarative::QmlObject *obj = it.next(); | 835 | return; | ||
835 | if (obj == qmlObj) { | | |||
836 | it.remove(); | | |||
837 | obj->deleteLater(); | | |||
838 | } | | |||
839 | } | 836 | } | ||
837 | qmlObj->deleteLater(); | ||||
840 | }); | 838 | }); | ||
841 | } | 839 | connect(dialog, &PlasmaQuick::Dialog::visibleChanged, qmlObj, [qmlObj](bool visible) { | ||
842 | | ||||
843 | void ShellCorona::alternativesVisibilityChanged(bool visible) | | |||
844 | { | | |||
845 | if (visible) { | 840 | if (visible) { | ||
846 | return; | 841 | return; | ||
847 | } | 842 | } | ||
848 | 843 | qmlObj->deleteLater(); | |||
849 | QObject *root = sender(); | 844 | }); | ||
850 | | ||||
851 | QMutableListIterator<KDeclarative::QmlObject *> it(m_alternativesObjects); | | |||
852 | while (it.hasNext()) { | | |||
853 | KDeclarative::QmlObject *obj = it.next(); | | |||
854 | if (obj->rootObject() == root) { | | |||
855 | it.remove(); | | |||
856 | obj->deleteLater(); | | |||
857 | } | | |||
858 | } | | |||
859 | } | 845 | } | ||
860 | 846 | | |||
861 | void ShellCorona::unload() | 847 | void ShellCorona::unload() | ||
862 | { | 848 | { | ||
863 | if (m_shell.isEmpty()) { | 849 | if (m_shell.isEmpty()) { | ||
864 | return; | 850 | return; | ||
865 | } | 851 | } | ||
866 | qDeleteAll(m_desktopViewforId); | 852 | qDeleteAll(m_desktopViewforId); | ||
▲ Show 20 Lines • Show All 1292 Lines • Show Last 20 Lines |