From 08a21154122d246908690599ab961a009db64464 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 7 Mar 2017 15:44:48 +0200 Subject: [PATCH] Properly renamed qrcode plugin module and made menu available for all address entries except for addressbook and blacklist --- setup.py | 3 +-- src/bitmessageqt/__init__.py | 29 +++++++++++++++++---- src/plugins/{qrcodeui.py => menu_qrcode.py} | 8 +----- 3 files changed, 26 insertions(+), 14 deletions(-) rename src/plugins/{qrcodeui.py => menu_qrcode.py} (89%) diff --git a/setup.py b/setup.py index ba34f6df..12670ed6 100644 --- a/setup.py +++ b/setup.py @@ -112,8 +112,7 @@ if __name__ == "__main__": zip_safe=False, entry_points={ 'bitmessage.gui.menu': [ - 'popMenuYourIdentities.qrcode = ' - 'pybitmessage.plugins.qrcodeui [qrcode]' + 'address.qrcode = pybitmessage.plugins.menu_qrcode [qrcode]' ], 'bitmessage.notification.message': [ 'notify2 = pybitmessage.plugins.notification_notify2' diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index b3e39001..5178392c 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -255,6 +255,18 @@ class MyForm(settingsmixin.SMainWindow): 'customContextMenuRequested(const QPoint&)'), self.on_context_menuYourIdentities) + # load all gui.menu plugins with prefix 'address' + self.menu_plugins = {'address': []} + for plugin in get_plugins('gui.menu', 'address'): + try: + handler, title = plugin(self) + except TypeError: + continue + self.menu_plugins['address'].append( + self.ui.addressContextMenuToolbarYourIdentities.addAction( + title, handler + )) + def init_chan_popup_menu(self, connectSignal=True): # Popup menu for the Channels tab self.ui.addressContextMenuToolbar = QtGui.QToolBar() @@ -3421,6 +3433,10 @@ class MyForm(settingsmixin.SMainWindow): self.popMenuSubscriptions.addSeparator() self.popMenuSubscriptions.addAction(self.actionsubscriptionsClipboard) self.popMenuSubscriptions.addSeparator() + # preloaded gui.menu plugins with prefix 'address' + for plugin in self.menu_plugins['address']: + self.popMenuSubscriptions.addAction(plugin) + self.popMenuSubscriptions.addSeparator() self.popMenuSubscriptions.addAction(self.actionMarkAllRead) self.popMenuSubscriptions.exec_( self.ui.treeWidgetSubscriptions.mapToGlobal(point)) @@ -3831,13 +3847,12 @@ class MyForm(settingsmixin.SMainWindow): self.popMenuYourIdentities.addAction(self.actionSpecialAddressBehaviorYourIdentities) self.popMenuYourIdentities.addAction(self.actionEmailGateway) self.popMenuYourIdentities.addSeparator() + # preloaded gui.menu plugins with prefix 'address' + for plugin in self.menu_plugins['address']: + self.popMenuYourIdentities.addAction(plugin) + self.popMenuYourIdentities.addSeparator() self.popMenuYourIdentities.addAction(self.actionMarkAllRead) - if get_plugins: - for plugin in get_plugins( - 'gui.menu', 'popMenuYourIdentities'): - plugin(self) - self.popMenuYourIdentities.exec_( self.ui.treeWidgetYourIdentities.mapToGlobal(point)) @@ -3857,6 +3872,10 @@ class MyForm(settingsmixin.SMainWindow): self.popMenu.addAction(self.actionEnable) self.popMenu.addAction(self.actionSetAvatar) self.popMenu.addSeparator() + # preloaded gui.menu plugins with prefix 'address' + for plugin in self.menu_plugins['address']: + self.popMenu.addAction(plugin) + self.popMenu.addSeparator() self.popMenu.addAction(self.actionMarkAllRead) self.popMenu.exec_( self.ui.treeWidgetChans.mapToGlobal(point)) diff --git a/src/plugins/qrcodeui.py b/src/plugins/menu_qrcode.py similarity index 89% rename from src/plugins/qrcodeui.py rename to src/plugins/menu_qrcode.py index d4dbcb69..0562907b 100644 --- a/src/plugins/qrcodeui.py +++ b/src/plugins/menu_qrcode.py @@ -73,10 +73,4 @@ def connect_plugin(form): dialog.render(str(form.getCurrentAccount())) dialog.exec_() - # return - form.actionShowQRCode = \ - form.ui.addressContextMenuToolbarYourIdentities.addAction( - _translate("MainWindow", "Show QR-code"), - on_action_ShowQR - ) - form.popMenuYourIdentities.addAction(form.actionShowQRCode) + return on_action_ShowQR, _translate("MainWindow", "Show QR-code")