From 0f84f444fbf7fabe7c61a04dee2d58cfab1ea3aa Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Thu, 27 Oct 2011 07:24:55 -0700 Subject: [PATCH] updating bindings --- core/reader.py | 45 ++++++++++++++++++++------------------------- core/update.py | 4 +++- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/core/reader.py b/core/reader.py index 4ed707e..6d26f99 100644 --- a/core/reader.py +++ b/core/reader.py @@ -73,31 +73,26 @@ class MainWindowReader(QtGui.QMainWindow, Ui_MainWindowReader): if self.preferences.generalFindUpdates: self.updateFinder.start() - bindings = [ - (self.actionOpen, 'triggered()', self.onActionOpen), - (self.actionPreferences, 'triggered()', self.onActionPreferences), - (self.actionAbout, 'triggered()', self.onActionAbout), - (self.actionZoomIn, 'triggered()', self.onActionZoomIn), - (self.actionZoomOut, 'triggered()', self.onActionZoomOut), - (self.actionZoomReset, 'triggered()', self.onActionZoomReset), - (self.actionFind, 'triggered()', self.onActionFind), - (self.actionFindNext, 'triggered()', self.onActionFindNext), - (self.actionToggleWrap, 'toggled(bool)', self.onActionToggleWrap), - (self.actionCopyDefinition, 'triggered()', self.onActionCopyDefinition), - (self.actionCopyAllDefinitions, 'triggered()', self.onActionCopyAllDefinitions), - (self.actionCopySentence, 'triggered()', self.onActionCopySentence), - (self.actionHomepage, 'triggered()', self.onActionHomepage), - (self.actionFeedback, 'triggered()', self.onActionFeedback), - (self.textDefinitions, 'anchorClicked(const QUrl&)', self.onDefinitionsAnchorClicked), - (self.textDefinitionSearch, 'returnPressed()', self.onDefinitionSearchReturn), - (self.listDefinitions, 'itemDoubleClicked(QListWidgetItem *)', self.onDefinitionDoubleClicked), - (self.dockDefinitions, 'visibilityChanged(bool)', self.onVisibilityChanged), - (self.dockAnki, 'visibilityChanged(bool)', self.onVisibilityChanged), - (self.updateFinder, 'updateSearchResult', self.onUpdaterSearchResult) - ] - - for action, signal, callback in bindings: - self.connect(action, QtCore.SIGNAL(signal), callback) + self.actionOpen.triggered.connect(self.onActionOpen) + self.actionPreferences.triggered.connect(self.onActionPreferences) + self.actionAbout.triggered.connect(self.onActionAbout) + self.actionZoomIn.triggered.connect(self.onActionZoomIn) + self.actionZoomOut.triggered.connect(self.onActionZoomOut) + self.actionZoomReset.triggered.connect(self.onActionZoomReset) + self.actionFind.triggered.connect(self.onActionFind) + self.actionFindNext.triggered.connect(self.onActionFindNext) + self.actionToggleWrap.toggled.connect(self.onActionToggleWrap) + self.actionCopyDefinition.triggered.connect(self.onActionCopyDefinition) + self.actionCopyAllDefinitions.triggered.connect(self.onActionCopyAllDefinitions) + self.actionCopySentence.triggered.connect(self.onActionCopySentence) + self.actionHomepage.triggered.connect(self.onActionHomepage) + self.actionFeedback.triggered.connect(self.onActionFeedback) + self.textDefinitions.anchorClicked.connect(self.onDefinitionsAnchorClicked) + self.textDefinitionSearch.returnPressed.connect(self.onDefinitionSearchReturn) + self.listDefinitions.itemDoubleClicked.connect(self.onDefinitionDoubleClicked) + self.dockDefinitions.visibilityChanged.connect(self.onVisibilityChanged) + self.dockAnki.visibilityChanged.connect(self.onVisibilityChanged) + self.updateFinder.updateResult.connect(self.onUpdaterSearchResult) def applyPreferences(self): diff --git a/core/update.py b/core/update.py index 5ef22b4..cbb3332 100644 --- a/core/update.py +++ b/core/update.py @@ -23,6 +23,8 @@ from constants import constants class UpdateFinder(QtCore.QThread): + updateResult = QtCore.pyqtSignal(str) + def run(self): latest = None try: @@ -35,4 +37,4 @@ class UpdateFinder(QtCore.QThread): except: pass finally: - self.emit(QtCore.SIGNAL('updateSearchResult'), latest) + self.updateResult.emit(latest)