summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-11-14 03:51:43 +0100
committerTreeki <treeki@gmail.com>2011-11-14 03:51:43 +0100
commit386647ceb4508dcbc194b723e232627e3c0a2175 (patch)
tree350f08f30b1f9dc0a8be2816e86b2968d6d2a074
parent081bdfe91b68665800ab751190a9fbaa57f1f226 (diff)
downloadkoopatlas-386647ceb4508dcbc194b723e232627e3c0a2175.tar.gz
koopatlas-386647ceb4508dcbc194b723e232627e3c0a2175.zip
layer list buttons now enabled/disabled properly
Diffstat (limited to '')
-rw-r--r--src/ui.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/ui.py b/src/ui.py
index 2b89d39..c594966 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -22,15 +22,24 @@ class KPLayerList(QtGui.QWidget):
self.layout.addWidget(self.toolbar)
self.setupToolbar(self.toolbar)
+ self.setButtonStates()
self.setLayout(self.layout)
def setupToolbar(self, tb):
- tb.addAction(QtGui.QIcon(), 'Add', self.addLayer)
- tb.addAction(QtGui.QIcon(), 'Remove', self.removeLayer)
- tb.addAction(QtGui.QIcon(), 'Move Up', self.moveUp)
- tb.addAction(QtGui.QIcon(), 'Move Down', self.moveDown)
+ self.actAdd = tb.addAction(QtGui.QIcon(), 'Add', self.addLayer)
+ self.actRemove = tb.addAction(QtGui.QIcon(), 'Remove', self.removeLayer)
+ self.actMoveUp = tb.addAction(QtGui.QIcon(), 'Move Up', self.moveUp)
+ self.actMoveDown = tb.addAction(QtGui.QIcon(), 'Move Down', self.moveDown)
+
+
+ def setButtonStates(self):
+ index = self.selectedLayerIndex()
+
+ self.actRemove.setEnabled((index != -1) and (len(KP.map.layers) > 1))
+ self.actMoveUp.setEnabled(index > 0)
+ self.actMoveDown.setEnabled((index != -1) and (index < (len(KP.map.layers) - 1)))
def selectedLayerIndex(self):
@@ -43,10 +52,12 @@ class KPLayerList(QtGui.QWidget):
@QtCore.pyqtSlot(QtCore.QModelIndex, QtCore.QModelIndex)
def handleRowChanged(self, current, previous):
self.selectedLayerChanged.emit(KP.map.layers[current.row()])
+ self.setButtonStates()
def addLayer(self):
KP.map.appendLayer(KP.map.createNewLayer())
+ self.setButtonStates()
def removeLayer(self):
layer = self.selectedLayer()