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
No related branches found
No related tags found
No related merge requests found
import asyncio
from PyQt5.QtCore import Qt, QObject, pyqtSignal
from PyQt5.QtWidgets import QApplication, QDialog, QVBoxLayout
......@@ -90,10 +88,10 @@ class CertificationController(QObject):
dialog.layout().addWidget(certification.view)
certification.accepted.connect(dialog.accept)
certification.rejected.connect(dialog.reject)
return certification.exec()
return dialog.exec()
@classmethod
async def certify_identity(cls, parent, app, connection, identity):
def certify_identity(cls, parent, app, connection, identity):
"""
Certify and identity
:param sakia.gui.component.controller.ComponentController parent: the parent
......@@ -102,11 +100,18 @@ class CertificationController(QObject):
:param sakia.data.entities.Identity identity: the identity certified
:return:
"""
dialog = cls.create(parent, app)
dialog.view.combo_connections.setCurrentText(connection.title())
dialog.user_information.change_identity(identity)
dialog.refresh()
return await dialog.async_exec()
dialog = QDialog(parent)
dialog.setWindowTitle(dialog.tr("Certification"))
dialog.setLayout(QVBoxLayout(dialog))
certification = cls.create(parent, app)
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):
self.model.set_connection(index)
......@@ -154,15 +159,14 @@ using cross checking which will help to reveal the problem if needs to be.</br>"
if result[0]:
QApplication.restoreOverrideCursor()
await self.view.show_success(self.model.notification())
self.view.accept()
self.accepted.emit()
else:
await self.view.show_error(self.model.notification(), result[1])
QApplication.restoreOverrideCursor()
self.view.button_box.setEnabled(True)
@asyncify
async def reject(self):
self.view.reject()
def reject(self):
self.rejected.emit()
def refresh(self):
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>"
Refresh user information
"""
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 .certification_uic import Ui_CertificationWidget
from sakia.gui.widgets import toast
......@@ -8,7 +8,7 @@ from duniterpy.documents import Identity, MalformedDocumentError
from enum import Enum
class CertificationView(QDialog, Ui_CertificationWidget):
class CertificationView(QWidget, Ui_CertificationWidget):
"""
The view of the certification component
"""
......
......@@ -83,7 +83,8 @@ class TransferController(QObject):
def open_transfer_with_pubkey(cls, parent, app, connection, pubkey):
transfer = cls.create(parent, app)
transfer.view.groupbox_connection.show()
transfer.view.combo_connections.setCurrentText(connection.title())
if connection:
transfer.view.combo_connections.setCurrentText(connection.title())
transfer.view.edit_pubkey.setText(pubkey)
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.QtCore import QT_TRANSLATE_NOOP, QRegExp
from .transfer_uic import Ui_TransferMoneyWidget
......@@ -7,7 +7,7 @@ from sakia.gui.widgets import toast
from sakia.gui.widgets.dialogs import QAsyncMessageBox
class TransferView(QDialog, Ui_TransferMoneyWidget):
class TransferView(QWidget, Ui_TransferMoneyWidget):
"""
Transfer component view
"""
......
......@@ -39,7 +39,7 @@ class ContextMenu(QObject):
informations.triggered.connect(lambda checked, i=identity: menu.informations(i))
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.triggered.connect(lambda checked, i=identity: menu.certify_identity(i))
menu.qmenu.addAction(certify)
......@@ -152,9 +152,8 @@ class ContextMenu(QObject):
def view_wot(self, identity):
self.view_identity_in_wot.emit(identity)
@asyncify
async def certify_identity(self, identity):
await CertificationController.certify_identity(None, self._app, self._connection, identity)
def certify_identity(self, identity):
CertificationController.certify_identity(None, self._app, self._connection, identity)
def send_again(self, 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.
Finish editing this message first!
Please register or to comment