Esempio n. 1
0
    def Make(menu):
        menu.clear()
        recent = appconfig.setdefault('recent_projects', [])
        def f(menu, v):
            projname, ext = os.path.splitext(os.path.basename(v))
            action = QAction(projname, menu)
            action.triggered.connect(lambda: appdata.project.OpenProjectFile(v))
            action.setStatusTip(v)
            menu.addAction(action)

        for v in reversed(recent):
            f(menu, v)
Esempio n. 2
0
    def Make(menu):
        menu.clear()

        def f(menu, doc):
            fm = appdata.app.fontMetrics()
            width = fm.averageCharWidth() * 80
            text = fm.elidedText(doc.name, Qt.ElideMiddle, width).replace(u'\u2026', '...')
            action = QAction(text, menu)
            action.triggered.connect(lambda: appdata.project.Compare(selected, doc))
            menu.addAction(action)

        selected = appdata.project.selected[0] if appdata.project.selected else None
        docs = set()
        if selected and hasattr(selected, 'doc') and isinstance(selected.doc, GraphDocument) and not getattr(selected.doc, 'doc_connection', None):
            for it in QTreeWidgetItemIterator(appdata.project):
                viewnode = it.value()
                if hasattr(viewnode, 'doc') and viewnode.doc != None and isinstance(viewnode.doc, GraphDocument) and viewnode is not selected:
                    docs.add(viewnode.doc)

        for d in docs:
            f(menu, d)