mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
CURA-5035: Clean-up
This commit is contained in:
parent
6e9f7174b6
commit
e13c45daee
19 changed files with 185 additions and 179 deletions
|
@ -43,27 +43,27 @@ Window
|
||||||
ToolboxLoadingPage
|
ToolboxLoadingPage
|
||||||
{
|
{
|
||||||
id: viewLoading
|
id: viewLoading
|
||||||
visible: manager.viewCategory != "installed" && manager.viewPage == "loading"
|
visible: toolbox.viewCategory != "installed" && toolbox.viewPage == "loading"
|
||||||
}
|
}
|
||||||
ToolboxDownloadsPage
|
ToolboxDownloadsPage
|
||||||
{
|
{
|
||||||
id: viewDownloads
|
id: viewDownloads
|
||||||
visible: manager.viewCategory != "installed" && manager.viewPage == "overview"
|
visible: toolbox.viewCategory != "installed" && toolbox.viewPage == "overview"
|
||||||
}
|
}
|
||||||
ToolboxDetailPage
|
ToolboxDetailPage
|
||||||
{
|
{
|
||||||
id: viewDetail
|
id: viewDetail
|
||||||
visible: manager.viewCategory != "installed" && manager.viewPage == "detail"
|
visible: toolbox.viewCategory != "installed" && toolbox.viewPage == "detail"
|
||||||
}
|
}
|
||||||
ToolboxAuthorPage
|
ToolboxAuthorPage
|
||||||
{
|
{
|
||||||
id: viewAuthor
|
id: viewAuthor
|
||||||
visible: manager.viewCategory != "installed" && manager.viewPage == "author"
|
visible: toolbox.viewCategory != "installed" && toolbox.viewPage == "author"
|
||||||
}
|
}
|
||||||
ToolboxInstalledPage
|
ToolboxInstalledPage
|
||||||
{
|
{
|
||||||
id: installedPluginList
|
id: installedPluginList
|
||||||
visible: manager.viewCategory == "installed"
|
visible: toolbox.viewCategory == "installed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ToolboxShadow
|
ToolboxShadow
|
||||||
|
@ -83,21 +83,21 @@ Window
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: manager
|
target: toolbox
|
||||||
onShowLicenseDialog:
|
onShowLicenseDialog:
|
||||||
{
|
{
|
||||||
licenseDialog.pluginName = manager.getLicenseDialogPluginName();
|
licenseDialog.pluginName = toolbox.getLicenseDialogPluginName();
|
||||||
licenseDialog.licenseContent = manager.getLicenseDialogLicenseContent();
|
licenseDialog.licenseContent = toolbox.getLicenseDialogLicenseContent();
|
||||||
licenseDialog.pluginFileLocation = manager.getLicenseDialogPluginFileLocation();
|
licenseDialog.pluginFileLocation = toolbox.getLicenseDialogPluginFileLocation();
|
||||||
licenseDialog.show();
|
licenseDialog.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: manager
|
target: toolbox
|
||||||
onShowRestartDialog:
|
onShowRestartDialog:
|
||||||
{
|
{
|
||||||
restartDialog.message = manager.getRestartDialogMessage();
|
restartDialog.message = toolbox.getRestartDialogMessage();
|
||||||
restartDialog.show();
|
restartDialog.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import UM 1.1 as UM
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
property var details: manager.authorsModel.items[0]
|
property var details: toolbox.authorsModel.items[0]
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
ToolboxBackColumn
|
ToolboxBackColumn
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,9 +41,9 @@ Item
|
||||||
height: UM.Theme.getSize("base_unit").height * 2
|
height: UM.Theme.getSize("base_unit").height * 2
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
manager.viewPage = "overview"
|
toolbox.viewPage = "overview"
|
||||||
manager.filterPackages("type", manager.viewCategory)
|
toolbox.filterPackages("type", toolbox.viewCategory)
|
||||||
manager.filterAuthors("type", manager.viewCategory)
|
toolbox.filterAuthors("type", toolbox.viewCategory)
|
||||||
}
|
}
|
||||||
style: ButtonStyle
|
style: ButtonStyle
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@ Item
|
||||||
spacing: UM.Theme.getSize("default_margin").height
|
spacing: UM.Theme.getSize("default_margin").height
|
||||||
Repeater
|
Repeater
|
||||||
{
|
{
|
||||||
model: manager.packagesModel
|
model: toolbox.packagesModel
|
||||||
delegate: ToolboxDetailTile {}
|
delegate: ToolboxDetailTile {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import UM 1.1 as UM
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
property var details: manager.packagesModel.items[0]
|
property var details: toolbox.packagesModel.items[0]
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
ToolboxBackColumn
|
ToolboxBackColumn
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,7 @@ Rectangle
|
||||||
Button {
|
Button {
|
||||||
id: installButton
|
id: installButton
|
||||||
text: {
|
text: {
|
||||||
if ( manager.isDownloading && manager.activePackage == model )
|
if ( toolbox.isDownloading && toolbox.activePackage == model )
|
||||||
{
|
{
|
||||||
return catalog.i18nc("@action:button", "Cancel")
|
return catalog.i18nc("@action:button", "Cancel")
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,9 @@ Rectangle
|
||||||
}
|
}
|
||||||
enabled:
|
enabled:
|
||||||
{
|
{
|
||||||
if ( manager.isDownloading )
|
if ( toolbox.isDownloading )
|
||||||
{
|
{
|
||||||
return manager.activePackage == model ? true : false
|
return toolbox.activePackage == model ? true : false
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -88,21 +88,21 @@ Rectangle
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
console.log( "MODEL", model.id )
|
console.log( "MODEL", model.id )
|
||||||
manager.activePackage = model
|
toolbox.activePackage = model
|
||||||
// if ( manager.isDownloading && manager.activePackage == model )
|
// if ( toolbox.isDownloading && toolbox.activePackage == model )
|
||||||
if ( manager.isDownloading )
|
if ( toolbox.isDownloading )
|
||||||
{
|
{
|
||||||
manager.cancelDownload();
|
toolbox.cancelDownload();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// manager.activePackage = model;
|
// toolbox.activePackage = model;
|
||||||
if ( model.can_upgrade )
|
if ( model.can_upgrade )
|
||||||
{
|
{
|
||||||
// manager.downloadAndInstallPlugin( model.update_url );
|
// toolbox.downloadAndInstallPlugin( model.update_url );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
manager.startDownload( model.download_url );
|
toolbox.startDownload( model.download_url );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ Column
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
id: heading
|
id: heading
|
||||||
text: manager.viewCategory == "material" ? "Maker Choices" : "Community Plugins"
|
text: toolbox.viewCategory == "material" ? "Maker Choices" : "Community Plugins"
|
||||||
width: parent.width
|
width: parent.width
|
||||||
color: UM.Theme.getColor("text_medium")
|
color: UM.Theme.getColor("text_medium")
|
||||||
font: UM.Theme.getFont("medium")
|
font: UM.Theme.getFont("medium")
|
||||||
|
@ -34,7 +34,7 @@ Column
|
||||||
|
|
||||||
Repeater
|
Repeater
|
||||||
{
|
{
|
||||||
model: manager.viewCategory == "material" ? manager.authorsModel : manager.packagesModel
|
model: toolbox.viewCategory == "material" ? toolbox.authorsModel : toolbox.packagesModel
|
||||||
delegate: ToolboxDownloadsGridTile
|
delegate: ToolboxDownloadsGridTile
|
||||||
{
|
{
|
||||||
Layout.preferredWidth: (grid.width - (grid.columns - 1) * grid.columnSpacing) / grid.columns
|
Layout.preferredWidth: (grid.width - (grid.columns - 1) * grid.columnSpacing) / grid.columns
|
||||||
|
|
|
@ -88,19 +88,19 @@ Item
|
||||||
}
|
}
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
if ( manager.viewCategory == "material" )
|
if ( toolbox.viewCategory == "material" )
|
||||||
{
|
{
|
||||||
manager.viewSelection = model.name
|
toolbox.viewSelection = model.name
|
||||||
manager.viewPage = "author"
|
toolbox.viewPage = "author"
|
||||||
manager.filterAuthors("name", model.name)
|
toolbox.filterAuthors("name", model.name)
|
||||||
manager.filterPackages("author_name", model.name)
|
toolbox.filterPackages("author_name", model.name)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
manager.viewSelection = model.id
|
toolbox.viewSelection = model.id
|
||||||
manager.viewPage = "detail"
|
toolbox.viewPage = "detail"
|
||||||
manager.filterAuthors("name", model.author_name)
|
toolbox.filterAuthors("name", model.author_name)
|
||||||
manager.filterPackages("id", model.id)
|
toolbox.filterPackages("id", model.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,13 @@ Column
|
||||||
Repeater
|
Repeater
|
||||||
{
|
{
|
||||||
model: {
|
model: {
|
||||||
if ( manager.viewCategory == "plugin" )
|
if ( toolbox.viewCategory == "plugin" )
|
||||||
{
|
{
|
||||||
return manager.pluginsShowcaseModel
|
return toolbox.pluginsShowcaseModel
|
||||||
}
|
}
|
||||||
if ( manager.viewCategory == "material" )
|
if ( toolbox.viewCategory == "material" )
|
||||||
{
|
{
|
||||||
return manager.materialsShowcaseModel
|
return toolbox.materialsShowcaseModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delegate: ToolboxDownloadsShowcaseTile {}
|
delegate: ToolboxDownloadsShowcaseTile {}
|
||||||
|
|
|
@ -51,19 +51,19 @@ Item
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: {
|
onClicked: {
|
||||||
switch(manager.viewCategory)
|
switch(toolbox.viewCategory)
|
||||||
{
|
{
|
||||||
case "material":
|
case "material":
|
||||||
manager.viewSelection = model.name
|
toolbox.viewSelection = model.name
|
||||||
manager.viewPage = "author"
|
toolbox.viewPage = "author"
|
||||||
manager.filterAuthors("name", model.name)
|
toolbox.filterAuthors("name", model.name)
|
||||||
manager.filterPackages("author_name", model.name)
|
toolbox.filterPackages("author_name", model.name)
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
manager.viewSelection = model.id
|
toolbox.viewSelection = model.id
|
||||||
manager.viewPage = "detail"
|
toolbox.viewPage = "detail"
|
||||||
manager.filterAuthors("name", model.author_name)
|
toolbox.filterAuthors("name", model.author_name)
|
||||||
manager.filterPackages("id", model.id)
|
toolbox.filterPackages("id", model.id)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ Item
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
visible: manager.restartRequired
|
visible: toolbox.restartRequired
|
||||||
text: "You will need to restart Cura before changes in plugins have effect."
|
text: "You will need to restart Cura before changes in plugins have effect."
|
||||||
height: UM.Theme.getSize("base_unit").height * 2
|
height: UM.Theme.getSize("base_unit").height * 2
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
@ -39,9 +39,9 @@ Item
|
||||||
right: closeButton.left
|
right: closeButton.left
|
||||||
rightMargin: UM.Theme.getSize("default_margin").width
|
rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
}
|
}
|
||||||
visible: manager.restartRequired
|
visible: toolbox.restartRequired
|
||||||
iconName: "dialog-restart"
|
iconName: "dialog-restart"
|
||||||
onClicked: manager.restart()
|
onClicked: toolbox.restart()
|
||||||
style: ButtonStyle
|
style: ButtonStyle
|
||||||
{
|
{
|
||||||
background: Rectangle
|
background: Rectangle
|
||||||
|
@ -72,9 +72,9 @@ Item
|
||||||
iconName: "dialog-close"
|
iconName: "dialog-close"
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
if ( manager.isDownloading )
|
if ( toolbox.isDownloading )
|
||||||
{
|
{
|
||||||
manager.cancelDownload()
|
toolbox.cancelDownload()
|
||||||
}
|
}
|
||||||
base.close();
|
base.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ Rectangle {
|
||||||
implicitHeight: 48
|
implicitHeight: 48
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
visible: manager.viewCategory == "plugin"
|
visible: toolbox.viewCategory == "plugin"
|
||||||
color: UM.Theme.getColor("primary")
|
color: UM.Theme.getColor("primary")
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -55,10 +55,10 @@ Rectangle {
|
||||||
}
|
}
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
manager.filterPackages("type", "plugin")
|
toolbox.filterPackages("type", "plugin")
|
||||||
manager.filterAuthors("type", "plugin")
|
toolbox.filterAuthors("type", "plugin")
|
||||||
manager.viewCategory = "plugin"
|
toolbox.viewCategory = "plugin"
|
||||||
manager.viewPage = "overview"
|
toolbox.viewPage = "overview"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ Rectangle {
|
||||||
implicitHeight: 48
|
implicitHeight: 48
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
visible: manager.viewCategory == "material"
|
visible: toolbox.viewCategory == "material"
|
||||||
color: UM.Theme.getColor("primary")
|
color: UM.Theme.getColor("primary")
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -92,10 +92,10 @@ Rectangle {
|
||||||
}
|
}
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
manager.filterPackages("type", "material")
|
toolbox.filterPackages("type", "material")
|
||||||
manager.filterAuthors("type", "material")
|
toolbox.filterAuthors("type", "material")
|
||||||
manager.viewCategory = "material"
|
toolbox.viewCategory = "material"
|
||||||
manager.viewPage = "overview"
|
toolbox.viewPage = "overview"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ Rectangle {
|
||||||
implicitWidth: 96
|
implicitWidth: 96
|
||||||
implicitHeight: 48
|
implicitHeight: 48
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: manager.viewCategory == "installed"
|
visible: toolbox.viewCategory == "installed"
|
||||||
color: UM.Theme.getColor("primary")
|
color: UM.Theme.getColor("primary")
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -129,6 +129,6 @@ Rectangle {
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClicked: manager.viewCategory = "installed"
|
onClicked: toolbox.viewCategory = "installed"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ ScrollView
|
||||||
Repeater
|
Repeater
|
||||||
{
|
{
|
||||||
id: materialList
|
id: materialList
|
||||||
model: manager.packagesModel
|
model: toolbox.packagesModel
|
||||||
delegate: ToolboxInstalledTile {}
|
delegate: ToolboxInstalledTile {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ ScrollView
|
||||||
Repeater
|
Repeater
|
||||||
{
|
{
|
||||||
id: pluginList
|
id: pluginList
|
||||||
model: manager.packagesModel
|
model: toolbox.packagesModel
|
||||||
delegate: ToolboxInstalledTile {}
|
delegate: ToolboxInstalledTile {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ Item
|
||||||
id: removeButton
|
id: removeButton
|
||||||
text: "Uninstall"
|
text: "Uninstall"
|
||||||
visible: model.can_uninstall && model.status == "installed"
|
visible: model.can_uninstall && model.status == "installed"
|
||||||
enabled: !manager.isDownloading
|
enabled: !toolbox.isDownloading
|
||||||
style: ButtonStyle
|
style: ButtonStyle
|
||||||
{
|
{
|
||||||
background: Rectangle
|
background: Rectangle
|
||||||
|
@ -125,7 +125,7 @@ Item
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onClicked: manager.removePlugin( model.id )
|
onClicked: toolbox.removePlugin( model.id )
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
@ -151,7 +151,7 @@ Item
|
||||||
}
|
}
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
manager.updatePackage(model.id);
|
toolbox.updatePackage(model.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProgressBar
|
ProgressBar
|
||||||
|
@ -161,8 +161,8 @@ Item
|
||||||
anchors.right: installButton.right
|
anchors.right: installButton.right
|
||||||
anchors.top: installButton.bottom
|
anchors.top: installButton.bottom
|
||||||
anchors.topMargin: 4
|
anchors.topMargin: 4
|
||||||
value: manager.isDownloading ? manager.downloadProgress : 0
|
value: toolbox.isDownloading ? toolbox.downloadProgress : 0
|
||||||
visible: manager.isDownloading
|
visible: toolbox.isDownloading
|
||||||
style: ProgressBarStyle
|
style: ProgressBarStyle
|
||||||
{
|
{
|
||||||
background: Rectangle
|
background: Rectangle
|
||||||
|
|
|
@ -59,7 +59,7 @@ UM.Dialog {
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
licenseDialog.close();
|
licenseDialog.close();
|
||||||
manager.installPlugin(licenseDialog.pluginFileLocation);
|
toolbox.installPlugin(licenseDialog.pluginFileLocation);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Button
|
Button
|
||||||
|
|
|
@ -66,7 +66,7 @@ Window {
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
bottomMargin: UM.Theme.getSize("default_margin").height
|
bottomMargin: UM.Theme.getSize("default_margin").height
|
||||||
}
|
}
|
||||||
onClicked: manager.restart()
|
onClicked: toolbox.restart()
|
||||||
style: ButtonStyle {
|
style: ButtonStyle {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: 96
|
implicitWidth: 96
|
||||||
|
|
|
@ -28,7 +28,7 @@ class AuthorsModel(ListModel):
|
||||||
# List of filters for queries. The result is the union of the each list of results.
|
# List of filters for queries. The result is the union of the each list of results.
|
||||||
self._filter = {} # type: Dict[str,str]
|
self._filter = {} # type: Dict[str,str]
|
||||||
|
|
||||||
def setMetaData(self, data):
|
def setMetadata(self, data):
|
||||||
self._authors_metadata = data
|
self._authors_metadata = data
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class PackagesModel(ListModel):
|
||||||
# List of filters for queries. The result is the union of the each list of results.
|
# List of filters for queries. The result is the union of the each list of results.
|
||||||
self._filter = {} # type: Dict[str,str]
|
self._filter = {} # type: Dict[str,str]
|
||||||
|
|
||||||
def setPackagesMetaData(self, data):
|
def setMetadata(self, data):
|
||||||
self._packages_metadata = data
|
self._packages_metadata = data
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ from .PackagesModel import PackagesModel
|
||||||
|
|
||||||
i18n_catalog = i18nCatalog("cura")
|
i18n_catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
## The Toolbox class is responsible of communicating with the server through the API
|
## 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):
|
||||||
|
@ -33,19 +32,17 @@ class Toolbox(QObject, Extension):
|
||||||
self._application = Application.getInstance()
|
self._application = Application.getInstance()
|
||||||
self._package_manager = None
|
self._package_manager = None
|
||||||
self._plugin_registry = Application.getInstance().getPluginRegistry()
|
self._plugin_registry = Application.getInstance().getPluginRegistry()
|
||||||
self._package_manager = None
|
|
||||||
self._packages_version = self._plugin_registry.APIVersion
|
self._packages_version = self._plugin_registry.APIVersion
|
||||||
self._api_version = 1
|
self._api_version = 1
|
||||||
self._api_url = "https://api-staging.ultimaker.com/cura-packages/v{api_version}/cura/v{package_version}".format( api_version = self._api_version, package_version = self._packages_version)
|
self._api_url = "https://api-staging.ultimaker.com/cura-packages/v{api_version}/cura/v{package_version}".format( api_version = self._api_version, package_version = self._packages_version)
|
||||||
|
|
||||||
|
# Network:
|
||||||
self._get_packages_request = None
|
self._get_packages_request = None
|
||||||
self._get_showcase_request = None
|
self._get_showcase_request = None
|
||||||
|
|
||||||
self._download_request = None
|
self._download_request = None
|
||||||
self._download_reply = None
|
self._download_reply = None
|
||||||
self._download_progress = 0
|
self._download_progress = 0
|
||||||
self._is_downloading = False
|
self._is_downloading = False
|
||||||
|
|
||||||
self._network_manager = None
|
self._network_manager = None
|
||||||
self._request_header = [
|
self._request_header = [
|
||||||
b"User-Agent",
|
b"User-Agent",
|
||||||
|
@ -59,13 +56,43 @@ class Toolbox(QObject, Extension):
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Data:
|
||||||
|
self._authors_metadata = []
|
||||||
self._packages_metadata = []
|
self._packages_metadata = []
|
||||||
|
self._metadata = {
|
||||||
|
"authors": [],
|
||||||
|
"packages": [],
|
||||||
|
"materials_showcase": [
|
||||||
|
{
|
||||||
|
"name": "DSM",
|
||||||
|
"email": "contact@dsm.nl",
|
||||||
|
"website": "www.dsm.nl",
|
||||||
|
"type": "material"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BASF",
|
||||||
|
"email": "contact@basf.de",
|
||||||
|
"website": "www.basf.de",
|
||||||
|
"type": "material"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Models:
|
||||||
|
self._authors_model = None
|
||||||
self._packages_model = None
|
self._packages_model = None
|
||||||
self._plugins_showcase_model = None
|
self._plugins_showcase_model = None
|
||||||
self._plugins_installed_model = None
|
self._plugins_installed_model = None
|
||||||
self._materials_showcase_model = None
|
self._materials_showcase_model = None
|
||||||
self._materials_installed_model = None
|
self._materials_installed_model = None
|
||||||
self._authors_model = None
|
self._models = {
|
||||||
|
"authors": None,
|
||||||
|
"packages": None,
|
||||||
|
"plugins_showcase": None,
|
||||||
|
"plugins_installed": None,
|
||||||
|
"materials_showcase": None,
|
||||||
|
"materials_installed": None
|
||||||
|
}
|
||||||
|
|
||||||
# These properties are for keeping track of the UI state:
|
# These properties are for keeping track of the UI state:
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
|
@ -87,21 +114,10 @@ class Toolbox(QObject, Extension):
|
||||||
# installed, or otherwise modified.
|
# installed, or otherwise modified.
|
||||||
self._active_package = None
|
self._active_package = None
|
||||||
|
|
||||||
# Nowadays can be 'plugins', 'materials' or 'installed'
|
|
||||||
self._current_view = "plugins"
|
|
||||||
self._detail_data = {} # Extraneous since can just use the data prop of the model.
|
|
||||||
|
|
||||||
self._dialog = None
|
self._dialog = None
|
||||||
self._restartDialog = None
|
self._restartDialog = None
|
||||||
self._restart_required = False
|
self._restart_required = False
|
||||||
|
|
||||||
# Installed plugins are really installed after reboot. In order to
|
|
||||||
# prevent the user from downloading the same file over and over again,
|
|
||||||
# we keep track of the upgraded plugins.
|
|
||||||
self._newly_installed_plugin_ids = []
|
|
||||||
self._newly_uninstalled_plugin_ids = []
|
|
||||||
self._plugin_statuses = {} # type: Dict[str, str]
|
|
||||||
|
|
||||||
# variables for the license agreement dialog
|
# variables for the license agreement dialog
|
||||||
self._license_dialog_plugin_name = ""
|
self._license_dialog_plugin_name = ""
|
||||||
self._license_dialog_license_content = ""
|
self._license_dialog_license_content = ""
|
||||||
|
@ -110,15 +126,10 @@ class Toolbox(QObject, Extension):
|
||||||
|
|
||||||
Application.getInstance().initializationFinished.connect(self._onAppInitialized)
|
Application.getInstance().initializationFinished.connect(self._onAppInitialized)
|
||||||
|
|
||||||
def _onAppInitialized(self):
|
|
||||||
self._package_manager = Application.getInstance().getCuraPackageManager()
|
|
||||||
|
|
||||||
packagesMetadataChanged = pyqtSignal()
|
|
||||||
authorsMetadataChanged = pyqtSignal()
|
|
||||||
pluginsShowcaseMetadataChanged = pyqtSignal()
|
|
||||||
materialsShowcaseMetadataChanged = pyqtSignal()
|
|
||||||
metadataChanged = pyqtSignal()
|
|
||||||
|
|
||||||
|
# Signals:
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
# Downloading changes
|
# Downloading changes
|
||||||
activePackageChanged = pyqtSignal()
|
activePackageChanged = pyqtSignal()
|
||||||
onDownloadProgressChanged = pyqtSignal()
|
onDownloadProgressChanged = pyqtSignal()
|
||||||
|
@ -129,6 +140,7 @@ class Toolbox(QObject, Extension):
|
||||||
viewChanged = pyqtSignal()
|
viewChanged = pyqtSignal()
|
||||||
detailViewChanged = pyqtSignal()
|
detailViewChanged = pyqtSignal()
|
||||||
filterChanged = pyqtSignal()
|
filterChanged = pyqtSignal()
|
||||||
|
metadataChanged = pyqtSignal()
|
||||||
showLicenseDialog = pyqtSignal()
|
showLicenseDialog = pyqtSignal()
|
||||||
showRestartDialog = pyqtSignal()
|
showRestartDialog = pyqtSignal()
|
||||||
|
|
||||||
|
@ -158,9 +170,11 @@ class Toolbox(QObject, Extension):
|
||||||
self._restart_dialog_message = message
|
self._restart_dialog_message = message
|
||||||
self.showRestartDialog.emit()
|
self.showRestartDialog.emit()
|
||||||
|
|
||||||
|
def _onAppInitialized(self):
|
||||||
|
self._package_manager = Application.getInstance().getCuraPackageManager()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def browsePackages(self):
|
def browsePackages(self):
|
||||||
self._package_manager = Application.getInstance().getCuraPackageManager()
|
|
||||||
# Create the network manager:
|
# Create the network manager:
|
||||||
# This was formerly its own function but really had no reason to be as
|
# This was formerly its own function but really had no reason to be as
|
||||||
# it was never called more than once ever.
|
# it was never called more than once ever.
|
||||||
|
@ -180,13 +194,14 @@ class Toolbox(QObject, Extension):
|
||||||
def _createDialog(self, qml_name):
|
def _createDialog(self, qml_name):
|
||||||
Logger.log("d", "Toolbox: Creating dialog [%s].", qml_name)
|
Logger.log("d", "Toolbox: 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)
|
||||||
dialog = Application.getInstance().createQmlComponent(path, {"manager": self})
|
dialog = Application.getInstance().createQmlComponent(path, {"toolbox": self})
|
||||||
return dialog
|
return dialog
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def installPlugin(self, file_path):
|
def installPlugin(self, file_path):
|
||||||
self._package_manager.installPackage(file_path)
|
self._package_manager.installPackage(file_path)
|
||||||
self.metadataChanged.emit()
|
self.metadataChanged.emit()
|
||||||
|
# TODO: Stuff
|
||||||
self.openRestartDialog("TODO")
|
self.openRestartDialog("TODO")
|
||||||
self._restart_required = True
|
self._restart_required = True
|
||||||
self.restartRequiredChanged.emit()
|
self.restartRequiredChanged.emit()
|
||||||
|
@ -197,53 +212,20 @@ class Toolbox(QObject, Extension):
|
||||||
self.metadataChanged.emit()
|
self.metadataChanged.emit()
|
||||||
self._restart_required = True
|
self._restart_required = True
|
||||||
self.restartRequiredChanged.emit()
|
self.restartRequiredChanged.emit()
|
||||||
|
# TODO: Stuff
|
||||||
Application.getInstance().messageBox(i18n_catalog.i18nc("@window:title", "Plugin browser"), "TODO")
|
Application.getInstance().messageBox(i18n_catalog.i18nc("@window:title", "Plugin browser"), "TODO")
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def enablePlugin(self, plugin_id):
|
def enablePlugin(self, plugin_id):
|
||||||
self._plugin_registry.enablePlugin(plugin_id)
|
self._plugin_registry.enablePlugin(plugin_id)
|
||||||
self.metadataChanged.emit()
|
self.metadataChanged.emit()
|
||||||
Logger.log("i", "%s was set as 'active'", id)
|
Logger.log("i", "%s was set as 'active'.", plugin_id)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def disablePlugin(self, plugin_id):
|
def disablePlugin(self, plugin_id):
|
||||||
self._plugin_registry.disablePlugin(plugin_id)
|
self._plugin_registry.disablePlugin(plugin_id)
|
||||||
self.metadataChanged.emit()
|
self.metadataChanged.emit()
|
||||||
Logger.log("i", "%s was set as 'deactive'", id)
|
Logger.log("i", "%s was set as 'deactive'.", plugin_id)
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
|
||||||
def pluginsModel(self):
|
|
||||||
self._plugins_model = PluginsModel(None, self._view_category)
|
|
||||||
# self._plugins_model.update()
|
|
||||||
|
|
||||||
# Check each plugin the registry for matching plugin from server
|
|
||||||
# metadata, and if found, compare the versions. Higher version sets
|
|
||||||
# 'can_upgrade' to 'True':
|
|
||||||
for plugin in self._plugins_model.items:
|
|
||||||
if self._checkCanUpgrade(plugin["id"], plugin["version"]):
|
|
||||||
plugin["can_upgrade"] = True
|
|
||||||
|
|
||||||
for item in self._packages_metadata:
|
|
||||||
if item["id"] == plugin["id"]:
|
|
||||||
plugin["update_url"] = item["file_location"]
|
|
||||||
return self._plugins_model
|
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
|
||||||
def pluginsShowcaseModel(self):
|
|
||||||
return self._plugins_showcase_model
|
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
|
||||||
def materialsShowcaseModel(self):
|
|
||||||
return self._materials_showcase_model
|
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
|
||||||
def packagesModel(self):
|
|
||||||
return self._packages_model
|
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
|
||||||
def authorsModel(self):
|
|
||||||
return self._authors_model
|
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = metadataChanged)
|
@pyqtProperty(bool, notify = metadataChanged)
|
||||||
def dataReady(self):
|
def dataReady(self):
|
||||||
|
@ -257,6 +239,23 @@ class Toolbox(QObject, Extension):
|
||||||
def restart(self):
|
def restart(self):
|
||||||
CuraApplication.getInstance().windowClosed()
|
CuraApplication.getInstance().windowClosed()
|
||||||
|
|
||||||
|
# @pyqtProperty(QObject, notify = metadataChanged)
|
||||||
|
# def pluginsModel(self):
|
||||||
|
# self._plugins_model = PluginsModel(None, self._view_category)
|
||||||
|
# # self._plugins_model.update()
|
||||||
|
#
|
||||||
|
# # Check each plugin the registry for matching plugin from server
|
||||||
|
# # metadata, and if found, compare the versions. Higher version sets
|
||||||
|
# # 'can_upgrade' to 'True':
|
||||||
|
# for plugin in self._plugins_model.items:
|
||||||
|
# if self._checkCanUpgrade(plugin["id"], plugin["version"]):
|
||||||
|
# plugin["can_upgrade"] = True
|
||||||
|
#
|
||||||
|
# for item in self._packages_metadata:
|
||||||
|
# if item["id"] == plugin["id"]:
|
||||||
|
# plugin["update_url"] = item["file_location"]
|
||||||
|
# return self._plugins_model
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Checks
|
# Checks
|
||||||
|
@ -285,14 +284,6 @@ class Toolbox(QObject, Extension):
|
||||||
self._network_manager.finished.connect(self._onRequestFinished)
|
self._network_manager.finished.connect(self._onRequestFinished)
|
||||||
self._network_manager.networkAccessibleChanged.connect(self._onNetworkAccesibleChanged)
|
self._network_manager.networkAccessibleChanged.connect(self._onNetworkAccesibleChanged)
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = restartRequiredChanged)
|
|
||||||
def restartRequired(self):
|
|
||||||
return self._restart_required
|
|
||||||
|
|
||||||
@pyqtSlot()
|
|
||||||
def restart(self):
|
|
||||||
CuraApplication.getInstance().windowClosed()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Make API Calls
|
# Make API Calls
|
||||||
|
@ -311,6 +302,8 @@ class Toolbox(QObject, Extension):
|
||||||
self._get_showcase_request.setRawHeader(*self._request_header)
|
self._get_showcase_request.setRawHeader(*self._request_header)
|
||||||
self._network_manager.get(self._get_showcase_request)
|
self._network_manager.get(self._get_showcase_request)
|
||||||
|
|
||||||
|
# TODO: Request authors and request material showcase
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def startDownload(self, url):
|
def startDownload(self, url):
|
||||||
Logger.log("i", "Toolbox: Attempting to download & install package from %s.", url)
|
Logger.log("i", "Toolbox: Attempting to download & install package from %s.", url)
|
||||||
|
@ -335,7 +328,7 @@ class Toolbox(QObject, Extension):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Handlers for Download Events
|
# Handlers for Network Events
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
def _onNetworkAccesibleChanged(self, accessible):
|
def _onNetworkAccesibleChanged(self, accessible):
|
||||||
if accessible == 0:
|
if accessible == 0:
|
||||||
|
@ -369,44 +362,29 @@ class Toolbox(QObject, Extension):
|
||||||
json_data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
json_data = json.loads(bytes(reply.readAll()).decode("utf-8"))
|
||||||
print(json_data)
|
print(json_data)
|
||||||
# Create packages model with all packages:
|
# Create packages model with all packages:
|
||||||
if not self._packages_model:
|
if not self._models["packages"]:
|
||||||
self._packages_model = PackagesModel()
|
self._models["packages"] = PackagesModel()
|
||||||
self._packages_metadata = json_data["data"]
|
self._metadata["packages"] = json_data["data"]
|
||||||
self._packages_model.setPackagesMetaData(self._packages_metadata)
|
self._models["packages"].setMetadata(self._metadata["packages"])
|
||||||
self.metadataChanged.emit()
|
self.metadataChanged.emit()
|
||||||
|
|
||||||
# Create authors model with all authors:
|
# Create authors model with all authors:
|
||||||
if not self._authors_model:
|
if not self._authors_model:
|
||||||
self._authors_model = AuthorsModel()
|
self._authors_model = AuthorsModel()
|
||||||
# TODO: Remove this hacky code once there's an API call for this.
|
# TODO: Replace this with a proper API call:
|
||||||
self._authors_metadata = []
|
for package in self._metadata["packages"]:
|
||||||
for package in self._packages_metadata:
|
|
||||||
package["author"]["type"] = package["package_type"]
|
package["author"]["type"] = package["package_type"]
|
||||||
if package["author"] not in self._authors_metadata:
|
if package["author"] not in self._authors_metadata:
|
||||||
self._authors_metadata.append(package["author"])
|
self._metadata["authors"].append(package["author"])
|
||||||
self._authors_model.setMetaData(self._authors_metadata)
|
self._models["author"].setMetadata(self._metadata["authors"])
|
||||||
self.metadataChanged.emit()
|
self.metadataChanged.emit()
|
||||||
self.setViewPage("overview")
|
|
||||||
|
|
||||||
# TODO: Also replace this with a proper API call:
|
if not self._models["materials_showcase"]:
|
||||||
if not self._materials_showcase_model:
|
self._models["materials_showcase"] = AuthorsModel()
|
||||||
self._materials_showcase_model = AuthorsModel()
|
# TODO: Replace this with a proper API call:
|
||||||
# TODO: Remove this hacky code once there's an API call for this.
|
self._models["materials_showcase"].setMetadata(self._metadata["materials_showcase"])
|
||||||
self._materials_showcase_model.setMetaData([
|
|
||||||
{
|
|
||||||
"name": "DSM",
|
|
||||||
"email": "contact@dsm.nl",
|
|
||||||
"website": "www.dsm.nl",
|
|
||||||
"type": "material"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "BASF",
|
|
||||||
"email": "contact@basf.de",
|
|
||||||
"website": "www.basf.de",
|
|
||||||
"type": "material"
|
|
||||||
}
|
|
||||||
])
|
|
||||||
self.metadataChanged.emit()
|
self.metadataChanged.emit()
|
||||||
|
|
||||||
self.setViewPage("overview")
|
self.setViewPage("overview")
|
||||||
|
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
|
@ -467,7 +445,7 @@ class Toolbox(QObject, Extension):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Getter & Setters
|
# Getter & Setters for Properties:
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
def setDownloadProgress(self, progress):
|
def setDownloadProgress(self, progress):
|
||||||
if progress != self._download_progress:
|
if progress != self._download_progress:
|
||||||
|
@ -515,7 +493,35 @@ class Toolbox(QObject, Extension):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Model Filtering
|
# Expose Models:
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
|
def authorsModel(self):
|
||||||
|
return self._models["authors"]
|
||||||
|
|
||||||
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
|
def packagesModel(self):
|
||||||
|
return self._models["packages"]
|
||||||
|
|
||||||
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
|
def pluginsShowcaseModel(self):
|
||||||
|
return self._models["plugins_showcase"]
|
||||||
|
|
||||||
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
|
def pluginsInstalledModel(self):
|
||||||
|
return self._models["plugins_installed"]
|
||||||
|
|
||||||
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
|
def materialsShowcaseModel(self):
|
||||||
|
return self._models["materials_showcase"]
|
||||||
|
|
||||||
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
|
def materialsInstalledModel(self):
|
||||||
|
return self._models["materials_installed"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Filter Models:
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str)
|
||||||
def filterPackages(self, filterType, parameter):
|
def filterPackages(self, filterType, parameter):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue