def init(self): # get screen win = self['main_window'] screen = win.get_screen() print screen.get_width(), screen.get_height() self.current_window = None self.move(0,0) #print self.get_position() palette = Palette(self) palette.show() vbox = self['vbox'] hpaned = gtk.HPaned() hpaned.show() win.remove(vbox) hpaned.pack1(vbox, shrink=False) hpaned.pack2(palette.toplevel()) hpaned.set_property('position', 300) vbox0 = gtk.VBox() vbox0.pack_start(hpaned, expand=False) centerbox = gtk.HBox() centerbox.show() vbox0.pack_start(centerbox) vbox0.show() win.add(vbox0) browser = Browser(self) browser.show() centerbox.pack_start(browser.toplevel(), expand=False) self.tree = WidgetTree(self) obtreeview = self.tree['treeview'] self.tree.remove(obtreeview) browser.toplevel().append_page(obtreeview) #self.tree.move(0, self.get_height()+60) self.tree.hide() editor = Editor(self) editor.show() centerbox.pack_start(editor.toplevel()) propertybrowser = PropertyBrowser(self) self.propertybrowser = propertybrowser pbnotebook = propertybrowser['notebook'] propertybrowser.toplevel().remove(pbnotebook) centerbox.pack_start(pbnotebook, expand=False) propertybrowser.hide() self['toolbar'].set_style(gtk.TOOLBAR_ICONS)
def setup_property_browser(self): #setup dock dockWidget = QtGui.QDockWidget('properties', self) dockWidget.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.addDockWidget(Qt.RightDockWidgetArea, dockWidget) #container widget self.props_browser = {'propsbrowser': PropertyBrowser()} dockWidget.setWidget(self.props_browser['propsbrowser'])
def __init__(self, parent=None): super().__init__(parent) self.mMapDocument = None self.mPropertyBrowser = PropertyBrowser() self.setObjectName("propertiesDock") self.mActionAddProperty = QAction(self) self.mActionAddProperty.setEnabled(False) self.mActionAddProperty.setIcon(QIcon(":/images/16x16/add.png")) self.mActionAddProperty.triggered.connect(self.addProperty) self.mActionRemoveProperty = QAction(self) self.mActionRemoveProperty.setEnabled(False) self.mActionRemoveProperty.setIcon(QIcon(":/images/16x16/remove.png")) self.mActionRemoveProperty.triggered.connect(self.removeProperty) self.mActionRenameProperty = QAction(self) self.mActionRenameProperty.setEnabled(False) self.mActionRenameProperty.setIcon(QIcon(":/images/16x16/rename.png")) self.mActionRenameProperty.triggered.connect(self.renameProperty) Utils.setThemeIcon(self.mActionAddProperty, "add") Utils.setThemeIcon(self.mActionRemoveProperty, "remove") Utils.setThemeIcon(self.mActionRenameProperty, "rename") toolBar = QToolBar() toolBar.setFloatable(False) toolBar.setMovable(False) toolBar.setIconSize(QSize(16, 16)) toolBar.addAction(self.mActionAddProperty) toolBar.addAction(self.mActionRemoveProperty) toolBar.addAction(self.mActionRenameProperty) widget = QWidget(self) layout = QVBoxLayout(widget) layout.setContentsMargins(5, 5, 5, 5) layout.setSpacing(0) layout.addWidget(self.mPropertyBrowser) layout.addWidget(toolBar) widget.setLayout(layout) self.setWidget(widget) manager = DocumentManager.instance() manager.currentDocumentChanged.connect(self.mapDocumentChanged) self.mPropertyBrowser.currentItemChangedSignal.connect( self.currentItemChanged) self.retranslateUi()
def init(self): # get screen win = self['main_window'] screen = win.get_screen() print screen.get_width(), screen.get_height() self.current_window = None self.move(0,0) #print self.get_position() browser = PropertyBrowser() browser.show() self.browser = browser self.tree = WidgetTree(self) self.tree.show() self.tree.move(0, self.get_height()+60) self['toolbar'].set_style(gtk.TOOLBAR_ICONS) w, h = browser['property_browser'].get_size() browser['property_browser'].move(screen.get_width()-w, self.get_height()+60)
def init(self): # get screen win = self['main_window'] screen = win.get_screen() print screen.get_width(), screen.get_height() self.current_window = None self.move(0, 0) #print self.get_position() browser = PropertyBrowser() browser.show() self.browser = browser self.tree = WidgetTree(self) self.tree.show() self.tree.move(0, self.get_height() + 60) self['toolbar'].set_style(gtk.TOOLBAR_ICONS) w, h = browser['property_browser'].get_size() browser['property_browser'].move(screen.get_width() - w, self.get_height() + 60)
def init(self): # get screen win = self['main_window'] screen = win.get_screen() print screen.get_width(), screen.get_height() self.current_window = None self.move(0, 0) #print self.get_position() palette = Palette(self) palette.show() vbox = self['vbox'] hpaned = gtk.HPaned() hpaned.show() win.remove(vbox) hpaned.pack1(vbox, shrink=False) hpaned.pack2(palette.toplevel()) hpaned.set_property('position', 300) vbox0 = gtk.VBox() vbox0.pack_start(hpaned, expand=False) centerbox = gtk.HBox() centerbox.show() vbox0.pack_start(centerbox) vbox0.show() win.add(vbox0) browser = Browser(self) browser.show() centerbox.pack_start(browser.toplevel(), expand=False) self.tree = WidgetTree(self) obtreeview = self.tree['treeview'] self.tree.remove(obtreeview) browser.toplevel().append_page(obtreeview) #self.tree.move(0, self.get_height()+60) self.tree.hide() editor = Editor(self) editor.show() centerbox.pack_start(editor.toplevel()) propertybrowser = PropertyBrowser(self) self.propertybrowser = propertybrowser pbnotebook = propertybrowser['notebook'] propertybrowser.toplevel().remove(pbnotebook) centerbox.pack_start(pbnotebook, expand=False) propertybrowser.hide() self['toolbar'].set_style(gtk.TOOLBAR_ICONS)
def __init__(self, parent = None): super().__init__(parent) self.mMapDocument = None self.mPropertyBrowser = PropertyBrowser() self.setObjectName("propertiesDock") self.mActionAddProperty = QAction(self) self.mActionAddProperty.setEnabled(False) self.mActionAddProperty.setIcon(QIcon(":/images/16x16/add.png")) self.mActionAddProperty.triggered.connect(self.addProperty) self.mActionRemoveProperty = QAction(self) self.mActionRemoveProperty.setEnabled(False) self.mActionRemoveProperty.setIcon(QIcon(":/images/16x16/remove.png")) self.mActionRemoveProperty.triggered.connect(self.removeProperty) self.mActionRenameProperty = QAction(self) self.mActionRenameProperty.setEnabled(False) self.mActionRenameProperty.setIcon(QIcon(":/images/16x16/rename.png")) self.mActionRenameProperty.triggered.connect(self.renameProperty) Utils.setThemeIcon(self.mActionAddProperty, "add") Utils.setThemeIcon(self.mActionRemoveProperty, "remove") Utils.setThemeIcon(self.mActionRenameProperty, "rename") toolBar = QToolBar() toolBar.setFloatable(False) toolBar.setMovable(False) toolBar.setIconSize(QSize(16, 16)) toolBar.addAction(self.mActionAddProperty) toolBar.addAction(self.mActionRemoveProperty) toolBar.addAction(self.mActionRenameProperty) widget = QWidget(self) layout = QVBoxLayout(widget) layout.setContentsMargins(5, 5, 5, 5) layout.setSpacing(0) layout.addWidget(self.mPropertyBrowser) layout.addWidget(toolBar) widget.setLayout(layout) self.setWidget(widget) manager = DocumentManager.instance() manager.currentDocumentChanged.connect(self.mapDocumentChanged) self.mPropertyBrowser.currentItemChangedSignal.connect(self.currentItemChanged) self.retranslateUi()
class PropertiesDock(QDockWidget): def __init__(self, parent = None): super().__init__(parent) self.mMapDocument = None self.mPropertyBrowser = PropertyBrowser() self.setObjectName("propertiesDock") self.mActionAddProperty = QAction(self) self.mActionAddProperty.setEnabled(False) self.mActionAddProperty.setIcon(QIcon(":/images/16x16/add.png")) self.mActionAddProperty.triggered.connect(self.addProperty) self.mActionRemoveProperty = QAction(self) self.mActionRemoveProperty.setEnabled(False) self.mActionRemoveProperty.setIcon(QIcon(":/images/16x16/remove.png")) self.mActionRemoveProperty.triggered.connect(self.removeProperty) self.mActionRenameProperty = QAction(self) self.mActionRenameProperty.setEnabled(False) self.mActionRenameProperty.setIcon(QIcon(":/images/16x16/rename.png")) self.mActionRenameProperty.triggered.connect(self.renameProperty) Utils.setThemeIcon(self.mActionAddProperty, "add") Utils.setThemeIcon(self.mActionRemoveProperty, "remove") Utils.setThemeIcon(self.mActionRenameProperty, "rename") toolBar = QToolBar() toolBar.setFloatable(False) toolBar.setMovable(False) toolBar.setIconSize(QSize(16, 16)) toolBar.addAction(self.mActionAddProperty) toolBar.addAction(self.mActionRemoveProperty) toolBar.addAction(self.mActionRenameProperty) widget = QWidget(self) layout = QVBoxLayout(widget) layout.setContentsMargins(5, 5, 5, 5) layout.setSpacing(0) layout.addWidget(self.mPropertyBrowser) layout.addWidget(toolBar) widget.setLayout(layout) self.setWidget(widget) manager = DocumentManager.instance() manager.currentDocumentChanged.connect(self.mapDocumentChanged) self.mPropertyBrowser.currentItemChangedSignal.connect(self.currentItemChanged) self.retranslateUi() def bringToFront(self): self.show() self.raise_() self.mPropertyBrowser.setFocus() def event(self, event): x = event.type() if x==QEvent.KeyPress or x==QEvent.ShortcutOverride: keyEvent = event if (keyEvent.matches(QKeySequence.Delete) or keyEvent.key() == Qt.Key_Backspace): if event.type() == QEvent.KeyPress: self.removeProperty() event.accept() return True elif x==QEvent.LanguageChange: self.retranslateUi() else: pass return super().event(event) def mapDocumentChanged(self, mapDocument): if type(mapDocument)==list: mapDocument = mapDocument[0] if (self.mMapDocument): self.mMapDocument.disconnect() self.mMapDocument = mapDocument self.mPropertyBrowser.setMapDocument(mapDocument) if (mapDocument): mapDocument.currentObjectChanged.connect(self.currentObjectChanged) mapDocument.tilesetFileNameChanged.connect(self.tilesetFileNameChanged) mapDocument.editCurrentObject.connect(self.bringToFront) self.currentObjectChanged(mapDocument.currentObject()) else: self.currentObjectChanged(None) def currentObjectChanged(self, object): if type(object)==list and len(object)>0: object = object[0] self.mPropertyBrowser.setObject(object) enabled = object != None and not isExternal(object) self.mPropertyBrowser.setEnabled(enabled) self.mActionAddProperty.setEnabled(enabled) def currentItemChanged(self, item): isCustomProperty = self.mPropertyBrowser.isCustomPropertyItem(item) external = isExternal(self.mPropertyBrowser.object()) self.mActionRemoveProperty.setEnabled(isCustomProperty and not external) self.mActionRenameProperty.setEnabled(isCustomProperty and not external) def tilesetFileNameChanged(self, tileset): object = self.mMapDocument.currentObject() if (not object): return update = False x = object.typeId() if x==Object.TilesetType: update = object == tileset elif x==Object.TileType: update = object.tileset() == tileset elif x==Object.TerrainType: update = object.tileset() == tileset else: pass if (update): self.currentObjectChanged(object) self.currentItemChanged(self.mPropertyBrowser.currentItem()) def addProperty(self, *args): l = len(args) if l==0: property, ok = QInputDialog.getText(self.mPropertyBrowser, self.tr("Add Property"), self.tr("Name:"), QLineEdit.Normal,'') if ok: self.addProperty(property) elif l==1: arg1 = args[0] tp = type(arg1) if tp==bool: self.addProperty() elif tp in [str, QString]: name = arg1 if name=='': return object = self.mMapDocument.currentObject() if (not object): return if (not object.hasProperty(name)): undoStack = self.mMapDocument.undoStack() undoStack.push(SetProperty(self.mMapDocument, self.mMapDocument.currentObjects(), name, QString())) self.mPropertyBrowser.editCustomProperty(name) def removeProperty(self): item = self.mPropertyBrowser.currentItem() object = self.mMapDocument.currentObject() if (not item or not object): return name = item.property().propertyName() undoStack = self.mMapDocument.undoStack() items = item.parent().children() if items.count() > 1: currentItemIndex = items.indexOf(item) if item == items.last(): self.mPropertyBrowser.setCurrentItem(items.at(currentItemIndex - 1)) else: self.mPropertyBrowser.setCurrentItem(items.at(currentItemIndex + 1)) undoStack.push(RemoveProperty(self.mMapDocument, self.mMapDocument.currentObjects(), name)) def renameProperty(self, *args): l = len(args) if l==0: item = self.mPropertyBrowser.currentItem() if (not item): return oldName = item.property().propertyName() dialog = QInputDialog(self.mPropertyBrowser) dialog.setInputMode(QInputDialog.TextInput) dialog.setLabelText(self.tr("Name:")) dialog.setTextValue(oldName) dialog.setWindowTitle(self.tr("Rename Property")) dialog.open(self.renameProperty) elif l==1: name = args[0] if (name.isEmpty()): return item = self.mPropertyBrowser.currentItem() if (not item): return oldName = item.property().propertyName() if (oldName == name): return undoStack = self.mMapDocument.undoStack() undoStack.push(RenameProperty(self.mMapDocument, self.mMapDocument.currentObjects(), oldName, name)) def retranslateUi(self): self.setWindowTitle(self.tr("Properties")) self.mActionAddProperty.setText(self.tr("Add Property")) self.mActionRemoveProperty.setText(self.tr("Remove Property")) self.mActionRenameProperty.setText(self.tr("Rename Property"))
class PropertiesDock(QDockWidget): def __init__(self, parent=None): super().__init__(parent) self.mMapDocument = None self.mPropertyBrowser = PropertyBrowser() self.setObjectName("propertiesDock") self.mActionAddProperty = QAction(self) self.mActionAddProperty.setEnabled(False) self.mActionAddProperty.setIcon(QIcon(":/images/16x16/add.png")) self.mActionAddProperty.triggered.connect(self.addProperty) self.mActionRemoveProperty = QAction(self) self.mActionRemoveProperty.setEnabled(False) self.mActionRemoveProperty.setIcon(QIcon(":/images/16x16/remove.png")) self.mActionRemoveProperty.triggered.connect(self.removeProperty) self.mActionRenameProperty = QAction(self) self.mActionRenameProperty.setEnabled(False) self.mActionRenameProperty.setIcon(QIcon(":/images/16x16/rename.png")) self.mActionRenameProperty.triggered.connect(self.renameProperty) Utils.setThemeIcon(self.mActionAddProperty, "add") Utils.setThemeIcon(self.mActionRemoveProperty, "remove") Utils.setThemeIcon(self.mActionRenameProperty, "rename") toolBar = QToolBar() toolBar.setFloatable(False) toolBar.setMovable(False) toolBar.setIconSize(QSize(16, 16)) toolBar.addAction(self.mActionAddProperty) toolBar.addAction(self.mActionRemoveProperty) toolBar.addAction(self.mActionRenameProperty) widget = QWidget(self) layout = QVBoxLayout(widget) layout.setContentsMargins(5, 5, 5, 5) layout.setSpacing(0) layout.addWidget(self.mPropertyBrowser) layout.addWidget(toolBar) widget.setLayout(layout) self.setWidget(widget) manager = DocumentManager.instance() manager.currentDocumentChanged.connect(self.mapDocumentChanged) self.mPropertyBrowser.currentItemChangedSignal.connect( self.currentItemChanged) self.retranslateUi() def bringToFront(self): self.show() self.raise_() self.mPropertyBrowser.setFocus() def event(self, event): x = event.type() if x == QEvent.KeyPress or x == QEvent.ShortcutOverride: keyEvent = event if (keyEvent.matches(QKeySequence.Delete) or keyEvent.key() == Qt.Key_Backspace): if event.type() == QEvent.KeyPress: self.removeProperty() event.accept() return True elif x == QEvent.LanguageChange: self.retranslateUi() else: pass return super().event(event) def mapDocumentChanged(self, mapDocument): if type(mapDocument) == list: mapDocument = mapDocument[0] if (self.mMapDocument): self.mMapDocument.disconnect() self.mMapDocument = mapDocument self.mPropertyBrowser.setMapDocument(mapDocument) if (mapDocument): mapDocument.currentObjectChanged.connect(self.currentObjectChanged) mapDocument.tilesetFileNameChanged.connect( self.tilesetFileNameChanged) mapDocument.editCurrentObject.connect(self.bringToFront) self.currentObjectChanged(mapDocument.currentObject()) else: self.currentObjectChanged(None) def currentObjectChanged(self, object): if type(object) == list and len(object) > 0: object = object[0] self.mPropertyBrowser.setObject(object) enabled = object != None and not isExternal(object) self.mPropertyBrowser.setEnabled(enabled) self.mActionAddProperty.setEnabled(enabled) def currentItemChanged(self, item): isCustomProperty = self.mPropertyBrowser.isCustomPropertyItem(item) external = isExternal(self.mPropertyBrowser.object()) self.mActionRemoveProperty.setEnabled(isCustomProperty and not external) self.mActionRenameProperty.setEnabled(isCustomProperty and not external) def tilesetFileNameChanged(self, tileset): object = self.mMapDocument.currentObject() if (not object): return update = False x = object.typeId() if x == Object.TilesetType: update = object == tileset elif x == Object.TileType: update = object.tileset() == tileset elif x == Object.TerrainType: update = object.tileset() == tileset else: pass if (update): self.currentObjectChanged(object) self.currentItemChanged(self.mPropertyBrowser.currentItem()) def addProperty(self, *args): l = len(args) if l == 0: property, ok = QInputDialog.getText(self.mPropertyBrowser, self.tr("Add Property"), self.tr("Name:"), QLineEdit.Normal, '') if ok: self.addProperty(property) elif l == 1: arg1 = args[0] tp = type(arg1) if tp == bool: self.addProperty() elif tp in [str, QString]: name = arg1 if name == '': return object = self.mMapDocument.currentObject() if (not object): return if (not object.hasProperty(name)): undoStack = self.mMapDocument.undoStack() undoStack.push( SetProperty(self.mMapDocument, self.mMapDocument.currentObjects(), name, QString())) self.mPropertyBrowser.editCustomProperty(name) def removeProperty(self): item = self.mPropertyBrowser.currentItem() object = self.mMapDocument.currentObject() if (not item or not object): return name = item.property().propertyName() undoStack = self.mMapDocument.undoStack() items = item.parent().children() if items.count() > 1: currentItemIndex = items.indexOf(item) if item == items.last(): self.mPropertyBrowser.setCurrentItem( items.at(currentItemIndex - 1)) else: self.mPropertyBrowser.setCurrentItem( items.at(currentItemIndex + 1)) undoStack.push( RemoveProperty(self.mMapDocument, self.mMapDocument.currentObjects(), name)) def renameProperty(self, *args): l = len(args) if l == 0: item = self.mPropertyBrowser.currentItem() if (not item): return oldName = item.property().propertyName() dialog = QInputDialog(self.mPropertyBrowser) dialog.setInputMode(QInputDialog.TextInput) dialog.setLabelText(self.tr("Name:")) dialog.setTextValue(oldName) dialog.setWindowTitle(self.tr("Rename Property")) dialog.open(self.renameProperty) elif l == 1: name = args[0] if (name.isEmpty()): return item = self.mPropertyBrowser.currentItem() if (not item): return oldName = item.property().propertyName() if (oldName == name): return undoStack = self.mMapDocument.undoStack() undoStack.push( RenameProperty(self.mMapDocument, self.mMapDocument.currentObjects(), oldName, name)) def retranslateUi(self): self.setWindowTitle(self.tr("Properties")) self.mActionAddProperty.setText(self.tr("Add Property")) self.mActionRemoveProperty.setText(self.tr("Remove Property")) self.mActionRenameProperty.setText(self.tr("Rename Property"))