diff --git a/src/sakia/gui/contact.py b/src/sakia/gui/contact.py index 43ed578a94f1796be9abc7bc7031a7bae512f9d2..04fcfb8ab976dbf46c7a1a7979e3e16af433272b 100644 --- a/src/sakia/gui/contact.py +++ b/src/sakia/gui/contact.py @@ -20,7 +20,13 @@ class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog): 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) self.setupUi(self) @@ -45,6 +51,21 @@ class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog): } 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): name = self.edit_name.text() pubkey = self.edit_pubkey.text() diff --git a/src/sakia/gui/mainwindow.py b/src/sakia/gui/mainwindow.py index e17df1194b87e0e1030e57a56b7f004a88b413ab..842484ec6172a244cb6fbc4a3b8375c1739f56d3 100644 --- a/src/sakia/gui/mainwindow.py +++ b/src/sakia/gui/mainwindow.py @@ -213,12 +213,12 @@ class MainWindow(QObject): @pyqtSlot() def delete_contact(self): contact = self.sender().data() - self.account.remove_contacts(contact) + self.account.remove_contact(contact) @pyqtSlot() def edit_contact(self): 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_() def action_change_account(self, account_name): @@ -249,7 +249,7 @@ class MainWindow(QObject): self.password_asker) 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_() def open_preferences_dialog(self):