From 6c43c419feb091b3a09239378a00f422a541ecf4 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 11 Oct 2023 11:44:43 -0600 Subject: [PATCH] Mastodon: Added autocomplete users management in account settings; user autocomplete works already in posts --- src/controller/mastodon/messages.py | 8 ++++++-- src/controller/mastodon/settings.py | 7 ++++--- src/wxUI/dialogs/mastodon/configuration.py | 2 -- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/controller/mastodon/messages.py b/src/controller/mastodon/messages.py index 444391ec..016f7f9f 100644 --- a/src/controller/mastodon/messages.py +++ b/src/controller/mastodon/messages.py @@ -9,6 +9,7 @@ from twitter_text import parse_tweet, config from controller import messages from sessions.mastodon import templates from wxUI.dialogs.mastodon import postDialogs +from extra.autocompletionUsers import completion def character_count(post_text, post_cw, character_limit=500): # We will use text for counting character limit only. @@ -38,14 +39,17 @@ class post(messages.basicMessage): widgetUtils.connect_event(self.message.translate, widgetUtils.BUTTON_PRESSED, self.translate) widgetUtils.connect_event(self.message.add, widgetUtils.BUTTON_PRESSED, self.on_attach) widgetUtils.connect_event(self.message.remove_attachment, widgetUtils.BUTTON_PRESSED, self.remove_attachment) - # ToDo: Add autocomplete feature to mastodon and uncomment this. - # widgetUtils.connect_event(self.message.autocomplete_users, widgetUtils.BUTTON_PRESSED, self.autocomplete_users) + widgetUtils.connect_event(self.message.autocomplete_users, widgetUtils.BUTTON_PRESSED, self.autocomplete_users) widgetUtils.connect_event(self.message.add_post, widgetUtils.BUTTON_PRESSED, self.add_post) widgetUtils.connect_event(self.message.remove_post, widgetUtils.BUTTON_PRESSED, self.remove_post) self.attachments = [] self.thread = [] self.text_processor() + def autocomplete_users(self, *args, **kwargs): + c = completion.autocompletionUsers(self.message, self.session.session_id) + c.show_menu() + def add_post(self, event, update_gui=True, *args, **kwargs): text = self.message.text.GetValue() attachments = self.attachments[::] diff --git a/src/controller/mastodon/settings.py b/src/controller/mastodon/settings.py index a9d06764..be615baa 100644 --- a/src/controller/mastodon/settings.py +++ b/src/controller/mastodon/settings.py @@ -9,7 +9,8 @@ import output from collections import OrderedDict from wxUI import commonMessageDialogs from wxUI.dialogs.mastodon import configuration -#from extra.autocompletionUsers import scan, manage +from extra.autocompletionUsers import manage +from extra.autocompletionUsers.mastodon import scan from extra.ocr import OCRSpace from controller.settings import globalSettingsController from . templateEditor import EditTemplate @@ -29,8 +30,8 @@ class accountSettingsController(globalSettingsController): def create_config(self): self.dialog.create_general_account() -# widgetUtils.connect_event(self.dialog.general.userAutocompletionScan, widgetUtils.BUTTON_PRESSED, self.on_autocompletion_scan) -# widgetUtils.connect_event(self.dialog.general.userAutocompletionManage, widgetUtils.BUTTON_PRESSED, self.on_autocompletion_manage) + widgetUtils.connect_event(self.dialog.general.userAutocompletionScan, widgetUtils.BUTTON_PRESSED, self.on_autocompletion_scan) + widgetUtils.connect_event(self.dialog.general.userAutocompletionManage, widgetUtils.BUTTON_PRESSED, self.on_autocompletion_manage) self.dialog.set_value("general", "disable_streaming", self.config["general"]["disable_streaming"]) self.dialog.set_value("general", "relative_time", self.config["general"]["relative_times"]) self.dialog.set_value("general", "read_preferences_from_instance", self.config["general"]["read_preferences_from_instance"]) diff --git a/src/wxUI/dialogs/mastodon/configuration.py b/src/wxUI/dialogs/mastodon/configuration.py index 4737f7e0..187c74bc 100644 --- a/src/wxUI/dialogs/mastodon/configuration.py +++ b/src/wxUI/dialogs/mastodon/configuration.py @@ -13,9 +13,7 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog): sizer = wx.BoxSizer(wx.VERTICAL) userAutocompletionBox = wx.StaticBox(self, label=_("User autocompletion settings")) self.userAutocompletionScan = wx.Button(self, wx.ID_ANY, _("Scan account and add followers and following users to the user autocompletion database")) - self.userAutocompletionScan.Enable(False) self.userAutocompletionManage = wx.Button(self, wx.ID_ANY, _("Manage autocompletion database")) - self.userAutocompletionManage.Enable(False) autocompletionSizer = wx.StaticBoxSizer(userAutocompletionBox, wx.HORIZONTAL) autocompletionSizer.Add(self.userAutocompletionScan, 0, wx.ALL, 5) autocompletionSizer.Add(self.userAutocompletionManage, 0, wx.ALL, 5)