Commit a12205f322 (PR #1891) introduced
a circular ownership: qmlRegisterSingletonType<Systray>(...) makes the
QQmlEngine own the resulting singleton Systray instance, however, the
QQmlEngine _trayEngine itself is owned by the Systray instance. This
circular ownership results in a crash when the destructor of Systray
calls the destructor of _trayEngine which attempts to call the destructor
of Systray.
This commit solves this problem by making ownCloudGui, which is the
parent of Systray, the parent of the _trayEngine.
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Seems like Qt sometimes doesn't like the QML window's screen property to be set
to a C++ (QVariant) pointer value, so we use the index: Qt.application.screens[]
See Qt docs: https://doc.qt.io/qt-5/qml-qtquick-window-window.html#screen-prop
This fix returns the matching window's index from the QGuiApplication::screens()
list to the QML side, instead of the window pointer.
Steps to reproduce the crash with the previous code:
- Open the Tray menu and close it a few times,
or scroll randomly up and down in its activity list.
Tested with Qt 5.12.5
Signed-off-by: Michael Schuster <michael@schuster.ms>
This leads to simplifying the computation code quite a bit as well.
Indeed we're separating concern between what is window size dependent or
not and that shows.
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This was leading to the same logic being duplicated several times. It's
fine to return the QScreen* on the QML side directly but wrapped into a
QVariant.
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
The API is just more convenient there, the rect and point types on the
QML side are just pale shadow of their C++ counterparts.
Also improved a bit the constness of the Systray class.
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
This also fixes a couple of warnings at places (out of order init for
instance) and a potential bug in the webflow credentials / qtkeychain
integration.
Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
The member _trayEngine, allocated in the constructor, was leaking.
This commit sets the Systray instance as the Qt object tree parent of
the _trayEngine to fix the leak.
While at it, a few unused header includes have been removed.
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
It it never set by calling code so the default value of 10000 is used. It is only used in the call to QSystemTrayIcon, which uses 10000 as default value too.
Signed-off-by: Nicolas Fella <nicolas.fella@gmx.de>
- Modify Window.qml and Systray to show the App menu upon clicking the App button
on the top-right. Fall back to opening the general URL in case no apps are found.
- Introduce a new UserAppsModel in UserModel.cpp to access the fetched server Apps
from AccountState (propagated down from the User class).
Signed-off-by: Michael Schuster <michael@schuster.ms>