From 348643d67a91cb33b7802f244d28414ba8040563 Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Wed, 14 Sep 2011 15:42:56 +0200 Subject: [PATCH] add imageChange slot to inserters This gets called every time the current image in the label tool changes to make the inserter aware of this. --- sloth/gui/annotationscene.py | 2 ++ sloth/items/inserters.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/sloth/gui/annotationscene.py b/sloth/gui/annotationscene.py index 56bc73a..ee98ed1 100644 --- a/sloth/gui/annotationscene.py +++ b/sloth/gui/annotationscene.py @@ -115,6 +115,7 @@ class AnnotationScene(QGraphicsScene): def onInserterFinished(self): self.sender().inserterFinished.disconnect(self.onInserterFinished) + self._labeltool.currentImageChanged.disconnect(self.sender()) self._labeltool.exitInsertMode() self._inserter = None @@ -131,6 +132,7 @@ class AnnotationScene(QGraphicsScene): if inserter is None: raise InvalidArgumentException("Could not find inserter for class '%s' with default properties '%s'" % (label_class, default_properties)) inserter.inserterFinished.connect(self.onInserterFinished) + self._labeltool.currentImageChanged.connect(inserter.imageChange) self._inserter = inserter LOG.debug("Created inserter for class '%s' with default properties '%s'" % (label_class, default_properties)) diff --git a/sloth/items/inserters.py b/sloth/items/inserters.py index 50f9fdc..5719ed0 100644 --- a/sloth/items/inserters.py +++ b/sloth/items/inserters.py @@ -28,6 +28,12 @@ class ItemInserter(QObject): def keyPressEvent(self, event, image_item): event.ignore() + def imageChange(self): + """ + Slot which gets called if the current image in the labeltool changes. + """ + pass + def allowOutOfSceneEvents(self): return False