mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-26 20:31:35 -07:00
CURA-5035 Better linking between Toolbox and CuraPluginManager
This commit is contained in:
parent
5d395f549a
commit
523518020c
6 changed files with 183 additions and 68 deletions
|
|
@ -9,6 +9,7 @@ import UM 1.1 as UM
|
|||
|
||||
Rectangle
|
||||
{
|
||||
property bool installed: toolbox.isInstalled(model.id)
|
||||
width: base.width - UM.Theme.getSize("double_margin").width
|
||||
height: UM.Theme.getSize("base_unit").height * 8
|
||||
color: "transparent"
|
||||
|
|
@ -48,17 +49,28 @@ Rectangle
|
|||
Button {
|
||||
id: installButton
|
||||
text: {
|
||||
if ( toolbox.isDownloading && toolbox.activePackage == model )
|
||||
if (installed)
|
||||
{
|
||||
return catalog.i18nc("@action:button", "Cancel")
|
||||
return catalog.i18nc("@action:button", "Installed")
|
||||
}
|
||||
else
|
||||
{
|
||||
return catalog.i18nc("@action:button", "Install")
|
||||
if ( toolbox.isDownloading && toolbox.activePackage == model )
|
||||
{
|
||||
return catalog.i18nc("@action:button", "Cancel")
|
||||
}
|
||||
else
|
||||
{
|
||||
return catalog.i18nc("@action:button", "Install")
|
||||
}
|
||||
}
|
||||
}
|
||||
enabled:
|
||||
{
|
||||
if (installed)
|
||||
{
|
||||
return true
|
||||
}
|
||||
if ( toolbox.isDownloading )
|
||||
{
|
||||
return toolbox.activePackage == model ? true : false
|
||||
|
|
@ -74,12 +86,47 @@ Rectangle
|
|||
{
|
||||
implicitWidth: 96
|
||||
implicitHeight: 30
|
||||
color: control.hovered ? UM.Theme.getColor("primary_hover") : UM.Theme.getColor("primary")
|
||||
color:
|
||||
{
|
||||
if (installed)
|
||||
{
|
||||
return UM.Theme.getColor("action_button_disabled")
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( control.hovered )
|
||||
{
|
||||
return UM.Theme.getColor("primary_hover")
|
||||
}
|
||||
else
|
||||
{
|
||||
return UM.Theme.getColor("primary")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
label: Label
|
||||
{
|
||||
text: control.text
|
||||
color: control.hovered ? UM.Theme.getColor("button_text") : UM.Theme.getColor("button_text_hover")
|
||||
color:
|
||||
{
|
||||
if (installed)
|
||||
{
|
||||
return UM.Theme.getColor("action_button_disabled_text")
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( control.hovered )
|
||||
{
|
||||
return UM.Theme.getColor("button_text_hover")
|
||||
}
|
||||
else
|
||||
{
|
||||
return UM.Theme.getColor("button_text")
|
||||
}
|
||||
}
|
||||
}
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
font: UM.Theme.getFont("default_bold")
|
||||
|
|
@ -87,22 +134,29 @@ Rectangle
|
|||
}
|
||||
onClicked:
|
||||
{
|
||||
console.log( "MODEL", model.id )
|
||||
toolbox.activePackage = model
|
||||
// if ( toolbox.isDownloading && toolbox.activePackage == model )
|
||||
if ( toolbox.isDownloading )
|
||||
if (installed)
|
||||
{
|
||||
toolbox.cancelDownload();
|
||||
toolbox.viewCategory = "installed"
|
||||
}
|
||||
else
|
||||
{
|
||||
// toolbox.activePackage = model;
|
||||
if ( model.can_upgrade )
|
||||
// if ( toolbox.isDownloading && toolbox.activePackage == model )
|
||||
if ( toolbox.isDownloading )
|
||||
{
|
||||
// toolbox.downloadAndInstallPlugin( model.update_url );
|
||||
toolbox.cancelDownload();
|
||||
}
|
||||
else {
|
||||
toolbox.startDownload( model.download_url );
|
||||
else
|
||||
{
|
||||
toolbox.activePackage = model
|
||||
// toolbox.activePackage = model;
|
||||
if ( model.can_upgrade )
|
||||
{
|
||||
// toolbox.downloadAndInstallPlugin( model.update_url );
|
||||
}
|
||||
else
|
||||
{
|
||||
toolbox.startDownload( model.download_url );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -115,4 +169,9 @@ Rectangle
|
|||
height: UM.Theme.getSize("default_lining").height
|
||||
anchors.bottom: parent.bottom
|
||||
}
|
||||
Connections
|
||||
{
|
||||
target: toolbox
|
||||
onInstallChanged: installed = toolbox.isInstalled(model.id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import UM 1.1 as UM
|
|||
Item
|
||||
{
|
||||
id: base
|
||||
property bool canUpdate: false
|
||||
property bool isEnabled: true
|
||||
height: UM.Theme.getSize("base_unit").height * 8
|
||||
anchors
|
||||
{
|
||||
|
|
@ -27,7 +29,7 @@ Item
|
|||
Column
|
||||
{
|
||||
id: pluginInfo
|
||||
property var color: model.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
|
||||
property var color: isEnabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
|
||||
height: parent.height
|
||||
anchors
|
||||
{
|
||||
|
|
@ -75,7 +77,7 @@ Item
|
|||
}
|
||||
Label
|
||||
{
|
||||
text: "<a href=\"mailto:"+model.author_email+"?Subject=Cura: "+model.name+"\">"+model.author+"</a>"
|
||||
text: "<a href=\"mailto:"+model.author_email+"?Subject=Cura: "+model.name+"\">"+model.author_name+"</a>"
|
||||
width: parent.width
|
||||
height: 24
|
||||
wrapMode: Text.WordWrap
|
||||
|
|
@ -102,8 +104,17 @@ Item
|
|||
|
||||
Button {
|
||||
id: removeButton
|
||||
text: "Uninstall"
|
||||
// visible: model.can_uninstall && model.status == "installed"
|
||||
text:
|
||||
{
|
||||
if (model.is_bundled)
|
||||
{
|
||||
return isEnabled ? catalog.i18nc("@action:button", "Disable") : catalog.i18nc("@action:button", "Enable")
|
||||
}
|
||||
else
|
||||
{
|
||||
return catalog.i18nc("@action:button", "Uninstall")
|
||||
}
|
||||
}
|
||||
enabled: !toolbox.isDownloading
|
||||
style: ButtonStyle
|
||||
{
|
||||
|
|
@ -125,13 +136,30 @@ Item
|
|||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
onClicked: toolbox.removePlugin( model.id )
|
||||
onClicked:
|
||||
{
|
||||
if (model.is_bundled)
|
||||
{
|
||||
if (toolbox.isEnabled(model.id))
|
||||
{
|
||||
toolbox.disable(model.id)
|
||||
}
|
||||
else
|
||||
{
|
||||
toolbox.enable(model.id)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toolbox.uninstall( model.id )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: updateButton
|
||||
text: "Update"
|
||||
// enabled: model.can_update
|
||||
text: catalog.i18nc("@action:button", "Update")
|
||||
visible: canUpdate
|
||||
style: ButtonStyle
|
||||
{
|
||||
background: Rectangle
|
||||
|
|
@ -151,7 +179,7 @@ Item
|
|||
}
|
||||
onClicked:
|
||||
{
|
||||
toolbox.updatePackage(model.id);
|
||||
toolbox.update(model.id);
|
||||
}
|
||||
}
|
||||
ProgressBar
|
||||
|
|
@ -177,4 +205,10 @@ Item
|
|||
}
|
||||
}
|
||||
}
|
||||
Connections
|
||||
{
|
||||
target: toolbox
|
||||
onEnabledChanged: isEnabled = toolbox.isEnabled(model.id)
|
||||
onMetadataChanged: canUpdate = toolbox.canUpdate(model.id)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ UM.Dialog {
|
|||
onClicked:
|
||||
{
|
||||
licenseDialog.close();
|
||||
toolbox.installPlugin(licenseDialog.pluginFileLocation);
|
||||
toolbox.install(licenseDialog.pluginFileLocation);
|
||||
}
|
||||
},
|
||||
Button
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue