summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2012-07-23 14:52:35 -0500
committerColin Noga <Tempus@chronometry.ca>2012-07-23 14:52:35 -0500
commitf630d7b9258539e4a6453f7f05d95bc360f82e0a (patch)
tree27dfe676c0bf5653591249836b887bb1fc6a8916 /src
parent1498632b8bc91d0f83dcbfbdd03fa7499ef0985e (diff)
downloadkoopatlas-f630d7b9258539e4a6453f7f05d95bc360f82e0a.tar.gz
koopatlas-f630d7b9258539e4a6453f7f05d95bc360f82e0a.zip
Added auto-layer swap click with Ctrl-Click on an object or doodad. Does not work when path layer is selected, for Treekis code benefit.
Diffstat (limited to 'src')
-rw-r--r--src/editorui/editormain.py28
-rw-r--r--src/ui.py5
2 files changed, 26 insertions, 7 deletions
diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py
index 11df8dd..c3d2aea 100644
--- a/src/editorui/editormain.py
+++ b/src/editorui/editormain.py
@@ -741,19 +741,33 @@ class KPEditorWidget(QtGui.QGraphicsView):
def mousePressEvent(self, event):
- # itemsUnder = self.scene().items(self.mapToScene(event.pos()), Qt.IntersectsItemShape, Qt.AscendingOrder)
if event.button() == Qt.RightButton:
self._tryToPaint(event)
event.accept()
- # elif itemsUnder:
- # QtGui.QGraphicsView.mousePressEvent(self, event)
+ elif event.modifiers() == Qt.ControlModifier:
+ if isinstance(self.scene().currentLayer, KPPathLayer):
+ QtGui.QGraphicsView.mousePressEvent(self, event)
+ return
+
+ itemsUnder = self.scene().items(self.mapToScene(event.pos()), Qt.IntersectsItemShape, Qt.AscendingOrder)
+
+ if itemsUnder:
+
+ self.scene().clearSelection()
+
+ kLayer = itemsUnder[0]._layerRef()
+ if isinstance(kLayer, (KPPathTileLayer, KPPathLayer)):
+ QtGui.QGraphicsView.mousePressEvent(self, event)
+ return
+
+ KP.mainWindow.handleSelectedLayerChanged(kLayer)
+ index = KP.map.refLayer(kLayer)
+ print 'selecting row {0}'.format(index)
+ KP.mainWindow.layerList.selectLayer(index)
- # if len(self.scene().selectedItems()) < 2:
- # self.scene().clearSelection()
- # itemsUnder[0].setSelected(True)
- # itemsUnder[0].grabMouse()
+ itemsUnder[0].setSelected(True)
else:
QtGui.QGraphicsView.mousePressEvent(self, event)
diff --git a/src/ui.py b/src/ui.py
index 6754f17..39c438a 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -313,6 +313,11 @@ class KPLayerList(QtGui.QWidget):
def selectedLayer(self):
return KP.map.layers[self.selectedLayerIndex()]
+ def selectLayer(self, row):
+ index = self.listView.currentIndex()
+ newIndex = index.sibling(row, 0)
+ self.listView.setCurrentIndex(newIndex)
+
@QtCore.pyqtSlot(QtCore.QModelIndex)
def handleRowChanged(self, current):
self.selectedLayerChanged.emit(KP.map.layers[current.row()])