diff --git a/src/cutecoin/gui/community_tab.py b/src/cutecoin/gui/community_tab.py index 1847b6e14331cbe06d21cffc57618fadadeabfe2..97e5ad2a3d048ecc2754ea11663b9cde2bfc6be1 100644 --- a/src/cutecoin/gui/community_tab.py +++ b/src/cutecoin/gui/community_tab.py @@ -49,7 +49,7 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): self.button_membership.setText("Send membership demand") self.button_leaving.hide() - self.wot_tab = WotTabWidget(account, community, password_asker) + self.wot_tab = WotTabWidget(account, community, password_asker, self) self.tabs_information.addTab(self.wot_tab, QIcon(':/icons/wot_icon'), "Wot") def member_context_menu(self, point): @@ -65,15 +65,15 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): menu = QMenu(self) add_contact = QAction("Add as contact", self) - add_contact.triggered.connect(self.add_member_as_contact) + add_contact.triggered.connect(self.menu_add_as_contact) add_contact.setData(member) send_money = QAction("Send money", self) - send_money.triggered.connect(self.send_money_to_member) + send_money.triggered.connect(self.menu_send_money) send_money.setData(member) certify = QAction("Certify identity", self) - certify.triggered.connect(self.certify_member) + certify.triggered.connect(self.menu_certify_member) certify.setData(member) view_wot = QAction("View in WoT", self) @@ -88,16 +88,26 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): # Show the context menu. menu.exec_(QCursor.pos()) - def add_member_as_contact(self): + def menu_add_as_contact(self): person = self.sender().data() + self.add_member_as_contact(person) + + def menu_send_money(self): + person = self.sender().data() + self.send_money_to_member(person) + + def menu_certify_member(self): + person = self.sender().data() + self.certify_member(person) + + def add_member_as_contact(self, person): dialog = ConfigureContactDialog(self.account, self.window(), person) result = dialog.exec_() if result == QDialog.Accepted: self.window().refresh_contacts() - def send_money_to_member(self): + def send_money_to_member(self, person): dialog = TransferMoneyDialog(self.account, self.password_asker) - person = self.sender().data() dialog.edit_pubkey.setText(person.pubkey) dialog.combo_community.setCurrentText(self.community.name()) dialog.radio_pubkey.setChecked(True) @@ -105,9 +115,8 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): currency_tab = self.window().currencies_tabwidget.currentWidget() currency_tab.table_history.model().invalidate() - def certify_member(self): + def certify_member(self, person): dialog = CertificationDialog(self.account, self.password_asker) - person = self.sender().data() dialog.combo_community.setCurrentText(self.community.name()) dialog.edit_pubkey.setText(person.pubkey) dialog.radio_pubkey.setChecked(True) diff --git a/src/cutecoin/gui/contact.py b/src/cutecoin/gui/contact.py index 3a0cd82de7d6b45a7611f3a45e544fb77a48d89f..469b9fb88839af42fc85ed08fdc1c20c8839a92d 100644 --- a/src/cutecoin/gui/contact.py +++ b/src/cutecoin/gui/contact.py @@ -16,7 +16,7 @@ class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog): classdocs ''' - def __init__(self, account, parent=None, contact=None): + def __init__(self, account, parent=None, contact=None, edit=False): ''' Constructor ''' @@ -28,8 +28,8 @@ class ConfigureContactDialog(QDialog, Ui_ConfigureContactDialog): if contact: self.edit_name.setText(contact.name) self.edit_pubkey.setText(contact.pubkey) - - self.button_box.button(QDialogButtonBox.Ok).setEnabled(False) + if edit: + self.button_box.button(QDialogButtonBox.Ok).setEnabled(False) def accept(self): name = self.edit_name.text() diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index bb7d1c9a63a69acd9bfd62b09d4b7f8d83b53a5a..e2d776610600a9cce4320ba8e2e0455dd562749d 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -138,7 +138,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): @pyqtSlot() def edit_contact(self): contact = self.sender().data() - dialog = ConfigureContactDialog(self.app.current_account, self, contact) + dialog = ConfigureContactDialog(self.app.current_account, self, contact, True) result = dialog.exec_() if result == QDialog.Accepted: self.window().refresh_contacts() diff --git a/src/cutecoin/gui/wot_tab.py b/src/cutecoin/gui/wot_tab.py index df97f6d214856e350f71d65e32dab1372ee2efaf..9933e02296d0e8b6977efebab5228977625bb75c 100644 --- a/src/cutecoin/gui/wot_tab.py +++ b/src/cutecoin/gui/wot_tab.py @@ -23,6 +23,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): :return: """ super().__init__(parent) + self.parent = parent # construct from qtDesigner self.setupUi(self) @@ -60,7 +61,7 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): :param dict metadata: Graph node metadata of the identity """ # create Person from node metadata - person = Person(metadata['text'], metadata['id']) + person = self.get_person_from_metadata(metadata) certifiers = person.certifiers_of(self.community) # reset graph @@ -230,32 +231,19 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): ) def sign_node(self, metadata): - # open certify dialog - dialog = CertificationDialog(self.account, self.password_asker) - dialog.combo_community.setCurrentText(self.community.name()) - dialog.edit_pubkey.setText(metadata['id']) - dialog.radio_pubkey.setChecked(True) - dialog.combo_community.setCurrentText(self.community.name()) - dialog.exec_() + person = self.get_person_from_metadata(metadata) + self.parent.certify_member(person) def send_money_to_node(self, metadata): - dialog = TransferMoneyDialog(self.account, self.password_asker) - dialog.edit_pubkey.setText(metadata['id']) - dialog.combo_community.setCurrentText(self.community.name()) - dialog.radio_pubkey.setChecked(True) - - if dialog.exec_() == QDialog.Accepted: - currency_tab = self.window().currencies_tabwidget.currentWidget() - currency_tab.table_history.model().invalidate() + person = self.get_person_from_metadata(metadata) + self.parent.send_money_to_member(person) def add_node_as_contact(self, metadata): # check if contact already exists... if metadata['id'] == self.account.pubkey or metadata['id'] in [contact.pubkey for contact in self.account.contacts]: return False - dialog = ConfigureContactDialog(self.account, self.window()) - dialog.edit_name.setText(metadata['text']) - dialog.edit_pubkey.setText(metadata['id']) - dialog.exec_() + person = self.get_person_from_metadata(metadata) + self.parent.add_member_as_contact(person) def get_block_mediantime(self, number): try: @@ -264,3 +252,6 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): logging.debug('community.get_block request error : ' + str(e)) return False return block.mediantime + + def get_person_from_metadata(self, metadata): + return Person(metadata['text'], metadata['id'])