Example #1
0
def pytest_qml_qmlEngineAvailable(engine: QQmlEngine):
    global db
    global fk
    global th
    from mycartable.main import (
        add_database_to_types,
    )

    add_database_to_types(db)
    ctx = engine.rootContext()
    ctx.setContextProperty("fk", fk)
    ctx.setContextProperty("th", th)
Example #2
0
    def __init__(self) :
        QObject.__init__( self )
        self.app = QApplication( sys.argv )
        self.app.setApplicationName( 'Waterfall' )
        engine = QQmlEngine()

        appDirPath = os.path.dirname( os.path.abspath( __file__ ) )
        rootContext = engine.rootContext()
        rootContext.setContextProperty( 'controller', self )
        rootContext.setContextProperty( 'appPath', appDirPath.replace( "\\", "/" ) + "/" )
        windowComp = QQmlComponent( engine, QUrl( 'qml/Main.qml' ) )
        
        self.window = windowComp.create()
        self.window.show()
        self.app.exec()
Example #3
0
def main(argv, app):

    engine = QQmlEngine(app)
    engine.quit.connect(app.quit)
    component = QQmlComponent(engine)
    component.loadUrl(QUrl('Wizard/Wizard.qml'))
    if component.isReady():
        mainWindow = component.create()
        file = FileInfo()
        context = engine.rootContext()
        context.setContextProperty('FileInfo', file)

    else:
        print(component.errorString())

    sys.exit(app.exec_())
Example #4
0
        toolbar = self.addToolBar('Exit')
        # toolbar.setObjectName('ToolBar')
        # toolbar.addAction(exitAction)
        # toolbar.addAction(processUrlAction)

        self.restoreState()
        self.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    qmlRegisterType(JiraMain, 'JiraTree', 1, 0, 'MainWindow')

    engine = QQmlEngine()
    # Create a component factory and load the QML script.
    component = QQmlComponent(engine)
    component.loadUrl(QUrl.fromLocalFile('main.qml'))
    jm = component.create()
    [print(e.toString()) for e in component.errors()]
    engine.rootContext().setContextProperty("mainWindow", jm)
    if jm is None:
        print("JM is none")
        print({e.toString() for e in component.errors()})

#	ex = JiraMain(None)
    print("Run")
    app.exec()
    print("Exit")
    sys.exit()
Example #5
0
class QMLApplicationWidget(QWidget):
    def __init__(self, fileUrl, parent=None):
        super(QMLApplicationWidget, self).__init__(parent=parent)

        self.setLayout(QVBoxLayout())

        self.app = runningApp()
        self.epFileUrl = fileUrl
        self.fsw = FileWatcher(parent=self)
        self.fsw.pathChanged.connect(self.onReloadApp)
        self.fsw.watch(self.epFileUrl)

        self.stack = QStackedWidget()
        self.layout().addWidget(self.stack)

        self.gInterface = GHandler(self)
        self.iInterface = IHandler(self)
        self.ldInterface = LDHandler(self)
        self.sparqlInterface = SparQLHandler(self)
        self.ipidInterface = IPIDHandler(self)

        self.currentComponent = None

        # Clone the IPFS profile
        self.webProfile = self.app.webProfiles['ipfs'].quickClone()

        # TODO: move this in global place
        self.models = {
            'Articles': ArticlesModel(),
            'Channels': MultimediaChannelsModel(),
            'Shouts': ShoutsModel()
        }
        self.setupEngine()

    @property
    def comp(self):
        return self.currentComponent

    def onReloadApp(self, chPath):
        print(chPath, 'changed')

        self.engine.clearComponentCache()
        self.load()

    def setupEngine(self):
        ipfsCtx = self.app.ipfsCtx
        filesModel = ipfsCtx.currentProfile.filesModel

        # stores = services.getByDotName('ld.rdf.graphs')

        self.engine = QQmlEngine(self)
        ctx = self.engine.rootContext()

        # XML graph exports paths
        # ctx.setContextProperty('graphGXmlPath',
        #                        stores.graphG.xmlExportUrl)

        ctx.setContextProperty('g', self.gInterface)
        ctx.setContextProperty('ld', self.ldInterface)
        ctx.setContextProperty('sparql', self.sparqlInterface)
        ctx.setContextProperty('iContainer', self.iInterface)
        ctx.setContextProperty('ipid', self.ipidInterface)

        # Pass the web profile
        ctx.setContextProperty('ipfsWebProfile', self.webProfile)

        ctx.setContextProperty('modelArticles', self.models['Articles'])
        ctx.setContextProperty('modelMultiChannels', self.models['Channels'])
        ctx.setContextProperty('modelShouts', self.models['Shouts'])
        ctx.setContextProperty('modelMfs', filesModel)

    def resizeEvent(self, event):
        super().resizeEvent(event)

        if self.comp:
            self.iInterface.size = event.size()
            self.iInterface.sizeChanged.emit(event.size().width(),
                                             event.size().height())

    def importComponent(self, path):
        self.engine.addImportPath(path)
        self.fsw.watchWalk(Path(path))

    def load(self):
        # stores = services.getByDotName('ld.rdf.graphs')
        qcomp = quickEnginedWidget(self.engine,
                                   QUrl.fromLocalFile(self.epFileUrl),
                                   parent=self.stack)

        if not qcomp:
            return

        self.stack.addWidget(qcomp)
        self.stack.setCurrentWidget(qcomp)

        self.stack.setFocus(Qt.OtherFocusReason)
        qcomp.setFocus(Qt.OtherFocusReason)

        self.currentComponent = qcomp