diff --git a/res/ui/import_account.ui b/res/ui/import_account.ui deleted file mode 100644 index 6ca68c0155e14ae4587d38bc51a7a9af3e761eb1..0000000000000000000000000000000000000000 --- a/res/ui/import_account.ui +++ /dev/null @@ -1,135 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ImportAccountDialog</class> - <widget class="QDialog" name="ImportAccountDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>124</height> - </rect> - </property> - <property name="windowTitle"> - <string>Import an account</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLineEdit" name="edit_file"/> - </item> - <item> - <widget class="QPushButton" name="button_import"> - <property name="text"> - <string>Import a file</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Name of the account :</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="edit_name"/> - </item> - </layout> - </item> - <item> - <widget class="QLabel" name="label_errors"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="button_box"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>button_box</sender> - <signal>accepted()</signal> - <receiver>ImportAccountDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>button_box</sender> - <signal>rejected()</signal> - <receiver>ImportAccountDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>button_import</sender> - <signal>clicked()</signal> - <receiver>ImportAccountDialog</receiver> - <slot>import_account()</slot> - <hints> - <hint type="sourcelabel"> - <x>349</x> - <y>21</y> - </hint> - <hint type="destinationlabel"> - <x>199</x> - <y>51</y> - </hint> - </hints> - </connection> - <connection> - <sender>edit_name</sender> - <signal>textEdited(QString)</signal> - <receiver>ImportAccountDialog</receiver> - <slot>name_changed()</slot> - <hints> - <hint type="sourcelabel"> - <x>259</x> - <y>52</y> - </hint> - <hint type="destinationlabel"> - <x>199</x> - <y>51</y> - </hint> - </hints> - </connection> - </connections> - <slots> - <slot>import_account()</slot> - <slot>name_changed()</slot> - </slots> -</ui> diff --git a/res/ui/tx_lifecycle.png b/res/ui/tx_lifecycle.png deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/sakia/app.py b/src/sakia/app.py index 7adcf4864012d3d7bc33af6e87a9b76b454a8513..eb160b030a71fafe58af5e901018a51433669d7d 100644 --- a/src/sakia/app.py +++ b/src/sakia/app.py @@ -62,6 +62,7 @@ class Application(QObject): transactions_services = attr.ib(default=attr.Factory(dict)) documents_service = attr.ib(default=None) current_ref = attr.ib(default=Relative) + _logger = attr.ib(default=attr.Factory(lambda:logging.getLogger('sakia'))) available_version = attr.ib(init=False) _translator = attr.ib(init=False) @@ -76,7 +77,7 @@ class Application(QObject): app_data = AppDataFile.in_config_path(options.config_path).load_or_init() app = cls(qapp, loop, options, app_data, None, None) #app.set_proxy() - #app.get_last_version() + app.get_last_version() app.load_profile(app_data.default) app.start_coroutines() app.documents_service = DocumentsService.instanciate(app) @@ -164,38 +165,35 @@ class Application(QObject): @asyncify async def get_last_version(self): - if self.preferences['enable_proxy'] is True: - connector = ProxyConnector("http://{0}:{1}".format( - self.preferences['proxy_address'], - self.preferences['proxy_port'])) + if self.parameters.enable_proxy is True: + proxy = "http://{0}:{1}".format(self.parameters.proxy_address, self.parameters.proxy_port) else: - connector = None + proxy = None try: - with aiohttp.Timeout(15): - response = await aiohttp.get("https://api.github.com/repos/duniter/sakia/releases", connector=connector) - if response.status == 200: - releases = await response.json() - latest = None - for r in releases: - if not latest: - latest = r - else: - latest_date = datetime.datetime.strptime(latest['published_at'], "%Y-%m-%dT%H:%M:%SZ") - date = datetime.datetime.strptime(r['published_at'], "%Y-%m-%dT%H:%M:%SZ") - if latest_date < date: + with aiohttp.ClientSession() as session: + with aiohttp.Timeout(15): + response = await session.get("https://api.github.com/repos/duniter/sakia/releases", proxy=proxy) + if response.status == 200: + releases = await response.json() + latest = None + for r in releases: + if not latest: latest = r - latest_version = latest["tag_name"] - version = (__version__ == latest_version, - latest_version, - latest["html_url"]) - logging.debug("Found version : {0}".format(latest_version)) - logging.debug("Current version : {0}".format(__version__)) - self.available_version = version - self.version_requested.emit() + else: + latest_date = datetime.datetime.strptime(latest['published_at'], "%Y-%m-%dT%H:%M:%SZ") + date = datetime.datetime.strptime(r['published_at'], "%Y-%m-%dT%H:%M:%SZ") + if latest_date < date: + latest = r + latest_version = latest["tag_name"] + version = (__version__ == latest_version, + latest_version, + latest["html_url"]) + logging.debug("Found version : {0}".format(latest_version)) + logging.debug("Current version : {0}".format(__version__)) + self.available_version = version + self.version_requested.emit() except (aiohttp.errors.ClientError, aiohttp.errors.TimeoutError) as e: - logging.debug("Could not connect to github : {0}".format(str(e))) - except Exception as e: - pass + self._logger.debug("Could not connect to github : {0}".format(str(e))) def save_parameters(self, parameters): self.parameters = UserParametersFile\ diff --git a/src/sakia/data/entities/user_parameters.py b/src/sakia/data/entities/user_parameters.py index 69157254672487478b138954d14226b5570b6e32..2a270bdec51f7e6dd7979c13a3529ee1b13ef0ae 100644 --- a/src/sakia/data/entities/user_parameters.py +++ b/src/sakia/data/entities/user_parameters.py @@ -13,7 +13,7 @@ class UserParameters: digits_after_comma = attr.ib(convert=int, default=2) maximized = attr.ib(convert=bool, default=False) notifications = attr.ib(convert=bool, default=True) - enable_proxy = attr.ib(convert=bool, default=True) + enable_proxy = attr.ib(convert=bool, default=False) proxy_type = attr.ib(convert=int, default=0) proxy_address = attr.ib(convert=str, default="") proxy_port = attr.ib(convert=int, default=8080) diff --git a/src/sakia/gui/main_window/controller.py b/src/sakia/gui/main_window/controller.py index 872ec7d682985a44766fff2ed9bdb3bbddad7c99..ac1f20d61ab82175a45adf51c02010b3616de05a 100644 --- a/src/sakia/gui/main_window/controller.py +++ b/src/sakia/gui/main_window/controller.py @@ -1,11 +1,4 @@ -""" -Created on 1 févr. 2014 - -@author: inso -""" -import aiohttp import logging -import traceback from PyQt5.QtWidgets import QMessageBox, QApplication from PyQt5.QtCore import QEvent, pyqtSlot, QObject diff --git a/res/ui/about.ui b/src/sakia/gui/main_window/toolbar/about.ui similarity index 100% rename from res/ui/about.ui rename to src/sakia/gui/main_window/toolbar/about.ui diff --git a/src/sakia/gui/main_window/toolbar/controller.py b/src/sakia/gui/main_window/toolbar/controller.py index 79e296cacc87f3bca41c2c89043ebbc1a3e9e63b..96e9d45f80a174a5b3aef718e1e41a6b9b1349ed 100644 --- a/src/sakia/gui/main_window/toolbar/controller.py +++ b/src/sakia/gui/main_window/toolbar/controller.py @@ -33,6 +33,7 @@ class ToolbarController(QObject): self.view.button_membership.clicked.connect(self.send_join_demand) self.view.action_add_connection.triggered.connect(self.open_add_connection_dialog) self.view.action_parameters.triggered.connect(self.open_settings_dialog) + self.view.action_about.triggered.connect(self.open_about_dialog) @classmethod def create(cls, app, navigation): @@ -97,6 +98,10 @@ class ToolbarController(QObject): self.model.app.new_connection.emit(connection_config.model.connection) self.enable_actions(True) + def open_about_dialog(self): + text = self.model.about_text() + self.view.show_about(text) + def retranslateUi(self, widget): """ Method to complete translations missing from generated code diff --git a/src/sakia/gui/main_window/toolbar/model.py b/src/sakia/gui/main_window/toolbar/model.py index 877891cd7dd9ed4814b81a87056e25b3e498221c..a7b32325fbda10afc3b9438849a4256fb36a0ae0 100644 --- a/src/sakia/gui/main_window/toolbar/model.py +++ b/src/sakia/gui/main_window/toolbar/model.py @@ -1,6 +1,7 @@ from PyQt5.QtCore import QObject from sakia.data.processors import ConnectionsProcessor import attr +from sakia import __version__ @attr.s() @@ -25,4 +26,37 @@ class ToolbarModel(QObject): return self.app.parameters.notifications def connections(self): - return ConnectionsProcessor.instanciate(self.app).connections() \ No newline at end of file + return ConnectionsProcessor.instanciate(self.app).connections() + + def about_text(self): + latest = self.app.available_version + version_info = "" + version_url = "" + if not latest[0]: + version_info = "Latest release : {version}" \ + .format(version='.'.join(latest[1])) + version_url = latest[2] + + new_version_text = """ + <p><b>{version_info}</b></p> + <p><a href={version_url}>Download link</a></p> + """.format(version_info=version_info, + version_url=version_url) + return """ + <h1>Sakia</h1> + + <p>Python/Qt Duniter client</p> + + <p>Version : {:}</p> + {new_version_text} + + <p>License : GPLv3</p> + + <p><b>Authors</b></p> + + <p>inso</p> + <p>vit</p> + <p>canercandan</p> + <p>Moul</p> + """.format(__version__, + new_version_text=new_version_text) \ No newline at end of file diff --git a/src/sakia/gui/main_window/toolbar/view.py b/src/sakia/gui/main_window/toolbar/view.py index f8bede1c4dc4cb535a76354f0e3c783df1524932..aff49df9eaeec92d5644b6a5d35c78b9bf0aebba 100644 --- a/src/sakia/gui/main_window/toolbar/view.py +++ b/src/sakia/gui/main_window/toolbar/view.py @@ -1,8 +1,8 @@ from PyQt5.QtWidgets import QFrame, QAction, QMenu, QSizePolicy, QInputDialog, QDialog from sakia.gui.widgets.dialogs import dialog_async_exec -from PyQt5.QtGui import QIcon from PyQt5.QtCore import QObject, QT_TRANSLATE_NOOP, Qt from .toolbar_uic import Ui_SakiaToolbar +from .about_uic import Ui_AboutPopup class ToolbarView(QFrame, Ui_SakiaToolbar): @@ -28,6 +28,9 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): self.action_parameters = QAction(self.tr("Settings"), tool_menu) tool_menu.addAction(self.action_parameters) + self.action_about = QAction(self.tr("About"), tool_menu) + tool_menu.addAction(self.action_about) + self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Minimum) self.setMaximumHeight(60) @@ -44,3 +47,10 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): for c in connections: if c.title() == result: return c + + def show_about(self, text): + dialog = QDialog(self) + about_dialog = Ui_AboutPopup() + about_dialog.setupUi(dialog) + about_dialog.label.setText(text) + dialog.exec() diff --git a/src/sakia/gui/main_window/view.py b/src/sakia/gui/main_window/view.py index 9ab91913cc567e64504f5d1ca07f2064f3ffaddf..024a392eabe5ec46580a1084c58aa25674210443 100644 --- a/src/sakia/gui/main_window/view.py +++ b/src/sakia/gui/main_window/view.py @@ -10,3 +10,4 @@ class MainWindowView(QMainWindow, Ui_MainWindow): def __init__(self): super().__init__(None) self.setupUi(self) +