コード例 #1
0
    def loadContextMenu(self, *args):

        menu = QMenu(self.w_tree)
        path = self.w_tree.currentItem().text(0)
        if os.path.isdir(path):
            dirPath = path
        else:
            dirPath = os.path.dirname(path)
        if os.path.exists(dirPath):
            menu.addAction(unicode("Open Folder", errors='replace'),
                           self.openFolder)
        menu.addAction(unicode("Copy Path", errors='replace'), self.copyPath)
        separator = QAction(self.w_tree)
        separator.setSeparator(True)
        menu.addAction(separator)
        menu.addAction(unicode("Replace Path", errors='replace'),
                       self.replacePath)
        separator = QAction(self.w_tree)
        separator.setSeparator(True)
        menu.addAction(separator)
        if self.unusedExists():
            menu.addAction(unicode("Remove Unused Files", errors='replace'),
                           self.removeUnused)
        pos = QCursor.pos()
        point = QtCore.QPoint(pos.x() + 10, pos.y())
        menu.exec_(point)