diff --git a/src/sakia/gui/navigation/controller.py b/src/sakia/gui/navigation/controller.py index a25a3da918a61e33147d6baeab0f48fb9ceccc93..2e8293bd809ee5e26fabc9a07ff9dd91aee46783 100644 --- a/src/sakia/gui/navigation/controller.py +++ b/src/sakia/gui/navigation/controller.py @@ -138,6 +138,11 @@ class NavigationController(QObject): if raw_data and raw_data["component"] == "Informations": menu = QMenu(self.view) if raw_data['misc']['connection'].uid: + action_view_in_wot = QAction(self.tr("View in Web of Trust"), menu) + menu.addAction(action_view_in_wot) + action_view_in_wot.triggered.connect(lambda c: + self.model.view_in_wot(raw_data['misc']['connection'])) + action_gen_revokation = QAction(self.tr("Save revokation document"), menu) menu.addAction(action_gen_revokation) action_gen_revokation.triggered.connect(lambda c: diff --git a/src/sakia/gui/navigation/graphs/wot/model.py b/src/sakia/gui/navigation/graphs/wot/model.py index 5e211dbc2c60654e372ef7889aff9f5cff61e42c..92e567c12c6d8be1286705140501e5d87ad4ac49 100644 --- a/src/sakia/gui/navigation/graphs/wot/model.py +++ b/src/sakia/gui/navigation/graphs/wot/model.py @@ -51,10 +51,9 @@ class WotModel(BaseGraphModel): await self.wot_graph.initialize(self.identity) def refresh(self, identity): - connection_identity = self.identities_service.get_identity(self.connection.pubkey) - if self.identity == connection_identity == identity: + if self.identity == identity: # create empty graph instance - self.wot_graph.offline_init(connection_identity, connection_identity) + self.wot_graph.offline_init(identity) return True return False diff --git a/src/sakia/gui/navigation/graphs/wot/scene.py b/src/sakia/gui/navigation/graphs/wot/scene.py index e54f7fabcda50059a8ec3055a4e4746fcb5c1bfe..59d672257418c6ff562e77410651cf908fe45f66 100644 --- a/src/sakia/gui/navigation/graphs/wot/scene.py +++ b/src/sakia/gui/navigation/graphs/wot/scene.py @@ -4,6 +4,7 @@ from PyQt5.QtWidgets import QGraphicsScene from .edge import WotEdge from .node import WotNode +from sakia.helpers import dpi_ratio from ..base.scene import BaseScene @@ -141,8 +142,9 @@ class WotScene(BaseScene): if identity: # clear scene self.clear() - certifiers_graph_pos = WotScene.certifiers_partial_layout(nx_graph, identity.pubkey, scale=200) - certified_graph_pos = WotScene.certified_partial_layout(nx_graph, identity.pubkey, scale=200) + + certifiers_graph_pos = WotScene.certifiers_partial_layout(nx_graph, identity.pubkey, scale=200*dpi_ratio()) + certified_graph_pos = WotScene.certified_partial_layout(nx_graph, identity.pubkey, scale=200*dpi_ratio()) # create networkx graph for node in nx_graph.nodes(data=True): @@ -162,7 +164,7 @@ class WotScene(BaseScene): self.update() def update_path(self, nx_graph, path): - path_graph_pos = WotScene.path_partial_layout(nx_graph, path, scale=200) + path_graph_pos = WotScene.path_partial_layout(nx_graph, path, scale=200*dpi_ratio()) nodes_path = [n for n in nx_graph.nodes(data=True) if n[0] in path[1:]] for node in nodes_path: v = WotNode(node, path_graph_pos) diff --git a/src/sakia/gui/navigation/identity/model.py b/src/sakia/gui/navigation/identity/model.py index 4a63205f4bff5e18d63027790372a63abbf365b9..bc7c6cfeb6ca51a8ffd58dda278877b246fd28d1 100644 --- a/src/sakia/gui/navigation/identity/model.py +++ b/src/sakia/gui/navigation/identity/model.py @@ -52,9 +52,10 @@ class IdentityModel(QObject): async def refresh_identity_data(self): identity = self.identities_service.get_identity(self.connection.pubkey, self.connection.uid) + certified = self.identities_service.certifications_sent(self.connection.pubkey) identity = await self.identities_service.load_requirements(identity) certifiers = await self.identities_service.load_certifiers_of(identity) - await self.identities_service.load_certs_in_lookup(identity, certifiers, []) + await self.identities_service.load_certs_in_lookup(identity, certifiers, certified) self.table_model.init_certifiers() def table_data(self, index): diff --git a/src/sakia/gui/navigation/model.py b/src/sakia/gui/navigation/model.py index dbea2036fdcfda3ad52d62ea687608e552f69b98..dce2525509dcc4372401fb6db0e553bf9d5cdb47 100644 --- a/src/sakia/gui/navigation/model.py +++ b/src/sakia/gui/navigation/model.py @@ -134,12 +134,16 @@ class NavigationModel(QObject): return node + def view_in_wot(self, connection): + identity = self.app.identities_service.get_identity(connection.pubkey, connection.uid) + self.app.view_in_wot.emit(identity) + def generic_tree(self): return GenericTreeModel.create("Navigation", self.navigation[3]['children']) def add_connection(self, connection): raw_node = self.create_node(connection) - self.navigation[0]["children"].append(raw_node) + self.navigation[3]["children"].append(raw_node) return raw_node def set_current_data(self, raw_data): @@ -186,7 +190,13 @@ class NavigationModel(QObject): for data in self.navigation: connected_to = self._current_data['misc'].get('connection', None) if connected_to == connection: - self._current_data['widget'].disconnect() + try: + self._current_data['widget'].disconnect() + except TypeError as e: + if "disconnect()" in str(e): + pass + else: + raise await self.app.remove_connection(connection) async def send_leave(self, connection, secret_key, password): diff --git a/src/sakia/helpers.py b/src/sakia/helpers.py index 0e64a23937a01cbdc04c07e97ef311d34817863d..d7a0fd4a03238f8fa006386bb3553abad1a6e1e4 100644 --- a/src/sakia/helpers.py +++ b/src/sakia/helpers.py @@ -1,5 +1,6 @@ import re from PyQt5.QtCore import QSharedMemory +from PyQt5.QtWidgets import QApplication def timestamp_to_dhms(ts): @@ -42,4 +43,10 @@ def attrs_tuple_of_str(ls): if ls: # if string is not empty return tuple([str(a) for a in ls.split('\n')]) else: - return tuple() \ No newline at end of file + return tuple() + + +def dpi_ratio(): + screen = QApplication.screens()[0] + dotsPerInch = screen.logicalDotsPerInch() + return dotsPerInch / 96