From 09156303ff09d55ea0f7daa1be923a91fd9fc376 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 20 Oct 2014 23:16:21 +0100 Subject: [PATCH] Automatically focus canvas view if changing to canvas tab; Misc --- source/carla_host.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/carla_host.py b/source/carla_host.py index 0141f77d2..ddc171621 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -362,6 +362,8 @@ class HostWindow(QMainWindow): self.ui.miniCanvasPreview.miniCanvasMoved.connect(self.slot_miniCanvasMoved) + self.ui.tabWidget.currentChanged.connect(self.slot_tabChanged) + self.scene.scaleChanged.connect(self.slot_canvasScaleChanged) self.scene.sceneGroupMoved.connect(self.slot_canvasItemMoved) self.scene.pluginSelected.connect(self.slot_canvasPluginSelected) @@ -400,8 +402,10 @@ class HostWindow(QMainWindow): self.setProperWindowTitle() # Qt needs this so it properly creates & resizes the canvas + self.ui.tabWidget.blockSignals(True) self.ui.tabWidget.setCurrentIndex(1) self.ui.tabWidget.setCurrentIndex(0) + self.ui.tabWidget.blockSignals(False) # Plugin needs to have timers always running so it receives messages if self.host.isPlugin: @@ -1449,10 +1453,12 @@ class HostWindow(QMainWindow): width = self.ui.graphicsView.width() height = self.ui.graphicsView.height() else: + self.ui.tabWidget.blockSignals(True) self.ui.tabWidget.setCurrentIndex(1) width = self.ui.graphicsView.width() height = self.ui.graphicsView.height() self.ui.tabWidget.setCurrentIndex(0) + self.ui.tabWidget.blockSignals(False) self.ui.miniCanvasPreview.setViewSize(float(width)/self.fCanvasWidth, float(height)/self.fCanvasHeight) @@ -1513,6 +1519,13 @@ class HostWindow(QMainWindow): # -------------------------------------------------------------------------------------------------------- # Misc + @pyqtSlot(int) + def slot_tabChanged(self, index): + if index != 1: + return + + self.ui.graphicsView.setFocus() + @pyqtSlot(int) def slot_handleReloadAllCallback(self, pluginId): if pluginId >= self.fPluginCount: