diff options
Diffstat (limited to 'src/ui.py')
-rw-r--r-- | src/ui.py | 55 |
1 files changed, 32 insertions, 23 deletions
@@ -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) |