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

View File

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

View File

@ -107,3 +107,9 @@ class conversationBufferMenu(wx.Menu):
super(conversationBufferMenu, self).__init__() super(conversationBufferMenu, self).__init__()
self.delete = self.Append(wx.NewId(), _("Delete conversation")) 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"))