diff options
author | Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> | 2020-04-25 13:15:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 13:15:33 +0300 |
commit | 210253ce35a8d4821772a8efc4c949ba94baf060 (patch) | |
tree | edf361e341f23e157bb378550cbb8bfde62713b5 /src/gui/systray.cpp | |
parent | c126f1a540cfc8e00320b14a7c26a88ab44afc97 (diff) | |
parent | d54add6233cf3ce663f6f4f82689547f09cd5acf (diff) |
Merge pull request #1889 from nicolasfella/applicationengine
Use QQmlApplicationEngine instead of QQmlEngine
Diffstat (limited to 'src/gui/systray.cpp')
-rw-r--r-- | src/gui/systray.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index 33a07e68c..17ac06c6a 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -22,7 +22,7 @@ #include <QDesktopServices> #include <QGuiApplication> #include <QQmlComponent> -#include <QQmlEngine> +#include <QQmlApplicationEngine> #include <QScreen> #ifdef USE_FDO_NOTIFICATIONS @@ -50,20 +50,14 @@ Systray *Systray::instance() Systray::Systray() : _isOpen(false) , _syncIsPaused(false) - , _trayComponent(nullptr) - , _trayContext(nullptr) { - // Create QML tray engine, build component, set C++ backend context used in window.qml - // Use pointer instead of engine() helper function until Qt 5.12 is minimum standard - _trayEngine = new QQmlEngine; + _trayEngine = new QQmlApplicationEngine; _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); - _trayComponent = new QQmlComponent(_trayEngine, QUrl(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"))); - connect(UserModel::instance(), &UserModel::newUserSelected, this, &Systray::slotNewUserSelected); @@ -73,13 +67,11 @@ Systray::Systray() void Systray::create() { - if (_trayContext == nullptr) { - if (!AccountManager::instance()->accounts().isEmpty()) { - _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel()); - } - _trayContext = _trayEngine->contextForObject(_trayComponent->create()); - hideWindow(); + if (!AccountManager::instance()->accounts().isEmpty()) { + _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel()); } + _trayEngine->load(QStringLiteral("qrc:/qml/src/gui/tray/Window.qml")); + hideWindow(); } void Systray::slotNewUserSelected() |