mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
Update creating QML component in plugin browser - CURA-4568
This commit is contained in:
parent
74eb4958af
commit
e3f1144d97
2 changed files with 6 additions and 10 deletions
|
@ -1,12 +1,10 @@
|
||||||
# Copyright (c) 2016 Ultimaker B.V.
|
# Copyright (c) 2016 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from PyQt5.QtCore import QUrl, pyqtSignal, QObject, pyqtProperty, QCoreApplication
|
from PyQt5.QtCore import pyqtSignal, QObject, pyqtProperty, QCoreApplication
|
||||||
from UM.FlameProfiler import pyqtSlot
|
from UM.FlameProfiler import pyqtSlot
|
||||||
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Logger import Logger
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ from UM.Message import Message
|
||||||
|
|
||||||
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
|
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
|
||||||
from PyQt5.QtCore import QUrl, QObject, Qt, pyqtProperty, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import QUrl, QObject, Qt, pyqtProperty, pyqtSignal, pyqtSlot
|
||||||
from PyQt5.QtQml import QQmlComponent, QQmlContext
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -112,16 +111,15 @@ class PluginBrowser(QObject, Extension):
|
||||||
def _createDialog(self, qml_name):
|
def _createDialog(self, qml_name):
|
||||||
Logger.log("d", "Creating dialog [%s]", qml_name)
|
Logger.log("d", "Creating dialog [%s]", qml_name)
|
||||||
|
|
||||||
path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), qml_name))
|
path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), qml_name)
|
||||||
self._qml_component = QQmlComponent(Application.getInstance()._engine, path)
|
dialog = Application.getInstance().createQmlComponent(path, {
|
||||||
|
"manager": self
|
||||||
|
})
|
||||||
|
|
||||||
# We need access to engine (although technically we can't)
|
|
||||||
self._qml_context = QQmlContext(Application.getInstance()._engine.rootContext())
|
|
||||||
self._qml_context.setContextProperty("manager", self)
|
|
||||||
dialog = self._qml_component.create(self._qml_context)
|
|
||||||
if dialog is None:
|
if dialog is None:
|
||||||
Logger.log("e", "QQmlComponent status %s", self._qml_component.status())
|
Logger.log("e", "QQmlComponent status %s", self._qml_component.status())
|
||||||
Logger.log("e", "QQmlComponent errorString %s", self._qml_component.errorString())
|
Logger.log("e", "QQmlComponent errorString %s", self._qml_component.errorString())
|
||||||
|
|
||||||
return dialog
|
return dialog
|
||||||
|
|
||||||
def setIsDownloading(self, is_downloading):
|
def setIsDownloading(self, is_downloading):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue