Connection status indicators as avatar overlay

Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
Dominique Fuchs 2020-01-12 09:10:06 +01:00
parent bc8f64bb98
commit 8ec7cfa700
4 changed files with 26 additions and 0 deletions

View file

@ -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 {

View 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();

View 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);

View file

@ -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 {