123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- // 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
- Item
- {
- property bool canUpdate: false
- property bool isEnabled: true
- height: UM.Theme.getSize("toolbox_installed_tile").height
- anchors
- {
- left: parent.left
- right: parent.right
- }
- Rectangle
- {
- color: UM.Theme.getColor("lining")
- width: parent.width
- height: UM.Theme.getSize("default_lining").height
- anchors.bottom: parent.bottom
- }
- Column
- {
- id: pluginInfo
- property var color: isEnabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
- height: parent.height
- anchors
- {
- left: parent.left
- top: parent.top
- right: authorInfo.left
- topMargin: UM.Theme.getSize("default_margin").height
- rightMargin: UM.Theme.getSize("default_margin").width
- }
- Label
- {
- text: model.name
- width: parent.width
- height: UM.Theme.getSize("toolbox_property_label").height
- wrapMode: Text.WordWrap
- verticalAlignment: Text.AlignVCenter
- font: UM.Theme.getFont("default_bold")
- color: pluginInfo.color
- }
- Text
- {
- text: model.description
- width: parent.width
- height: UM.Theme.getSize("toolbox_property_label").height
- clip: true
- wrapMode: Text.WordWrap
- color: pluginInfo.color
- elide: Text.ElideRight
- }
- }
- Column
- {
- id: authorInfo
- height: parent.height
- width: Math.floor(UM.Theme.getSize("toolbox_action_button").width * 1.25)
- anchors
- {
- top: parent.top
- topMargin: UM.Theme.getSize("default_margin").height
- right: pluginActions.left
- rightMargin: UM.Theme.getSize("default_margin").width
- }
- Label
- {
- text:
- {
- if (model.author_email)
- {
- return "<a href=\"mailto:" + model.author_email + "?Subject=Cura: " + model.name + "\">" + model.author_name + "</a>"
- }
- else
- {
- return model.author_name
- }
- }
- width: parent.width
- height: UM.Theme.getSize("toolbox_property_label").height
- wrapMode: Text.WordWrap
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignLeft
- onLinkActivated: Qt.openUrlExternally("mailto:" + model.author_email + "?Subject=Cura: " + model.name + " Plugin")
- color: model.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
- }
- }
- Column
- {
- id: pluginActions
- width: childrenRect.width
- height: childrenRect.height
- spacing: UM.Theme.getSize("default_margin").height
- anchors
- {
- top: parent.top
- 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")
- }
- }
- enabled: !toolbox.isDownloading
- style: 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: Text
- {
- text: control.text
- color: UM.Theme.getColor("text")
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- }
- 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: catalog.i18nc("@action:button", "Update")
- visible: canUpdate
- style: ButtonStyle
- {
- background: Rectangle
- {
- implicitWidth: UM.Theme.getSize("toolbox_action_button").width
- implicitHeight: UM.Theme.getSize("toolbox_action_button").height
- color: control.hovered ? UM.Theme.getColor("primary_hover") : UM.Theme.getColor("primary")
- }
- label: Label
- {
- text: control.text
- color: control.hovered ? UM.Theme.getColor("button_text") : UM.Theme.getColor("button_text_hover")
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- font: UM.Theme.getFont("default_bold")
- }
- }
- onClicked:
- {
- toolbox.update(model.id);
- }
- }
- ProgressBar
- {
- id: progressbar
- anchors
- {
- left: updateButton.left
- right: updateButton.right
- top: updateButton.bottom
- topMargin: Math.floor(UM.Theme.getSize("default_margin") / 4)
- }
- value: toolbox.isDownloading ? toolbox.downloadProgress : 0
- visible: toolbox.isDownloading
- style: ProgressBarStyle
- {
- background: Rectangle
- {
- color: UM.Theme.getColor("lining")
- implicitHeight: Math.floor(UM.Theme.getSize("toolbox_progress_bar").height)
- }
- progress: Rectangle
- {
- color: UM.Theme.getColor("primary")
- }
- }
- }
- }
- Connections
- {
- target: toolbox
- onEnabledChanged: isEnabled = toolbox.isEnabled(model.id)
- onMetadataChanged: canUpdate = toolbox.canUpdate(model.id)
- }
- }
|