From 5d7aa492832d14cd951f867552059fbfb1a15ab0 Mon Sep 17 00:00:00 2001 From: Inso <insomniak.fr@gmail.com> Date: Fri, 1 May 2015 15:37:30 +0200 Subject: [PATCH] Added actions to the search button to look for members or direct connections --- res/ui/community_tab.ui | 18 ++++++++++++------ src/cutecoin/gui/community_tab.py | 28 +++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/res/ui/community_tab.ui b/res/ui/community_tab.ui index 287487df..9b000559 100644 --- a/res/ui/community_tab.ui +++ b/res/ui/community_tab.ui @@ -55,9 +55,15 @@ </widget> </item> <item> - <widget class="QPushButton" name="button_search"> + <widget class="QToolButton" name="button_search"> <property name="text"> - <string>Search...</string> + <string>Search</string> + </property> + <property name="popupMode"> + <enum>QToolButton::MenuButtonPopup</enum> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> </property> </widget> </item> @@ -177,7 +183,7 @@ <sender>edit_textsearch</sender> <signal>returnPressed()</signal> <receiver>CommunityTabWidget</receiver> - <slot>search()</slot> + <slot>search_text()</slot> <hints> <hint type="sourcelabel"> <x>170</x> @@ -193,10 +199,10 @@ <sender>button_search</sender> <signal>clicked()</signal> <receiver>CommunityTabWidget</receiver> - <slot>search()</slot> + <slot>search_text()</slot> <hints> <hint type="sourcelabel"> - <x>370</x> + <x>371</x> <y>62</y> </hint> <hint type="destinationlabel"> @@ -210,6 +216,6 @@ <slot>identity_context_menu(QPoint)</slot> <slot>send_membership_demand()</slot> <slot>send_membership_leaving()</slot> - <slot>search()</slot> + <slot>search_text()</slot> </slots> </ui> diff --git a/src/cutecoin/gui/community_tab.py b/src/cutecoin/gui/community_tab.py index ef0995bd..c26b2bee 100644 --- a/src/cutecoin/gui/community_tab.py +++ b/src/cutecoin/gui/community_tab.py @@ -59,6 +59,12 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): self.wot_tab = WotTabWidget(app, account, community, password_asker, self) self.tabs_information.addTab(self.wot_tab, QIcon(':/icons/wot_icon'), "WoT") + members_action = QAction(self.tr("Members"), self) + members_action.triggered.connect(self.search_members) + self.button_search.addAction(members_action) + direct_connections = QAction(self.tr("Direct connections"), self) + direct_connections.triggered.connect(self.search_direct_connections) + self.button_search.addAction(direct_connections) self.refresh() def identity_context_menu(self, point): @@ -212,9 +218,9 @@ The process to join back the community later will have to be done again.""") "{0}".format(e), QMessageBox.Ok) - def search(self): + def search_text(self): """ - Search nodes when return is pressed in combobox lineEdit + Search text and display found identities """ text = self.edit_textsearch.text() @@ -227,13 +233,29 @@ The process to join back the community later will have to be done again.""") return False persons = [] - logging.debug(response) for identity in response['results']: persons.append(Person.lookup(identity['pubkey'], self.community)) self.edit_textsearch.clear() self.refresh(persons) + def search_members(self): + """ + Search members of community and display found members + """ + pubkeys = self.community.members_pubkeys() + persons = [] + for p in pubkeys: + persons.append(Person.lookup(p, self.community)) + + self.edit_textsearch.clear() + self.refresh(persons) + + def search_direct_connections(self): + """ + Search members of community and display found members + """ + self.refresh() def refresh(self, persons=None): ''' -- GitLab