Beispiel #1
0
    def selectionChanged(self, selected, deselected):
        super().selectionChanged(selected, deselected)
        
        if (not self.mMapDocument or self.mSynching):
            return
        selectedRows = self.selectionModel().selectedRows()
        currentLayerIndex = -1
        selectedObjects = QList()
        for index in selectedRows:
            og = self.model().toLayer(index)
            if og:
                i = self.mMapDocument.map().layers().indexOf(og)
                if (currentLayerIndex == -1):
                    currentLayerIndex = i
                elif (currentLayerIndex != i):
                    currentLayerIndex = -2

            o = self.model().toMapObject(index)
            if o:
                selectedObjects.append(o)
        
        # Switch the current object layer if only one object layer (and/or its objects)
        # are included in the current selection.
        if (currentLayerIndex >= 0 and currentLayerIndex != self.mMapDocument.currentLayerIndex()):
            self.mMapDocument.setCurrentLayerIndex(currentLayerIndex)
        if (selectedObjects != self.mMapDocument.selectedObjects()):
            self.mSynching = True
            if (selectedObjects.count() == 1):
                o = selectedObjects.first()
                center = o.bounds().center()
                DocumentManager.instance().centerViewOn(center)

            self.mMapDocument.setSelectedObjects(selectedObjects)
            self.mSynching = False
Beispiel #2
0
 def centerViewOnLocalPixel(self, centerPos, delta = 0):
     mapView = DocumentManager.instance().currentMapView()
     if (not mapView):
         return
     if (delta != 0):
         mapView.zoomable().handleWheelDelta(delta)
     mapView.centerOn(self.mapToScene(centerPos))
Beispiel #3
0
 def centerViewOnLocalPixel(self, centerPos, delta=0):
     mapView = DocumentManager.instance().currentMapView()
     if (not mapView):
         return
     if (delta != 0):
         mapView.zoomable().handleWheelDelta(delta)
     mapView.centerOn(self.mapToScene(centerPos))
Beispiel #4
0
 def viewportRect(self):
     mapView = DocumentManager.instance().currentMapView()
     if (not mapView):
         return QRect(0, 0, 1, 1)
     sceneRect = mapView.sceneRect()
     viewRect = mapView.mapToScene(mapView.viewport().geometry()).boundingRect()
     return QRect((viewRect.x() - sceneRect.x()) / sceneRect.width() * self.mImageRect.width() + self.mImageRect.x(),
              (viewRect.y() - sceneRect.y()) / sceneRect.height() * self.mImageRect.height() + self.mImageRect.y(),
              viewRect.width() / sceneRect.width() * self.mImageRect.width(),
              viewRect.height() / sceneRect.height() * self.mImageRect.height())
Beispiel #5
0
 def mapToScene(self, p):
     if (self.mImageRect.isEmpty()):
         return QPointF()
     mapView = DocumentManager.instance().currentMapView()
     if (not mapView):
         return QPointF()
     sceneRect = mapView.sceneRect()
     p -= self.mImageRect.topLeft()
     return QPointF(p.x() * (sceneRect.width() / self.mImageRect.width()) + sceneRect.x(),
                    p.y() * (sceneRect.height() / self.mImageRect.height()) + sceneRect.y())
Beispiel #6
0
    def execute(self, inTerminal=False):
        # Save if save option is unset or True
        settings = QSettings()
        variant = settings.value("saveBeforeExecute", True)
        if variant.lower() == 'true':
            document = DocumentManager.instance().currentDocument()
            if (document):
                document.save()

        # Start the process
        CommandProcess(self, inTerminal)
Beispiel #7
0
    def __init__(self, parent = None):
        super().__init__(parent)
        self.mExpandedGroups = QMapList()
        self.mObjectsView = ObjectsView()
        self.mMapDocument = None

        self.setObjectName("ObjectsDock")
        self.mActionObjectProperties = QAction(self)
        self.mActionObjectProperties.setIcon(QIcon(":/images/16x16/document-properties.png"))
        Utils.setThemeIcon(self.mActionObjectProperties, "document-properties")
        self.mActionObjectProperties.triggered.connect(self.objectProperties)
        handler = MapDocumentActionHandler.instance()
        widget = QWidget(self)
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(5, 5, 5, 5)
        layout.setSpacing(0)
        layout.addWidget(self.mObjectsView)
        self.mActionNewLayer = QAction(self)
        self.mActionNewLayer.setIcon(QIcon(":/images/16x16/document-new.png"))
        self.mActionNewLayer.triggered.connect(handler.actionAddObjectGroup().triggered)
        self.mActionMoveToGroup = QAction(self)
        self.mActionMoveToGroup.setIcon(QIcon(":/images/16x16/layer-object.png"))
        toolBar = QToolBar()
        toolBar.setFloatable(False)
        toolBar.setMovable(False)
        toolBar.setIconSize(QSize(16, 16))
        toolBar.addAction(self.mActionNewLayer)
        toolBar.addAction(handler.actionDuplicateObjects())
        toolBar.addAction(handler.actionRemoveObjects())
        toolBar.addAction(self.mActionMoveToGroup)
        button = toolBar.widgetForAction(self.mActionMoveToGroup)
        self.mMoveToMenu = QMenu(self)
        button.setPopupMode(QToolButton.InstantPopup)
        button.setMenu(self.mMoveToMenu)
        self.mMoveToMenu.aboutToShow.connect(self.aboutToShowMoveToMenu)
        self.mMoveToMenu.triggered.connect(self.triggeredMoveToMenu)
        toolBar.addAction(self.mActionObjectProperties)
        layout.addWidget(toolBar)
        self.setWidget(widget)
        self.retranslateUi()
        DocumentManager.instance().documentAboutToClose.connect(self.documentAboutToClose)
 def copyPosition(self):
     view = DocumentManager.instance().currentMapView()
     if (not view):
         return
     globalPos = QCursor.pos()
     viewportPos = view.viewport().mapFromGlobal(globalPos)
     scenePos = view.mapToScene(viewportPos)
     renderer = self.mapDocument().renderer()
     tilePos = renderer.screenToTileCoords_(scenePos)
     x = math.floor(tilePos.x())
     y = math.floor(tilePos.y())
     QApplication.clipboard().setText(str(x) + ", " + str(y))
Beispiel #9
0
 def copyPosition(self):
     view = DocumentManager.instance().currentMapView()
     if (not view):
         return
     globalPos = QCursor.pos()
     viewportPos = view.viewport().mapFromGlobal(globalPos)
     scenePos = view.mapToScene(viewportPos)
     renderer = self.mapDocument().renderer()
     tilePos = renderer.screenToTileCoords_(scenePos)
     x = math.floor(tilePos.x())
     y = math.floor(tilePos.y())
     QApplication.clipboard().setText(str(x) + ", " + str(y))
Beispiel #10
0
    def __init__(self, command, inTerminal=False):
        super().__init__(DocumentManager.instance())
        self.mName = command.name
        self.mFinalCommand = command.finalCommand()
        if sys.platform == 'darwin':
            self.mFile = "tiledXXXXXX.command"

        # Give an error if the command is empty or just whitespace
        if (self.mFinalCommand.strip() == ''):
            self.handleError(QProcess.FailedToStart)
            return

        # Modify the command to run in a terminal
        if (inTerminal):
            if sys.platform == 'linux':
                hasGnomeTerminal = super().execute("which gnome-terminal") == 0
                if (hasGnomeTerminal):
                    self.mFinalCommand = "gnome-terminal -x " + self.mFinalCommand
                else:
                    self.mFinalCommand = "xterm -e " + self.mFinalCommand
            elif sys.platform == 'darwin':
                # The only way I know to launch a Terminal with a command on mac is
                # to make a .command file and open it. The client command invoke the
                # exectuable directly (rather than using open) in order to get std
                # output in the terminal. Otherwise, you can use the Console
                # application to see the output.
                # Create and write the command to a .command file
                if (not self.mFile.open()):
                    self.handleError(
                        self.tr("Unable to create/open %s" %
                                self.mFile.fileName()))
                    return

                self.mFile.write(self.mFinalCommand.toStdString().c_str())
                self.mFile.close()
                # Add execute permission to the file
                chmodRet = super().execute("chmod +x \"%s\"" %
                                           self.mFile.fileName())
                if (chmodRet != 0):
                    self.handleError(
                        self.tr("Unable to add executable permissions to %s" %
                                self.mFile.fileName()))
                    return

                # Use open command to launch the command in the terminal
                # -W makes it not return immediately
                # -n makes it open a new instance of terminal if it is open already
                self.mFinalCommand = "open -W -n \"%s\"" % self.mFile.fileName(
                )

        self.error.connect(self.handleError)
        self.finished.connect(self.deleteLater)
        self.start(self.mFinalCommand)
