From fa5d3bc2f6d6c93bdf923216c4837b57ddc6cb15 Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Wed, 19 Mar 2025 10:31:47 +0100 Subject: [PATCH 1/3] explicitly set colours for header items the _Universal_ theme notably sets [`icon.color` on `Button`s][0] and also the [`color` on `Label`s][1], ignoring what's set through the `palette` property ... [0]: https://github.com/qt/qtdeclarative/blob/215619d71b69be02348e12dc2dfea087c3ec2abb/src/quickcontrols/universal/Button.qml#L23 [1]: https://github.com/qt/qtdeclarative/blob/215619d71b69be02348e12dc2dfea087c3ec2abb/src/quickcontrols/universal/Label.qml#L12 Signed-off-by: Jyrki Gadinger --- src/gui/tray/CurrentAccountHeaderButton.qml | 4 ++++ src/gui/tray/HeaderButton.qml | 1 + 2 files changed, 5 insertions(+) diff --git a/src/gui/tray/CurrentAccountHeaderButton.qml b/src/gui/tray/CurrentAccountHeaderButton.qml index 787470f9aa..ca3a3a5ecd 100644 --- a/src/gui/tray/CurrentAccountHeaderButton.qml +++ b/src/gui/tray/CurrentAccountHeaderButton.qml @@ -198,6 +198,7 @@ Button { id: currentAccountUser Layout.alignment: Qt.AlignLeft | Qt.AlignBottom width: Style.currentAccountLabelWidth + color: palette.windowText text: UserModel.currentUser ? UserModel.currentUser.name : "" elide: Text.ElideRight @@ -209,6 +210,7 @@ Button { id: currentAccountServer Layout.alignment: Qt.AlignLeft | Qt.AlignBottom width: Style.currentAccountLabelWidth + color: palette.windowText text: UserModel.currentUser ? UserModel.currentUser.server : "" elide: Text.ElideRight visible: UserModel.numUsers() > 1 @@ -225,6 +227,7 @@ Button { id: emoji visible: UserModel.currentUser && UserModel.currentUser.statusEmoji !== "" width: Style.userStatusEmojiSize + color: palette.windowText text: UserModel.currentUser ? UserModel.currentUser.statusEmoji : "" } EnforcedPlainTextLabel { @@ -233,6 +236,7 @@ Button { Layout.fillWidth: true visible: UserModel.currentUser && UserModel.currentUser.statusMessage !== "" width: Style.currentAccountLabelWidth + color: palette.windowText text: UserModel.currentUser && UserModel.currentUser.statusMessage !== "" ? UserModel.currentUser.statusMessage : UserModel.currentUser ? UserModel.currentUser.server : "" diff --git a/src/gui/tray/HeaderButton.qml b/src/gui/tray/HeaderButton.qml index 6bdcb28768..b133a75329 100644 --- a/src/gui/tray/HeaderButton.qml +++ b/src/gui/tray/HeaderButton.qml @@ -32,6 +32,7 @@ Button { icon.width: Style.headerButtonIconSize icon.height: Style.headerButtonIconSize + icon.color: "transparent" Layout.alignment: Qt.AlignRight Layout.preferredWidth: Style.trayWindowHeaderHeight From fa6e4efbd954891bef3a48b6919657544c1da401 Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Wed, 19 Mar 2025 11:24:39 +0100 Subject: [PATCH 2/3] use colour from `Style` instead of palette for icons Signed-off-by: Jyrki Gadinger --- src/gui/tray/CurrentAccountHeaderButton.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/tray/CurrentAccountHeaderButton.qml b/src/gui/tray/CurrentAccountHeaderButton.qml index ca3a3a5ecd..3b7249704f 100644 --- a/src/gui/tray/CurrentAccountHeaderButton.qml +++ b/src/gui/tray/CurrentAccountHeaderButton.qml @@ -198,7 +198,7 @@ Button { id: currentAccountUser Layout.alignment: Qt.AlignLeft | Qt.AlignBottom width: Style.currentAccountLabelWidth - color: palette.windowText + color: Style.currentUserHeaderTextColor text: UserModel.currentUser ? UserModel.currentUser.name : "" elide: Text.ElideRight @@ -210,7 +210,7 @@ Button { id: currentAccountServer Layout.alignment: Qt.AlignLeft | Qt.AlignBottom width: Style.currentAccountLabelWidth - color: palette.windowText + color: Style.currentUserHeaderTextColor text: UserModel.currentUser ? UserModel.currentUser.server : "" elide: Text.ElideRight visible: UserModel.numUsers() > 1 @@ -227,7 +227,7 @@ Button { id: emoji visible: UserModel.currentUser && UserModel.currentUser.statusEmoji !== "" width: Style.userStatusEmojiSize - color: palette.windowText + color: Style.currentUserHeaderTextColor text: UserModel.currentUser ? UserModel.currentUser.statusEmoji : "" } EnforcedPlainTextLabel { @@ -236,7 +236,7 @@ Button { Layout.fillWidth: true visible: UserModel.currentUser && UserModel.currentUser.statusMessage !== "" width: Style.currentAccountLabelWidth - color: palette.windowText + color: Style.currentUserHeaderTextColor text: UserModel.currentUser && UserModel.currentUser.statusMessage !== "" ? UserModel.currentUser.statusMessage : UserModel.currentUser ? UserModel.currentUser.server : "" From 992ca675287c7d5dceb3f3e1d8e184f502997f08 Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Wed, 19 Mar 2025 11:25:09 +0100 Subject: [PATCH 3/3] align status icon display with e.g. Talk more - status icons have now a white background/border - "Invisible"/"Offline" icons are now hidden - UserModel.status property is now available in QML too when needed Signed-off-by: Jyrki Gadinger --- src/gui/tray/CurrentAccountHeaderButton.qml | 6 +++++- src/gui/tray/UserLine.qml | 3 ++- src/gui/tray/usermodel.cpp | 8 ++++++-- src/gui/tray/usermodel.h | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/gui/tray/CurrentAccountHeaderButton.qml b/src/gui/tray/CurrentAccountHeaderButton.qml index 3b7249704f..061a5d2fbb 100644 --- a/src/gui/tray/CurrentAccountHeaderButton.qml +++ b/src/gui/tray/CurrentAccountHeaderButton.qml @@ -162,9 +162,11 @@ Button { id: currentAccountStatusIndicatorBackground visible: UserModel.currentUser && UserModel.currentUser.isConnected && UserModel.currentUser.serverHasUserStatus + && UserModel.currentUser.status !== UserStatus.Invisible + && UserModel.currentUser.status !== UserStatus.Offline width: Style.accountAvatarStateIndicatorSize + + Style.trayFolderStatusIndicatorSizeOffset height: width - color: root.parentBackgroundColor + color: "white" anchors.bottom: currentAccountAvatar.bottom anchors.right: currentAccountAvatar.right radius: width * Style.trayFolderStatusIndicatorRadiusFactor @@ -174,6 +176,8 @@ Button { id: currentAccountStatusIndicator visible: UserModel.currentUser && UserModel.currentUser.isConnected && UserModel.currentUser.serverHasUserStatus + && UserModel.currentUser.status !== UserStatus.Invisible + && UserModel.currentUser.status !== UserStatus.Offline source: UserModel.currentUser ? UserModel.currentUser.statusIcon : "" cache: false x: currentAccountStatusIndicatorBackground.x + 1 diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index 010a9391b0..ea52fb09c2 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -50,9 +50,10 @@ AbstractButton { visible: model.isConnected && model.serverHasUserStatus width: accountStatusIndicator.sourceSize.width + 2 height: width + color: "white" anchors.bottom: accountAvatar.bottom anchors.right: accountAvatar.right - radius: width * Style.trayFolderStatusIndicatorRadiusFactor + radius: width * Style.trayFolderStatusIndicatorRadiusFactor } Image { diff --git a/src/gui/tray/usermodel.cpp b/src/gui/tray/usermodel.cpp index 65229590b3..6cb075b632 100644 --- a/src/gui/tray/usermodel.cpp +++ b/src/gui/tray/usermodel.cpp @@ -1349,8 +1349,9 @@ void UserModel::addUser(AccountStatePtr &user, const bool &isCurrent) }); connect(u, &User::statusChanged, this, [this, row] { - emit dataChanged(index(row, 0), index(row, 0), {UserModel::StatusIconRole, - UserModel::StatusEmojiRole, + emit dataChanged(index(row, 0), index(row, 0), {UserModel::StatusRole, + UserModel::StatusIconRole, + UserModel::StatusEmojiRole, UserModel::StatusMessageRole}); }); @@ -1542,6 +1543,8 @@ QVariant UserModel::data(const QModelIndex &index, int role) const return _users[index.row()]->server(); } else if (role == ServerHasUserStatusRole) { return _users[index.row()]->serverHasUserStatus(); + } else if (role == StatusRole) { + return QVariant::fromValue(_users[index.row()]->status()); } else if (role == StatusIconRole) { return _users[index.row()]->statusIcon(); } else if (role == StatusEmojiRole) { @@ -1568,6 +1571,7 @@ QHash UserModel::roleNames() const roles[NameRole] = "name"; roles[ServerRole] = "server"; roles[ServerHasUserStatusRole] = "serverHasUserStatus"; + roles[StatusRole] = "status"; roles[StatusIconRole] = "statusIcon"; roles[StatusEmojiRole] = "statusEmoji"; roles[StatusMessageRole] = "statusMessage"; diff --git a/src/gui/tray/usermodel.h b/src/gui/tray/usermodel.h index 2d56f01210..e4e40e1671 100644 --- a/src/gui/tray/usermodel.h +++ b/src/gui/tray/usermodel.h @@ -51,6 +51,7 @@ class User : public QObject Q_PROPERTY(QColor headerTextColor READ headerTextColor NOTIFY headerTextColorChanged) Q_PROPERTY(QColor accentColor READ accentColor NOTIFY accentColorChanged) Q_PROPERTY(bool serverHasUserStatus READ serverHasUserStatus CONSTANT) + Q_PROPERTY(UserStatus::OnlineStatus status READ status NOTIFY statusChanged) Q_PROPERTY(QUrl statusIcon READ statusIcon NOTIFY statusChanged) Q_PROPERTY(QString statusEmoji READ statusEmoji NOTIFY statusChanged) Q_PROPERTY(QString statusMessage READ statusMessage NOTIFY statusChanged) @@ -238,6 +239,7 @@ public: NameRole = Qt::UserRole + 1, ServerRole, ServerHasUserStatusRole, + StatusRole, StatusIconRole, StatusEmojiRole, StatusMessageRole,