From 63def5530fd76272cf266d740dc2d73d08bb42f5 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 11 Oct 2019 13:19:53 -0500 Subject: [PATCH] Added 'manage accounts' option in the application menu --- changelog.md | 3 ++- src/controller/mainController.py | 11 ++++++++++- src/sessionmanager/sessionManager.py | 12 +++++++++--- src/sessionmanager/wxUI.py | 17 ++++++++++++----- src/wxUI/mainWindow.py | 1 + 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 5ffd8f0..2042270 100644 --- a/changelog.md +++ b/changelog.md @@ -5,12 +5,13 @@ ### New additions * Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later. +* Switching accounts is now supported in socializer. In the application menu, there is an option called "manage accounts" which allows you to add or remove an account. Socializer will take changes after a restart of the application. In case of having multiple accounts, every time Socializer starts, you will see a dialog from where is possible to choose the account for logging in. * when selecting multiple audio files in audio buffers, multiple actions can be performed in all items, these actions are present in the contextual menu of the buffer (namely play, add/remove from the library and move to a different playlist). This means you can select all the audios you want and Socializer will perform the selected options in all items, making it a bit easier to operate with multiple songs. * Now it is possible to like and see who liked a comment when displaying it individually. This applies to comments in wall posts and topics. * Now it is possible to choose how many items Socializer will load in conversation buffers, from the General tab in the preferences dialog. The default value is 50 items, and the maximum value is 200. * There is a new tab called buffer settings, in the preferences dialog. Settings related to how many items should be loaded in certain buffer types have been moved to this tab, so it will separate better the configuration options in the application. * Added management of the Blacklist on VK. Users can be blocked from people buffers (friends, online, or any buffer inside friend requests). You can access the blacklist from the application menu, located in the menu bar. From there, you can unblock any previously blocked user. -* In the new timeline dialog, it is possible to create video buffers. +* In the new timeline dialog, it is possible to create video buffers by selecting the "video" radio button as buffer type. ### bugfixes diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 7072046..aa2bb42 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -22,7 +22,7 @@ from mysc import restart from mysc.repeating_timer import RepeatingTimer from mysc.thread_utils import call_threaded from mysc import localization -from sessionmanager import session, utils, renderers +from sessionmanager import session, utils, renderers, sessionManager from wxUI import (mainWindow, commonMessages, menus) from wxUI.dialogs import search as searchDialogs from wxUI.dialogs import creation, timeline @@ -629,6 +629,7 @@ class Controller(object): widgetUtils.connect_event(self.window, widgetUtils.MENU, self.open_logs, menuitem=self.window.open_logs) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.open_config, menuitem=self.window.open_config) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.blacklist, menuitem=self.window.blacklist) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.manage_accounts, menuitem=self.window.accounts) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.configuration, menuitem=self.window.settings_dialog) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_audio_album, menuitem=self.window.audio_album) @@ -737,6 +738,14 @@ class Controller(object): """ Opens the blacklist presenter.""" presenter = presenters.blacklistPresenter(session=self.session, view=views.blacklistDialog(), interactor=interactors.blacklistInteractor()) + def manage_accounts(self, *args, **kwargs): + accounts = sessionManager.sessionManagerController(starting=False) + accounts.view.get_response() + if hasattr(accounts, "modified"): + restart_msg = commonMessages.restart_program() + if restart_msg == widgetUtils.YES: + restart.restart_program() + def open_logs(self, *args, **kwargs): subprocess.call(["explorer", paths.logs_path()]) diff --git a/src/sessionmanager/sessionManager.py b/src/sessionmanager/sessionManager.py index 3a54367..78d4875 100644 --- a/src/sessionmanager/sessionManager.py +++ b/src/sessionmanager/sessionManager.py @@ -14,10 +14,14 @@ from .config_utils import Configuration log = logging.getLogger("sessionmanager.sessionManager") class sessionManagerController(object): - def __init__(self): + def __init__(self, starting=True): super(sessionManagerController, self).__init__() log.debug("Setting up the session manager.") - self.view = view.sessionManagerWindow() + if starting: + title=_("Select an account") + else: + title = _("Manage accounts") + self.view = view.sessionManagerWindow(starting=starting, title=title) widgetUtils.connect_event(self.view.new, widgetUtils.BUTTON_PRESSED, self.manage_new_account) widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.remove) self.fill_list() @@ -50,6 +54,7 @@ class sessionManagerController(object): name = s.settings["vk"]["user"] self.sessions.append((location, name)) self.view.list.insert_item(False, *[name]) + self.modified = True def get_authorisation(self, c): log.debug("Starting the authorisation process...") @@ -87,4 +92,5 @@ class sessionManagerController(object): selected_session = self.sessions[self.view.list.get_selected()] shutil.rmtree(path=os.path.join(paths.config_path(), selected_session[0]), ignore_errors=True) self.sessions.remove(selected_session) - self.view.list.remove_item(self.view.list.get_selected()) \ No newline at end of file + self.view.list.remove_item(self.view.list.get_selected()) + self.modified = True \ No newline at end of file diff --git a/src/sessionmanager/wxUI.py b/src/sessionmanager/wxUI.py index a6e1016..98ed8be 100644 --- a/src/sessionmanager/wxUI.py +++ b/src/sessionmanager/wxUI.py @@ -39,8 +39,8 @@ class newSessionDialog(widgetUtils.BaseDialog): return self.passw.GetValue() class sessionManagerWindow(widgetUtils.BaseDialog): - def __init__(self): - super(sessionManagerWindow, self).__init__(parent=None, title=_("Select an account"), size=wx.DefaultSize) + def __init__(self, title, starting=True): + super(sessionManagerWindow, self).__init__(parent=None, title=title, size=wx.DefaultSize) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) label = wx.StaticText(panel, -1, _(u"Accounts list"), size=wx.DefaultSize) @@ -51,13 +51,20 @@ class sessionManagerWindow(widgetUtils.BaseDialog): sizer.Add(listSizer, 0, wx.ALL, 5) self.new = wx.Button(panel, -1, _("New account"), size=wx.DefaultSize) self.remove = wx.Button(panel, -1, _(u"Remove account")) - ok = wx.Button(panel, wx.ID_OK, size=wx.DefaultSize) + if starting: + id_ok = wx.ID_OK + else: + id_ok = wx.ID_CANCEL + ok = wx.Button(panel, id_ok, size=wx.DefaultSize) ok.SetDefault() - cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize) + if starting: + cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize) + self.SetAffirmativeId(id_ok) buttons = wx.BoxSizer(wx.HORIZONTAL) buttons.Add(self.new, 0, wx.ALL, 5) buttons.Add(ok, 0, wx.ALL, 5) - buttons.Add(cancel, 0, wx.ALL, 5) + if starting: + buttons.Add(cancel, 0, wx.ALL, 5) sizer.Add(buttons, 0, wx.ALL, 5) panel.SetSizer(sizer) min = sizer.CalcMin() diff --git a/src/wxUI/mainWindow.py b/src/wxUI/mainWindow.py index fd8bfe4..3c049ce 100644 --- a/src/wxUI/mainWindow.py +++ b/src/wxUI/mainWindow.py @@ -16,6 +16,7 @@ class mainWindow(wx.Frame): self.delete_video_album = delete.Append(wx.NewId(), _("Video album")) app_.Append(wx.NewId(), _("Delete"), delete) self.blacklist = app_.Append(wx.NewId(), _("Blacklist")) + self.accounts = app_.Append(wx.NewId(), _("Manage accounts")) self.settings_dialog = app_.Append(wx.NewId(), _("Preferences")) me = wx.Menu() profile = wx.Menu()