diff --git a/src/cutecoin/gui/community_view.py b/src/cutecoin/gui/community_view.py index ffba895d12ffe2b3618194a10e38501e8cacbc61..b76ed0161cdf9b1b24b5cbde6c9c5ba326b3ea5a 100644 --- a/src/cutecoin/gui/community_view.py +++ b/src/cutecoin/gui/community_view.py @@ -63,11 +63,11 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): QIcon(':/icons/tx_icon'), self.tr("Transactions")) - self.tabs.addTab(self.tab_identities, + self.tabs.addTab(self.tab_wot, QIcon(':/icons/wot_icon'), self.tr("Web of Trust")) - self.tabs.addTab(self.tab_wot, + self.tabs.addTab(self.tab_identities, QIcon(':/icons/members_icon'), self.tr("Search Identities")) @@ -81,15 +81,21 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): self.tab_identities.change_account(account) def change_community(self, community): - self.community = community self.tab_network.change_community(community) self.tab_wot.change_community(community) self.tab_history.change_community(community) self.tab_identities.change_community(community) - self.community.network.new_block_mined.connect(self.refresh_block) - self.community.network.nodes_changed.connect(self.refresh_status) - self.community.inner_data_changed.connect(self.refresh_status) + if self.community: + self.community.network.new_block_mined.disconnect(self.refresh_block) + self.community.network.nodes_changed.disconnect(self.refresh_status) + self.community.inner_data_changed.disconnect(self.refresh_status) + if community: + community.network.new_block_mined.connect(self.refresh_block) + community.network.nodes_changed.connect(self.refresh_status) + community.inner_data_changed.connect(self.refresh_status) + self.label_currency.setText(community.currency) + self.community = community @pyqtSlot(str) def display_error(self, error): @@ -188,7 +194,7 @@ class CommunityWidget(QWidget, Ui_CommunityWidget): self.refresh_status() def referential_changed(self): - if self.tab_history.table_history.model(): + if self.community and self.tab_history.table_history.model(): self.tab_history.table_history.model().dataChanged.emit( QModelIndex(), QModelIndex(), diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index d15d5147ddcba63ad982cba8c3e1941283523d79..b7fec5a56ccce28460ea8469486ab93d0f0c1ce9 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -71,8 +71,10 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.homescreen.toolbutton_new_account.addAction(self.action_import) self.homescreen.button_disconnect.clicked.connect(lambda :self.action_change_account("")) self.centralWidget().layout().addWidget(self.homescreen) + self.homescreen.toolbutton_connect.setMenu(self.menu_change_account) self.community_view = CommunityWidget(self.app, self.status_label) + self.community_view.button_home.clicked.connect(lambda: self.change_community(None)) self.community_view.button_certification.clicked.connect(self.open_certification_dialog) self.community_view.button_send_money.clicked.connect(self.open_transfer_money_dialog) self.centralWidget().layout().addWidget(self.community_view) @@ -236,9 +238,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): @pyqtSlot(Community) def change_community(self, community): - logging.debug("Change on tile") - self.homescreen.hide() - self.community_view.show() + if self.community_view.community: + self.community_view.community.stop_coroutines() + + if community: + self.homescreen.hide() + self.community_view.show() + else: + self.homescreen.show() + self.community_view.hide() + self.community_view.change_community(community) def refresh_accounts(self): @@ -247,7 +256,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): action = QAction(account_name, self) action.triggered.connect(lambda checked, account_name=account_name: self.action_change_account(account_name)) self.menu_change_account.addAction(action) - self.homescreen.toolbutton_connect.addAction(action) def refresh_contacts(self): self.menu_contacts_list.clear() @@ -275,9 +283,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): if self.app.current_account is None: self.setWindowTitle(self.tr("CuteCoin {0}").format(__version__)) - self.menu_account.setEnabled(False) + self.action_add_a_contact.setEnabled(False) + self.actionCertification.setEnabled(False) + self.actionTransfer_money.setEnabled(False) self.action_configure_parameters.setEnabled(False) self.action_set_as_default.setEnabled(False) + self.menu_contacts_list.setEnabled(False) self.combo_referential.setEnabled(False) self.status_label.setText(self.tr("")) self.password_asker = None @@ -293,7 +304,10 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.combo_referential.blockSignals(False) logging.debug(self.app.preferences) self.combo_referential.setCurrentIndex(self.app.preferences['ref']) - self.menu_account.setEnabled(True) + self.action_add_a_contact.setEnabled(True) + self.actionCertification.setEnabled(True) + self.actionTransfer_money.setEnabled(True) + self.menu_contacts_list.setEnabled(True) self.action_configure_parameters.setEnabled(True) self.setWindowTitle(self.tr("CuteCoin {0} - Account : {1}").format(__version__, self.app.current_account.name)) diff --git a/src/cutecoin/gui/network_tab.py b/src/cutecoin/gui/network_tab.py index 8021fa81a7c33d738d715fd575d772f820a25df0..0c0e73c657765c123246e13c95263231d0cab2f9 100644 --- a/src/cutecoin/gui/network_tab.py +++ b/src/cutecoin/gui/network_tab.py @@ -41,9 +41,13 @@ class NetworkTabWidget(QWidget, Ui_NetworkTabWidget): self.table_network.resizeColumnsToContents() def change_community(self, community): + if community: + community.network.nodes_changed.connect(self.refresh_nodes) + if self.community: + self.community.network.nodes_changed.disconnect(self.refresh_nodes) + self.community = community self.table_network.model().change_community(community) - community.network.nodes_changed.connect(self.refresh_nodes) @pyqtSlot() def refresh_nodes(self): diff --git a/src/cutecoin/gui/transactions_tab.py b/src/cutecoin/gui/transactions_tab.py index d277810023e316f810b2b6f7edc84c143f5d9c79..5ef5cf9acadeb754d3d33623bfd9f9f6241eaaef 100644 --- a/src/cutecoin/gui/transactions_tab.py +++ b/src/cutecoin/gui/transactions_tab.py @@ -35,9 +35,12 @@ class TransactionsTabWidget(QWidget, Ui_transactionsTabWidget): self.refresh() def change_community(self, community): + if self.community: + self.community.inner_data_changed.disconnect(self.refresh_minimum_maximum) + if community: + community.inner_data_changed.connect(self.refresh_minimum_maximum) self.community = community self.refresh() - self.community.inner_data_changed.connect(self.refresh_minimum_maximum) def refresh_minimum_maximum(self): block = self.community.get_block(1) diff --git a/src/cutecoin/gui/wot_tab.py b/src/cutecoin/gui/wot_tab.py index c2d436721a00f2f7157d745da98593989bc5e711..16b7f83495484747ab40480a3de6c9d9f3c5119f 100644 --- a/src/cutecoin/gui/wot_tab.py +++ b/src/cutecoin/gui/wot_tab.py @@ -52,9 +52,12 @@ class WotTabWidget(QWidget, Ui_WotTabWidget): self.account = account def change_community(self, community): + if self.community: + self.community.network.new_block_mined.disconnect(self.refresh) + if community: + community.network.new_block_mined.connect(self.refresh) self.community = community self.reset() - self.community.network.new_block_mined.connect(self.refresh) def refresh_informations_frame(self): parameters = self.community.parameters