当前位置: 首页>>代码示例>>Python>>正文


Python Utils.setThemeIcon方法代码示例

本文整理汇总了Python中utils.Utils.setThemeIcon方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.setThemeIcon方法的具体用法?Python Utils.setThemeIcon怎么用?Python Utils.setThemeIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.Utils的用法示例。


在下文中一共展示了Utils.setThemeIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: showContextMenu

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def showContextMenu(self, clickedObjectItem, screenPos):
        selection = self.mMapScene.selectedObjectItems()
        if (clickedObjectItem and not selection.contains(clickedObjectItem)):
            selection.clear()
            selection.insert(clickedObjectItem)
            self.mMapScene.setSelectedObjectItems(selection)
        if selection.isEmpty():
            return

        selectedObjects = self.mapDocument().selectedObjects()
        objectGroups = self.mapDocument().map().objectGroups()

        menu = QMenu()
        duplicateAction = menu.addAction(self.tr("Duplicate %n Object(s)", "", selection.size()), self.duplicateObjects)
        removeAction = menu.addAction(self.tr("Remove %n Object(s)", "", selection.size()), self.removeObjects)

        duplicateAction.setIcon(QIcon("/images/16x16/stock-duplicate-16.png"))
        removeAction.setIcon(QIcon("/images/16x16/edit-delete.png"))

        menu.addSeparator()
        menu.addAction(self.tr("Flip Horizontally"), self.flipHorizontally, QKeySequence(self.tr("X")))
        menu.addAction(self.tr("Flip Vertically"), self.flipVertically, QKeySequence(self.tr("Y")))

        objectGroup = RaiseLowerHelper.sameObjectGroup(selection)
        if (objectGroup and objectGroup.drawOrder() == ObjectGroup.DrawOrder.IndexOrder):
            menu.addSeparator()
            menu.addAction(self.tr("Raise Object"), self.raise_, QKeySequence(self.tr("PgUp")))
            menu.addAction(self.tr("Lower Object"), self.lower, QKeySequence(self.tr("PgDown")))
            menu.addAction(self.tr("Raise Object to Top"), self.raiseToTop, QKeySequence(self.tr("Home")))
            menu.addAction(self.tr("Lower Object to Bottom"), self.lowerToBottom, QKeySequence(self.tr("End")))

        if (objectGroups.size() > 1):
            menu.addSeparator()
            moveToLayerMenu = menu.addMenu(self.tr("Move %n Object(s) to Layer", "", selectedObjects.size()))
            for objectGroup in objectGroups:
                action = moveToLayerMenu.addAction(objectGroup.name())
                action.setData(objectGroup)

        menu.addSeparator()
        propIcon = QIcon("images/16x16/document-properties.png")
        propertiesAction = menu.addAction(propIcon, self.tr("Object &Properties..."))
        # TODO Implement editing of properties for multiple objects
        propertiesAction.setEnabled(selectedObjects.size() == 1)

        Utils.setThemeIcon(removeAction, "edit-delete")
        Utils.setThemeIcon(propertiesAction, "document-properties")

        action = menu.exec(screenPos)
        if not action:
            return

        if action == propertiesAction:
            mapObject = selectedObjects.first()
            self.mapDocument().setCurrentObject(mapObject)
            self.mapDocument().emitEditCurrentObject()
            return
        
        objectGroup = action.data()
        if type(objectGroup) == ObjectGroup:
            self.mapDocument().moveObjectsToGroup(self.mapDocument().selectedObjects(), objectGroup)
开发者ID:theall,项目名称:Python-Tiled,代码行数:62,代码来源:abstractobjecttool.py

示例2: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def __init__(self, parent):
        super().__init__(parent)
        self.mMenu = QMenu(self)

        self.setIcon(QIcon(":images/24x24/system-run.png"))
        Utils.setThemeIcon(self, "system-run")
        self.retranslateUi()
        self.setPopupMode(QToolButton.MenuButtonPopup)
        self.setMenu(self.mMenu)
        self.mMenu.aboutToShow.connect(self.populateMenu)
        self.clicked.connect(self.runCommand)
