From a01f8091c01889d7ca90938f56ae176a74da5590 Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Wed, 29 Dec 2021 02:32:40 +0100 Subject: Implement notifications + "mute/unmute chat" menu - Added icons: Pinned and muted chats have icons. It's from Twemoji font, I've added credits in the README.md and source code of ChatlistItem.qml. I prefer to rely on .PNG for this one because icon might not be installed or exist on the system, and we avoid the black box problem. - Modified CMakeLists: added KNotifications as a required library - Modified build.sh: I cannot comprehend how the install(FILES) function from cmake works, so I used good old install from GNU coreutils. It copies usr/ structure and needed files (.desktop and .notifyrc) for KNotifications to work. - Aesthetic changes: context menu is shorter now due to the text being state-aware. You can now also mute a chat so you won't be notified on incoming messages. --- qml/ChatlistItem.qml | 55 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'qml/ChatlistItem.qml') diff --git a/qml/ChatlistItem.qml b/qml/ChatlistItem.qml index 6e37331..f0db86d 100644 --- a/qml/ChatlistItem.qml +++ b/qml/ChatlistItem.qml @@ -14,8 +14,10 @@ Kirigami.AbstractListItem { property string avatarSource property string username property int freshMsgCnt + property int visibility property bool isContactRequest property bool isPinned + property bool isMuted RowLayout { Kirigami.Avatar { @@ -34,6 +36,16 @@ Kirigami.AbstractListItem { Menu { id: contextMenu + + Action { + text: !root.isMuted ? "Mute chat" : "Unmute chat" + onTriggered: { + if (!root.isMuted) + root.context.setChatMuteDuration(root.chatId, -1) + else + root.context.setChatMuteDuration(root.chatId, 0) + } + } Action { text: "Block chat" @@ -46,23 +58,13 @@ Kirigami.AbstractListItem { Action { icon.name: "pin" - text: "Pin chat" - onTriggered: root.context.setChatVisibility(root.chatId, 2) - } - - Action { - text: "Unpin chat" - onTriggered: root.context.setChatVisibility(root.chatId, 0) + text: !root.isPinned ? "Pin chat" : "Unpin chat" + onTriggered: !root.isPinned ? root.context.setChatVisibility(root.chatId, 2) : root.context.setChatVisibility(root.chatId, 0) } Action { - text: "Archive chat" - onTriggered: root.context.setChatVisibility(root.chatId, 1) - } - - Action { - text: "Unarchive chat" - onTriggered: root.context.setChatVisibility(root.chatId, 0) + text: root.visibility != 1 ? "Archive chat" : "Unarchive chat" + onTriggered: root.visibility != 1 ? root.context.setChatVisibility(root.chatId, 1) : root.context.setChatVisibility(root.chatId, 0) } Action { @@ -111,13 +113,26 @@ Kirigami.AbstractListItem { } - // Pinned message badge - Label { + // Twemoji + // Copyright 2020 Twitter, Inc and other contributors. + // Muted chat badge + Image { + visible: root.isMuted + source: "qrc:/res/muted_48x48.png" + sourceSize.width: 24 + sourceSize.height: 24 + Layout.bottomMargin: 13 + } + + // Twemoji + // Copyright 2020 Twitter, Inc and other contributors. + // Pinned chat badge + Image { visible: root.isPinned - text: "📌" - font.pixelSize: 20 - rightPadding: 15 - bottomPadding: 15 + source: "qrc:/res/pin_48x48.png" + sourceSize.width: 24 + sourceSize.height: 24 + Layout.bottomMargin: 13 } } -- cgit v1.2.3-70-g09d2