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

Fix right click in top button views

parent 996477da
Branches
Tags
No related merge requests found
import asyncio
from PyQt5.QtCore import Qt, QObject, pyqtSignal from PyQt5.QtCore import Qt, QObject, pyqtSignal
from PyQt5.QtWidgets import QApplication, QDialog, QVBoxLayout from PyQt5.QtWidgets import QApplication, QDialog, QVBoxLayout
...@@ -90,10 +88,10 @@ class CertificationController(QObject): ...@@ -90,10 +88,10 @@ class CertificationController(QObject):
dialog.layout().addWidget(certification.view) dialog.layout().addWidget(certification.view)
certification.accepted.connect(dialog.accept) certification.accepted.connect(dialog.accept)
certification.rejected.connect(dialog.reject) certification.rejected.connect(dialog.reject)
return certification.exec() return dialog.exec()
@classmethod @classmethod
async def certify_identity(cls, parent, app, connection, identity): def certify_identity(cls, parent, app, connection, identity):
""" """
Certify and identity Certify and identity
:param sakia.gui.component.controller.ComponentController parent: the parent :param sakia.gui.component.controller.ComponentController parent: the parent
...@@ -102,11 +100,18 @@ class CertificationController(QObject): ...@@ -102,11 +100,18 @@ class CertificationController(QObject):
:param sakia.data.entities.Identity identity: the identity certified :param sakia.data.entities.Identity identity: the identity certified
:return: :return:
""" """
dialog = cls.create(parent, app) dialog = QDialog(parent)
dialog.view.combo_connections.setCurrentText(connection.title()) dialog.setWindowTitle(dialog.tr("Certification"))
dialog.user_information.change_identity(identity) dialog.setLayout(QVBoxLayout(dialog))
dialog.refresh() certification = cls.create(parent, app)
return await dialog.async_exec() if connection:
certification.view.combo_connections.setCurrentText(connection.title())
certification.user_information.change_identity(identity)
certification.refresh()
dialog.layout().addWidget(certification.view)
certification.accepted.connect(dialog.accept)
certification.rejected.connect(dialog.reject)
return dialog.exec()
def change_connection(self, index): def change_connection(self, index):
self.model.set_connection(index) self.model.set_connection(index)
...@@ -154,15 +159,14 @@ using cross checking which will help to reveal the problem if needs to be.</br>" ...@@ -154,15 +159,14 @@ using cross checking which will help to reveal the problem if needs to be.</br>"
if result[0]: if result[0]:
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()
await self.view.show_success(self.model.notification()) await self.view.show_success(self.model.notification())
self.view.accept() self.accepted.emit()
else: else:
await self.view.show_error(self.model.notification(), result[1]) await self.view.show_error(self.model.notification(), result[1])
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()
self.view.button_box.setEnabled(True) self.view.button_box.setEnabled(True)
@asyncify def reject(self):
async def reject(self): self.rejected.emit()
self.view.reject()
def refresh(self): def refresh(self):
stock = self.model.get_cert_stock() stock = self.model.get_cert_stock()
...@@ -208,14 +212,3 @@ using cross checking which will help to reveal the problem if needs to be.</br>" ...@@ -208,14 +212,3 @@ using cross checking which will help to reveal the problem if needs to be.</br>"
Refresh user information Refresh user information
""" """
self.user_information.search_identity(self.search_user.model.identity()) self.user_information.search_identity(self.search_user.model.identity())
def async_exec(self):
future = asyncio.Future()
self.view.finished.connect(lambda r: future.set_result(r))
self.view.open()
self.refresh()
return future
def exec(self):
self.refresh()
self.view.exec()
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QFileDialog, QMessageBox from PyQt5.QtWidgets import QWidget, QDialogButtonBox, QFileDialog, QMessageBox
from PyQt5.QtCore import QT_TRANSLATE_NOOP, Qt, pyqtSignal from PyQt5.QtCore import QT_TRANSLATE_NOOP, Qt, pyqtSignal
from .certification_uic import Ui_CertificationWidget from .certification_uic import Ui_CertificationWidget
from sakia.gui.widgets import toast from sakia.gui.widgets import toast
...@@ -8,7 +8,7 @@ from duniterpy.documents import Identity, MalformedDocumentError ...@@ -8,7 +8,7 @@ from duniterpy.documents import Identity, MalformedDocumentError
from enum import Enum from enum import Enum
class CertificationView(QDialog, Ui_CertificationWidget): class CertificationView(QWidget, Ui_CertificationWidget):
""" """
The view of the certification component The view of the certification component
""" """
......
...@@ -83,6 +83,7 @@ class TransferController(QObject): ...@@ -83,6 +83,7 @@ class TransferController(QObject):
def open_transfer_with_pubkey(cls, parent, app, connection, pubkey): def open_transfer_with_pubkey(cls, parent, app, connection, pubkey):
transfer = cls.create(parent, app) transfer = cls.create(parent, app)
transfer.view.groupbox_connection.show() transfer.view.groupbox_connection.show()
if connection:
transfer.view.combo_connections.setCurrentText(connection.title()) transfer.view.combo_connections.setCurrentText(connection.title())
transfer.view.edit_pubkey.setText(pubkey) transfer.view.edit_pubkey.setText(pubkey)
transfer.view.radio_pubkey.setChecked(True) transfer.view.radio_pubkey.setChecked(True)
......
from PyQt5.QtWidgets import QDialog, QDialogButtonBox from PyQt5.QtWidgets import QWidget, QDialogButtonBox
from PyQt5.QtGui import QRegExpValidator from PyQt5.QtGui import QRegExpValidator
from PyQt5.QtCore import QT_TRANSLATE_NOOP, QRegExp from PyQt5.QtCore import QT_TRANSLATE_NOOP, QRegExp
from .transfer_uic import Ui_TransferMoneyWidget from .transfer_uic import Ui_TransferMoneyWidget
...@@ -7,7 +7,7 @@ from sakia.gui.widgets import toast ...@@ -7,7 +7,7 @@ from sakia.gui.widgets import toast
from sakia.gui.widgets.dialogs import QAsyncMessageBox from sakia.gui.widgets.dialogs import QAsyncMessageBox
class TransferView(QDialog, Ui_TransferMoneyWidget): class TransferView(QWidget, Ui_TransferMoneyWidget):
""" """
Transfer component view Transfer component view
""" """
......
...@@ -39,7 +39,7 @@ class ContextMenu(QObject): ...@@ -39,7 +39,7 @@ class ContextMenu(QObject):
informations.triggered.connect(lambda checked, i=identity: menu.informations(i)) informations.triggered.connect(lambda checked, i=identity: menu.informations(i))
menu.qmenu.addAction(informations) menu.qmenu.addAction(informations)
if identity.uid and menu._connection.pubkey != identity.pubkey: if identity.uid and (not menu._connection or menu._connection.pubkey != identity.pubkey):
certify = QAction(menu.tr("Certify identity"), menu.qmenu.parent()) certify = QAction(menu.tr("Certify identity"), menu.qmenu.parent())
certify.triggered.connect(lambda checked, i=identity: menu.certify_identity(i)) certify.triggered.connect(lambda checked, i=identity: menu.certify_identity(i))
menu.qmenu.addAction(certify) menu.qmenu.addAction(certify)
...@@ -152,9 +152,8 @@ class ContextMenu(QObject): ...@@ -152,9 +152,8 @@ class ContextMenu(QObject):
def view_wot(self, identity): def view_wot(self, identity):
self.view_identity_in_wot.emit(identity) self.view_identity_in_wot.emit(identity)
@asyncify def certify_identity(self, identity):
async def certify_identity(self, identity): CertificationController.certify_identity(None, self._app, self._connection, identity)
await CertificationController.certify_identity(None, self._app, self._connection, identity)
def send_again(self, transfer): def send_again(self, transfer):
TransferController.send_transfer_again(None, self._app, self._connection, transfer) TransferController.send_transfer_again(None, self._app, self._connection, transfer)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment