mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Cura-5296 Use separate packages.json files in app and user data
This commit is contained in:
parent
6dbbfe91db
commit
0accdc6320
9 changed files with 1278 additions and 83 deletions
29
plugins/Toolbox/resources/qml/ToolboxActionButtonStyle.qml
Normal file
29
plugins/Toolbox/resources/qml/ToolboxActionButtonStyle.qml
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) 2018 Ultimaker B.V.
|
||||
// Toolbox is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
import UM 1.1 as UM
|
||||
|
||||
ButtonStyle
|
||||
{
|
||||
background: Rectangle
|
||||
{
|
||||
implicitWidth: UM.Theme.getSize("toolbox_action_button").width
|
||||
implicitHeight: UM.Theme.getSize("toolbox_action_button").height
|
||||
color: "transparent"
|
||||
border
|
||||
{
|
||||
width: UM.Theme.getSize("default_lining").width
|
||||
color: UM.Theme.getColor("lining")
|
||||
}
|
||||
}
|
||||
label: Label
|
||||
{
|
||||
text: control.text
|
||||
color: UM.Theme.getColor("text")
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ Item
|
|||
Column
|
||||
{
|
||||
id: pluginInfo
|
||||
property var color: isEnabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
|
||||
property var color: model.package_type === "plugin" && !isEnabled ? UM.Theme.getColor("lining") : UM.Theme.getColor("text")
|
||||
height: parent.height
|
||||
anchors
|
||||
{
|
||||
|
@ -49,12 +49,11 @@ Item
|
|||
Text
|
||||
{
|
||||
text: model.description
|
||||
maximumLineCount: 3
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
height: UM.Theme.getSize("toolbox_property_label").height
|
||||
clip: true
|
||||
wrapMode: Text.WordWrap
|
||||
color: pluginInfo.color
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
Column
|
||||
|
@ -104,19 +103,11 @@ Item
|
|||
right: parent.right
|
||||
topMargin: UM.Theme.getSize("default_margin").height
|
||||
}
|
||||
Button {
|
||||
id: removeButton
|
||||
text:
|
||||
{
|
||||
if (model.is_bundled)
|
||||
{
|
||||
return isEnabled ? catalog.i18nc("@action:button", "Disable") : catalog.i18nc("@action:button", "Enable")
|
||||
}
|
||||
else
|
||||
{
|
||||
return catalog.i18nc("@action:button", "Uninstall")
|
||||
}
|
||||
}
|
||||
Button
|
||||
{
|
||||
id: disableButton
|
||||
text: isEnabled ? catalog.i18nc("@action:button", "Disable") : catalog.i18nc("@action:button", "Enable")
|
||||
visible: model.type == "plugin"
|
||||
enabled: !toolbox.isDownloading
|
||||
style: ButtonStyle
|
||||
{
|
||||
|
@ -139,24 +130,36 @@ Item
|
|||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
onClicked:
|
||||
onClicked: toolbox.isEnabled(model.id) ? toolbox.disable(model.id) : toolbox.enable(model.id)
|
||||
}
|
||||
Button
|
||||
{
|
||||
id: removeButton
|
||||
text: catalog.i18nc("@action:button", "Uninstall")
|
||||
visible: !model.is_bundled
|
||||
enabled: !toolbox.isDownloading
|
||||
style: ButtonStyle
|
||||
{
|
||||
if (model.is_bundled)
|
||||
background: Rectangle
|
||||
{
|
||||
if (toolbox.isEnabled(model.id))
|
||||
implicitWidth: UM.Theme.getSize("toolbox_action_button").width
|
||||
implicitHeight: UM.Theme.getSize("toolbox_action_button").height
|
||||
color: "transparent"
|
||||
border
|
||||
{
|
||||
toolbox.disable(model.id)
|
||||
}
|
||||
else
|
||||
{
|
||||
toolbox.enable(model.id)
|
||||
width: UM.Theme.getSize("default_lining").width
|
||||
color: UM.Theme.getColor("lining")
|
||||
}
|
||||
}
|
||||
else
|
||||
label: Label
|
||||
{
|
||||
toolbox.uninstall(model.id)
|
||||
text: control.text
|
||||
color: UM.Theme.getColor("text")
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
onClicked: toolbox.uninstall(model.id)
|
||||
}
|
||||
Button
|
||||
{
|
||||
|
@ -180,10 +183,7 @@ Item
|
|||
font: UM.Theme.getFont("default_bold")
|
||||
}
|
||||
}
|
||||
onClicked:
|
||||
{
|
||||
toolbox.update(model.id);
|
||||
}
|
||||
onClicked: toolbox.update(model.id)
|
||||
}
|
||||
ProgressBar
|
||||
{
|
||||
|
|
|
@ -28,8 +28,9 @@ class PackagesModel(ListModel):
|
|||
self.addRoleName(Qt.UserRole + 11, "download_url")
|
||||
self.addRoleName(Qt.UserRole + 12, "last_updated")
|
||||
self.addRoleName(Qt.UserRole + 13, "is_bundled")
|
||||
self.addRoleName(Qt.UserRole + 14, "has_configs")
|
||||
self.addRoleName(Qt.UserRole + 15, "supported_configs")
|
||||
self.addRoleName(Qt.UserRole + 14, "is_enabled")
|
||||
self.addRoleName(Qt.UserRole + 15, "has_configs")
|
||||
self.addRoleName(Qt.UserRole + 16, "supported_configs")
|
||||
|
||||
# List of filters for queries. The result is the union of the each list of results.
|
||||
self._filter = {} # type: Dict[str, str]
|
||||
|
@ -52,20 +53,26 @@ class PackagesModel(ListModel):
|
|||
configs_model = ConfigsModel()
|
||||
configs_model.setConfigs(package["data"]["supported_configs"])
|
||||
|
||||
if "author_id" not in package["author"] or "display_name" not in package["author"]:
|
||||
package["author"]["author_id"] = ""
|
||||
package["author"]["display_name"] = ""
|
||||
# raise Exception("Detected a package with malformed author data.")
|
||||
|
||||
items.append({
|
||||
"id": package["package_id"],
|
||||
"type": package["package_type"],
|
||||
"name": package["display_name"],
|
||||
"version": package["package_version"],
|
||||
"author_id": package["author"]["author_id"] if "author_id" in package["author"] else package["author"]["name"],
|
||||
"author_name": package["author"]["display_name"] if "display_name" in package["author"] else package["author"]["name"],
|
||||
"author_id": package["author"]["author_id"],
|
||||
"author_name": package["author"]["display_name"],
|
||||
"author_email": package["author"]["email"] if "email" in package["author"] else None,
|
||||
"description": package["description"],
|
||||
"description": package["description"] if "description" in package else None,
|
||||
"icon_url": package["icon_url"] if "icon_url" in package else None,
|
||||
"image_urls": package["image_urls"] if "image_urls" in package else None,
|
||||
"download_url": package["download_url"] if "download_url" in package else None,
|
||||
"last_updated": package["last_updated"] if "last_updated" in package else None,
|
||||
"is_bundled": package["is_bundled"] if "is_bundled" in package else False,
|
||||
"is_enabled": package["is_enabled"] if "is_enabled" in package else False,
|
||||
"has_configs": has_configs,
|
||||
"supported_configs": configs_model
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue