diff options
author | Treeki <treeki@gmail.com> | 2011-11-14 04:24:40 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-11-14 04:24:40 +0100 |
commit | 055e832da46a246bdea89c59ac9eb07d9f335d9b (patch) | |
tree | 2bc17b2ca1e7a6d8f014a4ab03c57d9199b6ee92 | |
parent | 386647ceb4508dcbc194b723e232627e3c0a2175 (diff) | |
download | koopatlas-055e832da46a246bdea89c59ac9eb07d9f335d9b.tar.gz koopatlas-055e832da46a246bdea89c59ac9eb07d9f335d9b.zip |
myriad updates to the object and layer selectors
Diffstat (limited to '')
-rw-r--r-- | src/tileset.py | 6 | ||||
-rw-r--r-- | src/ui.py | 55 |
2 files changed, 34 insertions, 27 deletions
diff --git a/src/tileset.py b/src/tileset.py index 763c197..a68f733 100644 --- a/src/tileset.py +++ b/src/tileset.py @@ -199,11 +199,9 @@ class KPGroupModel(QtCore.QAbstractListModel): item, depth = self.container.getItem(index.row()) if isinstance(item, KPGroupItem): - return Qt.ItemFlags(32) + return Qt.NoItemFlags else: - return Qt.ItemFlags(33) - - return Qt.ItemFlags(33) + return Qt.ItemIsEnabled | Qt.ItemIsSelectable def data(self, index, role=Qt.DisplayRole): @@ -92,24 +92,17 @@ class KPObjectSelector(QtGui.QWidget): QtGui.QWidget.__init__(self) - font = QtGui.QFont() - font.setPixelSize(22) - font.setBold(True) - - icon = QtGui.QIcon('icons/downArrow.png') + self.menuSetup = False self.sorterButton = QtGui.QToolButton() - string = QtCore.QString(QtCore.QChar(0x25BE)) - string.append(' All Groups') - - self.sorterButton.setText(string) - self.sorterButton.setFont(font) - self.sorterButton.setPopupMode(2) + self.sorterButton.setText('Pick a Layer') + self.sorterButton.setEnabled(False) + self.sorterButton.setPopupMode(self.sorterButton.InstantPopup) + self.sorterButton.setToolButtonStyle(Qt.ToolButtonTextOnly) self.sorterButton.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.sorterMenu = QtGui.QMenu() - action = self.sorterMenu.addAction("test 1") self.sorterButton.setMenu(self.sorterMenu) @@ -127,16 +120,30 @@ class KPObjectSelector(QtGui.QWidget): self.listView.setMovement(QtGui.QListView.Static) self.listView.setResizeMode(QtGui.QListView.Adjust) self.listView.setWrapping(True) + self.listView.setEnabled(False) self.layout.addWidget(self.listView) self.setLayout(self.layout) + self.model = None + # Borrowed the signals and junk from Reggie, figure we'll need em' # Some more signals are set in setModel self.listView.clicked.connect(self.handleObjReplace) self.sorterMenu.aboutToShow.connect(self.fixUpMenuSize) self.sorterMenu.triggered.connect(self.toggleTopLevel) + + + def beginUsingMenu(self): + if self.menuSetup: return + + font = QtGui.QFont() + font.setPixelSize(18) + font.setBold(True) + self.sorterButton.setFont(font) + self.sorterButton.setEnabled(True) + self.menuSetup = True def fixUpMenuSize(self): @@ -146,8 +153,8 @@ class KPObjectSelector(QtGui.QWidget): def currentSelectedObject(self): """Returns the currently selected object reference, for painting purposes.""" - index = self.currentIndex().row() - object = self.model().groupItem().getItem(index) + index = self.listView.currentIndex().row() + object = self.model.groupItem().getItem(index) return object @@ -155,13 +162,18 @@ class KPObjectSelector(QtGui.QWidget): def setModel(self, model): """Sets the model and the menu sorting list""" + if model == self.model: + return + self.model = model self.listView.setModel(model) + self.listView.setEnabled(True) model.view = self.listView menuList = model.groupItem().getGroupList() + self.beginUsingMenu() string = QtCore.QString(QtCore.QChar(0x25BE)) string.append(' All Groups') @@ -252,11 +264,10 @@ class KPMainWindow(QtGui.QMainWindow): self.layerListDock = QtGui.QDockWidget('Layers') self.layerListDock.setWidget(self.layerList) - self.layerList.selectedLayerChanged.connect(self.scene.setCurrentLayer) + self.layerList.selectedLayerChanged.connect(self.handleSelectedLayerChanged) self.objectSelector = KPObjectSelector() self.objectSelector.objChanged.connect(self.handleSelectedObjectChanged) - self.updateObjectSelector() self.objectSelectorDock = QtGui.QDockWidget('Objects') self.objectSelectorDock.setWidget(self.objectSelector) @@ -266,13 +277,11 @@ class KPMainWindow(QtGui.QMainWindow): self.addDockWidget(Qt.RightDockWidgetArea, self.objectSelectorDock) - @QtCore.pyqtSlot() - def updateObjectSelector(self): - try: - tileset = KPTileset.loadFromArc('/Users/Tempus/Dropbox/NEWERsmbw/Test3.arc') - except IOError: - tileset = KPTileset.loadFromArc('/home/me/Dropbox/NEWERsmbw/Test3.arc') - self.objectSelector.setModel(tileset.getModel()) + @QtCore.pyqtSlot(KPLayer) + def handleSelectedLayerChanged(self, layer): + self.scene.setCurrentLayer(layer) + + self.objectSelector.setModel(KP.map.loadedTilesets[layer.tileset].getModel()) @QtCore.pyqtSlot(int, KPTileObject) |