123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474 |
- // Copyright (c) 2017 Ultimaker B.V.
- // PluginBrowser is released under the terms of the LGPLv3 or higher.
- import QtQuick 2.2
- import QtQuick.Dialogs 1.1
- import QtQuick.Window 2.2
- import QtQuick.Controls 1.4
- import QtQuick.Controls.Styles 1.4
- // TODO: Switch to QtQuick.Controls 2.x and remove QtQuick.Controls.Styles
- import UM 1.1 as UM
- Component {
- id: pluginDelegate
- Rectangle {
- // Don't show required plugins as they can't be managed anyway:
- height: !model.required ? 84 : 0
- visible: !model.required ? true : false
- color: "transparent"
- anchors {
- left: parent.left
- leftMargin: UM.Theme.getSize("default_margin").width
- right: parent.right
- rightMargin: UM.Theme.getSize("default_margin").width
- }
- // Bottom border:
- Rectangle {
- color: UM.Theme.getColor("lining")
- width: parent.width
- height: 1
- anchors.bottom: parent.bottom
- }
- // Plugin info
- Column {
- id: pluginInfo
- property var color: model.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining")
- // Styling:
- height: parent.height
- anchors {
- left: parent.left
- top: parent.top
- topMargin: UM.Theme.getSize("default_margin").height
- right: authorInfo.left
- rightMargin: UM.Theme.getSize("default_margin").width
- }
- Label {
- text: model.name
- width: parent.width
- height: 24
- wrapMode: Text.WordWrap
- verticalAlignment: Text.AlignVCenter
- font {
- pixelSize: 13
- bold: true
- }
- color: pluginInfo.color
- }
- Text {
- text: model.description
- width: parent.width
- height: 36
- clip: true
- wrapMode: Text.WordWrap
- color: pluginInfo.color
- elide: Text.ElideRight
- }
- }
- // Author info
- Column {
- id: authorInfo
- width: 192
- height: parent.height
- anchors {
- top: parent.top
- topMargin: UM.Theme.getSize("default_margin").height
- right: pluginActions.left
- rightMargin: UM.Theme.getSize("default_margin").width
- }
- Label {
- text: "<a href=\"mailto:"+model.author_email+"?Subject=Cura: "+model.name+"\">"+model.author+"</a>"
- width: parent.width
- height: 24
- 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")
- }
- }
- // Plugin actions
- Row {
- id: pluginActions
- width: 96
- height: parent.height
- anchors {
- top: parent.top
- right: parent.right
- topMargin: UM.Theme.getSize("default_margin").height
- }
- layoutDirection: Qt.RightToLeft
- spacing: UM.Theme.getSize("default_margin").width
- // For 3rd-Party Plugins:
- Button {
- id: installButton
- text: {
- if ( manager.isDownloading && pluginList.activePlugin == model ) {
- return catalog.i18nc( "@action:button", "Cancel" );
- } else {
- if (model.can_upgrade) {
- return catalog.i18nc("@action:button", "Update");
- }
- return catalog.i18nc("@action:button", "Install");
- }
- }
- visible: model.external && ((model.status !== "installed") || model.can_upgrade)
- style: ButtonStyle {
- background: Rectangle {
- implicitWidth: 96
- implicitHeight: 30
- color: "transparent"
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Label {
- text: control.text
- color: UM.Theme.getColor("text")
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- }
- onClicked: {
- if ( manager.isDownloading && pluginList.activePlugin == model ) {
- manager.cancelDownload();
- } else {
- pluginList.activePlugin = model;
- if ( model.can_upgrade ) {
- manager.downloadAndInstallPlugin( model.update_url );
- } else {
- manager.downloadAndInstallPlugin( model.file_location );
- }
- }
- }
- }
- Button {
- id: removeButton
- text: "Uninstall"
- visible: model.can_uninstall && model.status == "installed"
- enabled: !manager.isDownloading
- style: ButtonStyle {
- background: Rectangle {
- implicitWidth: 96
- implicitHeight: 30
- color: "transparent"
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Text {
- text: control.text
- color: UM.Theme.getColor("text")
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- }
- onClicked: manager.removePlugin( model.id )
- }
- // For Ultimaker Plugins:
- Button {
- id: enableButton
- text: "Enable"
- visible: !model.external && model.enabled == false
- style: ButtonStyle {
- background: Rectangle {
- implicitWidth: 96
- implicitHeight: 30
- color: "transparent"
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Text {
- text: control.text
- color: UM.Theme.getColor("text")
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- }
- onClicked: {
- manager.enablePlugin(model.id);
- }
- }
- Button {
- id: disableButton
- text: "Disable"
- visible: !model.external && model.enabled == true
- style: ButtonStyle {
- background: Rectangle {
- implicitWidth: 96
- implicitHeight: 30
- color: "transparent"
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Text {
- text: control.text
- color: UM.Theme.getColor("text")
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- }
- onClicked: {
- manager.disablePlugin(model.id);
- }
- }
- /*
- Rectangle {
- id: removeControls
- visible: model.status == "installed" && model.enabled
- width: 96
- height: 30
- color: "transparent"
- Button {
- id: removeButton
- text: "Disable"
- enabled: {
- if ( manager.isDownloading && pluginList.activePlugin == model ) {
- return false;
- } else if ( model.required ) {
- return false;
- } else {
- return true;
- }
- }
- onClicked: {
- manager.disablePlugin(model.id);
- }
- style: ButtonStyle {
- background: Rectangle {
- color: "white"
- implicitWidth: 96
- implicitHeight: 30
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: "grey"
- text: control.text
- horizontalAlignment: Text.AlignLeft
- }
- }
- }
- Button {
- id: removeDropDown
- property bool open: false
- UM.RecolorImage {
- anchors.centerIn: parent
- height: 10
- width: 10
- source: UM.Theme.getIcon("arrow_bottom")
- color: "grey"
- }
- enabled: {
- if ( manager.isDownloading && pluginList.activePlugin == model ) {
- return false;
- } else if ( model.required ) {
- return false;
- } else {
- return true;
- }
- }
- anchors.right: parent.right
- style: ButtonStyle {
- background: Rectangle {
- color: "transparent"
- implicitWidth: 30
- implicitHeight: 30
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: "grey"
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- }
- }
- // For the disable option:
- // onClicked: pluginList.model.setEnabled(model.id, checked)
- onClicked: {
- if ( !removeDropDown.open ) {
- removeDropDown.open = true
- }
- else {
- removeDropDown.open = false
- }
- }
- }
- Rectangle {
- id: divider
- width: 1
- height: parent.height
- anchors.right: removeDropDown.left
- color: UM.Theme.getColor("lining")
- }
- Column {
- id: options
- anchors {
- top: removeButton.bottom
- left: parent.left
- right: parent.right
- }
- height: childrenRect.height
- visible: removeDropDown.open
- Button {
- id: disableButton
- text: "Remove"
- height: 30
- width: parent.width
- onClicked: {
- removeDropDown.open = false;
- manager.removePlugin( model.id );
- }
- }
- }
- }
- */
- /*
- Button {
- id: enableButton
- visible: !model.enabled && model.status == "installed"
- onClicked: manager.enablePlugin( model.id );
- text: "Enable"
- style: ButtonStyle {
- background: Rectangle {
- color: "transparent"
- implicitWidth: 96
- implicitHeight: 30
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: UM.Theme.getColor("text")
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- }
- }
- }
- Button {
- id: updateButton
- visible: model.status == "installed" && model.can_upgrade && model.enabled
- // visible: model.already_installed
- text: {
- // If currently downloading:
- if ( manager.isDownloading && pluginList.activePlugin == model ) {
- return catalog.i18nc( "@action:button", "Cancel" );
- } else {
- return catalog.i18nc("@action:button", "Update");
- }
- }
- style: ButtonStyle {
- background: Rectangle {
- color: UM.Theme.getColor("primary")
- implicitWidth: 96
- implicitHeight: 30
- // radius: 4
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: "white"
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- }
- }
- }
- Button {
- id: externalControls
- visible: model.status == "available" ? true : false
- text: {
- // If currently downloading:
- if ( manager.isDownloading && pluginList.activePlugin == model ) {
- return catalog.i18nc( "@action:button", "Cancel" );
- } else {
- return catalog.i18nc("@action:button", "Install");
- }
- }
- onClicked: {
- if ( manager.isDownloading && pluginList.activePlugin == model ) {
- manager.cancelDownload();
- } else {
- pluginList.activePlugin = model;
- manager.downloadAndInstallPlugin( model.file_location );
- }
- }
- style: ButtonStyle {
- background: Rectangle {
- color: "transparent"
- implicitWidth: 96
- implicitHeight: 30
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: "grey"
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- }
- }
- }
- */
- ProgressBar {
- id: progressbar
- minimumValue: 0;
- maximumValue: 100
- anchors.left: installButton.left
- anchors.right: installButton.right
- anchors.top: installButton.bottom
- anchors.topMargin: 4
- value: manager.isDownloading ? manager.downloadProgress : 0
- visible: manager.isDownloading && pluginList.activePlugin == model
- style: ProgressBarStyle {
- background: Rectangle {
- color: "lightgray"
- implicitHeight: 6
- }
- progress: Rectangle {
- color: UM.Theme.getColor("primary")
- }
- }
- }
- }
- }
- }
|