From 5ff086b9c316bcc568054d8b3ee977e3986364db Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Sat, 24 Jan 2015 20:33:05 +0100 Subject: [PATCH] Added renew membership + warning when leaving a community --- res/ui/community_tab.ui | 32 +++++++++++--- src/cutecoin/gui/community_tab.py | 51 +++++++++++++---------- src/cutecoin/gui/process_cfg_community.py | 6 +-- 3 files changed, 57 insertions(+), 32 deletions(-) diff --git a/res/ui/community_tab.ui b/res/ui/community_tab.ui index 34d9f84b..e6b722a8 100644 --- a/res/ui/community_tab.ui +++ b/res/ui/community_tab.ui @@ -57,6 +57,19 @@ <property name="topMargin"> <number>5</number> </property> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> <item> <widget class="QLabel" name="label_quality"> <property name="text"> @@ -67,7 +80,14 @@ <item> <widget class="QPushButton" name="button_membership"> <property name="text"> - <string>Send membership demand</string> + <string>Renew membership</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="button_leaving"> + <property name="text"> + <string>Send leaving demand</string> </property> </widget> </item> @@ -92,8 +112,8 @@ <slot>send_membership_demand()</slot> <hints> <hint type="sourcelabel"> - <x>289</x> - <y>277</y> + <x>198</x> + <y>335</y> </hint> <hint type="destinationlabel"> <x>199</x> @@ -102,14 +122,14 @@ </hints> </connection> <connection> - <sender>button_membership</sender> + <sender>button_leaving</sender> <signal>clicked()</signal> <receiver>CommunityTabWidget</receiver> <slot>send_membership_leaving()</slot> <hints> <hint type="sourcelabel"> - <x>289</x> - <y>277</y> + <x>338</x> + <y>335</y> </hint> <hint type="destinationlabel"> <x>199</x> diff --git a/src/cutecoin/gui/community_tab.py b/src/cutecoin/gui/community_tab.py index 674b4548..752ef8f9 100644 --- a/src/cutecoin/gui/community_tab.py +++ b/src/cutecoin/gui/community_tab.py @@ -13,6 +13,7 @@ from ..gen_resources.community_tab_uic import Ui_CommunityTabWidget from .add_contact import AddContactDialog from .wot_tab import WotTabWidget from .transfer import TransferMoneyDialog +from .password_asker import PasswordAskerDialog from .certification import CertificationDialog from ..tools.exceptions import PersonNotFoundError, NoPeerAvailable @@ -33,14 +34,12 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): self.account = account self.password_asker = password_asker self.list_community_members.setModel(MembersListModel(community)) - self.button_membership.disconnect() if self.account.member_of(self.community): - self.button_membership.setText("Send leaving demand") - self.button_membership.clicked.connect(self.send_membership_leaving) + self.button_membership.setText("Renew membership") else: self.button_membership.setText("Send membership demand") - self.button_membership.clicked.connect(self.send_membership_demand) + self.button_leaving.hide() self.tabs_information.addTab(WotTabWidget(account, community, password_asker), @@ -121,23 +120,29 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): QMessageBox.Ok) def send_membership_leaving(self): - password = self.password_asker.ask() - if password == "": - return - - try: - self.account.send_membership(password, self.community, 'OUT') - QMessageBox.information(self, "Membership", - "Success sending leaving demand") - except ValueError as e: - QMessageBox.critical(self, "Leaving demand error", - e.message) - except NoPeerAvailable as e: - QMessageBox.critical(self, "Network error", - "Couldn't connect to network : {0}".format(e), - QMessageBox.Ok) - except Exception as e: - QMessageBox.critical(self, "Error", - "{0}".format(e), - QMessageBox.Ok) + reply = QMessageBox.warning(self, "Warning", + """Are you sure ? +Sending a membership demand cannot be canceled. +The process to join back the community later will have to be done again.""" +.format(self.account.pubkey), QMessageBox.Ok | QMessageBox.Cancel) + if reply == QMessageBox.Ok: + password = PasswordAskerDialog(self.app.current_account).ask() + if password == "": + return + + try: + self.account.send_membership(password, self.community, 'OUT') + QMessageBox.information(self, "Membership", + "Success sending leaving demand") + except ValueError as e: + QMessageBox.critical(self, "Leaving demand error", + e.message) + except NoPeerAvailable as e: + QMessageBox.critical(self, "Network error", + "Couldn't connect to network : {0}".format(e), + QMessageBox.Ok) + except Exception as e: + QMessageBox.critical(self, "Error", + "{0}".format(e), + QMessageBox.Ok) diff --git a/src/cutecoin/gui/process_cfg_community.py b/src/cutecoin/gui/process_cfg_community.py index 8cbf6230..fd36c316 100644 --- a/src/cutecoin/gui/process_cfg_community.py +++ b/src/cutecoin/gui/process_cfg_community.py @@ -175,9 +175,9 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): Person.lookup(self.account.pubkey, self.community, cached=False) except PersonNotFoundError as e: reply = QMessageBox.question(self, "Pubkey not found", - "The public key of your account wasn't found in the community. :\n \ - {0}\n \ - Would you like to publish the key ?".format(self.account.pubkey)) + """The public key of your account wasn't found in the community. :\n +{0}\n +Would you like to publish the key ?""".format(self.account.pubkey)) if reply == QMessageBox.Yes: password = self.password_asker.ask() if password == "": -- GitLab