开发者ID:theall,项目名称:Python-Tiled,代码行数:13,代码来源:commandbutton.py

示例3: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def __init__(self, parent = None):
        super().__init__(parent)
        self.mOpacityLabel = QLabel()
        self.mOpacitySlider = QSlider(Qt.Horizontal)
        self.mLayerView = LayerView()
        self.mMapDocument = None
        self.mUpdatingSlider = False
        self.mChangingLayerOpacity = False
        self.mUpdatingSlider = False

        self.setObjectName("layerDock")
        widget = QWidget(self)
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(5, 5, 5, 5)
        opacityLayout = QHBoxLayout()
        self.mOpacitySlider.setRange(0, 100)
        self.mOpacitySlider.setEnabled(False)
        opacityLayout.addWidget(self.mOpacityLabel)
        opacityLayout.addWidget(self.mOpacitySlider)
        self.mOpacityLabel.setBuddy(self.mOpacitySlider)
        handler = MapDocumentActionHandler.instance()
        newLayerMenu = QMenu(self)
        newLayerMenu.addAction(handler.actionAddTileLayer())
        newLayerMenu.addAction(handler.actionAddObjectGroup())
        newLayerMenu.addAction(handler.actionAddImageLayer())
        newIcon = QIcon(":/images/16x16/document-new.png")
        newLayerButton = QToolButton()
        newLayerButton.setPopupMode(QToolButton.InstantPopup)
        newLayerButton.setMenu(newLayerMenu)
        newLayerButton.setIcon(newIcon)
        Utils.setThemeIcon(newLayerButton, "document-new")
        buttonContainer = QToolBar()
        buttonContainer.setFloatable(False)
        buttonContainer.setMovable(False)
        buttonContainer.setIconSize(QSize(16, 16))
        buttonContainer.addWidget(newLayerButton)
        buttonContainer.addAction(handler.actionMoveLayerUp())
        buttonContainer.addAction(handler.actionMoveLayerDown())
        buttonContainer.addAction(handler.actionDuplicateLayer())
        buttonContainer.addAction(handler.actionRemoveLayer())
        buttonContainer.addSeparator()
        buttonContainer.addAction(handler.actionToggleOtherLayers())
        listAndToolBar = QVBoxLayout()
        listAndToolBar.setSpacing(0)
        listAndToolBar.addWidget(self.mLayerView)
        listAndToolBar.addWidget(buttonContainer)
        layout.addLayout(opacityLayout)
        layout.addLayout(listAndToolBar)
        self.setWidget(widget)
        self.retranslateUi()
        self.mOpacitySlider.valueChanged.connect(self.sliderValueChanged)
        self.updateOpacitySlider()
开发者ID:theall,项目名称:Python-Tiled,代码行数:54,代码来源:layerdock.py