Beispiel #11
0
    def lastPath(self, fileType):
        path = self.mSettings.value(lastPathKey(fileType))
        if path==None or path=='':
            documentManager = DocumentManager.instance()
            mapDocument = documentManager.currentDocument()
            if mapDocument:
                path = QFileInfo(mapDocument.fileName()).path()

        if path==None or path=='':
            path = QStandardPaths.writableLocation(QStandardPaths.DocumentsLocation)

        return path
Beispiel #12
0
 def mapToScene(self, p):
     if (self.mImageRect.isEmpty()):
         return QPointF()
     mapView = DocumentManager.instance().currentMapView()
     if (not mapView):
         return QPointF()
     sceneRect = mapView.sceneRect()
     p -= self.mImageRect.topLeft()
     return QPointF(
         p.x() * (sceneRect.width() / self.mImageRect.width()) +
         sceneRect.x(),
         p.y() * (sceneRect.height() / self.mImageRect.height()) +
         sceneRect.y())
Beispiel #13
0
 def viewportRect(self):
     mapView = DocumentManager.instance().currentMapView()
     if (not mapView):
         return QRect(0, 0, 1, 1)
     sceneRect = mapView.sceneRect()
     viewRect = mapView.mapToScene(
         mapView.viewport().geometry()).boundingRect()
     return QRect(
         (viewRect.x() - sceneRect.x()) / sceneRect.width() *
         self.mImageRect.width() + self.mImageRect.x(),
         (viewRect.y() - sceneRect.y()) / sceneRect.height() *
         self.mImageRect.height() + self.mImageRect.y(),
         viewRect.width() / sceneRect.width() * self.mImageRect.width(),
         viewRect.height() / sceneRect.height() * self.mImageRect.height())
Beispiel #14
0
    def finalCommand(self):
        finalCommand = self.command
        # Perform variable replacement
        mapDocument = DocumentManager.instance().currentDocument()
        if (mapDocument):
            fileName = mapDocument.fileName()
            finalCommand.replace("%mapfile", "\"%s\"" % (fileName))

            currentObject = mapDocument.currentObject()
            if type(currentObject) == MapObject:
                finalCommand.replace("%objecttype",
                                     "\"%s\"" % currentObject.type())

        return finalCommand
Beispiel #15
0
    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()
Beispiel #16
0
    def setMapDocument(self, map):
        dm = DocumentManager.instance()
        if (self.mMapDocument):
            self.mMapDocument.disconnect()
            mapView = dm.viewForDocument(self.mMapDocument)
#            if mapView:
#                mapView.zoomable().disconnect()
#                mapView.horizontalScrollBar().disconnect()
#                mapView.verticalScrollBar().disconnect()
        
        self.mMapDocument = map
        
        if (self.mMapDocument):
            self.mMapDocument.undoStack().indexChanged.connect(self.scheduleMapImageUpdate)
            mapView = dm.viewForDocument(self.mMapDocument)
            if mapView:
                mapView.horizontalScrollBar().valueChanged.connect(self.update)
                mapView.verticalScrollBar().valueChanged.connect(self.update)
                mapView.zoomable().scaleChanged.connect(self.update)
            
        self.scheduleMapImageUpdate()
Beispiel #17
0
    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()
Beispiel #18
0
    def setMapDocument(self, map):
        dm = DocumentManager.instance()
        if (self.mMapDocument):
            self.mMapDocument.disconnect()
            mapView = dm.viewForDocument(self.mMapDocument)
#            if mapView:
#                mapView.zoomable().disconnect()
#                mapView.horizontalScrollBar().disconnect()
#                mapView.verticalScrollBar().disconnect()

        self.mMapDocument = map

        if (self.mMapDocument):
            self.mMapDocument.undoStack().indexChanged.connect(
                self.scheduleMapImageUpdate)
            mapView = dm.viewForDocument(self.mMapDocument)
            if mapView:
                mapView.horizontalScrollBar().valueChanged.connect(self.update)
                mapView.verticalScrollBar().valueChanged.connect(self.update)
                mapView.zoomable().scaleChanged.connect(self.update)

        self.scheduleMapImageUpdate()
Beispiel #19
0
def stampFromContext(selectedTool):
    stamp = TileStamp()
    stampBrush = dynamic_cast(selectedTool, StampBrush)
    if stampBrush:
        # take the stamp from the stamp brush
        stamp = stampBrush.stamp()
    else:
        fillTool = dynamic_cast(selectedTool, BucketFillTool)
        if fillTool:
            # take the stamp from the fill tool
            stamp = fillTool.stamp()
        else:
            mapDocument = DocumentManager.instance().currentDocument()
            if mapDocument:
                # try making a stamp from the current tile selection
                tileLayer = dynamic_cast(mapDocument.currentLayer(), TileLayer)
                if (not tileLayer):
                    return stamp
                selection = mapDocument.selectedArea()
                if (selection.isEmpty()):
                    return stamp
                selection.translate(-tileLayer.position())
                copy = tileLayer.copy(selection)
                if (copy.size().isEmpty()):
                    return stamp
                map = mapDocument.map()
                copyMap = Map(map.orientation(),
                                       copy.width(), copy.height(),
                                       map.tileWidth(), map.tileHeight())
                # Add tileset references to map
                for tileset in copy.usedTilesets():
                    copyMap.addTileset(tileset)
                copyMap.setRenderOrder(map.renderOrder())
                copyMap.addLayer(copy.take())
                stamp.addVariation(copyMap)
    
    return stamp
Beispiel #20
0
def stampFromContext(selectedTool):
    stamp = TileStamp()
    stampBrush = dynamic_cast(selectedTool, StampBrush)
    if stampBrush:
        # take the stamp from the stamp brush
        stamp = stampBrush.stamp()
    else:
        fillTool = dynamic_cast(selectedTool, BucketFillTool)
        if fillTool:
            # take the stamp from the fill tool
            stamp = fillTool.stamp()
        else:
            mapDocument = DocumentManager.instance().currentDocument()
            if mapDocument:
                # try making a stamp from the current tile selection
                tileLayer = dynamic_cast(mapDocument.currentLayer(), TileLayer)
                if (not tileLayer):
                    return stamp
                selection = mapDocument.selectedArea()
                if (selection.isEmpty()):
                    return stamp
                selection.translate(-tileLayer.position())
                copy = tileLayer.copy(selection)
                if (copy.size().isEmpty()):
                    return stamp
                map = mapDocument.map()
                copyMap = Map(map.orientation(), copy.width(), copy.height(),
                              map.tileWidth(), map.tileHeight())
                # Add tileset references to map
                for tileset in copy.usedTilesets():
                    copyMap.addTileset(tileset)
                copyMap.setRenderOrder(map.renderOrder())
                copyMap.addLayer(copy.take())
                stamp.addVariation(copyMap)

    return stamp
Beispiel #21
0
    def handleError(self, arg):
        tp = type(arg)
        if tp == QProcess.ProcessError:
            error = arg
            errorStr = QString()
            x = error
            if x == super().FailedToStart:
                errorStr = self.tr("The command failed to start.")
            elif x == super().Crashed:
                errorStr = self.tr("The command crashed.")
            elif x == super().Timedout:
                errorStr = self.tr("The command timed out.")
            else:
                errorStr = self.tr("An unknown error occurred.")

            self.handleError(errorStr)
        elif tp in [QString, str]:
            error = arg
            title = self.tr("Error Executing %s" % self.mName)
            message = error + "\n\n" + self.mFinalCommand
            parent = DocumentManager.instance().widget()
            QMessageBox.warning(parent, title, message)
            # Make sure this object gets deleted if the process failed to start
            self.deleteLater()
Beispiel #22
0
    def __init__(self, parent=None):
        super().__init__(parent)

        # Shared tileset references because the dock wants to add new tiles
        self.mTilesets = QVector()
        self.mCurrentTilesets = QMap()
        self.mMapDocument = None
        self.mTabBar = QTabBar()
        self.mViewStack = QStackedWidget()
        self.mToolBar = QToolBar()
        self.mCurrentTile = None
        self.mCurrentTiles = None
        self.mNewTileset = QAction(self)
        self.mImportTileset = QAction(self)
        self.mExportTileset = QAction(self)
        self.mPropertiesTileset = QAction(self)
        self.mDeleteTileset = QAction(self)
        self.mEditTerrain = QAction(self)
        self.mAddTiles = QAction(self)
        self.mRemoveTiles = QAction(self)
        self.mTilesetMenuButton = TilesetMenuButton(self)
        self.mTilesetMenu = QMenu(self)  # opens on click of mTilesetMenu
        self.mTilesetActionGroup = QActionGroup(self)
        self.mTilesetMenuMapper = None  # needed due to dynamic content
        self.mEmittingStampCaptured = False
        self.mSynchronizingSelection = False

        self.setObjectName("TilesetDock")
        self.mTabBar.setMovable(True)
        self.mTabBar.setUsesScrollButtons(True)
        self.mTabBar.currentChanged.connect(self.updateActions)
        self.mTabBar.tabMoved.connect(self.moveTileset)
        w = QWidget(self)
        horizontal = QHBoxLayout()
        horizontal.setSpacing(0)
        horizontal.addWidget(self.mTabBar)
        horizontal.addWidget(self.mTilesetMenuButton)
        vertical = QVBoxLayout(w)
        vertical.setSpacing(0)
        vertical.setContentsMargins(5, 5, 5, 5)
        vertical.addLayout(horizontal)
        vertical.addWidget(self.mViewStack)
        horizontal = QHBoxLayout()
        horizontal.setSpacing(0)
        horizontal.addWidget(self.mToolBar, 1)
        vertical.addLayout(horizontal)
        self.mNewTileset.setIcon(QIcon(":images/16x16/document-new.png"))
        self.mImportTileset.setIcon(QIcon(":images/16x16/document-import.png"))
        self.mExportTileset.setIcon(QIcon(":images/16x16/document-export.png"))
        self.mPropertiesTileset.setIcon(
            QIcon(":images/16x16/document-properties.png"))
        self.mDeleteTileset.setIcon(QIcon(":images/16x16/edit-delete.png"))
        self.mEditTerrain.setIcon(QIcon(":images/16x16/terrain.png"))
        self.mAddTiles.setIcon(QIcon(":images/16x16/add.png"))
        self.mRemoveTiles.setIcon(QIcon(":images/16x16/remove.png"))
        Utils.setThemeIcon(self.mNewTileset, "document-new")
        Utils.setThemeIcon(self.mImportTileset, "document-import")
        Utils.setThemeIcon(self.mExportTileset, "document-export")
        Utils.setThemeIcon(self.mPropertiesTileset, "document-properties")
        Utils.setThemeIcon(self.mDeleteTileset, "edit-delete")
        Utils.setThemeIcon(self.mAddTiles, "add")
        Utils.setThemeIcon(self.mRemoveTiles, "remove")
        self.mNewTileset.triggered.connect(self.newTileset)
        self.mImportTileset.triggered.connect(self.importTileset)
        self.mExportTileset.triggered.connect(self.exportTileset)
        self.mPropertiesTileset.triggered.connect(self.editTilesetProperties)
        self.mDeleteTileset.triggered.connect(self.removeTileset)
        self.mEditTerrain.triggered.connect(self.editTerrain)
        self.mAddTiles.triggered.connect(self.addTiles)
        self.mRemoveTiles.triggered.connect(self.removeTiles)
        self.mToolBar.addAction(self.mNewTileset)
        self.mToolBar.setIconSize(QSize(16, 16))
        self.mToolBar.addAction(self.mImportTileset)
        self.mToolBar.addAction(self.mExportTileset)
        self.mToolBar.addAction(self.mPropertiesTileset)
        self.mToolBar.addAction(self.mDeleteTileset)
        self.mToolBar.addAction(self.mEditTerrain)
        self.mToolBar.addAction(self.mAddTiles)
        self.mToolBar.addAction(self.mRemoveTiles)
        self.mZoomable = Zoomable(self)
        self.mZoomComboBox = QComboBox()
        self.mZoomable.connectToComboBox(self.mZoomComboBox)
        horizontal.addWidget(self.mZoomComboBox)
        self.mViewStack.currentChanged.connect(self.updateCurrentTiles)
        TilesetManager.instance().tilesetChanged.connect(self.tilesetChanged)
        DocumentManager.instance().documentAboutToClose.connect(
            self.documentAboutToClose)
        self.mTilesetMenuButton.setMenu(self.mTilesetMenu)
        self.mTilesetMenu.aboutToShow.connect(self.refreshTilesetMenu)
        self.setWidget(w)
        self.retranslateUi()
        self.setAcceptDrops(True)
        self.updateActions()