From: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> Date: Sun, 12 Jan 2020 08:10:06 +0000 (+0100) Subject: Connection status indicators as avatar overlay X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~222^2^2~413^2~60 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8ec7cfa7008d1bba63f5f01338594cc665b937d3;p=nextcloud-desktop.git Connection status indicators as avatar overlay Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> --- diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index 82188aad8..d2db68ff3 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -41,6 +41,15 @@ MenuItem { source: ("image://avatars/" + index) Layout.preferredHeight: (userLineLayout.height -16) Layout.preferredWidth: (userLineLayout.height -16) + Image { + id: accountStateIndicator + source: userModelBackend.isUserConnected(index) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg" + cache: false + anchors.bottom: accountAvatar.bottom + anchors.right: accountAvatar.right + sourceSize.width: 16 + sourceSize.height: 16 + } } Column { diff --git a/src/gui/tray/UserModel.cpp b/src/gui/tray/UserModel.cpp index f8223d424..e4d8b5ecc 100644 --- a/src/gui/tray/UserModel.cpp +++ b/src/gui/tray/UserModel.cpp @@ -163,6 +163,11 @@ Q_INVOKABLE int UserModel::numUsers() return _users.size(); } +Q_INVOKABLE int UserModel::currentUserId() +{ + return _currentUserId; +} + Q_INVOKABLE bool UserModel::isUserConnected(const int &id) { return _users[id].isConnected(); diff --git a/src/gui/tray/UserModel.h b/src/gui/tray/UserModel.h index c1a390daf..18d0e334b 100644 --- a/src/gui/tray/UserModel.h +++ b/src/gui/tray/UserModel.h @@ -66,6 +66,7 @@ public: Q_INVOKABLE QString currentUserServer(); Q_INVOKABLE bool currentUserHasActivities(); Q_INVOKABLE bool currentServerHasTalk(); + Q_INVOKABLE int currentUserId(); Q_INVOKABLE bool isUserConnected(const int &id); Q_INVOKABLE void switchCurrentUser(const int &id); Q_INVOKABLE void login(const int &id); diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index 4c8072e84..c311b0503 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -39,6 +39,8 @@ Window { currentAccountAvatar.source = "image://avatars/currentUser" currentAccountUser.text = userModelBackend.currentUserName(); currentAccountServer.text = userModelBackend.currentUserServer(); + currentAccountStateIndicator.source = "" + currentAccountStateIndicator.source = userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg" } onNewUserSelected: { accountMenu.close(); @@ -248,6 +250,15 @@ Window { source: "image://avatars/currentUser" Layout.preferredHeight: (trayWindowHeaderBackground.height -16) Layout.preferredWidth: (trayWindowHeaderBackground.height -16) + Image { + id: currentAccountStateIndicator + source: userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg" + cache: false + anchors.bottom: currentAccountAvatar.bottom + anchors.right: currentAccountAvatar.right + sourceSize.width: 16 + sourceSize.height: 16 + } } Column {