From fe9b2d7188ea8ff4239661e502856083f9cf3d24 Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Tue, 13 Nov 2018 18:11:58 +0200 Subject: [PATCH] Moved actions and connections on tab "Blacklist" back to ui-file --- src/bitmessageqt/__init__.py | 6 +- src/bitmessageqt/blacklist.py | 48 +-------------- src/bitmessageqt/blacklist.ui | 110 +++++++++++++++++++++++++++++++++- 3 files changed, 113 insertions(+), 51 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index e74ba11b..e3fb58fe 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -1272,11 +1272,7 @@ class MainWindow(Window): self.retranslateUi(self) self.init_inbox_popup_menu(False) self.init_identities_popup_menu(False) - self.init_chan_popup_menu(False) - self.init_addressbook_popup_menu(False) - self.init_subscriptions_popup_menu(False) - self.init_sent_popup_menu(False) - self.blackwhitelist.init_blacklist_popup_menu(False) + self.blackwhitelist.init_blacklist_popup_menu() if event.type() == QtCore.QEvent.WindowStateChange: if self.windowState() & QtCore.Qt.WindowMinimized: if BMConfigParser().getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform: diff --git a/src/bitmessageqt/blacklist.py b/src/bitmessageqt/blacklist.py index 3897bddc..e5d11af8 100644 --- a/src/bitmessageqt/blacklist.py +++ b/src/bitmessageqt/blacklist.py @@ -17,21 +17,11 @@ class Blacklist(QtGui.QWidget, RetranslateMixin): super(Blacklist, self).__init__(parent) widgets.load('blacklist.ui', self) - QtCore.QObject.connect(self.radioButtonBlacklist, QtCore.SIGNAL( - "clicked()"), self.click_radioButtonBlacklist) - QtCore.QObject.connect(self.radioButtonWhitelist, QtCore.SIGNAL( - "clicked()"), self.click_radioButtonWhitelist) - QtCore.QObject.connect(self.pushButtonAddBlacklist, QtCore.SIGNAL( - "clicked()"), self.click_pushButtonAddBlacklist) - + self.blacklistContextMenuToolbar.setVisible(False) self.init_blacklist_popup_menu() - # Initialize blacklist - QtCore.QObject.connect(self.tableWidgetBlacklist, QtCore.SIGNAL( - "itemChanged(QTableWidgetItem *)"), self.tableWidgetBlacklistItemChanged) - # Set the icon sizes for the identicons - identicon_size = 3*7 + identicon_size = 3 * 7 self.tableWidgetBlacklist.setIconSize(QtCore.QSize(identicon_size, identicon_size)) self.UISignalThread = UISignaler.get() @@ -42,16 +32,12 @@ class Blacklist(QtGui.QWidget, RetranslateMixin): if BMConfigParser().get('bitmessagesettings', 'blackwhitelist') == 'white': BMConfigParser().set('bitmessagesettings', 'blackwhitelist', 'black') BMConfigParser().save() - # self.tableWidgetBlacklist.clearContents() - self.tableWidgetBlacklist.setRowCount(0) self.rerenderBlackWhiteList() def click_radioButtonWhitelist(self): if BMConfigParser().get('bitmessagesettings', 'blackwhitelist') == 'black': BMConfigParser().set('bitmessagesettings', 'blackwhitelist', 'white') BMConfigParser().save() - # self.tableWidgetBlacklist.clearContents() - self.tableWidgetBlacklist.setRowCount(0) self.rerenderBlackWhiteList() def click_pushButtonAddBlacklist(self): @@ -116,36 +102,8 @@ class Blacklist(QtGui.QWidget, RetranslateMixin): sqlExecute('''UPDATE whitelist SET label=? WHERE address=?''', str(item.text()), str(addressitem.text())) - def init_blacklist_popup_menu(self, connectSignal=True): + def init_blacklist_popup_menu(self): # Popup menu for the Blacklist page - self.blacklistContextMenuToolbar = QtGui.QToolBar() - # Actions - self.actionBlacklistNew = self.blacklistContextMenuToolbar.addAction( - _translate( - "MainWindow", "Add new entry"), self.on_action_BlacklistNew) - self.actionBlacklistDelete = self.blacklistContextMenuToolbar.addAction( - _translate( - "MainWindow", "Delete"), self.on_action_BlacklistDelete) - self.actionBlacklistClipboard = self.blacklistContextMenuToolbar.addAction( - _translate( - "MainWindow", "Copy address to clipboard"), - self.on_action_BlacklistClipboard) - self.actionBlacklistEnable = self.blacklistContextMenuToolbar.addAction( - _translate( - "MainWindow", "Enable"), self.on_action_BlacklistEnable) - self.actionBlacklistDisable = self.blacklistContextMenuToolbar.addAction( - _translate( - "MainWindow", "Disable"), self.on_action_BlacklistDisable) - self.actionBlacklistSetAvatar = self.blacklistContextMenuToolbar.addAction( - _translate( - "MainWindow", "Set avatar..."), - self.on_action_BlacklistSetAvatar) - self.tableWidgetBlacklist.setContextMenuPolicy( - QtCore.Qt.CustomContextMenu) - if connectSignal: - self.connect(self.tableWidgetBlacklist, QtCore.SIGNAL( - 'customContextMenuRequested(const QPoint&)'), - self.on_context_menuBlacklist) self.popMenuBlacklist = QtGui.QMenu(self) # self.popMenuBlacklist.addAction( self.actionBlacklistNew ) self.popMenuBlacklist.addAction(self.actionBlacklistDelete) diff --git a/src/bitmessageqt/blacklist.ui b/src/bitmessageqt/blacklist.ui index 80993fac..72d6fa69 100644 --- a/src/bitmessageqt/blacklist.ui +++ b/src/bitmessageqt/blacklist.ui @@ -10,6 +10,44 @@ 295 + + + + Add new entry + + + + + Delete + + + + + Copy address to clipboard + + + + + Enable + + + + + Disable + + + + + Set avatar... + + + + + + + + + @@ -62,6 +100,9 @@ true + + Qt::CustomContextMenu + true @@ -104,5 +145,72 @@ - + + + radioButtonBlacklist + clicked() + blacklist + click_radioButtonBlacklist + + + radioButtonWhitelist + clicked() + blacklist + click_radioButtonWhitelist + + + pushButtonAddBlacklist + clicked() + blacklist + click_pushButtonAddBlacklist + + + tableWidgetBlacklist + itemChanged(QTableWidgetItem*) + blacklist + tableWidgetBlacklistItemChanged + + + actionBlacklistNew + triggered() + blacklist + on_action_BlacklistNew + + + actionBlacklistDelete + triggered() + blacklist + on_action_BlacklistDelete + + + actionBlacklistClipboard + triggered() + blacklist + on_action_BlacklistClipboard + + + actionBlacklistEnable + triggered() + blacklist + on_action_BlacklistEnable + + + actionBlacklistDisable + triggered() + blacklist + on_action_BlacklistDisable + + + actionBlacklistSetAvatar + triggered() + blacklist + on_action_BlacklistSetAvatar + + + tableWidgetBlacklist + customContextMenuRequested(QPoint) + blacklist + on_context_menuBlacklist + +