mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Make the progressButton use signals instead of functions
Although the naming is still a bit off, it's much cleaner to use signals instead of functions. It's also more in line with how default QML components handle these kind of situations CURA-6006
This commit is contained in:
parent
838949dac7
commit
6a466c99b2
@ -18,19 +18,15 @@ Column
|
|||||||
id: installButton
|
id: installButton
|
||||||
active: toolbox.isDownloading && toolbox.activePackage == model
|
active: toolbox.isDownloading && toolbox.activePackage == model
|
||||||
complete: installed
|
complete: installed
|
||||||
readyAction: function()
|
onReadyAction:
|
||||||
{
|
{
|
||||||
toolbox.activePackage = model
|
toolbox.activePackage = model
|
||||||
toolbox.startDownload(model.download_url)
|
toolbox.startDownload(model.download_url)
|
||||||
}
|
}
|
||||||
activeAction: function()
|
onActiveAction: toolbox.cancelDownload()
|
||||||
{
|
|
||||||
toolbox.cancelDownload()
|
onCompleteAction: toolbox.viewCategory = "installed"
|
||||||
}
|
|
||||||
completeAction: function()
|
|
||||||
{
|
|
||||||
toolbox.viewCategory = "installed"
|
|
||||||
}
|
|
||||||
// Don't allow installing while another download is running
|
// Don't allow installing while another download is running
|
||||||
enabled: installed || !(toolbox.isDownloading && toolbox.activePackage != model)
|
enabled: installed || !(toolbox.isDownloading && toolbox.activePackage != model)
|
||||||
opacity: enabled ? 1.0 : 0.5
|
opacity: enabled ? 1.0 : 0.5
|
||||||
@ -44,20 +40,19 @@ Column
|
|||||||
readyLabel: catalog.i18nc("@action:button", "Update")
|
readyLabel: catalog.i18nc("@action:button", "Update")
|
||||||
activeLabel: catalog.i18nc("@action:button", "Updating")
|
activeLabel: catalog.i18nc("@action:button", "Updating")
|
||||||
completeLabel: catalog.i18nc("@action:button", "Updated")
|
completeLabel: catalog.i18nc("@action:button", "Updated")
|
||||||
readyAction: function()
|
|
||||||
|
onReadyAction:
|
||||||
{
|
{
|
||||||
toolbox.activePackage = model
|
toolbox.activePackage = model
|
||||||
toolbox.update(model.id)
|
toolbox.update(model.id)
|
||||||
}
|
}
|
||||||
activeAction: function()
|
onActiveAction: toolbox.cancelDownload()
|
||||||
{
|
|
||||||
toolbox.cancelDownload()
|
|
||||||
}
|
|
||||||
// Don't allow installing while another download is running
|
// Don't allow installing while another download is running
|
||||||
enabled: !(toolbox.isDownloading && toolbox.activePackage != model)
|
enabled: !(toolbox.isDownloading && toolbox.activePackage != model)
|
||||||
opacity: enabled ? 1.0 : 0.5
|
opacity: enabled ? 1.0 : 0.5
|
||||||
visible: canUpdate
|
visible: canUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections
|
Connections
|
||||||
{
|
{
|
||||||
target: toolbox
|
target: toolbox
|
||||||
|
@ -30,15 +30,13 @@ Column
|
|||||||
readyLabel: catalog.i18nc("@action:button", "Update")
|
readyLabel: catalog.i18nc("@action:button", "Update")
|
||||||
activeLabel: catalog.i18nc("@action:button", "Updating")
|
activeLabel: catalog.i18nc("@action:button", "Updating")
|
||||||
completeLabel: catalog.i18nc("@action:button", "Updated")
|
completeLabel: catalog.i18nc("@action:button", "Updated")
|
||||||
readyAction: function()
|
onReadyAction:
|
||||||
{
|
{
|
||||||
toolbox.activePackage = model
|
toolbox.activePackage = model
|
||||||
toolbox.update(model.id)
|
toolbox.update(model.id)
|
||||||
}
|
}
|
||||||
activeAction: function()
|
onActiveAction: toolbox.cancelDownload()
|
||||||
{
|
|
||||||
toolbox.cancelDownload()
|
|
||||||
}
|
|
||||||
// Don't allow installing while another download is running
|
// Don't allow installing while another download is running
|
||||||
enabled: !(toolbox.isDownloading && toolbox.activePackage != model)
|
enabled: !(toolbox.isDownloading && toolbox.activePackage != model)
|
||||||
opacity: enabled ? 1.0 : 0.5
|
opacity: enabled ? 1.0 : 0.5
|
||||||
|
@ -18,9 +18,9 @@ Item
|
|||||||
property var activeLabel: catalog.i18nc("@action:button", "Cancel")
|
property var activeLabel: catalog.i18nc("@action:button", "Cancel")
|
||||||
property var completeLabel: catalog.i18nc("@action:button", "Installed")
|
property var completeLabel: catalog.i18nc("@action:button", "Installed")
|
||||||
|
|
||||||
property var readyAction: null // Action when button is ready and clicked (likely install)
|
signal readyAction() // Action when button is ready and clicked (likely install)
|
||||||
property var activeAction: null // Action when button is active and clicked (likely cancel)
|
signal activeAction() // Action when button is active and clicked (likely cancel)
|
||||||
property var completeAction: null // Action when button is complete and clicked (likely go to installed)
|
signal completeAction() // Action when button is complete and clicked (likely go to installed)
|
||||||
|
|
||||||
width: UM.Theme.getSize("toolbox_action_button").width
|
width: UM.Theme.getSize("toolbox_action_button").width
|
||||||
height: UM.Theme.getSize("toolbox_action_button").height
|
height: UM.Theme.getSize("toolbox_action_button").height
|
||||||
@ -47,15 +47,15 @@ Item
|
|||||||
{
|
{
|
||||||
if (complete)
|
if (complete)
|
||||||
{
|
{
|
||||||
return completeAction()
|
completeAction()
|
||||||
}
|
}
|
||||||
else if (active)
|
else if (active)
|
||||||
{
|
{
|
||||||
return activeAction()
|
activeAction()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return readyAction()
|
readyAction()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
style: ButtonStyle
|
style: ButtonStyle
|
||||||
|
Loading…
x
Reference in New Issue
Block a user