コード例 #1
0
ファイル: fileBrowser.py プロジェクト: Zachacious/PyCreator
    def __init__(self, parent=None):
        super(FileBrowserDock, self).__init__(parent)

        self.initDock("File Browser")

        # make sure icons are loaded
        Icons.load()

        # self.openFunction = openFunc

        # tree view
        self.fileTree = widgets.FileSystemTreeView()
        self.fileTree.set_root_path(os.getcwd())
        self.contextMenu = FileBrowserMenu()
        self.fileTree.set_context_menu(self.contextMenu)

        # enable drag and drop
        self.fileTree.setDragEnabled(True)
        self.fileTree.setDragDropMode(
            QtWidgets.QAbstractItemView.DragDrop)
        self.fileTree.viewport().setAcceptDrops(True)
        self.fileTree.setDropIndicatorShown(True)
        # To Do -- not use a private member --
        self.fileTree._fs_model_source.setReadOnly(False)
        self.fileTree.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.fileTree.setDefaultDropAction(QtCore.Qt.MoveAction)

        # Folder button
        self.menuHLayout = QtWidgets.QHBoxLayout()
        self.menuHLayout.setContentsMargins(1, 1, 1, 1)
        self.menuHLayout.addStretch(1)
        self.menuBtn = QtWidgets.QPushButton(Icons.folder, "...", self)
        self.menuBtn.setFlat(True)
        self.menuBtn.setStyleSheet("background-color: "
                                   "rgba(255, 255, 255, 0);")
        self.menuHLayout.addWidget(self.menuBtn)
        self.menuVLayout = QtWidgets.QVBoxLayout()
        self.menuVLayout.setContentsMargins(1, 1, 1, 1)
        self.menuVLayout.addLayout(self.menuHLayout)
        self.menuVLayout.addStretch(1)
        self.fileTree.setLayout(self.menuVLayout)

        self.dirContextMenu = DirMenu()
        self.menuBtn.setMenu(self.dirContextMenu)

        self.dirContextMenu.parentDirAction.triggered.connect(
            self.onParentDirClicked)
        self.dirContextMenu.openDirAction.triggered.connect(
            self.onOpenDirClicked)

        # add everything to the dock
        self.contents = QtWidgets.QWidget()
        self.layout = QtWidgets.QGridLayout(self.contents)
        self.layout.addWidget(self.fileTree, 0, 0, 1, 1)
        self.setWidget(self.contents)

        self.fileTree.doubleClicked.connect(self.onOpenItem)
        self.contextMenu.OpenAction.triggered.connect(self.openFile)
コード例 #2
0
ファイル: fileBrowser.py プロジェクト: Zachacious/PyCreator
    def __init__(self, parent=None):
        super(FileBrowserDock, self).__init__(parent)

        self.initDock("File Browser")

        # make sure icons are loaded
        Icons.load()

        # self.openFunction = openFunc

        # tree view
        self.fileTree = widgets.FileSystemTreeView()
        self.fileTree.set_root_path(os.getcwd())
        self.contextMenu = FileBrowserMenu()
        self.fileTree.set_context_menu(self.contextMenu)

        # enable drag and drop
        self.fileTree.setDragEnabled(True)
        self.fileTree.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop)
        self.fileTree.viewport().setAcceptDrops(True)
        self.fileTree.setDropIndicatorShown(True)
        # To Do -- not use a private member --
        self.fileTree._fs_model_source.setReadOnly(False)
        self.fileTree.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.fileTree.setDefaultDropAction(QtCore.Qt.MoveAction)

        # Folder button
        self.menuHLayout = QtWidgets.QHBoxLayout()
        self.menuHLayout.setContentsMargins(1, 1, 1, 1)
        self.menuHLayout.addStretch(1)
        self.menuBtn = QtWidgets.QPushButton(Icons.folder, "...", self)
        self.menuBtn.setFlat(True)
        self.menuBtn.setStyleSheet("background-color: "
                                   "rgba(255, 255, 255, 0);")
        self.menuHLayout.addWidget(self.menuBtn)
        self.menuVLayout = QtWidgets.QVBoxLayout()
        self.menuVLayout.setContentsMargins(1, 1, 1, 1)
        self.menuVLayout.addLayout(self.menuHLayout)
        self.menuVLayout.addStretch(1)
        self.fileTree.setLayout(self.menuVLayout)

        self.dirContextMenu = DirMenu()
        self.menuBtn.setMenu(self.dirContextMenu)

        self.dirContextMenu.parentDirAction.triggered.connect(
            self.onParentDirClicked)
        self.dirContextMenu.openDirAction.triggered.connect(
            self.onOpenDirClicked)

        # add everything to the dock
        self.contents = QtWidgets.QWidget()
        self.layout = QtWidgets.QGridLayout(self.contents)
        self.layout.addWidget(self.fileTree, 0, 0, 1, 1)
        self.setWidget(self.contents)

        self.fileTree.doubleClicked.connect(self.onOpenItem)
        self.contextMenu.OpenAction.triggered.connect(self.openFile)
コード例 #3
0
    def __init__(self, parent=None):
        super(MainMenuBar, self).__init__(parent)
        self.mainWindow = parent  # parent should be a MainWindow

        self.docks = []

        # sub-menus
        self.openRecMenu = \
            widgets.MenuRecentFiles(self,
                                    self.mainWindow.recent_files_manager)

        # must load icons here
        Icons.load()

        # Actions --
        # file actions
        self.newAct = QtWidgets.QAction(Icons.new, "&New", self)
        self.newAct.setShortcut('Ctrl+N')

        self.openAct = QtWidgets.QAction(Icons.openFile, "&Open", self)
        self.openAct.setShortcut('Ctrl+O')
        self.openRecAct = QtWidgets.QAction("Open &Recent", self)
        self.openRecAct.setMenu(self.openRecMenu)

        self.saveAct = QtWidgets.QAction(Icons.save, "&Save", self)
        self.saveAct.setShortcut('Ctrl+S')
        self.saveAsAct = QtWidgets.QAction(Icons.saveAs, "Save &As...", self)
        self.saveAsAct.setShortcut('Ctrl+Shift+S')
        self.saveAllAct = QtWidgets.QAction(Icons.saveAll, "Save A&ll", self)
        self.saveAllAct.setShortcut('Ctrl+Shift+A')

        self.closeAllAct = QtWidgets.QAction("Close All", self)

        self.exitAct = QtWidgets.QAction("E&xit", self)
        self.exitAct.setShortcut('Alt+F4')

        # tool actions
        self.interpAct = QtWidgets.QAction("&Interpreter Config...", self)
        self.runConfigAct = QtWidgets.QAction(Icons.runConfig,
                                              "Run &Config...", self)
        self.runAct = QtWidgets.QAction(Icons.run, "&Run", self)
        self.runAct.setShortcut('F5')

        # Top-level menus
        self.fileMenu = QtWidgets.QMenu("&File", self)
        self.fileMenu.addAction(self.newAct)
        self.fileMenu.addAction(self.openAct)
        self.fileMenu.addAction(self.openRecAct)
        self.fileMenu.addAction(self.closeAllAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.saveAct)
        self.fileMenu.addAction(self.saveAsAct)
        self.fileMenu.addAction(self.saveAllAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.exitAct)
        self.addAction(self.fileMenu.menuAction())  # add to menubar

        self.editMenu = \
            QtWidgets.QMenu("&Edit", self)  # edit menu updated dynamically
        # self.editMenu.addActions(self.mainWindow.editor.actions())
        self.addAction(self.editMenu.menuAction())

        self.toolsMenu = QtWidgets.QMenu("&Tools", self)
        self.toolsMenu.addAction(self.interpAct)
        self.toolsMenu.addAction(self.runConfigAct)
        self.toolsMenu.addAction(self.runAct)
        self.toolsMenu.addSeparator()
        self.addAction(self.toolsMenu.menuAction())

        self.viewMenu = QtWidgets.QMenu("&View", self)
        self.addAction(self.viewMenu.menuAction())

        self.helpMenu = QtWidgets.QMenu("&Help", self)
        self.addAction(self.helpMenu.menuAction())