示例4: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def __init__(self, mapDocument, tileset, parent = None):
        super().__init__(parent)
        self.mUi = Ui_EditTerrainDialog()
        self.mMapDocument = mapDocument
        self.mInitialUndoStackIndex = self.mMapDocument.undoStack().index()
        self.mTileset = tileset

        self.mUi.setupUi(self)
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
        Utils.setThemeIcon(self.mUi.redo, "edit-redo")
        Utils.setThemeIcon(self.mUi.undo, "edit-undo")
        zoomable = Zoomable(self)
        zoomable.connectToComboBox(self.mUi.zoomComboBox)
        tilesetModel = TilesetModel(self.mTileset, self.mUi.tilesetView)
        mapDocument.tileTerrainChanged.connect(tilesetModel.tilesChanged)
        self.mUi.tilesetView.setEditTerrain(True)
        self.mUi.tilesetView.setMapDocument(mapDocument)
        self.mUi.tilesetView.setZoomable(zoomable)
        self.mUi.tilesetView.setModel(tilesetModel)
        self.mTerrainModel = mapDocument.terrainModel()
        rootIndex = self.mTerrainModel.index(tileset)
        self.mUi.terrainList.setMapDocument(mapDocument)
        self.mUi.terrainList.setModel(self.mTerrainModel)
        self.mUi.terrainList.setRootIndex(rootIndex)
        terrainListHeader = self.mUi.terrainList.header()
        terrainListHeader.setSectionResizeMode(0, QHeaderView.ResizeToContents)
        selectionModel = self.mUi.terrainList.selectionModel()
        selectionModel.currentRowChanged.connect(self.selectedTerrainChanged)
        if (self.mTerrainModel.rowCount(rootIndex) > 0):
            selectionModel.setCurrentIndex(self.mTerrainModel.index(0, 0, rootIndex),
                                            QItemSelectionModel.SelectCurrent |
                                            QItemSelectionModel.Rows)
            self.mUi.terrainList.setFocus()

        self.mUi.eraseTerrain.toggled.connect(self.eraseTerrainToggled)
        self.mUi.addTerrainTypeButton.clicked.connect(self.addTerrainType)
        self.mUi.removeTerrainTypeButton.clicked.connect(self.removeTerrainType)
        self.mUi.tilesetView.createNewTerrainSignal.connect(self.addTerrainType)
        self.mUi.tilesetView.terrainImageSelected.connect(self.setTerrainImage)
        undoStack = mapDocument.undoStack()
        undoStack.indexChanged.connect(self.updateUndoButton)
        undoStack.canRedoChanged.connect(self.mUi.redo.setEnabled)
        self.mUi.undo.clicked.connect(undoStack.undo)
        self.mUi.redo.clicked.connect(undoStack.redo)
        self.mUndoShortcut = QShortcut(QKeySequence.Undo, self)
        self.mRedoShortcut = QShortcut(QKeySequence.Redo, self)
        self.mUndoShortcut.activated.connect(undoStack.undo)
        self.mRedoShortcut.activated.connect(undoStack.redo)
        eraseShortcut = QShortcut(QKeySequence(self.tr("E")), self)
        eraseShortcut.activated.connect(self.mUi.eraseTerrain.toggle)
        self.updateUndoButton()
        Utils.restoreGeometry(self)
开发者ID:theall,项目名称:Python-Tiled,代码行数:54,代码来源:editterraindialog.py

示例5: contextMenuEvent

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
 def contextMenuEvent(self, event):
     terrain = self.terrainAt(self.indexAt(event.pos()))
     if (not terrain):
         return
     isExternal = terrain.tileset().isExternal()
     menu = QMenu()
     propIcon = QIcon(":images/16x16/document-properties.png")
     terrainProperties = menu.addAction(propIcon,
                                              self.tr("Terrain Properties..."))
     terrainProperties.setEnabled(not isExternal)
     Utils.setThemeIcon(terrainProperties, "document-properties")
     menu.addSeparator()
     terrainProperties.triggered.connect(self.editTerrainProperties)
     menu.exec(event.globalPos())
开发者ID:theall,项目名称:Python-Tiled,代码行数:16,代码来源:terrainview.py

示例6: showHandleContextMenu

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
 def showHandleContextMenu(self, clickedHandle, screenPos):
     if (clickedHandle and not self.mSelectedHandles.contains(clickedHandle)):
         self.setSelectedHandle(clickedHandle)
     n = self.mSelectedHandles.size()
     delIcon = QIcon(":images/16x16/edit-delete.png")
     delText = self.tr("Delete %n Node(s)", "", n)
     menu = QMenu()
     deleteNodesAction = menu.addAction(delIcon, delText)
     joinNodesAction = menu.addAction(self.tr("Join Nodes"))
     splitSegmentsAction = menu.addAction(self.tr("Split Segments"))
     Utils.setThemeIcon(deleteNodesAction, "edit-delete")
     joinNodesAction.setEnabled(n > 1)
     splitSegmentsAction.setEnabled(n > 1)
     deleteNodesAction.triggered.connect(self.deleteNodes)
     joinNodesAction.triggered.connect(self.joinNodes)
     splitSegmentsAction.triggered.connect(self.splitSegments)
     menu.exec(screenPos)
开发者ID:theall,项目名称:Python-Tiled,代码行数:19,代码来源:editpolygontool.py

示例7: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    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)
开发者ID:theall,项目名称:Python-Tiled,代码行数:43,代码来源:objectsdock.py

示例8: contextMenuEvent

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        model = self.tilesetModel()
        if (not model):
            return
        tile = model.tileAt(index)
        isExternal = model.tileset().isExternal()
        menu = QMenu()
        propIcon = QIcon(":images/16x16/document-properties.png")
        if (tile):
            if (self.mEditTerrain):
                # Select this tile to make sure it is clear that only a single
                # tile is being used.
                self.selectionModel().setCurrentIndex(index,
                                                  QItemSelectionModel.SelectCurrent |
                                                  QItemSelectionModel.Clear)
                addTerrain = menu.addAction(self.tr("Add Terrain Type"))
                addTerrain.setEnabled(not isExternal)
                addTerrain.triggered.connect(self.createNewTerrain)
                if (self.mTerrainId != -1):
                    setImage = menu.addAction(self.tr("Set Terrain Image"))
                    setImage.setEnabled(not isExternal)
                    setImage.triggered.connect(self.selectTerrainImage)

            else:
                tileProperties = menu.addAction(propIcon,
                                                         self.tr("Tile Properties..."))
                tileProperties.setEnabled(not isExternal)
                Utils.setThemeIcon(tileProperties, "document-properties")
                tileProperties.triggered.connect(self.editTileProperties)

            menu.addSeparator()

        toggleGrid = menu.addAction(self.tr("Show Grid"))
        toggleGrid.setCheckable(True)
        toggleGrid.setChecked(self.mDrawGrid)
        prefs = preferences.Preferences.instance()
        toggleGrid.toggled.connect(prefs.setShowTilesetGrid)
        menu.exec(event.globalPos())
开发者ID:theall,项目名称:Python-Tiled,代码行数:41,代码来源:tilesetview.py

示例9: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def __init__(self, parent = None):
        super().__init__(parent)
        self.mUi = Ui_PreferencesDialog()
        self.mLanguages = LanguageManager.instance().availableLanguages()

        self.mUi.setupUi(self)
        self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)
        self.mUi.openGL.setEnabled(QGLFormat.hasOpenGL())
        for name in self.mLanguages:
            locale = QLocale(name)
            string = "%s (%s)"%(QLocale.languageToString(locale.language()), QLocale.countryToString(locale.country()))
            self.mUi.languageCombo.addItem(string, name)

        self.mUi.languageCombo.model().sort(0)
        self.mUi.languageCombo.insertItem(0, self.tr("System default"))
        self.mObjectTypesModel = ObjectTypesModel(self)
        self.mUi.objectTypesTable.setModel(self.mObjectTypesModel)
        self.mUi.objectTypesTable.setItemDelegateForColumn(1, ColorDelegate(self))
        horizontalHeader = self.mUi.objectTypesTable.horizontalHeader()
        horizontalHeader.setSectionResizeMode(QHeaderView.Stretch)
        Utils.setThemeIcon(self.mUi.addObjectTypeButton, "add")
        Utils.setThemeIcon(self.mUi.removeObjectTypeButton, "remove")
        self.fromPreferences()
        self.mUi.languageCombo.currentIndexChanged.connect(self.languageSelected)
        self.mUi.openGL.toggled.connect(self.useOpenGLToggled)
        self.mUi.gridColor.colorChanged.connect(preferences.Preferences.instance().setGridColor)
        self.mUi.gridFine.valueChanged.connect(preferences.Preferences.instance().setGridFine)
        self.mUi.objectLineWidth.valueChanged.connect(self.objectLineWidthChanged)
        self.mUi.objectTypesTable.selectionModel().selectionChanged.connect(self.selectedObjectTypesChanged)
        self.mUi.objectTypesTable.doubleClicked.connect(self.objectTypeIndexClicked)
        self.mUi.addObjectTypeButton.clicked.connect(self.addObjectType)
        self.mUi.removeObjectTypeButton.clicked.connect(self.removeSelectedObjectTypes)
        self.mUi.importObjectTypesButton.clicked.connect(self.importObjectTypes)
        self.mUi.exportObjectTypesButton.clicked.connect(self.exportObjectTypes)
        self.mObjectTypesModel.dataChanged.connect(self.applyObjectTypes)
        self.mObjectTypesModel.rowsRemoved.connect(self.applyObjectTypes)
        self.mUi.autoMapWhileDrawing.toggled.connect(self.useAutomappingDrawingToggled)
        self.mUi.openLastFiles.toggled.connect(self.openLastFilesToggled)
开发者ID:theall,项目名称:Python-Tiled,代码行数:40,代码来源:preferencesdialog.py

示例10: showContextMenu

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
 def showContextMenu(self, pos):
     index = self.mTileStampView.indexAt(pos)
     if (not index.isValid()):
         return
     menu = QMenu()
     sourceIndex = self.mProxyModel.mapToSource(index)
     if (self.mTileStampModel.isStamp(sourceIndex)):
         addStampVariation = QAction(self.mAddVariation.icon(), self.mAddVariation.text(), menu)
         deleteStamp = QAction(self.mDelete.icon(), self.tr("Delete Stamp"), menu)
         deleteStamp.triggered.connect(self.delete_)
         addStampVariation.triggered.connect(self.addVariation)
         menu.addAction(addStampVariation)
         menu.addSeparator()
         menu.addAction(deleteStamp)
     else :
         removeVariation = QAction(QIcon(":/images/16x16/remove.png"),
                                                self.tr("Remove Variation"),
                                                menu)
         Utils.setThemeIcon(removeVariation, "remove")
         removeVariation.triggered.connect(self.delete_)
         menu.addAction(removeVariation)
     
     menu.exec(self.mTileStampView.viewport().mapToGlobal(pos))
开发者ID:theall,项目名称:Python-Tiled,代码行数:25,代码来源:tilestampsdock.py

示例11: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    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()
开发者ID:theall,项目名称:Python-Tiled,代码行数:42,代码来源:propertiesdock.py

示例12: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def __init__(self, parent):
        super().__init__(CreationMode.CreateTile, parent)

        self.setIcon(QIcon(":images/24x24/insert-image.png"))
        Utils.setThemeIcon(self, "insert-image")
        self.languageChanged()
开发者ID:theall,项目名称:Python-Tiled,代码行数:8,代码来源:createtileobjecttool.py

示例13: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def __init__(self, parent):
        super().__init__(parent)

        self.setIcon(QIcon(":images/24x24/insert-rectangle.png"))
        Utils.setThemeIcon(self, "insert-rectangle")
        self.languageChanged()
开发者ID:theall,项目名称:Python-Tiled,代码行数:8,代码来源:createrectangleobjecttool.py

