Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Fella <nicolas.fella@gmx.de>2020-06-15 18:01:39 +0300
committerKevin Ottens <ervin@ipsquad.net>2020-06-16 15:34:59 +0300
commita12205f322d43476230881192616e47c9cf786ef (patch)
tree086a9ba855ae97b71513ca628298a4be39d72069 /src/gui/systray.cpp
parent1157ceafb1e197d3d0e150bd435986b7d10e6c7f (diff)
Port from context properties to singletons
Context properties are deprecated and will be removed in Qt 6. QML singletons are the better option here, especially given that UserModel and UserAppsModel already are singletons. Signed-off-by: Nicolas Fella <nicolas.fella@gmx.de>
Diffstat (limited to 'src/gui/systray.cpp')
-rw-r--r--src/gui/systray.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp
index c67fa4bef..6b15ddaba 100644
--- a/src/gui/systray.cpp
+++ b/src/gui/systray.cpp
@@ -54,9 +54,24 @@ Systray::Systray()
{
_trayEngine->addImportPath("qrc:/qml/theme");
_trayEngine->addImageProvider("avatars", new ImageProvider);
- _trayEngine->rootContext()->setContextProperty("userModelBackend", UserModel::instance());
- _trayEngine->rootContext()->setContextProperty("appsMenuModelBackend", UserAppsModel::instance());
- _trayEngine->rootContext()->setContextProperty("systrayBackend", this);
+
+ qmlRegisterSingletonType<UserModel>("com.nextcloud.desktopclient", 1, 0, "UserModel",
+ [](QQmlEngine *, QJSEngine *) -> QObject * {
+ return UserModel::instance();
+ }
+ );
+
+ qmlRegisterSingletonType<UserAppsModel>("com.nextcloud.desktopclient", 1, 0, "UserAppsModel",
+ [](QQmlEngine *, QJSEngine *) -> QObject * {
+ return UserAppsModel::instance();
+ }
+ );
+
+ qmlRegisterSingletonType<Systray>("com.nextcloud.desktopclient", 1, 0, "Systray",
+ [](QQmlEngine *, QJSEngine *) -> QObject * {
+ return Systray::instance();
+ }
+ );
connect(UserModel::instance(), &UserModel::newUserSelected,
this, &Systray::slotNewUserSelected);