This commit is contained in:
Jesús Pavón Abián
2026-02-02 09:37:54 +01:00
parent a72505e63b
commit afa12c89ec
3 changed files with 35 additions and 3 deletions

View File

@@ -5,7 +5,8 @@
"Bash(dir:*)", "Bash(dir:*)",
"Bash(findstr:*)", "Bash(findstr:*)",
"Bash(find:*)", "Bash(find:*)",
"Bash(python:*)" "Bash(python:*)",
"Bash(git checkout:*)"
] ]
} }
} }

View File

@@ -9,6 +9,7 @@ import output
import widgetUtils import widgetUtils
from controller import messages as base_messages from controller import messages as base_messages
from wxUI.dialogs.blueski import postDialogs from wxUI.dialogs.blueski import postDialogs
from extra.autocompletionUsers import completion
# Translation function is provided globally by TWBlue's language handler (_) # Translation function is provided globally by TWBlue's language handler (_)
@@ -99,6 +100,9 @@ logger.info("Blueski messages module loaded (placeholders).")
class post(base_messages.basicMessage): class post(base_messages.basicMessage):
# Bluesky character limit
MAX_CHARS = 300
def __init__(self, session: Any, title: str, caption: str, text: str = "", *args, **kwargs): def __init__(self, session: Any, title: str, caption: str, text: str = "", *args, **kwargs):
self.session = session self.session = session
self.title = title self.title = title
@@ -108,12 +112,29 @@ class post(base_messages.basicMessage):
self.message.text.SetInsertionPoint(len(self.message.text.GetValue())) self.message.text.SetInsertionPoint(len(self.message.text.GetValue()))
except Exception: except Exception:
pass pass
# Connect events for text processing and buttons
widgetUtils.connect_event(self.message.text, widgetUtils.ENTERED_TEXT, self.text_processor)
widgetUtils.connect_event(self.message.spoiler, widgetUtils.ENTERED_TEXT, self.text_processor)
widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck)
widgetUtils.connect_event(self.message.translate, widgetUtils.BUTTON_PRESSED, self.translate)
widgetUtils.connect_event(self.message.autocomplete_users, widgetUtils.BUTTON_PRESSED, self.autocomplete_users)
# Initial text processing to show character count
self.text_processor()
def get_data(self): def get_data(self):
return self.message.get_payload() return self.message.get_payload()
def text_processor(self): def text_processor(self, *args, **kwargs):
pass text = self.message.text.GetValue()
cw = self.message.spoiler.GetValue() if self.message.spoiler.IsEnabled() else ""
char_count = len(text) + len(cw)
self.message.SetTitle(_("%s - %s of %d characters") % (self.title, char_count, self.MAX_CHARS))
if char_count > self.MAX_CHARS:
self.session.sound.play("max_length.ogg")
def autocomplete_users(self, *args, **kwargs):
c = completion.autocompletionUsers(self.message, self.session.session_id)
c.show_menu()
def _g(obj: Any, key: str, default: Any = None) -> Any: def _g(obj: Any, key: str, default: Any = None) -> Any:

View File

@@ -49,6 +49,16 @@ class Post(wx.Dialog):
lang_row.Add(self.lang_choice, 0, wx.ALIGN_CENTER_VERTICAL) lang_row.Add(self.lang_choice, 0, wx.ALIGN_CENTER_VERTICAL)
main_sizer.Add(lang_row, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 6) main_sizer.Add(lang_row, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 6)
# Text actions (spellcheck, translate, autocomplete)
text_actions_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.autocomplete_users = wx.Button(self, wx.ID_ANY, _("Auto&complete users"))
text_actions_sizer.Add(self.autocomplete_users, 0, wx.ALL, 2)
self.spellcheck = wx.Button(self, wx.ID_ANY, _("Check &spelling"))
text_actions_sizer.Add(self.spellcheck, 0, wx.ALL, 2)
self.translate = wx.Button(self, wx.ID_ANY, _("&Translate"))
text_actions_sizer.Add(self.translate, 0, wx.ALL, 2)
main_sizer.Add(text_actions_sizer, 0, wx.LEFT | wx.RIGHT | wx.BOTTOM, 6)
# Buttons # Buttons
btn_sizer = wx.StdDialogButtonSizer() btn_sizer = wx.StdDialogButtonSizer()
self.send = wx.Button(self, wx.ID_OK, _("Send")) self.send = wx.Button(self, wx.ID_OK, _("Send"))