From ded97fccf73a4ce86baa03b9f0eaa495e77df12e Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Sun, 5 Jul 2015 18:35:06 +0200 Subject: [PATCH] Refresh nodes manually ( #135 ) --- res/icons/AUTHORS | 3 +- res/icons/icons.qrc | 1 + res/icons/noun_2149_cc.svg | 49 +++++++++++++++++++++++++++ res/ui/network_tab.ui | 58 +++++++++++++++++++++++++++++++- src/cutecoin/core/net/network.py | 5 +++ src/cutecoin/gui/network_tab.py | 4 +++ 6 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 res/icons/noun_2149_cc.svg diff --git a/res/icons/AUTHORS b/res/icons/AUTHORS index 85baffe9..4dc1d78f 100644 --- a/res/icons/AUTHORS +++ b/res/icons/AUTHORS @@ -14,4 +14,5 @@ noun_76373_cc.svg : Created by João Paulo noun_5197_cc.svg : Created by Bibzee noun_38960_cc.svg : Created by Agarunov Oktay-Abraham noun_42425_cc.svg : Created by Luis Rodrigues -noun_62146_cc.svg : Created by Sergey Krivoy \ No newline at end of file +noun_62146_cc.svg : Created by Sergey Krivoy +noun_2149_cc.svg : Created by Anand A Nair \ No newline at end of file diff --git a/res/icons/icons.qrc b/res/icons/icons.qrc index c1c37ab2..0de88085 100644 --- a/res/icons/icons.qrc +++ b/res/icons/icons.qrc @@ -12,6 +12,7 @@ <file alias="members_icon">noun_18704_cc.svg</file> <file alias="wallet_icon">noun_29542_cc.svg</file> <file alias="tx_icon">noun_63271_cc.svg</file> + <file alias="refresh_icon">noun_2149_cc.svg</file> <file alias="currency_icon">noun_43022_cc.svg</file> <file alias="settings_display_icon">noun_38960_cc.svg</file> <file alias="settings_app_icon">noun_42425_cc.svg</file> diff --git a/res/icons/noun_2149_cc.svg b/res/icons/noun_2149_cc.svg new file mode 100644 index 00000000..164b75ec --- /dev/null +++ b/res/icons/noun_2149_cc.svg @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + x="0px" + y="0px" + viewBox="0 0 100 125" + enable-background="new 0 0 100 100" + xml:space="preserve" + id="svg2" + inkscape:version="0.91 r13725" + sodipodi:docname="noun_2149_cc.svg"><metadata + id="metadata16"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs14" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="743" + inkscape:window-height="480" + id="namedview12" + showgrid="false" + inkscape:zoom="1.888" + inkscape:cx="48.267139" + inkscape:cy="72.791055" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="svg2" /><path + d="m 68.45393,90.514664 c -5.405642,3.785074 -11.719343,5.688849 -18.182514,5.596695 -0.851867,-0.01236 -1.701486,-0.05058 -2.54099,-0.126993 -0.341646,-0.03146 -0.686663,-0.08878 -1.030556,-0.133737 -0.657443,-0.08204 -1.314886,-0.171946 -1.963338,-0.300063 -0.39559,-0.07642 -0.781066,-0.17307 -1.171036,-0.267473 -0.631595,-0.147222 -1.25757,-0.294445 -1.872307,-0.479877 -0.297817,-0.08878 -0.585519,-0.197795 -0.877715,-0.293321 -0.712511,-0.236005 -1.417155,-0.485496 -2.103818,-0.773198 -0.157337,-0.06406 -0.306807,-0.133736 -0.463019,-0.204537 -0.804666,-0.351761 -1.595846,-0.727121 -2.364548,-1.144064 -0.03484,-0.01798 -0.06743,-0.03821 -0.102269,-0.05731 -2.601676,-1.422776 -4.97971,-3.204054 -7.063298,-5.285395 -0.03484,-0.03709 -0.06744,-0.07529 -0.102269,-0.109012 -0.643957,-0.6507 -1.26319,-1.335115 -1.850955,-2.042007 -0.12587,-0.147222 -0.241624,-0.312426 -0.36637,-0.466391 -4.248094,-5.31012 -6.808187,-12.031773 -6.808187,-19.347934 l 8.171398,0 -13.074688,-19.606413 -13.0724403,19.608661 8.1713992,0 c 0,8.598456 2.6803451,16.565317 7.2329971,23.153234 0.05731,0.09665 0.09553,0.191051 0.159585,0.280958 0.473134,0.676548 0.995717,1.295781 1.499195,1.934119 0.191052,0.242748 0.364122,0.492239 0.561917,0.727121 0.74735,0.901315 1.538529,1.756552 2.349937,2.585942 0.07529,0.07642 0.150594,0.159584 0.230386,0.236005 2.732041,2.739909 5.814719,5.042645 9.176107,6.881236 0.09215,0.0517 0.178689,0.10901 0.270844,0.15397 0.970992,0.52258 1.961091,0.99684 2.975914,1.43625 0.24949,0.10901 0.494486,0.22927 0.746225,0.33828 0.868724,0.35738 1.750934,0.67093 2.643259,0.96313 0.421437,0.14834 0.842875,0.29444 1.269932,0.42143 0.777693,0.23601 1.576739,0.42706 2.381405,0.61924 0.532697,0.12137 1.062023,0.25624 1.604835,0.36412 0.223643,0.0449 0.437171,0.10901 0.661939,0.1461 0.758587,0.13486 1.5183,0.21128 2.27464,0.30118 0.275339,0.0326 0.541688,0.0831 0.820399,0.10902 1.358715,0.13373 2.719679,0.22364 4.075024,0.22364 8.308506,0 16.409104,-2.54211 23.360018,-7.411686 2.215078,-1.552015 2.75789,-4.608845 1.199132,-6.823922 -1.553139,-2.222944 -4.616712,-2.759012 -6.82617,-1.206998 z" + id="path4" + inkscape:connector-curvature="0" + style="fill:#000000" /><path + d="M 91.499276,65.082295 C 91.492503,56.51643 88.831293,48.561931 84.298869,41.987501 84.234812,41.878489 84.189857,41.763858 84.113437,41.655969 83.551519,40.854675 82.93903,40.105078 82.325416,39.350985 82.255736,39.262201 82.19168,39.165553 82.115259,39.07677 77.971682,34.047611 72.762711,30.160269 66.864828,27.618156 c -0.165203,-0.06968 -0.325911,-0.146098 -0.485496,-0.2169 -0.944021,-0.388847 -1.907147,-0.733864 -2.87814,-1.054157 -0.351759,-0.118002 -0.695653,-0.242748 -1.047413,-0.350636 -0.849618,-0.25511 -1.704857,-0.459648 -2.573581,-0.663063 -0.478753,-0.107887 -0.950764,-0.230385 -1.43626,-0.325911 -0.234881,-0.04383 -0.465267,-0.115755 -0.700149,-0.159584 -0.64508,-0.112384 -1.290161,-0.160709 -1.941985,-0.242749 -0.446162,-0.05731 -0.887829,-0.128117 -1.333991,-0.173071 -1.086749,-0.102268 -2.165629,-0.146098 -3.24451,-0.162955 -0.196671,-0.0022 -0.385475,-0.0281 -0.579898,-0.0281 -0.03821,0 -0.0708,0.009 -0.105641,0.01348 -8.29502,0.0057 -16.383256,2.508398 -23.32518,7.373477 -2.218449,1.550891 -2.756766,4.609968 -1.201378,6.827293 1.549767,2.217324 4.60772,2.756765 6.826168,1.202503 5.361814,-3.753607 11.621571,-5.658506 18.036416,-5.597819 0.919297,0.0057 1.827355,0.05058 2.725298,0.137108 0.274217,0.0281 0.548432,0.06968 0.823771,0.10564 0.740607,0.08878 1.474471,0.191052 2.18923,0.331531 0.318045,0.06406 0.631594,0.147222 0.94402,0.216901 0.70914,0.160708 1.417155,0.332655 2.107189,0.542812 0.215777,0.06406 0.433801,0.146098 0.649577,0.216899 0.792303,0.258482 1.57112,0.537193 2.330832,0.856362 0.07642,0.03147 0.152841,0.0708 0.229262,0.101145 4.570634,1.96671 8.580475,4.992072 11.706982,8.778269 0.02023,0.02247 0.03821,0.05058 0.05843,0.07193 4.397563,5.359566 7.047564,12.208212 7.053183,19.663729 l -8.177018,0 13.080307,19.609783 13.069066,-19.609783 -8.164653,0 z" + id="path6" + inkscape:connector-curvature="0" + style="fill:#000000" /></svg> \ No newline at end of file diff --git a/res/ui/network_tab.ui b/res/ui/network_tab.ui index 9398b9b6..25edc665 100644 --- a/res/ui/network_tab.ui +++ b/res/ui/network_tab.ui @@ -16,6 +16,43 @@ <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="topMargin"> + <number>6</number> + </property> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="button_manual_refresh"> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="../icons/icons.qrc"> + <normaloff>:/icons/refresh_icon</normaloff>:/icons/refresh_icon</iconset> + </property> + <property name="iconSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + </widget> + </item> + </layout> + </item> <item> <widget class="QTableView" name="table_network"> <property name="contextMenuPolicy"> @@ -48,7 +85,9 @@ </item> </layout> </widget> - <resources/> + <resources> + <include location="../icons/icons.qrc"/> + </resources> <connections> <connection> <sender>table_network</sender> @@ -66,8 +105,25 @@ </hint> </hints> </connection> + <connection> + <sender>button_manual_refresh</sender> + <signal>clicked()</signal> + <receiver>NetworkTabWidget</receiver> + <slot>manual_nodes_refresh()</slot> + <hints> + <hint type="sourcelabel"> + <x>373</x> + <y>28</y> + </hint> + <hint type="destinationlabel"> + <x>199</x> + <y>149</y> + </hint> + </hints> + </connection> </connections> <slots> <slot>node_context_menu()</slot> + <slot>manual_nodes_refresh()</slot> </slots> </ui> diff --git a/src/cutecoin/core/net/network.py b/src/cutecoin/core/net/network.py index f9c3890b..ccb4716e 100644 --- a/src/cutecoin/core/net/network.py +++ b/src/cutecoin/core/net/network.py @@ -186,6 +186,11 @@ class Network(QObject): node = self.nodes[index] return self._root_nodes.index(node) + @asyncio.coroutine + def refresh_once(self): + for node in self.nodes: + node.refresh() + @asyncio.coroutine def discover_network(self): """ diff --git a/src/cutecoin/gui/network_tab.py b/src/cutecoin/gui/network_tab.py index 6f30a4cf..f38eebbb 100644 --- a/src/cutecoin/gui/network_tab.py +++ b/src/cutecoin/gui/network_tab.py @@ -5,6 +5,8 @@ Created on 20 févr. 2015 """ import logging +import asyncio + from PyQt5.QtGui import QCursor, QDesktopServices from PyQt5.QtWidgets import QWidget, QMenu, QAction from PyQt5.QtCore import Qt, QModelIndex, pyqtSlot, QUrl @@ -93,5 +95,7 @@ class NetworkTabWidget(QWidget, Ui_NetworkTabWidget): url = QUrl(peering.reverse_url("/peering")) QDesktopServices.openUrl(url) + def manual_nodes_refresh(self): + asyncio.async(self.community.network.refresh_once()) -- GitLab