mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
CURA-5137 Get the list of packages from the server
This commit is contained in:
parent
0416ba95ae
commit
89c27ae7f4
3 changed files with 14 additions and 15 deletions
|
@ -24,12 +24,13 @@ from cura.CuraApplication import CuraApplication
|
||||||
|
|
||||||
i18n_catalog = i18nCatalog("cura")
|
i18n_catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
## The Toolbox class is responsible of communicating with the server through the API
|
||||||
class Toolbox(QObject, Extension):
|
class Toolbox(QObject, Extension):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self._api_version = 4
|
self._api_version = 1
|
||||||
self._api_url = "http://software.ultimaker.com/cura/v%s/" % self._api_version
|
self._api_url = "https://api-staging.ultimaker.com/cura-packages/v%s/" % self._api_version
|
||||||
|
|
||||||
self._plugin_list_request = None
|
self._plugin_list_request = None
|
||||||
self._download_plugin_request = None
|
self._download_plugin_request = None
|
||||||
|
@ -119,18 +120,18 @@ class Toolbox(QObject, Extension):
|
||||||
return self._is_downloading
|
return self._is_downloading
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def browsePlugins(self):
|
def browsePackages(self):
|
||||||
self._createNetworkManager()
|
self._createNetworkManager()
|
||||||
self.requestPluginList()
|
self.requestPackageList()
|
||||||
|
|
||||||
if not self._dialog:
|
if not self._dialog:
|
||||||
self._dialog = self._createDialog("PluginBrowser.qml")
|
self._dialog = self._createDialog("PluginBrowser.qml")
|
||||||
self._dialog.show()
|
self._dialog.show()
|
||||||
|
|
||||||
@pyqtSlot()
|
def requestPackageList(self):
|
||||||
def requestPluginList(self):
|
cura_version = 4
|
||||||
Logger.log("i", "Requesting plugin list")
|
Logger.log("i", "Requesting package list")
|
||||||
url = QUrl(self._api_url + "plugins")
|
url = QUrl(self._api_url + "packages?cura_version={version}".format(version = cura_version))
|
||||||
self._plugin_list_request = QNetworkRequest(url)
|
self._plugin_list_request = QNetworkRequest(url)
|
||||||
self._plugin_list_request.setRawHeader(*self._request_header)
|
self._plugin_list_request.setRawHeader(*self._request_header)
|
||||||
self._network_manager.get(self._plugin_list_request)
|
self._network_manager.get(self._plugin_list_request)
|
||||||
|
@ -138,7 +139,6 @@ class Toolbox(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 = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "resources", "qml", qml_name)
|
path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "resources", "qml", qml_name)
|
||||||
Logger.log("d", "Creating dialog [%s]", path)
|
|
||||||
dialog = Application.getInstance().createQmlComponent(path, {"manager": self})
|
dialog = Application.getInstance().createQmlComponent(path, {"manager": self})
|
||||||
return dialog
|
return dialog
|
||||||
|
|
||||||
|
@ -223,7 +223,6 @@ class Toolbox(QObject, Extension):
|
||||||
self.openRestartDialog(result["message"])
|
self.openRestartDialog(result["message"])
|
||||||
self._restart_required = True
|
self._restart_required = True
|
||||||
self.restartRequiredChanged.emit()
|
self.restartRequiredChanged.emit()
|
||||||
# Application.getInstance().messageBox(i18n_catalog.i18nc("@window:title", "Plugin browser"), result["message"])
|
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def removePlugin(self, plugin_id):
|
def removePlugin(self, plugin_id):
|
||||||
|
|
|
@ -68,7 +68,7 @@ Item
|
||||||
|
|
||||||
property alias configureSettingVisibility: configureSettingVisibilityAction
|
property alias configureSettingVisibility: configureSettingVisibilityAction
|
||||||
|
|
||||||
property alias browsePlugins: browsePluginsAction
|
property alias browsePackages: browsePackagesAction
|
||||||
|
|
||||||
UM.I18nCatalog{id: catalog; name:"cura"}
|
UM.I18nCatalog{id: catalog; name:"cura"}
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ Item
|
||||||
|
|
||||||
Action
|
Action
|
||||||
{
|
{
|
||||||
id: browsePluginsAction
|
id: browsePackagesAction
|
||||||
text: catalog.i18nc("@action:menu", "Browse packages...")
|
text: catalog.i18nc("@action:menu", "Browse packages...")
|
||||||
iconName: "plugins_browse"
|
iconName: "plugins_browse"
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,7 +272,7 @@ UM.MainWindow
|
||||||
id: plugin_menu
|
id: plugin_menu
|
||||||
title: catalog.i18nc("@title:menu menubar:toplevel", "&Toolbox")
|
title: catalog.i18nc("@title:menu menubar:toplevel", "&Toolbox")
|
||||||
|
|
||||||
MenuItem { action: Cura.Actions.browsePlugins }
|
MenuItem { action: Cura.Actions.browsePackages }
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu
|
Menu
|
||||||
|
@ -668,9 +668,9 @@ UM.MainWindow
|
||||||
// show the plugin browser dialog
|
// show the plugin browser dialog
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: Cura.Actions.browsePlugins
|
target: Cura.Actions.browsePackages
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
curaExtensions.callExtensionMethod("Toolbox", "browsePlugins")
|
curaExtensions.callExtensionMethod("Toolbox", "browsePackages")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue