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

Refactor constructor of MemberDialog

parent 29193820
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>399</width> <width>473</width>
<height>283</height> <height>373</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
...@@ -173,6 +173,14 @@ ...@@ -173,6 +173,14 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>User informations</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3"/>
</widget>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="button_box"> <widget class="QDialogButtonBox" name="button_box">
<property name="orientation"> <property name="orientation">
......
...@@ -516,7 +516,7 @@ class Account(QObject): ...@@ -516,7 +516,7 @@ class Account(QObject):
await r.release() await r.release()
return result return result
else: else:
return (False, self.tr("Could not find user self certification.")) return False, self.tr("Could not find user self certification.")
async def revoke(self, password, community): async def revoke(self, password, community):
""" """
......
import datetime import datetime
import asyncio import asyncio
from PyQt5.QtWidgets import QDialog from PyQt5.QtCore import QObject
from PyQt5.QtWidgets import QDialog, QWidget
from ..core.graph import WoTGraph from ..core.graph import WoTGraph
from ..tools.decorators import asyncify from ..tools.decorators import asyncify
...@@ -9,12 +10,12 @@ from ..gen_resources.member_uic import Ui_DialogMember ...@@ -9,12 +10,12 @@ from ..gen_resources.member_uic import Ui_DialogMember
from ..tools.exceptions import MembershipNotFoundError from ..tools.exceptions import MembershipNotFoundError
class MemberDialog(QDialog, Ui_DialogMember): class MemberDialog(QObject):
""" """
classdocs A widget showing informations about a member
""" """
def __init__(self, app, account, community, identity): def __init__(self, app, account, community, identity, widget, ui):
""" """
Init MemberDialog Init MemberDialog
...@@ -22,20 +23,31 @@ class MemberDialog(QDialog, Ui_DialogMember): ...@@ -22,20 +23,31 @@ class MemberDialog(QDialog, Ui_DialogMember):
:param sakia.core.account.Account account: Account instance :param sakia.core.account.Account account: Account instance
:param sakia.core.community.Community community: Community instance :param sakia.core.community.Community community: Community instance
:param sakia.core.registry.identity.Identity identity: Identity instance :param sakia.core.registry.identity.Identity identity: Identity instance
: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: :return:
""" """
super().__init__() super().__init__()
self.setupUi(self) self.widget = widget
self.ui = ui
self.ui.setupUi(self.widget)
self.app = app self.app = app
self.community = community self.community = community
self.account = account self.account = account
self.identity = identity self.identity = identity
self.label_uid.setText(identity.uid) self.ui.label_uid.setText(identity.uid)
self.refresh() self.refresh()
@classmethod
def open_dialog(cls, app, account, community, identity):
return cls(app, account, community, identity, QDialog(), Ui_DialogMember()).exec()
@classmethod
def as_widget(cls, app, account, community, identity):
return cls(app, account, community, identity, QWidget(), Ui_DialogMember())
@asyncify @asyncify
async def refresh(self): async def refresh(self):
try: try:
join_date = await self.identity.get_join_date(self.community) join_date = await self.identity.get_join_date(self.community)
except MembershipNotFoundError: except MembershipNotFoundError:
...@@ -90,4 +102,7 @@ class MemberDialog(QDialog, Ui_DialogMember): ...@@ -90,4 +102,7 @@ class MemberDialog(QDialog, Ui_DialogMember):
text += "</table>" text += "</table>"
# set text in label # set text in label
self.label_properties.setText(text) self.ui.label_properties.setText(text)
def exec(self):
self.widget.exec()
...@@ -119,8 +119,7 @@ class ContextMenu(QObject): ...@@ -119,8 +119,7 @@ class ContextMenu(QObject):
clipboard.setText(identity.pubkey) clipboard.setText(identity.pubkey)
def informations(self, identity): def informations(self, identity):
dialog = MemberDialog(self._app, self._account, self._community, identity) MemberDialog.open_dialog(self._app, self._account, self._community, identity)
dialog.exec_()
def add_as_contact(self, identity): def add_as_contact(self, identity):
dialog = ConfigureContactDialog.from_identity( self.parent(), self._account, identity) dialog = ConfigureContactDialog.from_identity( self.parent(), self._account, identity)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment