diff --git a/data/resources/icons/scalable/status/padlock2-symbolic.svg b/data/resources/icons/scalable/status/padlock2-symbolic.svg new file mode 100644 index 000000000..8403823ea --- /dev/null +++ b/data/resources/icons/scalable/status/padlock2-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/data/resources/resources.gresource.xml b/data/resources/resources.gresource.xml index 2f0828c66..76b9cd67d 100644 --- a/data/resources/resources.gresource.xml +++ b/data/resources/resources.gresource.xml @@ -16,6 +16,7 @@ icons/scalable/status/message-read-symbolic.svg icons/scalable/status/message-unread-left-symbolic.svg icons/scalable/status/message-unread-right-symbolic.svg + icons/scalable/status/padlock2-symbolic.svg images/pattern.svg diff --git a/src/ui/session/content/chat_history.rs b/src/ui/session/content/chat_history.rs index cae99edf9..137e3bcf2 100644 --- a/src/ui/session/content/chat_history.rs +++ b/src/ui/session/content/chat_history.rs @@ -29,6 +29,7 @@ mod imp { pub(super) is_auto_scrolling: Cell, pub(super) is_loading_messages: Cell, pub(super) sticky: Cell, + pub(super) is_secret_chat: Cell, #[template_child] pub(super) window_title: TemplateChild, #[template_child] @@ -92,6 +93,9 @@ mod imp { glib::ParamSpecBoolean::builder("sticky") .read_only() .build(), + glib::ParamSpecBoolean::builder("is-secret-chat") + .read_only() + .build(), ] }); PROPERTIES.as_ref() @@ -106,6 +110,7 @@ mod imp { obj.set_chat(chat); } "sticky" => obj.set_sticky(value.get().unwrap()), + "is_secret_chat" => obj.set_is_secret_chat(value.get().unwrap()), _ => unimplemented!(), } } @@ -116,6 +121,7 @@ mod imp { match pspec.name() { "chat" => obj.chat().to_value(), "sticky" => obj.sticky().to_value(), + "is-secret-chat" => obj.is_secret_chat().to_value(), _ => unimplemented!(), } } @@ -311,6 +317,15 @@ impl ChatHistory { let imp = self.imp(); if let Some(chat) = chat { + match chat.chat_type() { + model::ChatType::Secret(_) => { + self.set_is_secret_chat(true); + } + _ => { + self.set_is_secret_chat(false); + } + } + self.action_set_enabled( "chat-history.leave-chat", match chat.chat_type() { @@ -412,6 +427,19 @@ impl ChatHistory { self.notify("sticky"); } + pub(crate) fn is_secret_chat(&self) -> bool { + self.imp().is_secret_chat.get() + } + + fn set_is_secret_chat(&self, is_secret_chat: bool) { + if self.is_secret_chat() == is_secret_chat { + return; + } + + self.imp().is_secret_chat.set(is_secret_chat); + self.notify("is-secret-chat"); + } + fn scroll_down(&self) { let imp = self.imp(); diff --git a/src/ui/session/content/chat_history.ui b/src/ui/session/content/chat_history.ui index 34d78ac31..909d47750 100644 --- a/src/ui/session/content/chat_history.ui +++ b/src/ui/session/content/chat_history.ui @@ -9,7 +9,18 @@ - + + + + + padlock2-symbolic + + + + + + diff --git a/src/ui/session/sidebar/row.blp b/src/ui/session/sidebar/row.blp index 3cfbab870..7cd39c6a0 100644 --- a/src/ui/session/sidebar/row.blp +++ b/src/ui/session/sidebar/row.blp @@ -28,6 +28,8 @@ template $PaplSidebarRow { Box { spacing: 6; + Image secret_chat_icon {} + Inscription title_label { hexpand: true; text-overflow: ellipsize_end; diff --git a/src/ui/session/sidebar/row.rs b/src/ui/session/sidebar/row.rs index f6ca2beaf..6db9f1ea0 100644 --- a/src/ui/session/sidebar/row.rs +++ b/src/ui/session/sidebar/row.rs @@ -27,6 +27,8 @@ mod imp { pub(super) chat_signal_group: OnceCell, pub(super) session_signal_group: OnceCell, #[template_child] + pub(super) secret_chat_icon: TemplateChild, + #[template_child] pub(super) title_label: TemplateChild, #[template_child] pub(super) message_status_icon: TemplateChild, @@ -368,6 +370,7 @@ impl Row { self.update_status_stack(); self.update_unread_count_style(); self.update_actions(); + self.update_secret_chat_style(); self.notify("item"); } @@ -580,6 +583,26 @@ impl Row { } } + fn update_secret_chat_style(&self) { + if let Some(item) = self.item() { + let imp = self.imp(); + let chat = item.chat_(); + let icon = &imp.secret_chat_icon; + match chat.chat_type() { + model::ChatType::Secret(_) => { + icon.set_icon_name(Some("padlock2-symbolic")); + icon.set_css_classes(&["accent"]); + icon.set_visible(true); + let title_label = &imp.title_label; + title_label.set_css_classes(&["accent"]); + } + _ => { + icon.set_visible(false); + } + } + } + } + fn update_archive_actions(&self, archive: bool, unarchive: bool) { self.action_set_enabled("sidebar-row.archive", archive); self.action_set_enabled("sidebar-row.unarchive", unarchive);