From 0ec6797d360c6a5a8d2d2487030d82d66feb5212 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Mon, 8 Apr 2024 11:56:59 +0200 Subject: [PATCH] fix some of the qml issues Signed-off-by: Matthieu Gallien --- src/gui/owncloudgui.cpp | 4 +-- src/gui/systray.cpp | 2 ++ src/gui/systray.h | 6 +++-- src/gui/tray/Window.qml | 57 +++++++++++++++++++---------------------- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 987c3ebe455ae..321e43b600d84 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -102,7 +102,7 @@ ownCloudGui::ownCloudGui(Application *parent) this, &ownCloudGui::slotShowSettings); connect(_tray.data(), &Systray::shutdown, - this, &ownCloudGui::slotShutdown); + this, &QCoreApplication::quit); ProgressDispatcher *pd = ProgressDispatcher::instance(); connect(pd, &ProgressDispatcher::progressInfo, this, @@ -599,13 +599,11 @@ void ownCloudGui::slotShutdown() { // explicitly close windows. This is somewhat of a hack to ensure // that saving the geometries happens ASAP during a OS shutdown - // those do delete on close if (!_settingsDialog.isNull()) _settingsDialog->close(); if (!_logBrowser.isNull()) _logBrowser->deleteLater(); - _app->quit(); } void ownCloudGui::slotToggleLogBrowser() diff --git a/src/gui/systray.cpp b/src/gui/systray.cpp index fb8451aa4c7b8..fec2202ef87e9 100644 --- a/src/gui/systray.cpp +++ b/src/gui/systray.cpp @@ -115,6 +115,8 @@ void Systray::create() if (_trayEngine) { if (!AccountManager::instance()->accounts().isEmpty()) { _trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel()); + } else { + _trayEngine->rootContext()->setContextProperty("activityModel", &_fakeActivityModel); } QQmlComponent trayWindowComponent(trayEngine(), QStringLiteral("qrc:/qml/src/gui/tray/Window.qml")); diff --git a/src/gui/systray.h b/src/gui/systray.h index 5a450580841a9..8a65c45e4d424 100644 --- a/src/gui/systray.h +++ b/src/gui/systray.h @@ -15,12 +15,12 @@ #ifndef SYSTRAY_H #define SYSTRAY_H -#include - #include "accountmanager.h" #include "tray/usermodel.h" +#include #include +#include class QScreen; class QQmlApplicationEngine; @@ -188,6 +188,8 @@ private slots: QSet _callsAlreadyNotified; QPointer _editFileLocallyLoadingDialog; QVector _fileDetailDialogs; + + QStringListModel _fakeActivityModel; }; } // namespace OCC diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index bbe0330d4af1d..f14b054f8420b 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -485,7 +485,7 @@ ApplicationWindow { Layout.leftMargin: Style.trayHorizontalMargin verticalAlignment: Qt.AlignCenter cache: false - source: UserModel.currentUser.avatar != "" ? UserModel.currentUser.avatar : "image://avatars/fallbackWhite" + source: (UserModel.currentUser && UserModel.currentUser.avatar !== "") ? UserModel.currentUser.avatar : "image://avatars/fallbackWhite" Layout.preferredHeight: Style.accountAvatarSize Layout.preferredWidth: Style.accountAvatarSize @@ -494,7 +494,7 @@ ApplicationWindow { Rectangle { id: currentAccountStatusIndicatorBackground - visible: UserModel.currentUser.isConnected + visible: UserModel.currentUser && UserModel.currentUser.isConnected && UserModel.currentUser.serverHasUserStatus width: Style.accountAvatarStateIndicatorSize + + Style.trayFolderStatusIndicatorSizeOffset height: width @@ -506,7 +506,7 @@ ApplicationWindow { Rectangle { id: currentAccountStatusIndicatorMouseHover - visible: UserModel.currentUser.isConnected + visible: UserModel.currentUser && UserModel.currentUser.isConnected && UserModel.currentUser.serverHasUserStatus width: Style.accountAvatarStateIndicatorSize + + Style.trayFolderStatusIndicatorSizeOffset height: width @@ -519,9 +519,9 @@ ApplicationWindow { Image { id: currentAccountStatusIndicator - visible: UserModel.currentUser.isConnected + visible: UserModel.currentUser && UserModel.currentUser.isConnected && UserModel.currentUser.serverHasUserStatus - source: UserModel.currentUser.statusIcon + source: UserModel.currentUser ? UserModel.currentUser.statusIcon : "" cache: false x: currentAccountStatusIndicatorBackground.x + 1 y: currentAccountStatusIndicatorBackground.y + 1 @@ -545,7 +545,7 @@ ApplicationWindow { id: currentAccountUser Layout.alignment: Qt.AlignLeft | Qt.AlignBottom width: Style.currentAccountLabelWidth - text: UserModel.currentUser.name + text: UserModel.currentUser ? UserModel.currentUser.name : "" elide: Text.ElideRight color: Style.currentUserHeaderTextColor @@ -557,7 +557,7 @@ ApplicationWindow { id: currentAccountServer Layout.alignment: Qt.AlignLeft | Qt.AlignBottom width: Style.currentAccountLabelWidth - text: UserModel.currentUser.server + text: UserModel.currentUser ? UserModel.currentUser.server : "" elide: Text.ElideRight color: Style.currentUserHeaderTextColor visible: UserModel.numUsers() > 1 @@ -565,26 +565,26 @@ ApplicationWindow { RowLayout { id: currentUserStatus - visible: UserModel.currentUser.isConnected && + visible: UserModel.currentUser && UserModel.currentUser.isConnected && UserModel.currentUser.serverHasUserStatus spacing: Style.accountLabelsSpacing width: parent.width EnforcedPlainTextLabel { id: emoji - visible: UserModel.currentUser.statusEmoji !== "" + visible: UserModel.currentUser && UserModel.currentUser.statusEmoji !== "" width: Style.userStatusEmojiSize - text: UserModel.currentUser.statusEmoji + text: UserModel.currentUser ? UserModel.currentUser.statusEmoji : "" } EnforcedPlainTextLabel { id: message Layout.alignment: Qt.AlignLeft | Qt.AlignBottom Layout.fillWidth: true - visible: UserModel.currentUser.statusMessage !== "" + visible: UserModel.currentUser && UserModel.currentUser.statusMessage !== "" width: Style.currentAccountLabelWidth - text: UserModel.currentUser.statusMessage !== "" + text: UserModel.currentUser && UserModel.currentUser.statusMessage !== "" ? UserModel.currentUser.statusMessage - : UserModel.currentUser.server + : UserModel.currentUser ? UserModel.currentUser.server : "" elide: Text.ElideRight color: Style.currentUserHeaderTextColor font.pixelSize: Style.subLinePixelSize @@ -639,7 +639,7 @@ ApplicationWindow { HeaderButton { id: trayWindowTalkButton - visible: UserModel.currentUser.serverHasTalk + visible: UserModel.currentUser && UserModel.currentUser.serverHasTalk icon.source: "qrc:///client/theme/white/talk-app.svg" icon.color: Style.currentUserHeaderTextColor onClicked: UserModel.openCurrentAccountTalk() @@ -736,21 +736,17 @@ ApplicationWindow { UnifiedSearchInputContainer { id: trayWindowUnifiedSearchInputContainer - height: Style.unifiedSearchInputContainerHeight + - topInset + - bottomInset + - bottomUnifiedSearchInputSeparator.height + height: Style.trayWindowHeaderHeight * 0.65 - anchors.top: trayWindowHeaderBackground.bottom - anchors.left: trayWindowMainItem.left - anchors.right: trayWindowMainItem.right + anchors { + top: trayWindowHeaderBackground.bottom + left: trayWindowMainItem.left + right: trayWindowMainItem.right - topInset: Style.trayHorizontalMargin + controlRoot.padding - leftInset: Style.trayHorizontalMargin + controlRoot.padding - rightInset: Style.trayHorizontalMargin + controlRoot.padding - bottomInset: bottomUnifiedSearchInputSeparator.visible ? - Style.trayHorizontalMargin + controlRoot.padding + bottomUnifiedSearchInputSeparator.height : - 0 + topMargin: Style.trayHorizontalMargin + controlRoot.padding + leftMargin: Style.trayHorizontalMargin + controlRoot.padding + rightMargin: Style.trayHorizontalMargin + controlRoot.padding + } text: UserModel.currentUser.unifiedSearchResultsListModel.searchTerm readOnly: !UserModel.currentUser.isConnected || UserModel.currentUser.unifiedSearchResultsListModel.currentFetchMoreInProgressProviderId @@ -880,9 +876,8 @@ ApplicationWindow { Rectangle { id: syncStatusSeparator - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom + Layout.fillWidth: true + Layout.preferredHeight: 1 height: 1 color: Style.menuBorder @@ -966,7 +961,7 @@ ApplicationWindow { } Connections { target: activityModel - onInteractiveActivityReceived: { + function onInteractiveActivityReceived() { if (!activityList.atYBeginning) { newActivitiesButtonLoader.active = true; }