Browse Source

Merge branch 'Ultimaker:master' into master

Mingda_js 3 years ago
parent
commit
9e7aca8244

+ 5 - 0
plugins/Marketplace/PackageModel.py

@@ -39,6 +39,7 @@ class PackageModel(QObject):
         self._package_type = package_data.get("package_type", "")
         self._is_bundled = package_data.get("is_bundled", False)
         self._icon_url = package_data.get("icon_url", "")
+        self._marketplace_url = package_data.get("marketplace_url", "")
         self._display_name = package_data.get("display_name", catalog.i18nc("@label:property", "Unknown Package"))
         tags = package_data.get("tags", [])
         self._is_checked_by_ultimaker = (self._package_type == "plugin" and "verified" in tags) or (
@@ -210,6 +211,10 @@ class PackageModel(QObject):
     def packageId(self) -> str:
         return self._package_id
 
+    @pyqtProperty(str, constant=True)
+    def marketplaceURL(self)-> str:
+        return self._marketplace_url
+
     @pyqtProperty(str, constant = True)
     def packageType(self) -> str:
         return self._package_type

+ 0 - 3
plugins/Marketplace/RemotePackageList.py

@@ -117,9 +117,6 @@ class RemotePackageList(PackageList):
             return
 
         for package_data in response_data["data"]:
-            package_id = package_data["package_id"]
-            if package_id in self._package_manager.local_packages_ids:
-                continue  # We should only show packages which are not already installed
             try:
                 package = PackageModel(package_data, parent = self)
                 self._connectManageButtonSignals(package)

+ 3 - 0
plugins/Marketplace/resources/images/Plugin.svg

@@ -0,0 +1,3 @@
+<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M39 14V8H27V14H21V8H9V14H7C6.20435 14 5.44129 14.3161 4.87868 14.8787C4.31607 15.4413 4 16.2044 4 17V37C4 37.7956 4.31607 38.5587 4.87868 39.1213C5.44129 39.6839 6.20435 40 7 40H41C41.7957 40 42.5587 39.6839 43.1213 39.1213C43.6839 38.5587 44 37.7956 44 37V17C44 16.2044 43.6839 15.4413 43.1213 14.8787C42.5587 14.3161 41.7957 14 41 14H39ZM29 10H37V14H29V10ZM11 10H19V14H11V10ZM42 38H6V16H42V38Z" fill="#000E1A"/>
+</svg>

File diff suppressed because it is too large
+ 1 - 0
plugins/Marketplace/resources/images/Spool.svg


+ 4 - 3
plugins/Marketplace/resources/qml/ManagedPackages.qml

@@ -13,13 +13,14 @@ Packages
     bannerVisible: UM.Preferences.getValue("cura/market_place_show_manage_packages_banner");
     bannerIcon: UM.Theme.getIcon("ArrowDoubleCircleRight")
     bannerText: catalog.i18nc("@text", "Manage your Ultimaker Cura plugins and material profiles here. Make sure to keep your plugins up to date and backup your setup regularly.")
-    bannerReadMoreUrl: "" // TODO add when support page is ready
+    bannerReadMoreUrl: "https://support.ultimaker.com/hc/en-us/articles/4411125921426/?utm_source=cura&utm_medium=software&utm_campaign=marketplace-learn-manage"
     onRemoveBanner: function() {
         UM.Preferences.setValue("cura/market_place_show_manage_packages_banner", false);
         bannerVisible = false;
     }
     searchInBrowserUrl: "https://marketplace.ultimaker.com/app/cura/plugins?utm_source=cura&utm_medium=software&utm_campaign=marketplace-search-plugins-browser"
-    packagesManageableInListView: true
-
+    showUpdateButton: true
+    showInstallButton: true
+    showDisableButton: true
     model: manager.LocalPackageList
 }

+ 138 - 154
plugins/Marketplace/resources/qml/Marketplace.qml

@@ -46,198 +46,182 @@ Window
     {
         anchors.fill: parent
         color: UM.Theme.getColor("main_background")
+    }
+    //The Marketplace can have a page in front of everything with package details. The stack view controls its visibility.
+    StackView
+    {
+        id: contextStack
+        anchors.fill: parent
+
+        initialItem: packageBrowse
 
-        //The Marketplace can have a page in front of everything with package details. The stack view controls its visibility.
-        StackView
+        ColumnLayout
         {
-            id: contextStack
-            anchors.fill: parent
+            id: packageBrowse
 
-            initialItem: packageBrowse
+            spacing: UM.Theme.getSize("narrow_margin").height
 
-            ColumnLayout
+            // Page title.
+            Item
             {
-                id: packageBrowse
+                implicitWidth: parent.width
+                implicitHeight: childrenRect.height + UM.Theme.getSize("default_margin").height
 
-                spacing: UM.Theme.getSize("default_margin").height
-
-                // Page title.
-                Item
+                Label
                 {
-                    Layout.preferredWidth: parent.width
-                    Layout.preferredHeight: childrenRect.height + UM.Theme.getSize("default_margin").height
-
-                    Label
+                    id: pageTitle
+                    anchors
                     {
-                        id: pageTitle
-                        anchors
-                        {
-                            left: parent.left
-                            leftMargin: UM.Theme.getSize("default_margin").width
-                            right: parent.right
-                            rightMargin: UM.Theme.getSize("default_margin").width
-                            bottom: parent.bottom
-                        }
-
-                        font: UM.Theme.getFont("large")
-                        color: UM.Theme.getColor("text")
-                        text: content.item ? content.item.pageTitle: catalog.i18nc("@title", "Loading...")
+                        left: parent.left
+                        leftMargin: UM.Theme.getSize("default_margin").width
+                        right: parent.right
+                        rightMargin: UM.Theme.getSize("default_margin").width
+                        bottom: parent.bottom
                     }
-                }
 
-                OnboardBanner
-                {
-                    visible: content.item && content.item.bannerVisible
-                    text: content.item && content.item.bannerText
-                    icon: content.item && content.item.bannerIcon
-                    onRemove: content.item && content.item.onRemoveBanner
-                    readMoreUrl: content.item && content.item.bannerReadMoreUrl
+                    font: UM.Theme.getFont("large")
+                    color: UM.Theme.getColor("text")
+                    text: content.item ? content.item.pageTitle: catalog.i18nc("@title", "Loading...")
                 }
+            }
+
+            OnboardBanner
+            {
+                visible: content.item && content.item.bannerVisible
+                text: content.item && content.item.bannerText
+                icon: content.item && content.item.bannerIcon
+                onRemove: content.item && content.item.onRemoveBanner
+                readMoreUrl: content.item && content.item.bannerReadMoreUrl
 
-                // Search & Top-Level Tabs
-                Item
+                Layout.fillWidth: true
+                Layout.leftMargin: UM.Theme.getSize("default_margin").width
+                Layout.rightMargin: UM.Theme.getSize("default_margin").width
+            }
+
+            // Search & Top-Level Tabs
+            Item
+            {
+                implicitHeight: childrenRect.height
+                implicitWidth: parent.width - 2 * UM.Theme.getSize("default_margin").width
+                Layout.alignment: Qt.AlignHCenter
+                RowLayout
                 {
-                    Layout.preferredHeight: childrenRect.height
-                    Layout.preferredWidth: parent.width - 2 * UM.Theme.getSize("thin_margin").width
-                    RowLayout
+                    width: parent.width
+                    height: UM.Theme.getSize("button_icon").height + UM.Theme.getSize("default_margin").height
+                    spacing: UM.Theme.getSize("thin_margin").width
+
+                    Cura.SearchBar
                     {
-                        width: parent.width
-                        height: UM.Theme.getSize("button_icon").height + UM.Theme.getSize("default_margin").height
-                        spacing: UM.Theme.getSize("thin_margin").width
+                        id: searchBar
+                        implicitHeight: UM.Theme.getSize("button_icon").height
+                        Layout.fillWidth: true
+                        onTextEdited: searchStringChanged(text)
+                    }
 
-                        Item
+                    // Page selection.
+                    TabBar
+                    {
+                        id: pageSelectionTabBar
+                        Layout.alignment: Qt.AlignRight
+                        height: UM.Theme.getSize("button_icon").height
+                        spacing: 0
+                        background: Rectangle { color: "transparent" }
+                        currentIndex: manager.tabShown
+
+                        onCurrentIndexChanged:
                         {
-                            Layout.preferredHeight: parent.height
-                            Layout.preferredWidth: searchBar.visible ? UM.Theme.getSize("thin_margin").width : 0
-                            Layout.fillWidth: ! searchBar.visible
+                            manager.tabShown = currentIndex
+                            searchBar.text = "";
+                            searchBar.visible = currentItem.hasSearch;
+                            content.source = currentItem.sourcePage;
                         }
 
-                        Cura.SearchBar
+                        PackageTypeTab
                         {
-                            id: searchBar
-                            Layout.preferredHeight: UM.Theme.getSize("button_icon").height
-                            Layout.fillWidth: true
-                            onTextEdited: searchStringChanged(text)
+                            id: pluginTabText
+                            width: implicitWidth
+                            text: catalog.i18nc("@button", "Plugins")
+                            property string sourcePage: "Plugins.qml"
+                            property bool hasSearch: true
                         }
-
-                        // Page selection.
-                        TabBar
+                        PackageTypeTab
                         {
-                            id: pageSelectionTabBar
-                            Layout.alignment: Qt.AlignRight
-                            height: UM.Theme.getSize("button_icon").height
-                            spacing: 0
-                            background: Rectangle { color: "transparent" }
-                            currentIndex: manager.tabShown
-
-                            onCurrentIndexChanged:
-                            {
-                                manager.tabShown = currentIndex
-                                searchBar.text = "";
-                                searchBar.visible = currentItem.hasSearch;
-                                content.source = currentItem.sourcePage;
-                            }
+                            id: materialsTabText
+                            width: implicitWidth
+                            text: catalog.i18nc("@button", "Materials")
+                            property string sourcePage: "Materials.qml"
+                            property bool hasSearch: true
+                        }
+                        ManagePackagesButton
+                        {
+                            property string sourcePage: "ManagedPackages.qml"
+                            property bool hasSearch: false
 
-                            PackageTypeTab
-                            {
-                                id: pluginTabText
-                                width: implicitWidth
-                                text: catalog.i18nc("@button", "Plugins")
-                                property string sourcePage: "Plugins.qml"
-                                property bool hasSearch: true
-                            }
-                            PackageTypeTab
+                            Cura.NotificationIcon
                             {
-                                id: materialsTabText
-                                width: implicitWidth
-                                text: catalog.i18nc("@button", "Materials")
-                                property string sourcePage: "Materials.qml"
-                                property bool hasSearch: true
-                            }
-                            ManagePackagesButton
-                            {
-                                property string sourcePage: "ManagedPackages.qml"
-                                property bool hasSearch: false
+                                anchors
+                                {
+                                    horizontalCenter: parent.right
+                                    verticalCenter: parent.top
+                                }
+                                visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
 
-                                Cura.NotificationIcon
+                                labelText:
                                 {
-                                    anchors
-                                    {
-                                        horizontalCenter: parent.right
-                                        verticalCenter: parent.top
-                                    }
-                                    visible: CuraApplication.getPackageManager().packagesWithUpdate.length > 0
-
-                                    labelText:
-                                    {
-                                        const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length
-                                        return itemCount > 9 ? "9+" : itemCount
-                                    }
+                                    const itemCount = CuraApplication.getPackageManager().packagesWithUpdate.length
+                                    return itemCount > 9 ? "9+" : itemCount
                                 }
                             }
                         }
-
-                        TextMetrics
-                        {
-                            id: pluginTabTextMetrics
-                            text: pluginTabText.text
-                            font: pluginTabText.font
-                        }
-                        TextMetrics
-                        {
-                            id: materialsTabTextMetrics
-                            text: materialsTabText.text
-                            font: materialsTabText.font
-                        }
                     }
                 }
+            }
 
-                FontMetrics
-                {
-                    id: fontMetrics
-                    font: UM.Theme.getFont("default")
-                }
+            FontMetrics
+            {
+                id: fontMetrics
+                font: UM.Theme.getFont("default")
+            }
 
-                Cura.TertiaryButton
-                {
-                    text: catalog.i18nc("@info", "Search in the browser")
-                    iconSource: UM.Theme.getIcon("LinkExternal")
-                    visible: pageSelectionTabBar.currentItem.hasSearch
-                    isIconOnRightSide: true
-                    height: fontMetrics.height
-                    textFont: fontMetrics.font
-                    textColor: UM.Theme.getColor("text")
-
-                    onClicked: content.item && Qt.openUrlExternally(content.item.searchInBrowserUrl)
-                }
+            Cura.TertiaryButton
+            {
+                text: catalog.i18nc("@info", "Search in the browser")
+                iconSource: UM.Theme.getIcon("LinkExternal")
+                visible: pageSelectionTabBar.currentItem.hasSearch
+                isIconOnRightSide: true
+                height: fontMetrics.height
+                textFont: fontMetrics.font
+                textColor: UM.Theme.getColor("text")
+
+                onClicked: content.item && Qt.openUrlExternally(content.item.searchInBrowserUrl)
+            }
+
+            // Page contents.
+            Rectangle
+            {
+                Layout.preferredWidth: parent.width
+                Layout.fillHeight: true
+                color: UM.Theme.getColor("detail_background")
 
                 // Page contents.
-                Rectangle
+                Loader
                 {
-                    Layout.preferredWidth: parent.width
-                    Layout.fillHeight: true
-                    color: UM.Theme.getColor("detail_background")
+                    id: content
+                    anchors.fill: parent
+                    anchors.margins: UM.Theme.getSize("default_margin").width
+                    source: "Plugins.qml"
 
-                    // Page contents.
-                    Loader
+                    Connections
                     {
-                        id: content
-                        anchors.fill: parent
-                        anchors.margins: UM.Theme.getSize("default_margin").width
-                        source: "Plugins.qml"
-
-                        Connections
+                        target: content
+                        function onLoaded()
                         {
-                            target: content
-                            function onLoaded()
-                            {
-                                pageTitle.text = content.item.pageTitle
-                                searchStringChanged.connect(handleSearchStringChanged)
-                            }
-                            function handleSearchStringChanged(new_search)
-                            {
-                                content.item.model.searchString = new_search
-                            }
+                            pageTitle.text = content.item.pageTitle
+                            searchStringChanged.connect(handleSearchStringChanged)
+                        }
+                        function handleSearchStringChanged(new_search)
+                        {
+                            content.item.model.searchString = new_search
                         }
                     }
                 }

+ 3 - 2
plugins/Marketplace/resources/qml/Materials.qml

@@ -10,13 +10,14 @@ Packages
     bannerVisible:  UM.Preferences.getValue("cura/market_place_show_material_banner")
     bannerIcon: UM.Theme.getIcon("Spool")
     bannerText: catalog.i18nc("@text", "Select and install material profiles optimised for your Ultimaker 3D printers.")
-    bannerReadMoreUrl: "" // TODO add when support page is ready
+    bannerReadMoreUrl: "https://support.ultimaker.com/hc/en-us/articles/360011968360/?utm_source=cura&utm_medium=software&utm_campaign=marketplace-learn-materials"
     onRemoveBanner: function() {
         UM.Preferences.setValue("cura/market_place_show_material_banner", false);
         bannerVisible = false;
     }
     searchInBrowserUrl: "https://marketplace.ultimaker.com/app/cura/materials?utm_source=cura&utm_medium=software&utm_campaign=marketplace-search-materials-browser"
-    packagesManageableInListView: false
+    showUpdateButton: true
+    showInstallButton: true
 
     model: manager.MaterialPackageList
 }

+ 1 - 4
plugins/Marketplace/resources/qml/OnboardBanner.qml

@@ -16,10 +16,7 @@ Rectangle
     property var onRemove
     property string readMoreUrl
 
-    Layout.preferredHeight: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height
-    Layout.fillWidth: true
-    Layout.margins: UM.Theme.getSize("default_margin").width
-
+    implicitHeight: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height
     color: UM.Theme.getColor("action_panel_secondary")
 
     // Icon

+ 3 - 51
plugins/Marketplace/resources/qml/PackageCard.qml

@@ -11,7 +11,9 @@ import Cura 1.6 as Cura
 Rectangle
 {
     property alias packageData: packageCardHeader.packageData
-    property alias manageableInListView: packageCardHeader.showManageButtons
+    property alias showUpdateButton:  packageCardHeader.showUpdateButton
+    property alias showDisableButton:  packageCardHeader.showDisableButton
+    property alias showInstallButton: packageCardHeader.showInstallButton
 
     height: childrenRect.height
     color: UM.Theme.getColor("main_background")
@@ -31,64 +33,14 @@ Rectangle
             {
                 id: descriptionLabel
                 width: parent.width
-                property real lastLineWidth: 0; //Store the width of the last line, to properly position the elision.
 
                 text: packageData.description
-                textFormat: Text.PlainText //Must be plain text, or we won't get onLineLaidOut signals. Don't auto-detect!
                 font: UM.Theme.getFont("default")
                 color: UM.Theme.getColor("text")
                 maximumLineCount: 2
                 wrapMode: Text.Wrap
                 elide: Text.ElideRight
                 visible: text !== ""
-
-                onLineLaidOut:
-                {
-                    if(truncated && line.isLast)
-                    {
-                        let max_line_width = parent.width - readMoreButton.width - fontMetrics.advanceWidth("… ") - 2 * UM.Theme.getSize("default_margin").width;
-                        if(line.implicitWidth > max_line_width)
-                        {
-                            line.width = max_line_width;
-                        }
-                        else
-                        {
-                            line.width = line.implicitWidth - fontMetrics.advanceWidth("…"); //Truncate the ellipsis. We're adding this ourselves.
-                        }
-                        descriptionLabel.lastLineWidth = line.implicitWidth;
-                    }
-                }
-            }
-            Label
-            {
-                id: tripleDotLabel
-                anchors.left: parent.left
-                anchors.leftMargin: descriptionLabel.lastLineWidth
-                anchors.bottom: descriptionLabel.bottom
-
-                text: "… "
-                font: descriptionLabel.font
-                color: descriptionLabel.color
-                visible: descriptionLabel.truncated && descriptionLabel.text !== ""
-            }
-            Cura.TertiaryButton
-            {
-                id: readMoreButton
-                anchors.right: parent.right
-                anchors.bottom: descriptionLabel.bottom
-                height: fontMetrics.height //Height of a single line.
-
-                text: catalog.i18nc("@info", "Read more")
-                iconSource: UM.Theme.getIcon("LinkExternal")
-
-                visible: descriptionLabel.truncated && descriptionLabel.text !== ""
-                enabled: visible
-                leftPadding: UM.Theme.getSize("default_margin").width
-                rightPadding: UM.Theme.getSize("wide_margin").width
-                textFont: descriptionLabel.font
-                isIconOnRightSide: true
-
-                onClicked: Qt.openUrlExternally(packageData.packageInfoUrl)
             }
         }
     }

+ 24 - 8
plugins/Marketplace/resources/qml/PackageCardHeader.qml

@@ -12,10 +12,13 @@ import Cura 1.6 as Cura
 // are combined into the reusable "PackageCardHeader" component
 Item
 {
-    default property alias contents: contentItem.children;
+    default property alias contents: contentItem.children
 
     property var packageData
-    property bool showManageButtons: false
+    property bool showDisableButton: false
+    property bool showInstallButton: false
+    property bool showUpdateButton: false
+
 
     width: parent.width
     height: UM.Theme.getSize("card").height
@@ -32,8 +35,21 @@ Item
         }
         width: UM.Theme.getSize("card_icon").width
         height: width
-
-        source: packageData.iconUrl != "" ? packageData.iconUrl : "../images/placeholder.svg"
+        sourceSize.height: height
+        sourceSize.width: width
+        source:
+        {
+            if (packageData.iconUrl != "")
+            {
+                return packageData.iconUrl
+            }
+            switch (packageData.packageType)
+            {
+                case "plugin": return "../images/Plugin.svg";
+                case "material": return "../images/Spool.svg";
+                default: return "../images/placeholder.svg";
+            }
+        }
     }
 
     ColumnLayout
@@ -103,7 +119,7 @@ Item
                     color: externalLinkButton.hovered ? UM.Theme.getColor("action_button_hovered"): "transparent"
                     radius: externalLinkButton.width / 2
                 }
-                onClicked: Qt.openUrlExternally(packageData.authorInfoUrl)
+                onClicked: Qt.openUrlExternally(packageData.marketplaceURL)
             }
         }
 
@@ -157,7 +173,7 @@ Item
             ManageButton
             {
                 id: enableManageButton
-                visible: showManageButtons && packageData.isInstalled && !packageData.isToBeInstalled && packageData.packageType != "material"
+                visible: showDisableButton && packageData.isInstalled && !packageData.isToBeInstalled && packageData.packageType != "material"
                 enabled: !packageData.busy
 
                 button_style: !packageData.isActive
@@ -171,7 +187,7 @@ Item
             ManageButton
             {
                 id: installManageButton
-                visible: showManageButtons && (packageData.canDowngrade || !packageData.isBundled)
+                visible: showInstallButton && (packageData.canDowngrade || !packageData.isBundled)
                 enabled: !packageData.busy
                 busy: packageData.busy
                 button_style: !(packageData.isInstalled || packageData.isToBeInstalled)
@@ -201,7 +217,7 @@ Item
             ManageButton
             {
                 id: updateManageButton
-                visible: showManageButtons && packageData.canUpdate
+                visible: showUpdateButton && packageData.canUpdate
                 enabled: !packageData.busy
                 busy: packageData.busy
                 Layout.alignment: Qt.AlignTop

Some files were not shown because too many files changed in this diff