diff --git a/res/ui/preferences.ui b/res/ui/preferences.ui index cd29dddabdc898f26ca91d8e1dff81829b53cd5b..942d581dea141158954286712e06582ced288bd7 100644 --- a/res/ui/preferences.ui +++ b/res/ui/preferences.ui @@ -96,7 +96,7 @@ <item> <widget class="QStackedWidget" name="stackedWidget"> <property name="currentIndex"> - <number>1</number> + <number>0</number> </property> <widget class="QWidget" name="page"> <layout class="QVBoxLayout" name="verticalLayout_7"> @@ -333,51 +333,10 @@ <item> <widget class="QCheckBox" name="checkbox_proxy"> <property name="text"> - <string>Use a proxy server</string> + <string>Use a http proxy server</string> </property> </widget> </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_11"> - <property name="topMargin"> - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Proxy type : </string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="combox_proxytype"> - <item> - <property name="text"> - <string>HTTP</string> - </property> - </item> - <item> - <property name="text"> - <string>SOCKS5</string> - </property> - </item> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_9"> <item> diff --git a/src/cutecoin/core/app.py b/src/cutecoin/core/app.py index 4ae3e38a99bba709e9d0104f09ab7a5a4546856a..fe4c27a98ca0b57ee34f33b48a0d2891c5345c7b 100644 --- a/src/cutecoin/core/app.py +++ b/src/cutecoin/core/app.py @@ -23,6 +23,7 @@ from .registry.identities import IdentitiesRegistry from .. import __version__ from ..tools.exceptions import NameAlreadyExists, BadAccountFile from ..tools.decorators import asyncify +import i18n_rc class Application(QObject): @@ -52,6 +53,7 @@ class Application(QObject): self.available_version = (True, __version__, "") + self._translator = QTranslator(self.qapp) self._identities_registry = identities_registry self.preferences = {'account': "", 'lang': 'en_GB', @@ -74,10 +76,7 @@ class Application(QObject): app = cls(qapp, loop, identities_registry) app.load() app.switch_language() - if app.preferences['enable_proxy'] is True: - API.aiohttp_connector = ProxyConnector("http://{0}:{1}".format( - app.preferences['proxy_address'], - app.preferences['proxy_port'])) + app.set_proxy() if app.preferences["account"] != "": account = app.get_account(app.preferences["account"]) app.change_current_account(account) @@ -96,16 +95,28 @@ class Application(QObject): return app + def set_proxy(self): + if self.preferences['enable_proxy'] is True: + API.aiohttp_connector = ProxyConnector("http://{0}:{1}".format( + self.preferences['proxy_address'], + self.preferences['proxy_port'])) + else: + API.aiohttp_connector = None + def switch_language(self): - translator = QTranslator(self.qapp) logging.debug("Loading translations") locale = self.preferences['lang'] QLocale.setDefault(QLocale(locale)) - if translator.load(":/i18n/{0}".format(locale)): - if QCoreApplication.installTranslator(translator): - logging.debug("Loaded i18n/{0}".format(locale)) + if locale == "en_GB": + QCoreApplication.removeTranslator(self._translator) else: - logging.debug("Couldn't load translation") + QCoreApplication.removeTranslator(self._translator) + self._translator = QTranslator(self.qapp) + if self._translator.load(":/i18n/{0}".format(locale)): + if QCoreApplication.installTranslator(self._translator): + logging.debug("Loaded i18n/{0}".format(locale)) + else: + logging.debug("Couldn't load translation") def get_account(self, name): """ @@ -310,6 +321,8 @@ class Application(QObject): with open(preferences_path, 'w') as outfile: json.dump(preferences, outfile, indent=4) + self.set_proxy() + def save(self, account): """ Save an account diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py index f7bfeb96855d6716e554dc6d5e1f0ceceb06d781..f9d7dc6ec0731f92e6cfe2a8bf13dcb3e164c8a0 100644 --- a/src/cutecoin/core/net/network.py +++ b/src/cutecoin/core/net/network.py @@ -328,12 +328,12 @@ class Network(QObject): node = self.sender() if node.state in (Node.ONLINE, Node.DESYNCED): self.check_nodes_sync() - self.nodes_changed.emit() else: if node.last_change + 3600 < time.time(): node.disconnect() self.nodes.remove(node) - self.nodes_changed.emit() + + self.nodes_changed.emit() logging.debug("{0} -> {1}".format(self._block_found[:10], self.latest_block_hash[:10])) if self._block_found != self.latest_block_hash and node.state == Node.ONLINE: diff --git a/src/cutecoin/gui/preferences.py b/src/cutecoin/gui/preferences.py index 919d50de092ee9435132737ead8351d74ac8eba7..32d541e465a5d2df7afdad0892ca50c76a11b625 100644 --- a/src/cutecoin/gui/preferences.py +++ b/src/cutecoin/gui/preferences.py @@ -80,8 +80,6 @@ class PreferencesDialog(QDialog, Ui_PreferencesDialog): self.app.save_preferences(pref) # change UI translation self.app.switch_language() - toast.display(self.tr("Preferences"), - self.tr("A restart is needed to apply your new preferences.")) super().accept() def reject(self):