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

New local node manager feature

parent 3b4ae3b0
Branches
Tags
No related merge requests found
...@@ -66,8 +66,15 @@ ...@@ -66,8 +66,15 @@
</property> </property>
<addaction name="actionAbout"/> <addaction name="actionAbout"/>
</widget> </widget>
<widget class="QMenu" name="menuDuniter">
<property name="title">
<string>Dunit&amp;er</string>
</property>
<addaction name="actionManage_local_node"/>
</widget>
<addaction name="menu_file"/> <addaction name="menu_file"/>
<addaction name="menu_account"/> <addaction name="menu_account"/>
<addaction name="menuDuniter"/>
<addaction name="menu_help"/> <addaction name="menu_help"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
...@@ -176,6 +183,11 @@ ...@@ -176,6 +183,11 @@
<string>&amp;Add account</string> <string>&amp;Add account</string>
</property> </property>
</action> </action>
<action name="actionManage_local_node">
<property name="text">
<string>Manage local node</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../icons/icons.qrc"/> <include location="../icons/icons.qrc"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NodeManager</class>
<widget class="QDialog" name="NodeManager">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1024</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Node manager</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWebView" name="web_view">
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKitWidgets/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
...@@ -3,12 +3,12 @@ Created on 1 févr. 2014 ...@@ -3,12 +3,12 @@ Created on 1 févr. 2014
@author: inso @author: inso
""" """
import asyncio import aiohttp
import logging import logging
from PyQt5.QtWidgets import QMainWindow, QAction, QFileDialog, QMessageBox, QLabel, QComboBox, QDialog, QApplication from PyQt5.QtWidgets import QMainWindow, QAction, QFileDialog, QMessageBox, QLabel, QComboBox, QDialog, QApplication
from PyQt5.QtCore import QLocale, QEvent, \ from PyQt5.QtCore import QLocale, QEvent, \
pyqtSlot, QDateTime, QTimer, Qt, QObject pyqtSlot, QDateTime, QTimer, Qt, QObject, QUrl
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
from ..gen_resources.mainwindow_uic import Ui_MainWindow from ..gen_resources.mainwindow_uic import Ui_MainWindow
...@@ -23,6 +23,7 @@ from .password_asker import PasswordAskerDialog ...@@ -23,6 +23,7 @@ from .password_asker import PasswordAskerDialog
from .preferences import PreferencesDialog from .preferences import PreferencesDialog
from .process_cfg_community import ProcessConfigureCommunity from .process_cfg_community import ProcessConfigureCommunity
from .homescreen import HomeScreenWidget from .homescreen import HomeScreenWidget
from .node_manager import NodeManager
from ..core import money from ..core import money
from ..core.community import Community from ..core.community import Community
from ..tools.decorators import asyncify from ..tools.decorators import asyncify
...@@ -35,7 +36,8 @@ class MainWindow(QObject): ...@@ -35,7 +36,8 @@ class MainWindow(QObject):
classdocs classdocs
""" """
def __init__(self, app, account, homescreen, community_view, widget, ui, def __init__(self, app, account, homescreen, community_view, node_manager,
widget, ui,
label_icon, label_status, label_time, combo_referential, label_icon, label_status, label_time, combo_referential,
password_asker): password_asker):
""" """
...@@ -44,6 +46,7 @@ class MainWindow(QObject): ...@@ -44,6 +46,7 @@ class MainWindow(QObject):
:param sakia.core.Account account: the account :param sakia.core.Account account: the account
:param HomeScreenWidgetcreen homescreen: the homescreen :param HomeScreenWidgetcreen homescreen: the homescreen
:param CommunityView community_view: the community view :param CommunityView community_view: the community view
:param NodeManager node_manager: the local node manager dialog
:param QMainWindow widget: the widget of the main window :param QMainWindow widget: the widget of the main window
:param Ui_MainWindow ui: the ui of the widget :param Ui_MainWindow ui: the ui of the widget
:param QLabel label_icon: the label of the icon in the statusbar :param QLabel label_icon: the label of the icon in the statusbar
...@@ -82,6 +85,9 @@ class MainWindow(QObject): ...@@ -82,6 +85,9 @@ class MainWindow(QObject):
self.community_view = community_view self.community_view = community_view
self.node_manager = node_manager
def _init_ui(self): def _init_ui(self):
""" """
Connects elements of the UI to the local slots Connects elements of the UI to the local slots
...@@ -102,6 +108,8 @@ class MainWindow(QObject): ...@@ -102,6 +108,8 @@ class MainWindow(QObject):
self.ui.actionPreferences.triggered.connect(self.open_preferences_dialog) self.ui.actionPreferences.triggered.connect(self.open_preferences_dialog)
self.ui.actionAbout.triggered.connect(self.open_about_popup) self.ui.actionAbout.triggered.connect(self.open_about_popup)
self.ui.actionManage_local_node.triggered.connect(self.open_duniter_ui)
def _init_homescreen(self): def _init_homescreen(self):
""" """
Initialize homescreen signals/slots and data Initialize homescreen signals/slots and data
...@@ -132,8 +140,10 @@ class MainWindow(QObject): ...@@ -132,8 +140,10 @@ class MainWindow(QObject):
@classmethod @classmethod
def startup(cls, app): def startup(cls, app):
qmainwindow = QMainWindow() qmainwindow = QMainWindow()
main_window = cls(app, None, HomeScreenWidget(app, None), main_window = cls(app, None, HomeScreenWidget(app, None),
CommunityWidget(app, None, None), CommunityWidget(app, None, None),
NodeManager.create(qmainwindow),
qmainwindow, Ui_MainWindow(), qmainwindow, Ui_MainWindow(),
QLabel("", qmainwindow), QLabel("", qmainwindow), QLabel("", qmainwindow), QLabel("", qmainwindow),
QLabel("", qmainwindow), QComboBox(qmainwindow), QLabel("", qmainwindow), QComboBox(qmainwindow),
...@@ -347,6 +357,11 @@ class MainWindow(QObject): ...@@ -347,6 +357,11 @@ class MainWindow(QObject):
delete_action.setData(contact) delete_action.setData(contact)
delete_action.triggered.connect(self.delete_contact) delete_action.triggered.connect(self.delete_contact)
@asyncify
async def open_duniter_ui(self, checked=False):
if not self.node_manager.widget.isVisible():
self.node_manager.open_home_page()
def refresh(self): def refresh(self):
""" """
Refresh main window Refresh main window
......
import aiohttp
from PyQt5.QtCore import QObject, QEvent, QUrl
from PyQt5.QtWidgets import QDialog
from ..gen_resources.node_manager_uic import Ui_NodeManager
from .widgets.dialogs import QAsyncMessageBox
from ..tools.decorators import asyncify
class NodeManager(QObject):
"""
A widget showing informations about a member
"""
def __init__(self, widget, ui):
"""
Init MemberDialog
:param PyQt5.QtWidget widget: The class of the widget
:param sakia.gen_resources.member_uic.Ui_DialogMember ui: the class of the ui applyed to the widget
:return:
"""
super().__init__()
self.widget = widget
self.ui = ui
self.ui.setupUi(self.widget)
self.widget.installEventFilter(self)
@classmethod
def create(cls, parent):
dialog = cls(QDialog(parent), Ui_NodeManager())
return dialog
@asyncify
async def open_home_page(self):
try:
with aiohttp.ClientSession() as session:
response = await session.get("http://127.0.0.1:9220")
if response.status == 200:
self.ui.web_view.load(QUrl("http://127.0.0.1:9220"))
self.ui.web_view.show()
self.widget.show()
else:
await QAsyncMessageBox.critical(self.widget, "Local node manager",
"Could not access to local node ui.")
except aiohttp.ClientError:
await QAsyncMessageBox.critical(self.widget, "Local node manager",
"Could not connect to node. Please make sure it's running.")
def eventFilter(self, source, event):
if event.type() == QEvent.Resize:
self.widget.resizeEvent(event)
return self.widget.eventFilter(source, event)
def exec(self):
self.widget.exec()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment