Added an actions button inside all displayed posts which is able to translate and check spelling on posts' messages

This commit is contained in:
Manuel Cortez 2021-04-21 08:57:47 -05:00
parent 1d9e6f8074
commit e23c6645f6
4 changed files with 17 additions and 7 deletions

View File

@ -4,6 +4,7 @@
### new additions
* Added an actions button that allows you to perform several tasks from the parts of the application where it appears. For now, the action button is shown in any displayed post or repost, and also in chat messages. When pressed, it opens a menu from where you can translate texts or do spelling correction on the message.
* It is now possible to read an article from a wall post. The article will be opened in a new dialog. This might work better in countries where VK is blocked as users no longer need to open the web browser. Unfortunately, as articles are mainly undocumented in the API, it is not possible to perform other actions besides reading them from Socializer.
* the spelling correction module is able to add words to the dictionary so it will learn which words should start to ignore.
* Added a new setting, in the preferences dialog, that allows you to turn on the debug logging feature. With this feature Enabled, Socializer will log more information regarding what is doing while an error occurs. This feature must be enabled when you want to report an issue and send us your logs.

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import six
import widgetUtils
import wx
from extra import translator
from pubsub import pub
from wxUI import menus
from wxUI import commonMessages
@ -119,9 +119,9 @@ class displayPostInteractor(base.baseInteractor):
def on_show_tools_menu(self, *args, **kwargs):
menu = menus.toolsMenu()
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_open_url, menuitem=menu.url)
# widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_open_url, menuitem=menu.url)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_translate, menuitem=menu.translate)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_spellcheck, menuitem=menu.CheckSpelling)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_spellcheck, menuitem=menu.spellcheck)
self.view.PopupMenu(menu, self.view.tools.GetPosition())
def on_open_url(self, *args, **kwargs):
@ -135,8 +135,11 @@ class displayPostInteractor(base.baseInteractor):
dlg = translator.gui.translateDialog()
if dlg.get_response() == widgetUtils.OK:
text_to_translate = self.view.get("post_view")
dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
self.presenter.translate(text_to_translate, dest)
language_dict = translator.translator.available_languages()
for k in language_dict:
if language_dict[k] == dlg.dest_lang.GetStringSelection():
dst = k
self.presenter.translate(text_to_translate, dst)
dlg.Destroy()
def on_spellcheck(self, event=None):

View File

@ -309,7 +309,7 @@ class displayPostPresenter(base.basePresenter):
output.speak(_("Translated"))
def spellcheck(self, text):
checker = SpellChecker.spellchecker.spellChecker(text, "")
checker = SpellChecker.spellchecker.spellChecker(text)
if hasattr(checker, "fixed_text"):
self.send_message("set", control="post_view", value=checker.fixed_text)
self.send_message("focus_control", control="post_view")

View File

@ -106,4 +106,10 @@ class conversationBufferMenu(wx.Menu):
def __init__(self):
super(conversationBufferMenu, self).__init__()
self.delete = self.Append(wx.NewId(), _("Delete conversation"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
class toolsMenu(wx.Menu):
def __init__(self, *args, **kwargs):
super(toolsMenu, self).__init__(*args, **kwargs)
self.translate = self.Append(wx.NewId(), _("&Translate message"))
self.spellcheck = self.Append(wx.NewId(), _("Spelling &correction"))