diff --git a/src/gui/accountstate.cpp b/src/gui/accountstate.cpp index a5dadb0b32..0c80266bdd 100644 --- a/src/gui/accountstate.cpp +++ b/src/gui/accountstate.cpp @@ -230,6 +230,7 @@ bool AccountState::isDesktopNotificationsAllowed() const void AccountState::setDesktopNotificationsAllowed(bool isAllowed) { _isDesktopNotificationsAllowed = isAllowed; + emit desktopNotificationsAllowedChanged(); } void AccountState::checkConnectivity() diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index f0d1a2f997..46d59f5ca2 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -202,6 +202,7 @@ signals: void isConnectedChanged(); void hasFetchedNavigationApps(); void statusChanged(); + void desktopNotificationsAllowedChanged(); protected Q_SLOTS: void slotConnectionValidatorResult(ConnectionValidator::Status status, const QStringList &errors); diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index dd2ddb722c..d4d9b5edc0 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -93,7 +93,7 @@ MenuItem { sourceSize.height: Style.accountAvatarStateIndicatorSize Accessible.role: Accessible.Indicator - Accessible.name: model.isStatusOnline ? qsTr("Current user status is online") : qsTr("Current user status is do not disturb") + Accessible.name: model.isDesktopNotificationsAllowed ? qsTr("Current user status is online") : qsTr("Current user status is do not disturb") } } diff --git a/src/gui/tray/UserModel.cpp b/src/gui/tray/UserModel.cpp index 379d23a66d..840c2f19e9 100644 --- a/src/gui/tray/UserModel.cpp +++ b/src/gui/tray/UserModel.cpp @@ -56,6 +56,7 @@ User::User(AccountStatePtr &account, const bool &isCurrent, QObject *parent) connect(_account->account().data(), &Account::accountChangedAvatar, this, &User::avatarChanged); connect(_account.data(), &AccountState::statusChanged, this, &User::statusChanged); + connect(_account.data(), &AccountState::desktopNotificationsAllowedChanged, this, &User::desktopNotificationsAllowedChanged); connect(_activityModel, &ActivityListModel::sendNotificationRequest, this, &User::slotSendNotificationRequest); } @@ -745,6 +746,11 @@ void UserModel::addUser(AccountStatePtr &user, const bool &isCurrent) emit dataChanged(index(row, 0), index(row, 0), {UserModel::StatusIconRole, UserModel::StatusMessageRole}); }); + + connect(u, &User::desktopNotificationsAllowedChanged, this, [this, row] { + emit dataChanged(index(row, 0), index(row, 0), {UserModel::DesktopNotificationsAllowedRole}); + }); + _users << u; if (isCurrent) { @@ -884,12 +890,14 @@ QVariant UserModel::data(const QModelIndex &index, int role) const return _users[index.row()]->name(); } else if (role == ServerRole) { return _users[index.row()]->server(); - } else if (role == ServerUserStatus) { + } else if (role == ServerUserStatusRole) { return _users[index.row()]->serverHasUserStatus(); } else if (role == StatusIconRole) { return _users[index.row()]->statusIcon(); } else if (role == StatusMessageRole) { return _users[index.row()]->statusMessage(); + } else if (role == DesktopNotificationsAllowedRole) { + return _users[index.row()]->isDesktopNotificationsAllowed(); } else if (role == AvatarRole) { return _users[index.row()]->avatarUrl(); } else if (role == IsCurrentUserRole) { @@ -907,12 +915,13 @@ QHash UserModel::roleNames() const QHash roles; roles[NameRole] = "name"; roles[ServerRole] = "server"; + roles[ServerUserStatusRole] = "serverUserStatus"; roles[StatusIconRole] = "statusIcon"; roles[StatusMessageRole] = "statusMessage"; + roles[DesktopNotificationsAllowedRole] = "isDesktopNotificationsAllowed"; roles[AvatarRole] = "avatar"; roles[IsCurrentUserRole] = "isCurrentUser"; roles[IsConnectedRole] = "isConnected"; - roles[ServerUserStatus] = "serverUserStatus"; roles[IdRole] = "id"; return roles; } diff --git a/src/gui/tray/UserModel.h b/src/gui/tray/UserModel.h index 9968d90f98..278d8c89e0 100644 --- a/src/gui/tray/UserModel.h +++ b/src/gui/tray/UserModel.h @@ -21,9 +21,10 @@ class User : public QObject Q_OBJECT Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString server READ server CONSTANT) + Q_PROPERTY(bool serverHasUserStatus READ serverHasUserStatus) Q_PROPERTY(QUrl statusIcon READ statusIcon NOTIFY statusChanged) Q_PROPERTY(QString statusMessage READ statusMessage NOTIFY statusChanged) - Q_PROPERTY(bool serverHasUserStatus READ serverHasUserStatus) + Q_PROPERTY(QString isDesktopNotificationsAllowed READ isDesktopNotificationsAllowed NOTIFY desktopNotificationsAllowedChanged) Q_PROPERTY(bool hasLocalFolder READ hasLocalFolder NOTIFY hasLocalFolderChanged) Q_PROPERTY(bool serverHasTalk READ serverHasTalk NOTIFY serverHasTalkChanged) Q_PROPERTY(QString avatar READ avatarUrl NOTIFY avatarChanged) @@ -65,6 +66,7 @@ signals: void avatarChanged(); void accountStateChanged(int state); void statusChanged(); + void desktopNotificationsAllowedChanged(); public slots: void slotItemCompleted(const QString &folder, const SyncFileItemPtr &item); @@ -156,12 +158,13 @@ public: enum UserRoles { NameRole = Qt::UserRole + 1, ServerRole, + ServerUserStatusRole, StatusIconRole, StatusMessageRole, + DesktopNotificationsAllowedRole, AvatarRole, IsCurrentUserRole, IsConnectedRole, - ServerUserStatus, IdRole }; diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index b713332b06..a3f5f0fdd6 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -381,7 +381,7 @@ Window { sourceSize.height: Style.accountAvatarStateIndicatorSize Accessible.role: Accessible.Indicator - Accessible.name: UserModel.isUserStatusOnline(UserModel.currentUserId()) ? qsTr("Current user status is online") : qsTr("Current user status is do not disturb") + Accessible.name: UserModel.isDesktopNotificationsAllowed ? qsTr("Current user status is online") : qsTr("Current user status is do not disturb") } }