diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index 4e23266cdd..62b8ad7779 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -560,6 +560,18 @@ QtObject: selectedChannel.muted = false self.status.chat.unmuteChat(selectedChannel) self.chats.updateChat(selectedChannel) + + proc muteCurrentChannel*(self: ChatsView) {.slot.} = + self.activeChannel.mute() + let channel = self.chats.getChannelById(self.activeChannel.id()) + channel.muted = true + self.chats.updateChat(channel) + + proc unmuteCurrentChannel*(self: ChatsView) {.slot.} = + self.activeChannel.unmute() + let channel = self.chats.getChannelById(self.activeChannel.id()) + channel.muted = false + self.chats.updateChat(channel) proc channelIsMuted*(self: ChatsView, channelIndex: int): bool {.slot.} = if (self.chats.chats.len == 0): return false diff --git a/src/app/chat/views/chat_item.nim b/src/app/chat/views/chat_item.nim index 2c5f8415a4..80d17ad395 100644 --- a/src/app/chat/views/chat_item.nim +++ b/src/app/chat/views/chat_item.nim @@ -125,6 +125,15 @@ QtObject: read = isMember notify = membershipChanged + proc mutedChanged*(self: ChatItemView) {.signal.} + + proc muted*(self: ChatItemView): bool {.slot.} = + return ?.self.chatItem.muted + + QtProperty[bool] muted: + read = muted + notify = mutedChanged + proc contains*(self: ChatItemView, pubKey: string): bool {.slot.} = if self.chatItem.isNil: return false return self.chatItem.contains(pubKey) @@ -132,3 +141,13 @@ QtObject: proc isAdmin*(self: ChatItemView, pubKey: string): bool {.slot.} = if self.chatItem.isNil: return false return self.chatItem.isAdmin(pubKey) + + proc mute*(self: ChatItemView) {.slot.} = + self.status.chat.muteChat(self.chatItem) + self.chatItem.muted = true + self.mutedChanged() + + proc unmute*(self: ChatItemView) {.slot.} = + self.status.chat.unmuteChat(self.chatItem) + self.chatItem.muted = false + self.mutedChanged() diff --git a/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml b/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml index 09078cf2a1..1ddb34f0f1 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/TopBar.qml @@ -32,6 +32,7 @@ Rectangle { chatName: chatsModel.activeChannel.name chatType: chatsModel.activeChannel.chatType identicon: chatsModel.activeChannel.identicon + muted: chatsModel.activeChannel.muted identiconSize: 36 onClicked: { @@ -55,6 +56,7 @@ Rectangle { chatName: chatsModel.activeChannel.name chatType: chatsModel.activeChannel.chatType identicon: chatsModel.activeChannel.identicon + muted: chatsModel.activeChannel.muted } } diff --git a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml index 5b5d940372..2025c6caf7 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml @@ -83,6 +83,7 @@ Rectangle { anchors.right: contactTime.left anchors.rightMargin: Style.current.smallPadding elide: Text.ElideRight + color: muted ? Style.current.secondaryText : Style.current.textColor font.weight: Font.Medium font.pixelSize: 15 anchors.left: channelIcon.visible ? channelIcon.right : contactImage.right diff --git a/ui/app/img/bell-disabled.svg b/ui/app/img/bell-disabled.svg new file mode 100644 index 0000000000..49bf44ffb5 --- /dev/null +++ b/ui/app/img/bell-disabled.svg @@ -0,0 +1,4 @@ + + + + diff --git a/ui/shared/status/StatusChatInfo.qml b/ui/shared/status/StatusChatInfo.qml index 9bde2a250d..c0abb7f67f 100644 --- a/ui/shared/status/StatusChatInfo.qml +++ b/ui/shared/status/StatusChatInfo.qml @@ -1,5 +1,6 @@ import QtQuick 2.13 import QtQuick.Controls 2.13 +import QtGraphicalEffects 1.13 import "../../imports" import "../../shared" import "../../shared/status" @@ -13,6 +14,7 @@ Item { property string identicon property int identiconSize: 40 property bool isCompact: false + property bool muted: false property string profileImage: chatType === Constants.chatTypeOneToOne ? appMain.getProfileImage(chatId) || "" : "" @@ -61,6 +63,35 @@ Item { font.pixelSize: 15 } + SVGImage { + property bool hovered: false + + id: bellImg + visible: root.muted + source: "../../app/img/bell-disabled.svg" + anchors.verticalCenter: chatName.verticalCenter + anchors.left: chatName.right + anchors.leftMargin: 4 + width: 12.5 + height: 12.5 + + ColorOverlay { + anchors.fill: parent + source: parent + color: bellImg.hovered ? Style.current.textColor : Style.current.darkGrey + } + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + onEntered: bellImg.hovered = true + onExited: bellImg.hovered = false + onClicked: { + chatsModel.unmuteCurrentChannel() + } + } + } Connections { target: profileModel.contacts diff --git a/ui/shared/status/StatusChatInfoButton.qml b/ui/shared/status/StatusChatInfoButton.qml index 7122d53325..e39f505982 100644 --- a/ui/shared/status/StatusChatInfoButton.qml +++ b/ui/shared/status/StatusChatInfoButton.qml @@ -13,6 +13,7 @@ Button { property string identicon property int identiconSize: 40 property bool isCompact: false + property bool muted: false implicitHeight: 48 implicitWidth: content.width + 8 @@ -24,6 +25,7 @@ Button { chatId: control.chatId chatName: control.chatName chatType: control.chatType + muted: control.muted identicon: { if (control.chatType === Constants.chatTypeOneToOne) { return appMain.getProfileImage(control.chatId) || control.identicon