示例14: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def __init__(self, stampManager, parent = None):
        super().__init__(parent)
        
        self.mTileStampManager = stampManager
        self.mTileStampModel = stampManager.tileStampModel()
        self.mProxyModel = QSortFilterProxyModel(self.mTileStampModel)
        self.mFilterEdit = QLineEdit(self)
        self.mNewStamp = QAction(self)
        self.mAddVariation = QAction(self)
        self.mDuplicate = QAction(self)
        self.mDelete = QAction(self)
        self.mChooseFolder = QAction(self)

        self.setObjectName("TileStampsDock")
        self.mProxyModel.setSortLocaleAware(True)
        self.mProxyModel.setSortCaseSensitivity(Qt.CaseInsensitive)
        self.mProxyModel.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.mProxyModel.setSourceModel(self.mTileStampModel)
        self.mProxyModel.sort(0)
        self.mTileStampView = TileStampView(self)
        self.mTileStampView.setModel(self.mProxyModel)
        self.mTileStampView.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
        self.mTileStampView.header().setStretchLastSection(False)
        self.mTileStampView.header().setSectionResizeMode(0, QHeaderView.Stretch)
        self.mTileStampView.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
        self.mTileStampView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.mTileStampView.customContextMenuRequested.connect(self.showContextMenu)
        self.mNewStamp.setIcon(QIcon(":images/16x16/document-new.png"))
        self.mAddVariation.setIcon(QIcon(":/images/16x16/add.png"))
        self.mDuplicate.setIcon(QIcon(":/images/16x16/stock-duplicate-16.png"))
        self.mDelete.setIcon(QIcon(":images/16x16/edit-delete.png"))
        self.mChooseFolder.setIcon(QIcon(":images/16x16/document-open.png"))
        Utils.setThemeIcon(self.mNewStamp, "document-new")
        Utils.setThemeIcon(self.mAddVariation, "add")
        Utils.setThemeIcon(self.mDelete, "edit-delete")
        Utils.setThemeIcon(self.mChooseFolder, "document-open")

        self.mFilterEdit.setClearButtonEnabled(True)
        self.mFilterEdit.textChanged.connect(self.mProxyModel.setFilterFixedString)
        self.mTileStampModel.stampRenamed.connect(self.ensureStampVisible)
        self.mNewStamp.triggered.connect(self.newStamp)
        self.mAddVariation.triggered.connect(self.addVariation)
        self.mDuplicate.triggered.connect(self.duplicate)
        self.mDelete.triggered.connect(self.delete_)
        self.mChooseFolder.triggered.connect(self.chooseFolder)
        self.mDuplicate.setEnabled(False)
        self.mDelete.setEnabled(False)
        self.mAddVariation.setEnabled(False)
        widget = QWidget(self)
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(5, 5, 5, 5)
        
        buttonContainer = QToolBar()
        buttonContainer.setFloatable(False)
        buttonContainer.setMovable(False)
        buttonContainer.setIconSize(QSize(16, 16))
        buttonContainer.addAction(self.mNewStamp)
        buttonContainer.addAction(self.mAddVariation)
        buttonContainer.addAction(self.mDuplicate)
        buttonContainer.addAction(self.mDelete)
        stretch = QWidget()
        stretch.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        buttonContainer.addWidget(stretch)
        buttonContainer.addAction(self.mChooseFolder)
        listAndToolBar = QVBoxLayout()
        listAndToolBar.setSpacing(0)
        listAndToolBar.addWidget(self.mFilterEdit)
        listAndToolBar.addWidget(self.mTileStampView)
        listAndToolBar.addWidget(buttonContainer)
        layout.addLayout(listAndToolBar)
        selectionModel = self.mTileStampView.selectionModel()
        selectionModel.currentRowChanged.connect(self.currentRowChanged)
        self.setWidget(widget)
        self.retranslateUi()
开发者ID:theall,项目名称:Python-Tiled,代码行数:76,代码来源:tilestampsdock.py

示例15: __init__

# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import setThemeIcon [as 别名]
    def __init__(self, parent = None):
        super().__init__(parent)
        self.mMapDocument = None

        MapDocumentActionHandler.mInstance = self
        self.mActionSelectAll = QAction(self)
        self.mActionSelectAll.setShortcuts(QKeySequence.SelectAll)
        self.mActionSelectNone = QAction(self)
        self.mActionSelectNone.setShortcut(self.tr("Ctrl+Shift+A"))
        self.mActionCropToSelection = QAction(self)
        self.mActionAddTileLayer = QAction(self)
        self.mActionAddObjectGroup = QAction(self)
        self.mActionAddImageLayer = QAction(self)
        self.mActionDuplicateLayer = QAction(self)
        self.mActionDuplicateLayer.setShortcut(self.tr("Ctrl+Shift+D"))
        self.mActionDuplicateLayer.setIcon(QIcon(":/images/16x16/stock-duplicate-16.png"))
        self.mActionMergeLayerDown = QAction(self)
        self.mActionRemoveLayer = QAction(self)
        self.mActionRemoveLayer.setIcon(QIcon(":/images/16x16/edit-delete.png"))
        self.mActionSelectPreviousLayer = QAction(self)
        self.mActionSelectPreviousLayer.setShortcut(self.tr("Ctrl+PgUp"))
        self.mActionSelectNextLayer = QAction(self)
        self.mActionSelectNextLayer.setShortcut(self.tr("Ctrl+PgDown"))
        self.mActionMoveLayerUp = QAction(self)
        self.mActionMoveLayerUp.setShortcut(self.tr("Ctrl+Shift+Up"))
        self.mActionMoveLayerUp.setIcon(
                QIcon(":/images/16x16/go-up.png"))
        self.mActionMoveLayerDown = QAction(self)
        self.mActionMoveLayerDown.setShortcut(self.tr("Ctrl+Shift+Down"))
        self.mActionMoveLayerDown.setIcon(
                QIcon(":/images/16x16/go-down.png"))
        self.mActionToggleOtherLayers = QAction(self)
        self.mActionToggleOtherLayers.setShortcut(self.tr("Ctrl+Shift+H"))
        self.mActionToggleOtherLayers.setIcon(
                QIcon(":/images/16x16/show_hide_others.png"))
        self.mActionLayerProperties = QAction(self)
        self.mActionLayerProperties.setIcon(
                QIcon(":images/16x16/document-properties.png"))
        self.mActionDuplicateObjects = QAction(self)
        self.mActionDuplicateObjects.setIcon(QIcon(":/images/16x16/stock-duplicate-16.png"))
        self.mActionRemoveObjects = QAction(self)
        self.mActionRemoveObjects.setIcon(QIcon(":/images/16x16/edit-delete.png"))
        Utils.setThemeIcon(self.mActionRemoveLayer, "edit-delete")
        Utils.setThemeIcon(self.mActionMoveLayerUp, "go-up")
        Utils.setThemeIcon(self.mActionMoveLayerDown, "go-down")
        Utils.setThemeIcon(self.mActionLayerProperties, "document-properties")
        Utils.setThemeIcon(self.mActionRemoveObjects, "edit-delete")
        self.mActionSelectAll.triggered.connect(self.selectAll)
        self.mActionSelectNone.triggered.connect(self.selectNone)
        self.mActionCropToSelection.triggered.connect(self.cropToSelection)
        self.mActionAddTileLayer.triggered.connect(self.addTileLayer)
        self.mActionAddObjectGroup.triggered.connect(self.addObjectGroup)
        self.mActionAddImageLayer.triggered.connect(self.addImageLayer)
        self.mActionDuplicateLayer.triggered.connect(self.duplicateLayer)
        self.mActionMergeLayerDown.triggered.connect(self.mergeLayerDown)
        self.mActionSelectPreviousLayer.triggered.connect(self.selectPreviousLayer)
        self.mActionSelectNextLayer.triggered.connect(self.selectNextLayer)
        self.mActionRemoveLayer.triggered.connect(self.removeLayer)
        self.mActionMoveLayerUp.triggered.connect(self.moveLayerUp)
        self.mActionMoveLayerDown.triggered.connect(self.moveLayerDown)
        self.mActionToggleOtherLayers.triggered.connect(self.toggleOtherLayers)
        self.mActionLayerProperties.triggered.connect(self.layerProperties)
        self.mActionDuplicateObjects.triggered.connect(self.duplicateObjects)
        self.mActionRemoveObjects.triggered.connect(self.removeObjects)
        self.updateActions()
        self.retranslateUi()
开发者ID:theall,项目名称:Python-Tiled,代码行数:68,代码来源:mapdocumentactionhandler.py


注:本文中的utils.Utils.setThemeIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。