예제 #1
0
    def _init_context_menu(self):
        import res_rc

        self._graph_menu = QtGui.QMenu()

        self._graph_menu.addAction(
            QtGui.QAction(QtGui.QIcon(":/arrow_right.svg"),
                          "&Export graph",
                          self,
                          triggered=self._export,
                          shortcut='Ctrl+Shift+E'))
        self._graph_menu.addAction(
            QtGui.QAction(QtGui.QIcon(":/save.svg"),
                          "&Save data",
                          self,
                          triggered=self._save,
                          shortcut='Ctrl+S'))

        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._popupMenu)
예제 #2
0
    def __init__(self, parent=None):
        super(ProjectTreeWidget, self).__init__(parent)

        self.setColumnCount(1)
        self.setHeaderLabel("Projects")

        # explorer actions
        self.renameAction = QtGui.QAction(QtGui.QIcon(":/tag_stroke.svg"),
                                          "&Rename",
                                          self,
                                          triggered=self.rename)
        self.renameAction.setToolTip("Rename project...")

        self.refreshAction = QtGui.QAction(QtGui.QIcon(":/spin.svg"),
                                           "Refresh",
                                           self,
                                           triggered=self.refresh,
                                           shortcut="F5")
        self.refreshAction.setToolTip("Refresh")

        self.newProjectAction = QtGui.QAction(
            QtGui.QIcon(":/document_alt_stroke.svg"),
            "&New Project",
            self,
            triggered=self.newProject)
        self.newProjectAction.setToolTip("Create new project...")

        self.importProjectAction = QtGui.QAction(QtGui.QIcon(":/import.svg"),
                                                 "&Import Project",
                                                 self,
                                                 triggered=self.importProject)
        self.importProjectAction.setToolTip("Import existing project...")

        self.newModelAction = QtGui.QAction(QtGui.QIcon(":/atoms.svg"),
                                            "&New Model",
                                            self,
                                            triggered=self.newModel)
        self.newModelAction.setToolTip("Create new model...")

        self.importModelAction = QtGui.QAction(QtGui.QIcon(":/import.svg"),
                                               "&Import Model",
                                               self,
                                               triggered=self.importModel)
        self.importModelAction.setToolTip("Import existing model...")

        self.removeProjectAction = QtGui.QAction(QtGui.QIcon(":/x.svg"),
                                                 "&Remove Project",
                                                 self,
                                                 triggered=self.removeProject,
                                                 shortcut='Del')
        self.newProjectAction.setToolTip("Remove project")

        self.removeProjectAction = QtGui.QAction(
            QtGui.QIcon(":/folder_fill.svg"),
            "Open Project &Location",
            self,
            triggered=self.removeProject)
        self.newProjectAction.setToolTip(
            "Opens project location in file explorer")

        # explorer menus
        self.explorerDefaultMenu = QtGui.QMenu()
        self.explorerDefaultMenu.addAction(self.newProjectAction)
        self.explorerDefaultMenu.addAction(self.importProjectAction)
        self.explorerDefaultMenu.addSeparator()
        #self.explorerDefaultMenu.addAction(self.copyAction)
        #self.explorerDefaultMenu.addAction(self.cutAction)
        #self.explorerDefaultMenu.addAction(self.pasteAction)
        self.explorerDefaultMenu.addAction(self.renameAction)
        self.explorerDefaultMenu.addSeparator()
        self.explorerDefaultMenu.addAction(self.refreshAction)

        self.explorerProjectMenu = QtGui.QMenu()
        self.explorerProjectMenu.addAction(self.newModelAction)
        self.explorerProjectMenu.addAction(self.importModelAction)
        #self.explorerProjectMenu.addSeparator()
        #self.explorerProjectMenu.addAction(self.copyAction)
        #self.explorerProjectMenu.addAction(self.cutAction)
        #self.explorerProjectMenu.addAction(self.pasteAction)
        self.explorerProjectMenu.addAction(self.renameAction)
        self.explorerProjectMenu.addAction(self.removeProjectAction)
        self.explorerProjectMenu.addSeparator()
        self.explorerProjectMenu.addAction(self.refreshAction)

        self.explorerFileMenu = QtGui.QMenu()
        #self.explorerFileMenu.addAction(self.newAction)
        self.explorerFileMenu.addAction(self.refreshAction)

        #setup signals and slots
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.explorerPopupMenu)

        #recent projects
        self.recent_projects = []