From 46419b0960c48513d04589fccbb5e8aa8ed14b06 Mon Sep 17 00:00:00 2001 From: Peter G Date: Sat, 18 Nov 2023 21:40:12 +0000 Subject: [PATCH] Highlight unread Converstations (#513) * Highlight unread conversations See: #512 * make highlighting configurable * more verbose variable names * remove the rectangle gain, it is too annoying * respect the setting --------- Co-authored-by: nephros --- qml/components/PhotoTextsListItem.qml | 3 +++ qml/components/settingsPage/SettingsBehavior.qml | 12 ++++++++++++ src/appsettings.cpp | 15 +++++++++++++++ src/appsettings.h | 5 +++++ 4 files changed, 35 insertions(+) diff --git a/qml/components/PhotoTextsListItem.qml b/qml/components/PhotoTextsListItem.qml index 5234437..57a1416 100644 --- a/qml/components/PhotoTextsListItem.qml +++ b/qml/components/PhotoTextsListItem.qml @@ -151,6 +151,9 @@ ListItem { truncationMode: TruncationMode.Fade anchors.verticalCenter: parent.verticalCenter width: Math.min(contentColumn.width - (verifiedImage.visible ? (verifiedImage.width + primaryTextRow.spacing) : 0) - (mutedImage.visible ? (mutedImage.width + primaryTextRow.spacing) : 0), implicitWidth) + font.bold: appSettings.highlightUnreadConversations && ( !chatListViewItem.isMuted && (chatListViewItem.unreadCount > 0 || chatListViewItem.isMarkedAsUnread) ) + font.italic: appSettings.highlightUnreadConversations && (chatListViewItem.unreadReactionCount > 0) + color: (appSettings.highlightUnreadConversations && (chatListViewItem.unreadCount > 0)) ? Theme.highlightColor : Theme.primaryColor } Image { diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index f0b2ea2..8ec3aec 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -70,6 +70,18 @@ AccordionItem { } } + TextSwitch { + width: parent.columnWidth + checked: appSettings.highlightUnreadConversations + text: qsTr("Highlight unread messages") + description: qsTr("Highlight Conversations with unread messages") + automaticCheck: false + onClicked: { + appSettings.highlightUnreadConversations = !checked + } + } + + TextSwitch { width: parent.columnWidth checked: appSettings.useOpenWith diff --git a/src/appsettings.cpp b/src/appsettings.cpp index c5af969..d749f93 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -37,6 +37,7 @@ namespace { const QString KEY_DELAY_MESSAGE_READ("delayMessageRead"); const QString KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN("focusTextAreaOnChatOpen"); const QString KEY_SPONSORED_MESS("sponsoredMess"); + const QString KEY_HIGHLIGHT_UNREADCONVS("highlightUnreadConversations"); } AppSettings::AppSettings(QObject *parent) : QObject(parent), settings(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/de.ygriega/fernschreiber/settings.conf", QSettings::NativeFormat) @@ -240,6 +241,20 @@ void AppSettings::setDelayMessageRead(bool enable) } } +bool AppSettings::highlightUnreadConversations() const +{ + return settings.value(KEY_HIGHLIGHT_UNREADCONVS, true).toBool(); +} + +void AppSettings::setHighlightUnreadConversations(bool enable) +{ + if (highlightUnreadConversations() != enable) { + LOG(KEY_HIGHLIGHT_UNREADCONVS << enable); + settings.setValue(KEY_HIGHLIGHT_UNREADCONVS, enable); + emit highlightUnreadConversationsChanged(); + } +} + bool AppSettings::getFocusTextAreaOnChatOpen() const { return settings.value(KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN, false).toBool(); diff --git a/src/appsettings.h b/src/appsettings.h index fbd5709..8071b44 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -40,6 +40,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool delayMessageRead READ delayMessageRead WRITE setDelayMessageRead NOTIFY delayMessageReadChanged) Q_PROPERTY(bool focusTextAreaOnChatOpen READ getFocusTextAreaOnChatOpen WRITE setFocusTextAreaOnChatOpen NOTIFY focusTextAreaOnChatOpenChanged) Q_PROPERTY(SponsoredMess sponsoredMess READ getSponsoredMess WRITE setSponsoredMess NOTIFY sponsoredMessChanged) + Q_PROPERTY(bool highlightUnreadConversations READ highlightUnreadConversations WRITE setHighlightUnreadConversations NOTIFY highlightUnreadConversationsChanged) public: enum SponsoredMess { @@ -107,6 +108,9 @@ public: SponsoredMess getSponsoredMess() const; void setSponsoredMess(SponsoredMess sponsoredMess); + bool highlightUnreadConversations() const; + void setHighlightUnreadConversations(bool enable); + signals: void sendByEnterChanged(); void focusTextAreaAfterSendChanged(); @@ -124,6 +128,7 @@ signals: void delayMessageReadChanged(); void focusTextAreaOnChatOpenChanged(); void sponsoredMessChanged(); + void highlightUnreadConversationsChanged(); private: QSettings settings;