Connection status indicators as avatar overlay
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sun, 12 Jan 2020 08:10:06 +0000 (09:10 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sun, 12 Jan 2020 08:10:06 +0000 (09:10 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/tray/UserLine.qml
src/gui/tray/UserModel.cpp
src/gui/tray/UserModel.h
src/gui/tray/Window.qml

index 82188aad818c1b4e2293bb8959ce951a4bccdbca..d2db68ff345a9cdd84924d42eef73a09cdb9878d 100644 (file)
@@ -41,6 +41,15 @@ MenuItem {
                         source: ("image://avatars/" + index)\r
                         Layout.preferredHeight: (userLineLayout.height -16)\r
                         Layout.preferredWidth: (userLineLayout.height -16)\r
+                        Image {\r
+                            id: accountStateIndicator\r
+                            source: userModelBackend.isUserConnected(index) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg"\r
+                            cache: false\r
+                            anchors.bottom: accountAvatar.bottom\r
+                            anchors.right: accountAvatar.right\r
+                            sourceSize.width: 16\r
+                            sourceSize.height: 16\r
+                        }\r
                     }\r
 \r
                     Column {\r
index f8223d424e90c2a218367d85d2c5207116ba9d68..e4d8b5ecc04676d91e79086b392da6f530bd4610 100644 (file)
@@ -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();
index c1a390daff5821bf15f95e53d0320cf5f962d89a..18d0e334b83fabf6dd91c87df6bc4b158c8ce67e 100644 (file)
@@ -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);
index 4c8072e84a68ff2979fbe305c13a741d6bc6ae46..c311b05039e447d80723b5c79f0c75bf0c32cc98 100644 (file)
@@ -39,6 +39,8 @@ Window {
             currentAccountAvatar.source = "image://avatars/currentUser"\r
             currentAccountUser.text = userModelBackend.currentUserName();\r
             currentAccountServer.text = userModelBackend.currentUserServer();\r
+            currentAccountStateIndicator.source = ""\r
+            currentAccountStateIndicator.source = userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg"\r
         }\r
         onNewUserSelected: {\r
             accountMenu.close();\r
@@ -248,6 +250,15 @@ Window {
                             source: "image://avatars/currentUser"\r
                             Layout.preferredHeight: (trayWindowHeaderBackground.height -16)\r
                             Layout.preferredWidth: (trayWindowHeaderBackground.height -16)\r
+                            Image {\r
+                                id: currentAccountStateIndicator\r
+                                source: userModelBackend.isUserConnected(userModelBackend.currentUserId()) ? "qrc:///client/theme/colored/state-ok.svg" : "qrc:///client/theme/colored/state-offline.svg"\r
+                                cache: false\r
+                                anchors.bottom: currentAccountAvatar.bottom\r
+                                anchors.right: currentAccountAvatar.right\r
+                                sourceSize.width: 16\r
+                                sourceSize.height: 16\r
+                            }\r
                         }\r
 \r
                         Column {\r