diff --git a/changelog.md b/changelog.md index d224f10..4b9a7f6 100644 --- a/changelog.md +++ b/changelog.md @@ -22,6 +22,7 @@ * Now it is possible to create and delete audio albums again. * Fixed errors when moving songs to albums. Now everything works as expected. * Added documents to the list of supported files when adding attachments to a wall post or private message. +* It is possible to enable or disable proxy from the preferences dialog. The application must be restarted for this change to take effect. ## Changes in version 0.18 (21.01.2019) diff --git a/src/interactors/configuration.py b/src/interactors/configuration.py index ddc6f1b..ab64287 100644 --- a/src/interactors/configuration.py +++ b/src/interactors/configuration.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import widgetUtils from pubsub import pub +from wxUI.commonMessages import restart_program as restart_program_dialog from . import base class configurationInteractor(base.baseInteractor): @@ -12,15 +13,22 @@ class configurationInteractor(base.baseInteractor): def set_setting(self, tab, setting, value): self.view.set_value(tab, setting, value) + def restart(self): + dlg = restart_program_dialog() + if dlg == widgetUtils.YES: + self.presenter.restart_application() + def install(self, *args, **kwargs): super(configurationInteractor, self).install(*args, **kwargs) pub.subscribe(self.create_tab, self.modulename+"_create_tab") pub.subscribe(self.set_setting, self.modulename+"_set") + pub.subscribe(self.restart, self.modulename+"_restart_program") def uninstall(self): super(configurationInteractor, self).uninstall() pub.unsubscribe(self.create_tab, self.modulename+"_create_tab") pub.unsubscribe(self.set_setting, self.modulename+"_set") + pub.unsubscribe(self.restart, self.modulename+"_restart_program") def start(self): self.view.realize() @@ -52,4 +60,5 @@ class configurationInteractor(base.baseInteractor): self.presenter.update_setting(section="load_at_startup", setting="audio_albums", value=self.view.get_value("startup", "audio_albums")) self.presenter.update_setting(section="load_at_startup", setting="video_albums", value=self.view.get_value("startup", "video_albums")) self.presenter.update_setting(section="load_at_startup", setting="communities", value=self.view.get_value("startup", "communities")) - self.presenter.save_settings_file() \ No newline at end of file + self.presenter.save_settings_file() + self.presenter.update_proxy(self.view.get_value("general", "use_proxy")) \ No newline at end of file diff --git a/src/presenters/configuration.py b/src/presenters/configuration.py index 7c6a9a6..f57aeec 100644 --- a/src/presenters/configuration.py +++ b/src/presenters/configuration.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +import config +from mysc import restart from . import base class configurationPresenter(base.basePresenter): @@ -43,6 +45,7 @@ class configurationPresenter(base.basePresenter): self.send_message("set", tab="general", setting="wall_buffer_count", value=self.session.settings["buffers"]["count_for_wall_buffers"]) self.send_message("set", tab="general", setting="video_buffers_count", value=self.session.settings["buffers"]["count_for_video_buffers"]) self.send_message("set", tab="general", setting="load_images", value=self.session.settings["general"]["load_images"]) + self.send_message("set", tab="general", setting="use_proxy", value=config.app["app-settings"]["use_proxy"]) self.send_message("set", tab="general", setting="update_channel", value=self.get_update_channel_label(self.session.settings["general"]["update_channel"])) self.send_message("create_tab", tab="chat") self.send_message("set", tab="chat", setting="notify_online", value=self.session.settings["chat"]["notify_online"]) @@ -63,4 +66,13 @@ class configurationPresenter(base.basePresenter): self.session.settings[section][setting] = value def save_settings_file(self): - self.session.settings.write() \ No newline at end of file + self.session.settings.write() + + def update_proxy(self, proxy_value): + if proxy_value != config.app["app-settings"]["use_proxy"]: + config.app["app-settings"]["use_proxy"] = proxy_value + config.app.write() + self.send_message("restart_program") + + def restart_application(self): + restart.restart_program() \ No newline at end of file diff --git a/src/views/dialogs/configuration.py b/src/views/dialogs/configuration.py index 4bd49ef..35a09d1 100644 --- a/src/views/dialogs/configuration.py +++ b/src/views/dialogs/configuration.py @@ -23,6 +23,8 @@ class general(wx.Panel, widgetUtils.BaseDialog): sizer.Add(box3, 0, wx.ALL, 5) self.load_images = wx.CheckBox(self, wx.NewId(), _("Load images in posts")) sizer.Add(self.load_images, 0, wx.ALL, 5) + self.use_proxy = wx.CheckBox(self, wx.NewId(), _("Use proxy")) + sizer.Add(self.use_proxy, 0, wx.ALL, 5) lbl4 = wx.StaticText(self, wx.NewId(), _("Update channel")) self.update_channel = wx.ComboBox(self, wx.NewId(), choices=[_("Stable"), _("Alpha")], value=_("Native"), style=wx.CB_READONLY) box4 = wx.BoxSizer(wx.HORIZONTAL) diff --git a/src/wxUI/commonMessages.py b/src/wxUI/commonMessages.py index f2748a9..ba1ba79 100644 --- a/src/wxUI/commonMessages.py +++ b/src/wxUI/commonMessages.py @@ -54,4 +54,7 @@ def remove_friend(user): return wx.MessageDialog(None, _("Are you sure you want to remove {user1_nom} from your friends?").format(**user), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() def post_deleted(): - return wx.MessageDialog(None, _("This post has been removed."), _("Error"), wx.ICON_ERROR).ShowModal() \ No newline at end of file + return wx.MessageDialog(None, _("This post has been removed."), _("Error"), wx.ICON_ERROR).ShowModal() + +def restart_program(): + return wx.MessageDialog(None, _("In order to apply the changes you requested, you must restart the program. Do you want to restart Socializer now?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() \ No newline at end of file