summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editorui/editormain.py28
-rw-r--r--src/editorui/objects.py2
-rw-r--r--src/ui.py32
3 files changed, 53 insertions, 9 deletions
diff --git a/src/editorui/editormain.py b/src/editorui/editormain.py
index 11df8dd..1ff08ee 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/editorui/objects.py b/src/editorui/objects.py
index 872e289..af5c664 100644
--- a/src/editorui/objects.py
+++ b/src/editorui/objects.py
@@ -18,7 +18,7 @@ class KPEditorObject(KPEditorItem):
self.resizing = None
if not hasattr(KPEditorObject, 'SELECTION_PEN'):
- KPEditorObject.SELECTION_PEN = QtGui.QPen(Qt.white, 1, Qt.DotLine)
+ KPEditorObject.SELECTION_PEN = QtGui.QPen(Qt.green, 1, Qt.DotLine)
# I don't bother setting the ZValue because it doesn't quite matter:
# only one layer's objects are ever clickable, and drawBackground takes
diff --git a/src/ui.py b/src/ui.py
index 540c52b..ba63320 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -116,7 +116,6 @@ class KPPathNodeList(QtGui.QWidget):
@QtCore.pyqtSlot(KPPathNodeItem, KPPathNodeItem)
def handleRowChanged(self, currentItem, previousItem):
- print currentItem, previousItem
try:
self.selectedLayerChanged.emit(currentItem.layer)
previousItem.associate.qtItem.setLayerSelected(False)
@@ -124,6 +123,18 @@ class KPPathNodeList(QtGui.QWidget):
except:
pass
+ if KP.app.keyboardModifiers() & Qt.ControlModifier:
+ layer = currentItem.layer
+
+ KP.mainWindow.scene.clearSelection()
+ listToUse = layer.objects + layer.doodads
+
+ for obj in listToUse:
+ item = obj.qtItem
+ if item:
+ item.setSelected(True)
+
+
@QtCore.pyqtSlot(KPPathNodeItem, KPPathNodeItem)
def jumpToPathNode(self, item):
try:
@@ -309,11 +320,30 @@ 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()])
self.setButtonStates()
+ if KP.app.keyboardModifiers() & Qt.ControlModifier:
+ index = self.selectedLayerIndex()
+ layer = KP.map.layers[index]
+
+ if (index != -1) and (len(KP.map.layers) > 1) and (not isinstance(layer, KPPathLayer)):
+
+ KP.mainWindow.scene.clearSelection()
+ listToUse = layer.objects
+
+ for obj in listToUse:
+ item = obj.qtItem
+ if item:
+ item.setSelected(True)
+
def addTileLayer(self):
from dialogs import KPTilesetChooserDialog