Esempio n. 1
0
        def __init__(self, *args, **kwargs):

            self.c = kwargs['c']
            del kwargs['c']
            QtWidgets.QWidget.__init__(self, *args, **kwargs)
            # were we opened by an @ rich node? Calling code will set
            self.at_rich = False
            # are we being closed by leaving an @ rich node? Calling code will set
            self.at_rich_close = False
            # read settings.
            self.reloadSettings()
            # load HTML template
            template_path = g.os_path_join(g.computeLeoDir(), 'plugins', 'cke_template.html')
            self.template = open(template_path).read()
            path = g.os_path_join(g.computeLeoDir(), 'external', 'ckeditor')
            self.template = self.template.replace(
                '[CKEDITOR]', QtCore.QUrl.fromLocalFile(path).toString())
            # make widget containing QWebView
            self.setLayout(QtWidgets.QVBoxLayout())
            self.layout().setSpacing(0)
            self.layout().setContentsMargins(0,0,0,0)
            # enable inspector, if this really is QtWebKit
            if real_webkit:
                QtWebKit.QWebSettings.globalSettings().setAttribute(
                    QtWebKit.QWebSettings.DeveloperExtrasEnabled, True)
            self.webview = QtWebKitWidgets.QWebView()
            self.layout().addWidget(self.webview)
            g.registerHandler('select3', self.select_node)
            g.registerHandler('unselect1', self.unselect_node)
            # load current node
            self.select_node('', {'c': self.c, 'new_p': self.c.p})
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        
        self.c = kwargs['c']
        
        del kwargs['c']
        QtWidgets.QWidget.__init__(self, *args, **kwargs)
        
        # were we opened by an @ rich node? Calling code will set
        self.at_rich = False
        # are we being closed by leaving an @ rich node? Calling code will set
        self.at_rich_close = False
        
        # read autosave preference
        if not hasattr(self.c, '_ckeeditor_autosave'):
            auto = self.c.config.getBool("richtext_cke_autosave") or False
            self.c._ckeeditor_autosave = auto
            if auto:
                g.es("NOTE: automatic saving of rich text edits")

        # load HTML template
        template_path = g.os_path_join(
            g.computeLeoDir(),
            'plugins', 'cke_template.html',
        )
        self.template = open(template_path).read()
        path = g.os_path_join(
            g.computeLeoDir(), 'external', 'ckeditor'
        )
        self.template = self.template.replace(
            '[CKEDITOR]', QtCore.QUrl.fromLocalFile(path).toString())
        
        # load config
        self.config = self.c.config.getData("richtext_cke_config")
        if self.config:
            self.config = '\n'.join(self.config).strip()

        # make widget containing QWebView    
        self.setLayout(QtWidgets.QVBoxLayout())
        self.layout().setSpacing(0)
        self.layout().setContentsMargins(0,0,0,0)
        # enable inspector
        QtWebKit.QWebSettings.globalSettings().setAttribute(
            QtWebKit.QWebSettings.DeveloperExtrasEnabled, True)

        self.webview = QtWebKitWidgets.QWebView()
        self.layout().addWidget(self.webview)
        
        g.registerHandler('select3', self.select_node)
        g.registerHandler('unselect1', self.unselect_node)

        # load current node
        self.select_node('', {'c': self.c, 'new_p': self.c.p})
Esempio n. 3
0
    def make_pointer(self):
        """make_pointer - Return a pixmap for a pointer
        """

        path = g.computeLeoDir()
        path = g.os_path_join(path, 'Icons', 'recorder', 'pointer.png')
        return QtGui.QPixmap(path)
Esempio n. 4
0
 def get_favicon(self):
     path = g.os_path_join(g.computeLeoDir(), 'Icons', 'LeoApp16.ico')
     try:
         f = StringIO()
         f2 = open(path)
         s = f2.read()
         f.write(s)
         return f
     except Exception:
         return None
Esempio n. 5
0
 def get_favicon(self):
     path = g.os_path_join(g.computeLeoDir(), 'Icons', 'LeoApp16.ico')
     # g.trace(g.os_path_exists(path),path)
     try:
         f = StringIO()
         # f.write(open(path).read())
         f2 = open(path)
         s = f.read()
         f.write(s)
         return f
     except Exception:
         return None
Esempio n. 6
0
    def __init__(self, c):
        '''Ctor for NbController class.'''
        self.c = c
        self.gnxcache = {}
        self.mw = ModelWrapper(["h", "b", "gnx", "level", "style"])
        #self.add_all_nodes()
        #self.add_subtree(p)
        if isQt5:
            from PyQt5.QtQuick import QQuickView
            self.view = view = QQuickView()
        else:
            self.view = view = QtDeclarative.QDeclarativeView()
        ctx = view.rootContext()

        @g.command("nb-all")
        def nb_all_f(event):
            self.add_all_nodes()
            self.view.show()

        @g.command("nb-subtree")
        def nb_subtree_f(event):
            p = self.c.p
            self.add_subtree(p)
            self.view.show()

        ctx.setContextProperty("nodesModel", self.mw.model)
        path = g.os_path_join(g.computeLeoDir(), 'plugins', 'qmlnb', 'qml', 'leonbmain.qml')
        view.setSource(QtCore.QUrl(path))
        if isQt5:
            mode = view.SizeRootObjectToView
        else:
            mode = QtDeclarative.QDeclarativeView.SizeRootObjectToView
        view.setResizeMode(mode)
        # Display the user interface and allow the user to interact with it.
        view.hide()
        view.setGeometry(100, 100, 800, 600)
        #view.show()
        c.dummy = view
Esempio n. 7
0
    def __init__(self, c):

        self.c = c    
        self.gnxcache = {}
        
        self.mw = ModelWrapper(["h", "b", "gnx", "level", "style"])

        #self.add_all_nodes()       
        #self.add_subtree(p)       
        self.view = view = QDeclarativeView()
        ctx = view.rootContext()        
        
        @g.command("nb-all")
        def nb_all_f(event):
            self.add_all_nodes()
            self.view.show()
        
            
        @g.command("nb-subtree")
        def nb_subtree_f(event):
            p = self.c.p
            self.add_subtree(p)
            self.view.show()
            
        ctx.setContextProperty("nodesModel", self.mw.model)
                
        path = g.os_path_join(g.computeLeoDir(), 'plugins', 'qmlnb', 'qml', 'leonbmain.qml')
        view.setSource(QUrl(path))
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        # Display the user interface and allow the user to interact with it.
        view.hide()
        view.setGeometry(100, 100, 800, 600)
        
        #view.show()
        
        c.dummy = view
Esempio n. 8
0
    def __init__(self, c):

        self.c = c
        self.gnxcache = {}

        self.mw = ModelWrapper(["h", "b", "gnx", "level", "style"])

        #self.add_all_nodes()
        #self.add_subtree(p)
        self.view = view = QtDeclarative.QDeclarativeView()
        ctx = view.rootContext()

        @g.command("nb-all")
        def nb_all_f(event):
            self.add_all_nodes()
            self.view.show()

        @g.command("nb-subtree")
        def nb_subtree_f(event):
            p = self.c.p
            self.add_subtree(p)
            self.view.show()

        ctx.setContextProperty("nodesModel", self.mw.model)

        path = g.os_path_join(g.computeLeoDir(), 'plugins', 'qmlnb', 'qml',
                              'leonbmain.qml')
        view.setSource(QtCore.QUrl(path))
        view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView)
        # Display the user interface and allow the user to interact with it.
        view.hide()
        view.setGeometry(100, 100, 800, 600)

        #view.show()

        c.dummy = view
Esempio n. 9
0
 def make_pointer(self):
     """Return a pixmap for a pointer."""
     path = g.computeLeoDir()
     path = g.os_path_join(path, 'Icons', 'recorder', 'pointer.png')
     return QtGui.QPixmap(path)
Esempio n. 10
0
    def __init__(self, owner=None):

        self.owner = owner

        # a = QtGui.QApplication([]) # argc, argv );

        QtWidgets.QWidget.__init__(self)
        uiPath = g.os_path_join(g.app.leoDir,
            'plugins', 'GraphCanvas', 'GraphCanvas.ui')

        # change directory for this to work
        old_dir = os.getcwd()
        try:

            os.chdir(g.os_path_join(g.computeLeoDir(), ".."))

            form_class, base_class = uic.loadUiType(uiPath)
            self.owner.c.frame.log.createTab('Graph', widget = self)
            self.UI = form_class()
            self.UI.setupUi(self)

        finally:

            os.chdir(old_dir)

        self.canvas = QtWidgets.QGraphicsScene()

        self.canvasView = GraphicsView(self.owner, self.canvas)
        self.canvasView.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)

        self.UI.canvasFrame.addWidget(self.canvasView)
        self.canvasView.setSceneRect(0,0,300,300)
        self.canvasView.setRenderHints(QtGui.QPainter.Antialiasing)
        u = self.UI
        o = self.owner

        u.btnUpdate.clicked.connect(lambda checked: o.do_update())
        u.btnGoto.clicked.connect(lambda checked: o.goto())

        u.btnLoad.clicked.connect(lambda checked: o.loadGraph())
        u.btnLoadSibs.clicked.connect(lambda checked: o.loadGraph('sibs'))
        u.btnLoadRecur.clicked.connect(lambda checked: o.loadGraph('recur'))

        u.btnLoadLinked.clicked.connect(lambda checked: o.loadLinked('linked'))
        u.btnLoadAll.clicked.connect(lambda checked: o.loadLinked('all'))

        u.btnUnLoad.clicked.connect(lambda checked: o.unLoad())
        u.btnClear.clicked.connect(lambda checked: o.clear())

        u.btnLocate.clicked.connect(lambda checked: o.locateNode())
        u.btnReset.clicked.connect(lambda checked: o.resetNode())
        u.btnColor.clicked.connect(lambda checked: o.setColor())
        u.btnTextColor.clicked.connect(lambda checked: o.setTextColor())
        u.btnClearFormatting.clicked.connect(lambda checked: o.clearFormatting())

        u.btnRect.clicked.connect(lambda checked: o.setNode(nodeRect))
        u.btnEllipse.clicked.connect(lambda checked: o.setNode(nodeEllipse))
        u.btnDiamond.clicked.connect(lambda checked: o.setNode(nodeDiamond))
        u.btnNone.clicked.connect(lambda checked: o.setNode(nodeNone))
        u.btnTable.clicked.connect(lambda checked: o.setNode(nodeTable))

        u.btnComment.clicked.connect(lambda checked: o.setNode(nodeComment))

        u.btnImage.clicked.connect(lambda checked: o.setNode(nodeImage))

        u.btnExport.clicked.connect(lambda checked: o.exportGraph())

        u.chkHierarchy.clicked.connect(lambda checked: o.do_update())

        menu = QtWidgets.QMenu(u.btnLayout)
        for name, func in o.layouts():
            menu.addAction(name, func)
        u.btnLayout.setMenu(menu)
Esempio n. 11
0
    def __init__(self, owner=None):

        self.owner = owner

        # a = QtGui.QApplication([]) # argc, argv );

        QtWidgets.QWidget.__init__(self)
        uiPath = g.os_path_join(g.app.leoDir, 'plugins', 'GraphCanvas',
                                'GraphCanvas.ui')

        # change directory for this to work
        old_dir = os.getcwd()
        try:

            os.chdir(g.os_path_join(g.computeLeoDir(), ".."))

            form_class, base_class = uic.loadUiType(uiPath)
            self.owner.c.frame.log.createTab('Graph', widget=self)
            self.UI = form_class()
            self.UI.setupUi(self)

        finally:

            os.chdir(old_dir)

        self.canvas = QtWidgets.QGraphicsScene()

        self.canvasView = GraphicsView(self.owner, self.canvas)
        self.canvasView.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag)

        self.UI.canvasFrame.addWidget(self.canvasView)
        self.canvasView.setSceneRect(0, 0, 300, 300)
        self.canvasView.setRenderHints(QtGui.QPainter.Antialiasing)
        u = self.UI
        o = self.owner

        u.btnUpdate.clicked.connect(lambda checked: o.do_update())
        u.btnGoto.clicked.connect(lambda checked: o.goto())

        u.btnLoad.clicked.connect(lambda checked: o.loadGraph())
        u.btnLoadSibs.clicked.connect(lambda checked: o.loadGraph('sibs'))
        u.btnLoadRecur.clicked.connect(lambda checked: o.loadGraph('recur'))

        u.btnLoadLinked.clicked.connect(lambda checked: o.loadLinked('linked'))
        u.btnLoadAll.clicked.connect(lambda checked: o.loadLinked('all'))

        u.btnUnLoad.clicked.connect(lambda checked: o.unLoad())
        u.btnClear.clicked.connect(lambda checked: o.clear())

        u.btnLocate.clicked.connect(lambda checked: o.locateNode())
        u.btnReset.clicked.connect(lambda checked: o.resetNode())
        u.btnColor.clicked.connect(lambda checked: o.setColor())
        u.btnTextColor.clicked.connect(lambda checked: o.setTextColor())
        u.btnClearFormatting.clicked.connect(
            lambda checked: o.clearFormatting())

        u.btnRect.clicked.connect(lambda checked: o.setNode(nodeRect))
        u.btnEllipse.clicked.connect(lambda checked: o.setNode(nodeEllipse))
        u.btnDiamond.clicked.connect(lambda checked: o.setNode(nodeDiamond))
        u.btnNone.clicked.connect(lambda checked: o.setNode(nodeNone))
        u.btnTable.clicked.connect(lambda checked: o.setNode(nodeTable))

        u.btnComment.clicked.connect(lambda checked: o.setNode(nodeComment))

        u.btnImage.clicked.connect(lambda checked: o.setNode(nodeImage))

        u.btnExport.clicked.connect(lambda checked: o.exportGraph())

        u.chkHierarchy.clicked.connect(lambda checked: o.do_update())

        menu = QtWidgets.QMenu(u.btnLayout)
        for name, func in o.layouts():
            menu.addAction(name, func)
        u.btnLayout.setMenu(menu)