Generalized connection check, now working for every user in account menu
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sun, 12 Jan 2020 07:50:13 +0000 (08:50 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sun, 12 Jan 2020 07:50:13 +0000 (08:50 +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

index 1bfd65c5598aa0217d8ddbf91b0e8e7579146b65..82188aad818c1b4e2293bb8959ce951a4bccdbca 100644 (file)
@@ -105,9 +105,9 @@ MenuItem {
                     }\r
 \r
                     MenuItem {\r
-                        text: userModelBackend.isCurrentUserConnected() ? "Log out" : "Log in"\r
+                        text: userModelBackend.isUserConnected(index) ? "Log out" : "Log in"\r
                         onClicked: {\r
-                            userModelBackend.isCurrentUserConnected() ? userModelBackend.logout(index) : userModelBackend.logout(index)\r
+                            userModelBackend.isUserConnected(index) ? userModelBackend.logout(index) : userModelBackend.logout(index)\r
                         }\r
                     }\r
 \r
index 2018daf0c3ae73c2e4b7ddb8701ec8e22101bc23..f8223d424e90c2a218367d85d2c5207116ba9d68 100644 (file)
@@ -163,9 +163,9 @@ Q_INVOKABLE int UserModel::numUsers()
     return _users.size();
 }
 
-Q_INVOKABLE bool UserModel::isCurrentUserConnected()
+Q_INVOKABLE bool UserModel::isUserConnected(const int &id)
 {
-    return _users[_currentUserId].isConnected();
+    return _users[id].isConnected();
 }
 
 Q_INVOKABLE QImage UserModel::currentUserAvatar()
index ee7198641394914ddb67791b794cdbc62c44f11e..c1a390daff5821bf15f95e53d0320cf5f962d89a 100644 (file)
@@ -62,11 +62,11 @@ public:
     Q_INVOKABLE void openCurrentAccountServer();
     Q_INVOKABLE QImage currentUserAvatar();
     Q_INVOKABLE int numUsers();
-    Q_INVOKABLE bool isCurrentUserConnected();
     Q_INVOKABLE QString currentUserName();
     Q_INVOKABLE QString currentUserServer();
     Q_INVOKABLE bool currentUserHasActivities();
     Q_INVOKABLE bool currentServerHasTalk();
+    Q_INVOKABLE bool isUserConnected(const int &id);
     Q_INVOKABLE void switchCurrentUser(const int &id);
     Q_INVOKABLE void login(const int &id);
     Q_INVOKABLE void logout(const int &id);