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

First level of refactoring : empty window

parent 2d5e95dd
No related branches found
No related tags found
No related merge requests found
Showing
with 214 additions and 361 deletions
...@@ -46,3 +46,4 @@ res/i18n/lang-* ...@@ -46,3 +46,4 @@ res/i18n/lang-*
out out
.directory .directory
temp temp
*_uic.py
\ No newline at end of file
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys, os, multiprocessing, subprocess import sys, os, multiprocessing, subprocess
sakia = os.path.abspath(os.path.join(os.path.dirname(__file__)))
resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'res')) resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'res'))
gen_ui = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src', 'sakia', 'gen_resources')) gen_ui = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src', 'sakia', 'presentation'))
gen_resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src')) gen_resources = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))
def convert_ui(args, **kwargs): def convert_ui(args, **kwargs):
...@@ -12,11 +14,15 @@ def convert_ui(args, **kwargs): ...@@ -12,11 +14,15 @@ def convert_ui(args, **kwargs):
def build_resources(): def build_resources():
try: try:
to_process = [] to_process = []
for root, dirs, files in os.walk(resources): for root, dirs, files in os.walk(sakia):
for f in files: for f in files:
if f.endswith('.ui'): if f.endswith('.ui'):
source = os.path.join(root, f) source = os.path.join(root, f)
if os.path.commonpath([resources, root]) == resources:
dest = os.path.join(gen_ui, os.path.splitext(os.path.basename(source))[0]+'_uic.py') dest = os.path.join(gen_ui, os.path.splitext(os.path.basename(source))[0]+'_uic.py')
else:
dest = os.path.join(root, os.path.splitext(os.path.basename(source))[0]+'_uic.py')
exe = 'pyuic5' exe = 'pyuic5'
elif f.endswith('.qrc'): elif f.endswith('.qrc'):
source = os.path.join(root, f) source = os.path.join(root, f)
......
...@@ -14,125 +14,6 @@ ...@@ -14,125 +14,6 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="button_home">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/home_icon</normaloff>:/icons/home_icon</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_currency">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_send_money">
<property name="text">
<string>Send money</string>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/payment_icon</normaloff>:/icons/payment_icon</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_certification">
<property name="text">
<string>Certification</string>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/certification_icon</normaloff>:/icons/certification_icon</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_membership">
<property name="text">
<string>Renew membership</string>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/renew_membership</normaloff>:/icons/renew_membership</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolbutton_menu">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../icons/icons.qrc">
<normaloff>:/icons/menu_icon</normaloff>:/icons/menu_icon</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
<property name="arrowType">
<enum>Qt::NoArrow</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QTabWidget" name="tabs"/> <widget class="QTabWidget" name="tabs"/>
</item> </item>
......
__all__ = ['controller', 'model']
from PyQt5.QtCore import QObject
class AgentController(QObject):
"""
The navigation panel
"""
def __init__(self, parent, view, model):
"""
Constructor of the navigation agent
:param PyQt5.QtWidgets.QWidget presentation: the presentation
:param sakia.core.gui.navigation.model.NavigationModel model: the model
"""
super().__init__(parent)
self.view = view
self.model = model
def attach(self, controller):
controller.setParent(self)
return controller
from PyQt5.QtCore import QObject
class AgentModel(QObject):
"""
An agent
"""
def __init__(self, parent):
"""
Constructor of an agent
:param sakia.core.gui.agent.controller.AbstractAgentController controller: the controller
"""
super().__init__(parent)
@property
def account(self):
return self.app.current_account
...@@ -14,7 +14,8 @@ from .widgets.dialogs import QAsyncMessageBox ...@@ -14,7 +14,8 @@ from .widgets.dialogs import QAsyncMessageBox
from .member import MemberDialog from .member import MemberDialog
from ..tools.decorators import asyncify, once_at_a_time from ..tools.decorators import asyncify, once_at_a_time
from ..tools.exceptions import NoPeerAvailable from ..tools.exceptions import NoPeerAvailable
from ..gen_resources.certification_uic import Ui_CertificationDialog from ..presentation.certification_uic import Ui_CertificationDialog
class CertificationDialog(QObject): class CertificationDialog(QObject):
""" """
......
...@@ -13,13 +13,12 @@ from PyQt5.QtWidgets import QWidget, QMessageBox, QDialog, QPushButton, QTabBar, ...@@ -13,13 +13,12 @@ from PyQt5.QtWidgets import QWidget, QMessageBox, QDialog, QPushButton, QTabBar,
from .graphs.wot_tab import WotTabWidget from .graphs.wot_tab import WotTabWidget
from .widgets import toast from .widgets import toast
from .widgets.dialogs import QAsyncMessageBox, QAsyncFileDialog, dialog_async_exec
from .identities_tab import IdentitiesTabWidget from .identities_tab import IdentitiesTabWidget
from .informations_tab import InformationsTabWidget from .informations_tab import InformationsTabWidget
from .network_tab import NetworkTabWidget from .network_tab import NetworkTabWidget
from .transactions_tab import TransactionsTabWidget from .transactions_tab import TransactionsTabWidget
from .graphs.explorer_tab import ExplorerTabWidget from .graphs.explorer_tab import ExplorerTabWidget
from ..gen_resources.community_view_uic import Ui_CommunityWidget from ..presentation.community_view_uic import Ui_CommunityWidget
from ..tools.decorators import asyncify, once_at_a_time, cancel_once_task from ..tools.decorators import asyncify, once_at_a_time, cancel_once_task
from ..tools.exceptions import MembershipNotFoundError, LookupFailureError, NoPeerAvailable from ..tools.exceptions import MembershipNotFoundError, LookupFailureError, NoPeerAvailable
...@@ -35,10 +34,6 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): ...@@ -35,10 +34,6 @@ class CommunityWidget(QWidget, Ui_CommunityWidget):
_tab_identities_label = QT_TRANSLATE_NOOP("CommunityWidget", "Search Identities") _tab_identities_label = QT_TRANSLATE_NOOP("CommunityWidget", "Search Identities")
_tab_network_label = QT_TRANSLATE_NOOP("CommunityWidget", "Network") _tab_network_label = QT_TRANSLATE_NOOP("CommunityWidget", "Network")
_tab_informations_label = QT_TRANSLATE_NOOP("CommunityWidget", "Informations") _tab_informations_label = QT_TRANSLATE_NOOP("CommunityWidget", "Informations")
_action_showinfo_text = QT_TRANSLATE_NOOP("CommunityWidget", "Show informations")
_action_explore_text = QT_TRANSLATE_NOOP("CommunityWidget", "Explore the Web of Trust")
_action_publish_uid_text = QT_TRANSLATE_NOOP("CommunityWidget", "Publish UID")
_action_revoke_uid_text = QT_TRANSLATE_NOOP("CommunityWidget", "Revoke UID")
def __init__(self, app, status_label, label_icon): def __init__(self, app, status_label, label_icon):
""" """
...@@ -61,16 +56,8 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): ...@@ -61,16 +56,8 @@ class CommunityWidget(QWidget, Ui_CommunityWidget):
self.tab_network = NetworkTabWidget(self.app) self.tab_network = NetworkTabWidget(self.app)
self.tab_explorer = ExplorerTabWidget(self.app) self.tab_explorer = ExplorerTabWidget(self.app)
self.action_publish_uid = QAction(self.tr(CommunityWidget._action_publish_uid_text), self)
self.action_revoke_uid = QAction(self.tr(CommunityWidget._action_revoke_uid_text), self)
self.action_showinfo = QAction(self.tr(CommunityWidget._action_showinfo_text), self)
self.action_explorer = QAction(self.tr(CommunityWidget._action_explore_text), self)
super().setupUi(self) super().setupUi(self)
tool_menu = QMenu(self.tr("Tools"), self.toolbutton_menu)
self.toolbutton_menu.setMenu(tool_menu)
self.tab_identities.view_in_wot.connect(self.tab_wot.draw_graph) self.tab_identities.view_in_wot.connect(self.tab_wot.draw_graph)
self.tab_identities.view_in_wot.connect(lambda: self.tabs.setCurrentWidget(self.tab_wot.widget)) self.tab_identities.view_in_wot.connect(lambda: self.tabs.setCurrentWidget(self.tab_wot.widget))
self.tab_history.view_in_wot.connect(self.tab_wot.draw_graph) self.tab_history.view_in_wot.connect(self.tab_wot.draw_graph)
...@@ -94,27 +81,6 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): ...@@ -94,27 +81,6 @@ class CommunityWidget(QWidget, Ui_CommunityWidget):
QIcon(":/icons/network_icon"), QIcon(":/icons/network_icon"),
self.tr("Network")) self.tr("Network"))
action_showinfo = QAction(self.tr("Show informations"), self.toolbutton_menu)
action_showinfo.triggered.connect(lambda : self.show_closable_tab(self.tab_informations,
QIcon(":/icons/informations_icon"), self.tr("Informations")))
tool_menu.addAction(action_showinfo)
action_showexplorer = QAction(self.tr("Show explorer"), self.toolbutton_menu)
action_showexplorer.triggered.connect(lambda : self.show_closable_tab(self.tab_explorer.widget,
QIcon(":/icons/explorer_icon"), self.tr("Explorer")))
tool_menu.addAction(action_showexplorer)
menu_advanced = QMenu(self.tr("Advanced"), self.toolbutton_menu)
action_gen_revokation = QAction(self.tr("Save revokation document"), menu_advanced)
action_gen_revokation.triggered.connect(self.action_save_revokation)
menu_advanced.addAction(action_gen_revokation)
tool_menu.addMenu(menu_advanced)
self.action_publish_uid.triggered.connect(self.publish_uid)
tool_menu.addAction(self.action_publish_uid)
self.button_membership.clicked.connect(self.send_membership_demand)
def show_closable_tab(self, tab, icon, title): def show_closable_tab(self, tab, icon, title):
if self.tabs.indexOf(tab) == -1: if self.tabs.indexOf(tab) == -1:
self.tabs.addTab(tab, icon, title) self.tabs.addTab(tab, icon, title)
...@@ -175,31 +141,6 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): ...@@ -175,31 +141,6 @@ class CommunityWidget(QWidget, Ui_CommunityWidget):
error, error,
QMessageBox.Ok) QMessageBox.Ok)
@asyncify
async def action_save_revokation(self, checked=False):
password = await self.password_asker.async_exec()
if self.password_asker.result() == QDialog.Rejected:
return
raw_document = await self.account.generate_revokation(self.community, password)
# Testable way of using a QFileDialog
selected_files = await QAsyncFileDialog.get_save_filename(self, self.tr("Save a revokation document"),
"", self.tr("All text files (*.txt)"))
if selected_files:
path = selected_files[0]
if not path.endswith('.txt'):
path = "{0}.txt".format(path)
with open(path, 'w') as save_file:
save_file.write(raw_document)
dialog = QMessageBox(QMessageBox.Information, self.tr("Revokation file"),
self.tr("""<div>Your revokation document has been saved.</div>
<div><b>Please keep it in a safe place.</b></div>
The publication of this document will remove your identity from the network.</p>"""), QMessageBox.Ok,
self)
dialog.setTextFormat(Qt.RichText)
await dialog_async_exec(dialog)
@once_at_a_time @once_at_a_time
@asyncify @asyncify
async def refresh_block(self, block_number): async def refresh_block(self, block_number):
...@@ -317,40 +258,6 @@ The publication of this document will remove your identity from the network.</p> ...@@ -317,40 +258,6 @@ The publication of this document will remove your identity from the network.</p>
self.status_label.setText(label_text) self.status_label.setText(label_text)
self.label_icon.setPixmap(QPixmap(icon).scaled(24, 24, Qt.KeepAspectRatio, Qt.SmoothTransformation)) self.label_icon.setPixmap(QPixmap(icon).scaled(24, 24, Qt.KeepAspectRatio, Qt.SmoothTransformation))
@once_at_a_time
@asyncify
async def refresh_quality_buttons(self):
if self.account and self.community:
try:
account_identity = await self.account.identity(self.community)
published_uid = await account_identity.published_uid(self.community)
uid_is_revokable = await account_identity.uid_is_revokable(self.community)
if published_uid:
logging.debug("UID Published")
self.action_revoke_uid.setEnabled(uid_is_revokable)
is_member = await account_identity.is_member(self.community)
if is_member:
self.button_membership.setText(self.tr("Renew membership"))
self.button_membership.setEnabled(True)
self.button_certification.setEnabled(True)
self.action_publish_uid.setEnabled(False)
else:
logging.debug("Not a member")
self.button_membership.setText(self.tr("Send membership demand"))
self.button_membership.setEnabled(True)
self.action_publish_uid.setEnabled(False)
if await self.community.get_block(0) is not None:
self.button_certification.setEnabled(False)
else:
logging.debug("UID not published")
self.button_membership.setEnabled(False)
self.button_certification.setEnabled(False)
self.action_publish_uid.setEnabled(True)
except LookupFailureError:
self.button_membership.setEnabled(False)
self.button_certification.setEnabled(False)
self.action_publish_uid.setEnabled(False)
def showEvent(self, event): def showEvent(self, event):
self.refresh_status() self.refresh_status()
...@@ -360,69 +267,6 @@ The publication of this document will remove your identity from the network.</p> ...@@ -360,69 +267,6 @@ The publication of this document will remove your identity from the network.</p>
self.tab_history.refresh_balance() self.tab_history.refresh_balance()
self.tab_informations.refresh() self.tab_informations.refresh()
@asyncify
async def send_membership_demand(self, checked=False):
password = await self.password_asker.async_exec()
if self.password_asker.result() == QDialog.Rejected:
return
result = await self.account.send_membership(password, self.community, 'IN')
if result[0]:
if self.app.preferences['notifications']:
toast.display(self.tr("Membership"), self.tr("Success sending Membership demand"))
else:
await QAsyncMessageBox.information(self, self.tr("Membership"),
self.tr("Success sending Membership demand"))
else:
if self.app.preferences['notifications']:
toast.display(self.tr("Membership"), result[1])
else:
await QAsyncMessageBox.critical(self, self.tr("Membership"),
result[1])
@asyncify
async def send_membership_leaving(self):
reply = await QAsyncMessageBox.warning(self, self.tr("Warning"),
self.tr("""Are you sure ?
Sending a leaving demand cannot be canceled.
The process to join back the community later will have to be done again.""")
.format(self.account.pubkey), QMessageBox.Ok | QMessageBox.Cancel)
if reply == QMessageBox.Ok:
password = self.password_asker.exec_()
if self.password_asker.result() == QDialog.Rejected:
return
result = await self.account.send_membership(password, self.community, 'OUT')
if result[0]:
if self.app.preferences['notifications']:
toast.display(self.tr("Revoke"), self.tr("Success sending Revoke demand"))
else:
await QAsyncMessageBox.information(self, self.tr("Revoke"),
self.tr("Success sending Revoke demand"))
else:
if self.app.preferences['notifications']:
toast.display(self.tr("Revoke"), result[1])
else:
await QAsyncMessageBox.critical(self, self.tr("Revoke"),
result[1])
@asyncify
async def publish_uid(self, checked=False):
password = await self.password_asker.async_exec()
if self.password_asker.result() == QDialog.Rejected:
return
result = await self.account.send_selfcert(password, self.community)
if result[0]:
if self.app.preferences['notifications']:
toast.display(self.tr("UID"), self.tr("Success publishing your UID"))
else:
await QAsyncMessageBox.information(self, self.tr("Membership"),
self.tr("Success publishing your UID"))
else:
if self.app.preferences['notifications']:
toast.display(self.tr("UID"), result[1])
else:
await QAsyncMessageBox.critical(self, self.tr("UID"),
result[1])
def retranslateUi(self, widget): def retranslateUi(self, widget):
""" """
Method to complete translations missing from generated code Method to complete translations missing from generated code
...@@ -434,9 +278,6 @@ The process to join back the community later will have to be done again.""") ...@@ -434,9 +278,6 @@ The process to join back the community later will have to be done again.""")
self.tabs.setTabText(self.tabs.indexOf(self.tab_informations), self.tr(CommunityWidget._tab_informations_label)) self.tabs.setTabText(self.tabs.indexOf(self.tab_informations), self.tr(CommunityWidget._tab_informations_label))
self.tabs.setTabText(self.tabs.indexOf(self.tab_history.widget), self.tr(CommunityWidget._tab_history_label)) self.tabs.setTabText(self.tabs.indexOf(self.tab_history.widget), self.tr(CommunityWidget._tab_history_label))
self.tabs.setTabText(self.tabs.indexOf(self.tab_identities.widget), self.tr(CommunityWidget._tab_identities_label)) self.tabs.setTabText(self.tabs.indexOf(self.tab_identities.widget), self.tr(CommunityWidget._tab_identities_label))
self.action_publish_uid.setText(self.tr(CommunityWidget._action_publish_uid_text))
self.action_revoke_uid.setText(self.tr(CommunityWidget._action_revoke_uid_text))
self.action_showinfo.setText(self.tr(CommunityWidget._action_showinfo_text))
super().retranslateUi(self) super().retranslateUi(self)
def showEvent(self, QShowEvent): def showEvent(self, QShowEvent):
......
...@@ -9,7 +9,7 @@ import logging ...@@ -9,7 +9,7 @@ import logging
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QMessageBox from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QMessageBox
from ..core.registry import IdentitiesRegistry from ..core.registry import IdentitiesRegistry
from ..tools.exceptions import ContactAlreadyExists from ..tools.exceptions import ContactAlreadyExists
from ..gen_resources.contact_uic import Ui_ConfigureContactDialog from ..presentation.contact_uic import Ui_ConfigureContactDialog
class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog): class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog):
......
...@@ -7,7 +7,7 @@ from ...tools.exceptions import NoPeerAvailable ...@@ -7,7 +7,7 @@ from ...tools.exceptions import NoPeerAvailable
from ...tools.decorators import asyncify, once_at_a_time, cancel_once_task from ...tools.decorators import asyncify, once_at_a_time, cancel_once_task
from ...core.graph import ExplorerGraph from ...core.graph import ExplorerGraph
from .graph_tab import GraphTabWidget from .graph_tab import GraphTabWidget
from ...gen_resources.explorer_tab_uic import Ui_ExplorerTabWidget from ...presentation.explorer_tab_uic import Ui_ExplorerTabWidget
class ExplorerTabWidget(GraphTabWidget, Ui_ExplorerTabWidget): class ExplorerTabWidget(GraphTabWidget, Ui_ExplorerTabWidget):
......
...@@ -5,7 +5,7 @@ from PyQt5.QtCore import QEvent, pyqtSignal, QT_TRANSLATE_NOOP, QObject ...@@ -5,7 +5,7 @@ from PyQt5.QtCore import QEvent, pyqtSignal, QT_TRANSLATE_NOOP, QObject
from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QWidget
from ...tools.decorators import asyncify, once_at_a_time, cancel_once_task from ...tools.decorators import asyncify, once_at_a_time, cancel_once_task
from ...core.graph import WoTGraph from ...core.graph import WoTGraph
from ...gen_resources.wot_tab_uic import Ui_WotTabWidget from ...presentation.wot_tab_uic import Ui_WotTabWidget
from ...gui.widgets.busy import Busy from ...gui.widgets.busy import Busy
from .graph_tab import GraphTabWidget from .graph_tab import GraphTabWidget
......
...@@ -6,7 +6,7 @@ Created on 31 janv. 2015 ...@@ -6,7 +6,7 @@ Created on 31 janv. 2015
from PyQt5.QtWidgets import QWidget, QFrame, QGridLayout, QAction from PyQt5.QtWidgets import QWidget, QFrame, QGridLayout, QAction
from PyQt5.QtCore import QEvent, Qt, pyqtSlot, pyqtSignal from PyQt5.QtCore import QEvent, Qt, pyqtSlot, pyqtSignal
from ..gen_resources.homescreen_uic import Ui_HomescreenWidget from ..presentation.homescreen_uic import Ui_HomescreenWidget
from .community_tile import CommunityTile from .community_tile import CommunityTile
from ..core.community import Community from ..core.community import Community
import logging import logging
......
...@@ -14,7 +14,7 @@ from duniterpy.api import bma, errors ...@@ -14,7 +14,7 @@ from duniterpy.api import bma, errors
from duniterpy.documents import BlockUID from duniterpy.documents import BlockUID
from ..models.identities import IdentitiesFilterProxyModel, IdentitiesTableModel from ..models.identities import IdentitiesFilterProxyModel, IdentitiesTableModel
from ..gen_resources.identities_tab_uic import Ui_IdentitiesTab from ..presentation.identities_tab_uic import Ui_IdentitiesTab
from ..core.registry import Identity, BlockchainState from ..core.registry import Identity, BlockchainState
from ..tools.exceptions import NoPeerAvailable from ..tools.exceptions import NoPeerAvailable
from ..tools.decorators import asyncify, once_at_a_time, cancel_once_task from ..tools.decorators import asyncify, once_at_a_time, cancel_once_task
......
...@@ -7,7 +7,7 @@ import re ...@@ -7,7 +7,7 @@ import re
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QMessageBox, QFileDialog from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QMessageBox, QFileDialog
from ..tools.exceptions import Error from ..tools.exceptions import Error
from ..gen_resources.import_account_uic import Ui_ImportAccountDialog from ..presentation.import_account_uic import Ui_ImportAccountDialog
class ImportAccountDialog(QDialog, Ui_ImportAccountDialog): class ImportAccountDialog(QDialog, Ui_ImportAccountDialog):
......
...@@ -8,7 +8,7 @@ import logging ...@@ -8,7 +8,7 @@ import logging
import math import math
from PyQt5.QtCore import QLocale, QDateTime, QEvent from PyQt5.QtCore import QLocale, QDateTime, QEvent
from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QWidget
from ..gen_resources.informations_tab_uic import Ui_InformationsTabWidget from ..presentation.informations_tab_uic import Ui_InformationsTabWidget
from ..tools.decorators import asyncify, once_at_a_time, cancel_once_task from ..tools.decorators import asyncify, once_at_a_time, cancel_once_task
from ..tools.exceptions import NoPeerAvailable from ..tools.exceptions import NoPeerAvailable
from .widgets import Busy from .widgets import Busy
......
"""
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
from PyQt5.QtGui import QIcon
from ..password_asker import PasswordAskerDialog
from ...__init__ import __version__
from ..widgets import toast
from ..agent.controller import AgentController
from .view import MainWindowView
from .model import MainWindowModel
from ..status_bar.controller import StatusBarController
class MainWindowController(AgentController):
"""
classdocs
"""
def __init__(self, view, model, password_asker, status_bar):
"""
Init
:param MainWindowView view: the ui of the mainwindow agent
:param sakia.gui.main_window.model.MainWindowModel: the model of the mainwindow agent
:param sakia.gui.status_bar.controller.StatusBarController: the controller of the status bar agent
:param PasswordAsker password_asker: the password asker of the application
:type: sakia.core.app.Application
"""
# Set up the user interface from Designer.
super().__init__(None, view, model)
self.initialized = False
self.password_asker = password_asker
if status_bar:
self.status_bar = self.attach(status_bar)
QApplication.setWindowIcon(QIcon(":/icons/sakia_logo"))
@classmethod
def startup(cls, app):
view = MainWindowView(None)
model = MainWindowModel(None, app)
main_window = cls(view, model,PasswordAskerDialog(None), None)
main_window.status_bar = main_window.attach(StatusBarController.create(main_window, app))
main_window.view.setStatusBar(main_window.status_bar.view)
#app.version_requested.connect(main_window.latest_version_requested)
#app.account_imported.connect(main_window.import_account_accepted)
#app.account_changed.connect(main_window.change_account)
view.showMaximized()
main_window.refresh()
return main_window
def change_account(self):
if self.account:
self.account.contacts_changed.disconnect(self.refresh_contacts)
self.account = self.app.current_account
self.password_asker.change_account(self.account)
self.refresh()
@pyqtSlot(str)
def display_error(self, error):
QMessageBox.critical(self, ":(",
error,
QMessageBox.Ok)
@pyqtSlot(int)
def referential_changed(self, index):
if self.account:
self.account.set_display_referential(index)
if self.community_view:
self.community_view.referential_changed()
self.homescreen.referential_changed()
@pyqtSlot()
def latest_version_requested(self):
latest = self.app.available_version
logging.debug("Latest version requested")
if not latest[0]:
version_info = self.tr("Please get the latest release {version}") \
.format(version=latest[1])
version_url = latest[2]
if self.app.preferences['notifications']:
toast.display("sakia", """{version_info}""".format(
version_info=version_info,
version_url=version_url))
def refresh(self):
"""
Refresh main window
When the selected account changes, all the widgets
in the window have to be refreshed
"""
self.status_bar.refresh()
self.view.setWindowTitle(self.tr("sakia {0}").format(__version__))
def eventFilter(self, target, event):
"""
Event filter on the widget
:param QObject target: the target of the event
:param QEvent event: the event
:return: bool
"""
if target == self.widget:
if event.type() == QEvent.LanguageChange:
self.ui.retranslateUi(self)
self.refresh()
return self.widget.eventFilter(target, event)
return False
...@@ -14,76 +14,11 @@ ...@@ -14,76 +14,11 @@
<string notr="true">Sakia</string> <string notr="true">Sakia</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_6"/> <layout class="QVBoxLayout" name="verticalLayout_6">
</widget> <item>
<widget class="QMenuBar" name="menubar"> <layout class="QHBoxLayout" name="horizontalLayout"/>
<property name="geometry"> </item>
<rect> </layout>
<x>0</x>
<y>0</y>
<width>900</width>
<height>30</height>
</rect>
</property>
<widget class="QMenu" name="menu_file">
<property name="title">
<string>Fi&amp;le</string>
</property>
<addaction name="action_import"/>
<addaction name="action_export"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
<addaction name="action_quit"/>
</widget>
<widget class="QMenu" name="menu_account">
<property name="title">
<string>Acco&amp;unt</string>
</property>
<widget class="QMenu" name="menu_contacts_list">
<property name="title">
<string>Co&amp;ntacts</string>
</property>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menu_change_account">
<property name="title">
<string>&amp;Open</string>
</property>
</widget>
<widget class="QMenu" name="menuAdvanced">
<property name="title">
<string>Advanced</string>
</property>
<addaction name="action_revoke_identity"/>
</widget>
<addaction name="menu_change_account"/>
<addaction name="action_configure_parameters"/>
<addaction name="action_add_account"/>
<addaction name="separator"/>
<addaction name="actionCertification"/>
<addaction name="actionTransfer_money"/>
<addaction name="separator"/>
<addaction name="action_add_a_contact"/>
<addaction name="menu_contacts_list"/>
<addaction name="separator"/>
<addaction name="menuAdvanced"/>
</widget>
<widget class="QMenu" name="menu_help">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<widget class="QMenu" name="menu_duniter">
<property name="title">
<string>&amp;Duniter</string>
</property>
<addaction name="actionManage_local_node"/>
</widget>
<addaction name="menu_file"/>
<addaction name="menu_account"/>
<addaction name="menu_duniter"/>
<addaction name="menu_help"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<action name="actionManage_accounts"> <action name="actionManage_accounts">
...@@ -198,7 +133,7 @@ ...@@ -198,7 +133,7 @@
</action> </action>
<action name="action_revoke_identity"> <action name="action_revoke_identity">
<property name="text"> <property name="text">
<string>Revoke an identity</string> <string>&amp;Revoke an identity</string>
</property> </property>
</action> </action>
</widget> </widget>
......
from sakia.gui.agent.model import AgentModel
from sakia.core.money import Referentials
class MainWindowModel(AgentModel):
"""
The model of Navigation agent
"""
def __init__(self, parent, app):
super().__init__(parent)
self.app = app
def referentials(self):
return Referentials
from PyQt5.QtWidgets import QMainWindow
from .mainwindow_uic import Ui_MainWindow
class MainWindowView(QMainWindow, Ui_MainWindow):
"""
The model of Navigation agent
"""
def __init__(self, parent):
super().__init__(parent)
self.setupUi(self)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment