summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main.py16
-rw-r--r--src/mapdata.py8
-rw-r--r--src/ui.py6
3 files changed, 27 insertions, 3 deletions
diff --git a/src/main.py b/src/main.py
index 1d53521..1ef7039 100644
--- a/src/main.py
+++ b/src/main.py
@@ -18,4 +18,20 @@ class KP:
KP.mainWindow.show()
KP.app.exec_()
+
+
+ @classmethod
+ def icon(cls, name):
+ try:
+ cache = cls.iconCache
+ except AttributeError:
+ cache = {}
+ cls.iconCache = cache
+
+ try:
+ return cache[name]
+ except KeyError:
+ icon = QtGui.QIcon('Resources/%s.png' % name)
+ cache[name] = icon
+ return icon
diff --git a/src/mapdata.py b/src/mapdata.py
index 013e308..131c669 100644
--- a/src/mapdata.py
+++ b/src/mapdata.py
@@ -65,6 +65,8 @@ class KPTileLayer(KPLayer):
self.objects = []
self.cache = ['DUMMY_FLAG']
self.updateCache()
+
+ self.icon = KP.icon('LayerTile')
def _visibilityChanged(self, value):
for obj in self.objects:
@@ -145,6 +147,8 @@ class KPDoodadLayer(KPLayer):
def __init__(self):
KPLayer.__init__(self)
self.objects = []
+
+ self.icon = KP.icon('LayerObjects')
def _visibilityChanged(self, value):
for obj in self.objects:
@@ -208,6 +212,8 @@ class KPPathLayer(KPLayer):
KPLayer.__init__(self)
self.nodes = []
self.paths = []
+
+ self.icon = KP.icon('LayerPath')
def _visibilityChanged(self, value):
for objList in (self.nodes, self.paths):
@@ -267,6 +273,8 @@ class KPMap(object):
if (role == Qt.DisplayRole or role == Qt.EditRole):
return layer.name
+ elif role == Qt.DecorationRole:
+ return layer.icon
elif role == Qt.CheckStateRole:
return (Qt.Checked if layer.visible else Qt.Unchecked)
diff --git a/src/ui.py b/src/ui.py
index 2d7c1cc..c04f7df 100644
--- a/src/ui.py
+++ b/src/ui.py
@@ -30,9 +30,9 @@ class KPLayerList(QtGui.QWidget):
def setupToolbar(self, tb):
- self.actAddTile = tb.addAction(QtGui.QIcon(), 'T+', self.addTileLayer)
- self.actAddDoodad = tb.addAction(QtGui.QIcon(), 'D+', self.addDoodadLayer)
- self.actRemove = tb.addAction(QtGui.QIcon(), 'Remove', self.removeLayer)
+ self.actAddTile = tb.addAction(KP.icon('LayerNewTile'), 'Add Tile Layer', self.addTileLayer)
+ self.actAddDoodad = tb.addAction(KP.icon('LayerNewObjects'), 'Add Doodad Layer', self.addDoodadLayer)
+ self.actRemove = tb.addAction(KP.icon('LayerRemove'), 'Remove', self.removeLayer)
self.actMoveUp = tb.addAction(QtGui.QIcon(), 'Move Up', self.moveUp)
self.actMoveDown = tb.addAction(QtGui.QIcon(), 'Move Down', self.moveDown)