Skip to content
Snippets Groups Projects
Commit 6d232ba0 authored by inso's avatar inso
Browse files

Add about dialog back

parent 50a815a9
No related branches found
No related tags found
No related merge requests found
<?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>
...@@ -62,6 +62,7 @@ class Application(QObject): ...@@ -62,6 +62,7 @@ class Application(QObject):
transactions_services = attr.ib(default=attr.Factory(dict)) transactions_services = attr.ib(default=attr.Factory(dict))
documents_service = attr.ib(default=None) documents_service = attr.ib(default=None)
current_ref = attr.ib(default=Relative) current_ref = attr.ib(default=Relative)
_logger = attr.ib(default=attr.Factory(lambda:logging.getLogger('sakia')))
available_version = attr.ib(init=False) available_version = attr.ib(init=False)
_translator = attr.ib(init=False) _translator = attr.ib(init=False)
...@@ -76,7 +77,7 @@ class Application(QObject): ...@@ -76,7 +77,7 @@ class Application(QObject):
app_data = AppDataFile.in_config_path(options.config_path).load_or_init() app_data = AppDataFile.in_config_path(options.config_path).load_or_init()
app = cls(qapp, loop, options, app_data, None, None) app = cls(qapp, loop, options, app_data, None, None)
#app.set_proxy() #app.set_proxy()
#app.get_last_version() app.get_last_version()
app.load_profile(app_data.default) app.load_profile(app_data.default)
app.start_coroutines() app.start_coroutines()
app.documents_service = DocumentsService.instanciate(app) app.documents_service = DocumentsService.instanciate(app)
...@@ -164,15 +165,14 @@ class Application(QObject): ...@@ -164,15 +165,14 @@ class Application(QObject):
@asyncify @asyncify
async def get_last_version(self): async def get_last_version(self):
if self.preferences['enable_proxy'] is True: if self.parameters.enable_proxy is True:
connector = ProxyConnector("http://{0}:{1}".format( proxy = "http://{0}:{1}".format(self.parameters.proxy_address, self.parameters.proxy_port)
self.preferences['proxy_address'],
self.preferences['proxy_port']))
else: else:
connector = None proxy = None
try: try:
with aiohttp.ClientSession() as session:
with aiohttp.Timeout(15): with aiohttp.Timeout(15):
response = await aiohttp.get("https://api.github.com/repos/duniter/sakia/releases", connector=connector) response = await session.get("https://api.github.com/repos/duniter/sakia/releases", proxy=proxy)
if response.status == 200: if response.status == 200:
releases = await response.json() releases = await response.json()
latest = None latest = None
...@@ -193,9 +193,7 @@ class Application(QObject): ...@@ -193,9 +193,7 @@ class Application(QObject):
self.available_version = version self.available_version = version
self.version_requested.emit() self.version_requested.emit()
except (aiohttp.errors.ClientError, aiohttp.errors.TimeoutError) as e: except (aiohttp.errors.ClientError, aiohttp.errors.TimeoutError) as e:
logging.debug("Could not connect to github : {0}".format(str(e))) self._logger.debug("Could not connect to github : {0}".format(str(e)))
except Exception as e:
pass
def save_parameters(self, parameters): def save_parameters(self, parameters):
self.parameters = UserParametersFile\ self.parameters = UserParametersFile\
......
...@@ -13,7 +13,7 @@ class UserParameters: ...@@ -13,7 +13,7 @@ class UserParameters:
digits_after_comma = attr.ib(convert=int, default=2) digits_after_comma = attr.ib(convert=int, default=2)
maximized = attr.ib(convert=bool, default=False) maximized = attr.ib(convert=bool, default=False)
notifications = attr.ib(convert=bool, default=True) 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_type = attr.ib(convert=int, default=0)
proxy_address = attr.ib(convert=str, default="") proxy_address = attr.ib(convert=str, default="")
proxy_port = attr.ib(convert=int, default=8080) proxy_port = attr.ib(convert=int, default=8080)
......
"""
Created on 1 févr. 2014
@author: inso
"""
import aiohttp
import logging import logging
import traceback
from PyQt5.QtWidgets import QMessageBox, QApplication from PyQt5.QtWidgets import QMessageBox, QApplication
from PyQt5.QtCore import QEvent, pyqtSlot, QObject from PyQt5.QtCore import QEvent, pyqtSlot, QObject
......
File moved
...@@ -33,6 +33,7 @@ class ToolbarController(QObject): ...@@ -33,6 +33,7 @@ class ToolbarController(QObject):
self.view.button_membership.clicked.connect(self.send_join_demand) 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_add_connection.triggered.connect(self.open_add_connection_dialog)
self.view.action_parameters.triggered.connect(self.open_settings_dialog) self.view.action_parameters.triggered.connect(self.open_settings_dialog)
self.view.action_about.triggered.connect(self.open_about_dialog)
@classmethod @classmethod
def create(cls, app, navigation): def create(cls, app, navigation):
...@@ -97,6 +98,10 @@ class ToolbarController(QObject): ...@@ -97,6 +98,10 @@ class ToolbarController(QObject):
self.model.app.new_connection.emit(connection_config.model.connection) self.model.app.new_connection.emit(connection_config.model.connection)
self.enable_actions(True) self.enable_actions(True)
def open_about_dialog(self):
text = self.model.about_text()
self.view.show_about(text)
def retranslateUi(self, widget): def retranslateUi(self, widget):
""" """
Method to complete translations missing from generated code Method to complete translations missing from generated code
......
from PyQt5.QtCore import QObject from PyQt5.QtCore import QObject
from sakia.data.processors import ConnectionsProcessor from sakia.data.processors import ConnectionsProcessor
import attr import attr
from sakia import __version__
@attr.s() @attr.s()
...@@ -26,3 +27,36 @@ class ToolbarModel(QObject): ...@@ -26,3 +27,36 @@ class ToolbarModel(QObject):
def connections(self): def connections(self):
return ConnectionsProcessor.instanciate(self.app).connections() 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
from PyQt5.QtWidgets import QFrame, QAction, QMenu, QSizePolicy, QInputDialog, QDialog from PyQt5.QtWidgets import QFrame, QAction, QMenu, QSizePolicy, QInputDialog, QDialog
from sakia.gui.widgets.dialogs import dialog_async_exec from sakia.gui.widgets.dialogs import dialog_async_exec
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import QObject, QT_TRANSLATE_NOOP, Qt from PyQt5.QtCore import QObject, QT_TRANSLATE_NOOP, Qt
from .toolbar_uic import Ui_SakiaToolbar from .toolbar_uic import Ui_SakiaToolbar
from .about_uic import Ui_AboutPopup
class ToolbarView(QFrame, Ui_SakiaToolbar): class ToolbarView(QFrame, Ui_SakiaToolbar):
...@@ -28,6 +28,9 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): ...@@ -28,6 +28,9 @@ class ToolbarView(QFrame, Ui_SakiaToolbar):
self.action_parameters = QAction(self.tr("Settings"), tool_menu) self.action_parameters = QAction(self.tr("Settings"), tool_menu)
tool_menu.addAction(self.action_parameters) 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.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Minimum)
self.setMaximumHeight(60) self.setMaximumHeight(60)
...@@ -44,3 +47,10 @@ class ToolbarView(QFrame, Ui_SakiaToolbar): ...@@ -44,3 +47,10 @@ class ToolbarView(QFrame, Ui_SakiaToolbar):
for c in connections: for c in connections:
if c.title() == result: if c.title() == result:
return c 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()
...@@ -10,3 +10,4 @@ class MainWindowView(QMainWindow, Ui_MainWindow): ...@@ -10,3 +10,4 @@ class MainWindowView(QMainWindow, Ui_MainWindow):
def __init__(self): def __init__(self):
super().__init__(None) super().__init__(None)
self.setupUi(self) self.setupUi(self)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment