Skip to content

Commit d757add

Browse files
authored
feat(private_conversation): add menu item and improve title display (#1059)
- Add "New private conversation" menu item (Ctrl+Shift+N) - Add `on_new_private_conversation()` handler for convenient private conversation creation - Display "(private)" label in frame title for private conversations - Refresh frame title when toggling conversation privacy status
1 parent f72761c commit d757add

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

basilisk/gui/main_frame.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ def update_item_label_suffix(item: wx.MenuItem, suffix: str = "..."):
126126
self.Bind(
127127
wx.EVT_MENU, self.on_new_default_conversation, new_conversation_item
128128
)
129+
new_private_conversation_item = conversation_menu.Append(
130+
wx.ID_ANY,
131+
# Translators: A label for a menu item to create a new private conversation
132+
_("New private conversation") + "\tCtrl+Shift+N",
133+
)
134+
self.Bind(
135+
wx.EVT_MENU,
136+
self.on_new_private_conversation,
137+
new_private_conversation_item,
138+
)
129139
self.new_conversation_profile_item: wx.MenuItem = conversation_menu.AppendSubMenu(
130140
self.build_profile_menu(self.on_new_conversation),
131141
# Translators: A label for a menu item to create a new conversation from a profile
@@ -547,6 +557,21 @@ def on_new_default_conversation(self, event: wx.Event | None):
547557
)
548558
self.new_conversation(profile)
549559

560+
def on_new_private_conversation(self, event: wx.Event | None):
561+
"""Create a new private conversation tab with the default profile.
562+
563+
Args:
564+
event: The event that triggered the new private conversation action. Can be None.
565+
"""
566+
self.handle_no_account_configured()
567+
profile = config.conversation_profiles().default_profile
568+
if profile:
569+
log.info(
570+
"Creating a new private conversation with default profile (%s)",
571+
profile.name,
572+
)
573+
self.new_conversation(profile, private=True)
574+
550575
def get_selected_profile_from_menu(
551576
self, event: wx.Event
552577
) -> config.ConversationProfile | None:
@@ -644,18 +669,23 @@ def get_default_conv_title(self) -> str:
644669
# Translators: A default title for a conversation
645670
return _("Conversation %d") % self.last_conversation_id
646671

647-
def new_conversation(self, profile: config.ConversationProfile | None):
672+
def new_conversation(
673+
self, profile: config.ConversationProfile | None, private: bool = False
674+
):
648675
"""Create a new conversation tab with the specified profile.
649676
650677
Creates a new conversation tab in the notebook with a default title and the specified profile.
651678
The tab is automatically added to the notebook and becomes the active tab.
652679
653680
Args:
654681
profile: The conversation profile to use for the new tab. If None, a default profile will be used.
682+
private: If True, mark the conversation as private. Defaults to False.
655683
"""
656684
new_tab = ConversationTab(
657685
self.notebook, title=self.get_default_conv_title(), profile=profile
658686
)
687+
if private:
688+
new_tab.set_private(True)
659689
self.add_conversation_tab(new_tab)
660690

661691
def add_conversation_tab(self, new_tab: ConversationTab):
@@ -759,11 +789,16 @@ def refresh_frame_title(self):
759789
"""Refresh the title of the main application frame based on the current conversation tab.
760790
761791
The frame title is updated to include the title of the currently selected conversation tab.
792+
If the conversation is private, "(private)" is appended to the title.
762793
"""
763794
current_tab = self.current_tab
764795
if not current_tab:
765796
return
766797
tab_title = current_tab.conversation.title or current_tab.title
798+
if current_tab.private:
799+
# Translators: Label appended to window title when conversation is private
800+
private_label = _("private")
801+
tab_title = f"{tab_title} ({private_label})"
767802
self.SetTitle(f"{tab_title} - {APP_NAME}")
768803

769804
def refresh_tabs(self):
@@ -1089,6 +1124,7 @@ def on_toggle_privacy(self, event: wx.Event):
10891124
if not tab:
10901125
return
10911126
tab.set_private(not tab.private)
1127+
self.refresh_frame_title()
10921128

10931129
def on_apply_conversation_profile(self, event: wx.Event):
10941130
"""Apply the selected conversation profile to the current conversation.

0 commit comments

Comments
 (0)