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

Fix bug #373 with contact dialog

parent be91490d
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,13 @@ class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog): ...@@ -20,7 +20,13 @@ class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog):
def __init__(self, app, account, parent=None, contact=None, index_edit=None): def __init__(self, app, account, parent=None, contact=None, index_edit=None):
""" """
Constructor Open the dialog to create a new contact
:param sakia.core.Application app: the application
:param sakia.core.Account account: the account
:param PyQt5.QtWidgets.QWidget parent: the parent widget
:param dict contact: the contact with a key 'name' and a key 'pubkey'
:param int index_edit: the index of the edited contact in the account contacts list
:return:
""" """
super().__init__(parent) super().__init__(parent)
self.setupUi(self) self.setupUi(self)
...@@ -45,6 +51,21 @@ class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog): ...@@ -45,6 +51,21 @@ class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog):
} }
return ConfigureContactDialog(app, account, parent, contact) return ConfigureContactDialog(app, account, parent, contact)
@classmethod
def new_contact(cls, app, account, parent):
"""
Open the dialog to create a new contact
:param sakia.core.Application app: the application
:param sakia.core.Account account: the account
:param PyQt5.QtWidgets.QWidget parent: the parent widget
:return:
"""
return ConfigureContactDialog(app, account, parent)
@classmethod
def edit_contact(cls, app, parent, account, index):
return ConfigureContactDialog(app, account, parent, None, index)
def accept(self): def accept(self):
name = self.edit_name.text() name = self.edit_name.text()
pubkey = self.edit_pubkey.text() pubkey = self.edit_pubkey.text()
......
...@@ -213,12 +213,12 @@ class MainWindow(QObject): ...@@ -213,12 +213,12 @@ class MainWindow(QObject):
@pyqtSlot() @pyqtSlot()
def delete_contact(self): def delete_contact(self):
contact = self.sender().data() contact = self.sender().data()
self.account.remove_contacts(contact) self.account.remove_contact(contact)
@pyqtSlot() @pyqtSlot()
def edit_contact(self): def edit_contact(self):
index = self.sender().data() index = self.sender().data()
dialog = ConfigureContactDialog(self.app, self.account, self, None, index) dialog = ConfigureContactDialog.edit_contact(self.app, self.account, self.widget, index)
dialog.exec_() dialog.exec_()
def action_change_account(self, account_name): def action_change_account(self, account_name):
...@@ -249,7 +249,7 @@ class MainWindow(QObject): ...@@ -249,7 +249,7 @@ class MainWindow(QObject):
self.password_asker) self.password_asker)
def open_add_contact_dialog(self): def open_add_contact_dialog(self):
dialog = ConfigureContactDialog(self.app, self.account, self) dialog = ConfigureContactDialog.new_contact(self.app, self.account, self.widget)
dialog.exec_() dialog.exec_()
def open_preferences_dialog(self): def open_preferences_dialog(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment