Skip to content

Commit

Permalink
feat(cconversation_profile): adding menu item to select a conversatio…
Browse files Browse the repository at this point in the history
…n profile for new conversation tab
  • Loading branch information
clementb49 committed Aug 10, 2024
1 parent 4425662 commit d2048f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions basilisk/conversation_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def serialize_profiles(

_profiles_name: set[str] = PrivateAttr(default_factory=set)

@property
def profiles_name(self) -> set[str]:
return self._profiles_name

@property
def default_profile(self) -> ConversationProfile:
return self[self.default_profile_name]
Expand Down
23 changes: 21 additions & 2 deletions basilisk/gui/main_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def update_item_label_suffix(item: wx.MenuItem, suffix: str = "..."):
_("New conversation") + " (Ctrl+N)",
)
self.Bind(wx.EVT_MENU, self.on_new_conversation, new_conversation_item)

self.new_conversation_profile_item: wx.MenuItem = conversation_menu.AppendSubMenu(
self.build_profile_menu(self.on_new_conversation),
# Translators: A label for a menu item to create a new conversation from a profile
_("New conversation from profile"),
)
open_conversation_item = conversation_menu.Append(
wx.ID_ANY,
# Translators: A label for a menu item to open a conversation
Expand Down Expand Up @@ -182,7 +188,6 @@ def update_item_label_suffix(item: wx.MenuItem, suffix: str = "..."):
menu_bar.Append(tool_menu, _("Too&ls"))
menu_bar.Append(help_menu, _("&Help"))
self.SetMenuBar(menu_bar)

sizer = wx.BoxSizer(wx.VERTICAL)
self.panel = wx.Panel(self)
minimize_taskbar = wx.Button(
Expand Down Expand Up @@ -472,7 +477,9 @@ def on_manage_conversation_profiles(self, event):
self, _("Manage conversation profiles")
)
if profile_dialog.ShowModal() == wx.ID_OK:
self.refresh_tabs()
self.new_conversation_profile_item.SetSubMenu(
self.build_profile_menu(self.on_new_conversation)
)

def on_install_nvda_addon(self, event):
import zipfile
Expand Down Expand Up @@ -567,3 +574,15 @@ def show_dialog():
log.debug(f"Download dialog shown: {download_dialog.IsShown()}")

wx.CallAfter(show_dialog)

def build_profile_menu(self, event_handler) -> wx.Menu:
"""
Build the conversation profile menu.
:return: The conversation profile menu.
"""
profile_menu = wx.Menu()
for profile in config.conf.conversation_profiles:
profile_item = profile_menu.Append(wx.ID_ANY, profile.name)
self.Bind(wx.EVT_MENU, event_handler, profile_item)
return profile_menu

0 comments on commit d2048f6

Please sign in to comment.