Browse Source

Merge branch 'ui_rework_4_0' of github.com:Ultimaker/Cura into CURA-5785-Restyle_stage_menu

Jaime van Kessel 6 years ago
parent
commit
1569fd7396

+ 0 - 4
cura/API/Interface/__init__.py

@@ -3,7 +3,6 @@
 
 
 from typing import TYPE_CHECKING
 from typing import TYPE_CHECKING
 
 
-from UM.PluginRegistry import PluginRegistry
 from cura.API.Interface.Settings import Settings
 from cura.API.Interface.Settings import Settings
 
 
 if TYPE_CHECKING:
 if TYPE_CHECKING:
@@ -23,9 +22,6 @@ if TYPE_CHECKING:
 
 
 class Interface:
 class Interface:
 
 
-    # For now we use the same API version to be consistent.
-    VERSION = PluginRegistry.APIVersion
-
     def __init__(self, application: "CuraApplication") -> None:
     def __init__(self, application: "CuraApplication") -> None:
         # API methods specific to the settings portion of the UI
         # API methods specific to the settings portion of the UI
         self.settings = Settings(application)
         self.settings = Settings(application)

+ 1 - 3
cura/API/__init__.py

@@ -4,7 +4,6 @@ from typing import Optional, TYPE_CHECKING
 
 
 from PyQt5.QtCore import QObject, pyqtProperty
 from PyQt5.QtCore import QObject, pyqtProperty
 
 
-from UM.PluginRegistry import PluginRegistry
 from cura.API.Backups import Backups
 from cura.API.Backups import Backups
 from cura.API.Interface import Interface
 from cura.API.Interface import Interface
 from cura.API.Account import Account
 from cura.API.Account import Account
@@ -22,7 +21,6 @@ if TYPE_CHECKING:
 class CuraAPI(QObject):
 class CuraAPI(QObject):
 
 
     # For now we use the same API version to be consistent.
     # For now we use the same API version to be consistent.
-    VERSION = PluginRegistry.APIVersion
     __instance = None  # type: "CuraAPI"
     __instance = None  # type: "CuraAPI"
     _application = None  # type: CuraApplication
     _application = None  # type: CuraApplication
 
 
@@ -62,4 +60,4 @@ class CuraAPI(QObject):
 
 
     @property
     @property
     def interface(self) -> "Interface":
     def interface(self) -> "Interface":
-        return self._interface
+        return self._interface

+ 2 - 1
cura/CuraApplication.py

@@ -134,7 +134,7 @@ except ImportError:
     CuraVersion = "master"  # [CodeStyle: Reflecting imported value]
     CuraVersion = "master"  # [CodeStyle: Reflecting imported value]
     CuraBuildType = ""
     CuraBuildType = ""
     CuraDebugMode = False
     CuraDebugMode = False
-    CuraSDKVersion = ""
+    CuraSDKVersion = "5.0.0"
 
 
 
 
 class CuraApplication(QtApplication):
 class CuraApplication(QtApplication):
@@ -164,6 +164,7 @@ class CuraApplication(QtApplication):
         super().__init__(name = "cura",
         super().__init__(name = "cura",
                          app_display_name = CuraAppDisplayName,
                          app_display_name = CuraAppDisplayName,
                          version = CuraVersion,
                          version = CuraVersion,
+                         api_version = CuraSDKVersion,
                          buildtype = CuraBuildType,
                          buildtype = CuraBuildType,
                          is_debug_mode = CuraDebugMode,
                          is_debug_mode = CuraDebugMode,
                          tray_icon_name = "cura-icon-32.png",
                          tray_icon_name = "cura-icon-32.png",

+ 1 - 1
cura/CuraVersion.py.in

@@ -1,4 +1,4 @@
-# Copyright (c) 2015 Ultimaker B.V.
+# Copyright (c) 2018 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 
 CuraAppDisplayName = "@CURA_APP_DISPLAY_NAME@"
 CuraAppDisplayName = "@CURA_APP_DISPLAY_NAME@"

+ 160 - 109
plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml

@@ -11,157 +11,208 @@ Item
     id: base
     id: base
 
 
     property var packageData
     property var packageData
-    property var technicalDataSheetUrl: {
+    property var technicalDataSheetUrl:
+    {
         var link = undefined
         var link = undefined
         if ("Technical Data Sheet" in packageData.links)
         if ("Technical Data Sheet" in packageData.links)
         {
         {
+            // HACK: This is the way the old API (used in 3.6-beta) used to do it. For safety it's still here,
+            // but it can be removed over time.
             link = packageData.links["Technical Data Sheet"]
             link = packageData.links["Technical Data Sheet"]
         }
         }
+        else if ("technicalDataSheet" in packageData.links)
+        {
+            link = packageData.links["technicalDataSheet"]
+        }
         return link
         return link
     }
     }
-
-    anchors.topMargin: UM.Theme.getSize("default_margin").height
-    height: visible ? childrenRect.height : 0
-    visible: packageData.type == "material" && packageData.has_configs
-    Label
+    property var safetyDataSheetUrl:
     {
     {
-        id: heading
-        anchors.topMargin: UM.Theme.getSize("default_margin").height
-        width: parent.width
-        text: catalog.i18nc("@label", "Compatibility")
-        wrapMode: Text.WordWrap
-        color: UM.Theme.getColor("text_medium")
-        font: UM.Theme.getFont("medium")
+        var sds_name = "safetyDataSheet"
+        return (sds_name in packageData.links) ? packageData.links[sds_name] : undefined
     }
     }
-    TableView
+    property var printingGuidelinesUrl:
     {
     {
-        id: table
-        anchors.top: heading.bottom
-        anchors.topMargin: UM.Theme.getSize("default_margin").height
+        var pg_name = "printingGuidelines"
+        return (pg_name in packageData.links) ? packageData.links[pg_name] : undefined
+    }
+    anchors.topMargin: UM.Theme.getSize("default_margin").height
+    height: visible ? childrenRect.height : 0
+
+    visible: packageData.type == "material" &&
+        (packageData.has_configs || technicalDataSheetUrl !== undefined ||
+            safetyDataSheetUrl !== undefined || printingGuidelinesUrl !== undefined)
+
+    Item
+    {
+        id: combatibilityItem
+        visible: packageData.has_configs
         width: parent.width
         width: parent.width
-        frameVisible: false
+        // This is a bit of a hack, but the whole QML is pretty messy right now. This needs a big overhaul.
+        height: visible ? heading.height + table.height: 0
 
 
-        // Workaround for scroll issues (QTBUG-49652)
-        flickableItem.interactive: false
-        Component.onCompleted:
+        Label
         {
         {
-            for (var i = 0; i < flickableItem.children.length; ++i)
-            {
-                flickableItem.children[i].enabled = false
-            }
+            id: heading
+            anchors.topMargin: UM.Theme.getSize("default_margin").height
+            width: parent.width
+            text: catalog.i18nc("@label", "Compatibility")
+            wrapMode: Text.WordWrap
+            color: UM.Theme.getColor("text_medium")
+            font: UM.Theme.getFont("medium")
         }
         }
-        selectionMode: 0
-        model: packageData.supported_configs
-        headerDelegate: Rectangle
+
+        TableView
         {
         {
-            color: UM.Theme.getColor("main_background")
-            height: UM.Theme.getSize("toolbox_chart_row").height
-            Label
+            id: table
+            anchors.top: heading.bottom
+            anchors.topMargin: UM.Theme.getSize("default_margin").height
+            width: parent.width
+            frameVisible: false
+
+            // Workaround for scroll issues (QTBUG-49652)
+            flickableItem.interactive: false
+            Component.onCompleted:
             {
             {
-                anchors.verticalCenter: parent.verticalCenter
-                elide: Text.ElideRight
-                text: styleData.value || ""
-                color: UM.Theme.getColor("text")
-                font: UM.Theme.getFont("default_bold")
+                for (var i = 0; i < flickableItem.children.length; ++i)
+                {
+                    flickableItem.children[i].enabled = false
+                }
             }
             }
-            Rectangle
+            selectionMode: 0
+            model: packageData.supported_configs
+            headerDelegate: Rectangle
             {
             {
-                anchors.bottom: parent.bottom
-                height: UM.Theme.getSize("default_lining").height
-                width: parent.width
-                color: "black"
+                color: UM.Theme.getColor("sidebar")
+                height: UM.Theme.getSize("toolbox_chart_row").height
+                Label
+                {
+                    anchors.verticalCenter: parent.verticalCenter
+                    elide: Text.ElideRight
+                    text: styleData.value || ""
+                    color: UM.Theme.getColor("text")
+                    font: UM.Theme.getFont("default_bold")
+                }
+                Rectangle
+                {
+                    anchors.bottom: parent.bottom
+                    height: UM.Theme.getSize("default_lining").height
+                    width: parent.width
+                    color: "black"
+                }
             }
             }
-        }
-        rowDelegate: Item
-        {
-            height: UM.Theme.getSize("toolbox_chart_row").height
-            Label
+            rowDelegate: Item
             {
             {
-                anchors.verticalCenter: parent.verticalCenter
-                elide: Text.ElideRight
-                text: styleData.value || ""
-                color: UM.Theme.getColor("text_medium")
-                font: UM.Theme.getFont("default")
+                height: UM.Theme.getSize("toolbox_chart_row").height
+                Label
+                {
+                    anchors.verticalCenter: parent.verticalCenter
+                    elide: Text.ElideRight
+                    text: styleData.value || ""
+                    color: UM.Theme.getColor("text_medium")
+                    font: UM.Theme.getFont("default")
+                }
             }
             }
-        }
-        itemDelegate: Item
-        {
-            height: UM.Theme.getSize("toolbox_chart_row").height
-            Label
+            itemDelegate: Item
             {
             {
-                anchors.verticalCenter: parent.verticalCenter
-                elide: Text.ElideRight
-                text: styleData.value || ""
-                color: UM.Theme.getColor("text_medium")
-                font: UM.Theme.getFont("default")
+                height: UM.Theme.getSize("toolbox_chart_row").height
+                Label
+                {
+                    anchors.verticalCenter: parent.verticalCenter
+                    elide: Text.ElideRight
+                    text: styleData.value || ""
+                    color: UM.Theme.getColor("text_medium")
+                    font: UM.Theme.getFont("default")
+                }
             }
             }
-        }
 
 
-        Component
-        {
-            id: columnTextDelegate
-            Label
+            Component
             {
             {
-                anchors.fill: parent
-                verticalAlignment: Text.AlignVCenter
-                text: styleData.value || ""
-                elide: Text.ElideRight
-                color: UM.Theme.getColor("text_medium")
-                font: UM.Theme.getFont("default")
+                id: columnTextDelegate
+                Label
+                {
+                    anchors.fill: parent
+                    verticalAlignment: Text.AlignVCenter
+                    text: styleData.value || ""
+                    elide: Text.ElideRight
+                    color: UM.Theme.getColor("text_medium")
+                    font: UM.Theme.getFont("default")
+                }
             }
             }
-        }
 
 
-        TableViewColumn
-        {
-            role: "machine"
-            title: "Machine"
-            width: Math.floor(table.width * 0.25)
-            delegate: columnTextDelegate
-        }
-        TableViewColumn
-        {
-            role: "print_core"
-            title: "Print Core"
-            width: Math.floor(table.width * 0.2)
-        }
-        TableViewColumn
-        {
-            role: "build_plate"
-            title: "Build Plate"
-            width: Math.floor(table.width * 0.225)
-        }
-        TableViewColumn
-        {
-            role: "support_material"
-            title: "Support"
-            width: Math.floor(table.width * 0.225)
-        }
-        TableViewColumn
-        {
-            role: "quality"
-            title: "Quality"
-            width: Math.floor(table.width * 0.1)
+            TableViewColumn
+            {
+                role: "machine"
+                title: "Machine"
+                width: Math.floor(table.width * 0.25)
+                delegate: columnTextDelegate
+            }
+            TableViewColumn
+            {
+                role: "print_core"
+                title: "Print Core"
+                width: Math.floor(table.width * 0.2)
+            }
+            TableViewColumn
+            {
+                role: "build_plate"
+                title: "Build Plate"
+                width: Math.floor(table.width * 0.225)
+            }
+            TableViewColumn
+            {
+                role: "support_material"
+                title: "Support"
+                width: Math.floor(table.width * 0.225)
+            }
+            TableViewColumn
+            {
+                role: "quality"
+                title: "Quality"
+                width: Math.floor(table.width * 0.1)
+            }
         }
         }
     }
     }
 
 
     Label
     Label
     {
     {
-        id: technical_data_sheet
-        anchors.top: table.bottom
+        id: data_sheet_links
+        anchors.top: combatibilityItem.bottom
         anchors.topMargin: UM.Theme.getSize("default_margin").height / 2
         anchors.topMargin: UM.Theme.getSize("default_margin").height / 2
-        visible: base.technicalDataSheetUrl !== undefined
+        visible: base.technicalDataSheetUrl !== undefined ||
+            base.safetyDataSheetUrl !== undefined || base.printingGuidelinesUrl !== undefined
+        height: visible ? contentHeight : 0
         text:
         text:
         {
         {
+            var result = ""
             if (base.technicalDataSheetUrl !== undefined)
             if (base.technicalDataSheetUrl !== undefined)
             {
             {
-                return "<a href='%1'>%2</a>".arg(base.technicalDataSheetUrl).arg("Technical Data Sheet")
+                var tds_name = catalog.i18nc("@action:label", "Technical Data Sheet")
+                result += "<a href='%1'>%2</a>".arg(base.technicalDataSheetUrl).arg(tds_name)
+            }
+            if (base.safetyDataSheetUrl !== undefined)
+            {
+                if (result.length > 0)
+                {
+                    result += "<br/>"
+                }
+                var sds_name = catalog.i18nc("@action:label", "Safety Data Sheet")
+                result += "<a href='%1'>%2</a>".arg(base.safetyDataSheetUrl).arg(sds_name)
             }
             }
-            return ""
+            if (base.printingGuidelinesUrl !== undefined)
+            {
+                if (result.length > 0)
+                {
+                    result += "<br/>"
+                }
+                var pg_name = catalog.i18nc("@action:label", "Printing Guidelines")
+                result += "<a href='%1'>%2</a>".arg(base.printingGuidelinesUrl).arg(pg_name)
+            }
+            return result
         }
         }
         font: UM.Theme.getFont("very_small")
         font: UM.Theme.getFont("very_small")
         color: UM.Theme.getColor("text")
         color: UM.Theme.getColor("text")
         linkColor: UM.Theme.getColor("text_link")
         linkColor: UM.Theme.getColor("text_link")
         onLinkActivated: Qt.openUrlExternally(link)
         onLinkActivated: Qt.openUrlExternally(link)
     }
     }
-
 }
 }

+ 1 - 1
plugins/Toolbox/resources/qml/ToolboxDetailTile.qml

@@ -37,7 +37,7 @@ Item
             anchors.top: packageName.bottom
             anchors.top: packageName.bottom
             width: parent.width
             width: parent.width
             text: model.description
             text: model.description
-            maximumLineCount: 3
+            maximumLineCount: 6
             elide: Text.ElideRight
             elide: Text.ElideRight
             wrapMode: Text.WordWrap
             wrapMode: Text.WordWrap
             color: UM.Theme.getColor("text")
             color: UM.Theme.getColor("text")

+ 2 - 2
plugins/Toolbox/src/PackagesModel.py

@@ -12,7 +12,7 @@ from UM.Qt.ListModel import ListModel
 from .ConfigsModel import ConfigsModel
 from .ConfigsModel import ConfigsModel
 
 
 
 
-##  Model that holds cura packages. By setting the filter property the instances held by this model can be changed.
+##  Model that holds Cura packages. By setting the filter property the instances held by this model can be changed.
 class PackagesModel(ListModel):
 class PackagesModel(ListModel):
     def __init__(self, parent = None):
     def __init__(self, parent = None):
         super().__init__(parent)
         super().__init__(parent)
@@ -70,7 +70,7 @@ class PackagesModel(ListModel):
 
 
                 # Links is a list of dictionaries with "title" and "url". Convert this list into a dict so it's easier
                 # Links is a list of dictionaries with "title" and "url". Convert this list into a dict so it's easier
                 # to process.
                 # to process.
-                link_list = package['data']['links'] if 'links' in package['data'] else []
+                link_list = package["data"]["links"] if "links" in package["data"] else []
                 links_dict = {d["title"]: d["url"] for d in link_list}
                 links_dict = {d["title"]: d["url"] for d in link_list}
 
 
             if "author_id" not in package["author"] or "display_name" not in package["author"]:
             if "author_id" not in package["author"] or "display_name" not in package["author"]:

+ 14 - 14
plugins/Toolbox/src/Toolbox.py

@@ -172,18 +172,18 @@ class Toolbox(QObject, Extension):
         self._cloud_api_version = self._getCloudAPIVersion()
         self._cloud_api_version = self._getCloudAPIVersion()
         self._cloud_api_root = self._getCloudAPIRoot()
         self._cloud_api_root = self._getCloudAPIRoot()
         self._api_url = "{cloud_api_root}/cura-packages/v{cloud_api_version}/cura/v{sdk_version}".format(
         self._api_url = "{cloud_api_root}/cura-packages/v{cloud_api_version}/cura/v{sdk_version}".format(
-            cloud_api_root=self._cloud_api_root,
-            cloud_api_version=self._cloud_api_version,
-            sdk_version=self._sdk_version
+            cloud_api_root = self._cloud_api_root,
+            cloud_api_version = self._cloud_api_version,
+            sdk_version = self._sdk_version
         )
         )
         self._request_urls = {
         self._request_urls = {
-            "authors": QUrl("{base_url}/authors".format(base_url=self._api_url)),
-            "packages": QUrl("{base_url}/packages".format(base_url=self._api_url)),
-            "plugins_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
-            "plugins_available": QUrl("{base_url}/packages?package_type=plugin".format(base_url=self._api_url)),
-            "materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
-            "materials_available": QUrl("{base_url}/packages?package_type=material".format(base_url=self._api_url)),
-            "materials_generic": QUrl("{base_url}/packages?package_type=material&tags=generic".format(base_url=self._api_url))
+            "authors": QUrl("{base_url}/authors".format(base_url = self._api_url)),
+            "packages": QUrl("{base_url}/packages".format(base_url = self._api_url)),
+            "plugins_showcase": QUrl("{base_url}/showcase".format(base_url = self._api_url)),
+            "plugins_available": QUrl("{base_url}/packages?package_type=plugin".format(base_url = self._api_url)),
+            "materials_showcase": QUrl("{base_url}/showcase".format(base_url = self._api_url)),
+            "materials_available": QUrl("{base_url}/packages?package_type=material".format(base_url = self._api_url)),
+            "materials_generic": QUrl("{base_url}/packages?package_type=material&tags=generic".format(base_url = self._api_url))
         }
         }
 
 
     # Get the API root for the packages API depending on Cura version settings.
     # Get the API root for the packages API depending on Cura version settings.
@@ -209,11 +209,11 @@ class Toolbox(QObject, Extension):
     # Get the packages version depending on Cura version settings.
     # Get the packages version depending on Cura version settings.
     def _getSDKVersion(self) -> Union[int, str]:
     def _getSDKVersion(self) -> Union[int, str]:
         if not hasattr(cura, "CuraVersion"):
         if not hasattr(cura, "CuraVersion"):
-            return self._plugin_registry.APIVersion
+            return self._application.getAPIVersion().getMajor()
         if not hasattr(cura.CuraVersion, "CuraSDKVersion"):  # type: ignore
         if not hasattr(cura.CuraVersion, "CuraSDKVersion"):  # type: ignore
-            return self._plugin_registry.APIVersion
+            return self._application.getAPIVersion().getMajor()
         if not cura.CuraVersion.CuraSDKVersion:  # type: ignore
         if not cura.CuraVersion.CuraSDKVersion:  # type: ignore
-            return self._plugin_registry.APIVersion
+            return self._application.getAPIVersion().getMajor()
         return cura.CuraVersion.CuraSDKVersion  # type: ignore
         return cura.CuraVersion.CuraSDKVersion  # type: ignore
 
 
     @pyqtSlot()
     @pyqtSlot()
@@ -299,7 +299,7 @@ class Toolbox(QObject, Extension):
         for plugin_id in old_plugin_ids:
         for plugin_id in old_plugin_ids:
             # Neither the installed packages nor the packages that are scheduled to remove are old plugins
             # Neither the installed packages nor the packages that are scheduled to remove are old plugins
             if plugin_id not in installed_package_ids and plugin_id not in scheduled_to_remove_package_ids:
             if plugin_id not in installed_package_ids and plugin_id not in scheduled_to_remove_package_ids:
-                Logger.log('i', 'Found a plugin that was installed with the old plugin browser: %s', plugin_id)
+                Logger.log("i", "Found a plugin that was installed with the old plugin browser: %s", plugin_id)
 
 
                 old_metadata = self._plugin_registry.getMetaData(plugin_id)
                 old_metadata = self._plugin_registry.getMetaData(plugin_id)
                 new_metadata = self._convertPluginMetadata(old_metadata)
                 new_metadata = self._convertPluginMetadata(old_metadata)

+ 5 - 0
plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py

@@ -11,6 +11,7 @@ def getMetaData():
             # From                           To                              Upgrade function
             # From                           To                              Upgrade function
             ("definition_changes", 3000004): ("definition_changes", 4000004, upgrade.upgradeInstanceContainer),
             ("definition_changes", 3000004): ("definition_changes", 4000004, upgrade.upgradeInstanceContainer),
             ("quality_changes", 3000004):    ("quality_changes", 4000004,    upgrade.upgradeInstanceContainer),
             ("quality_changes", 3000004):    ("quality_changes", 4000004,    upgrade.upgradeInstanceContainer),
+            ("quality", 3000004):            ("quality", 4000004,            upgrade.upgradeInstanceContainer),
             ("user", 3000004):               ("user", 4000004,               upgrade.upgradeInstanceContainer),
             ("user", 3000004):               ("user", 4000004,               upgrade.upgradeInstanceContainer),
         },
         },
         "sources": {
         "sources": {
@@ -22,6 +23,10 @@ def getMetaData():
                 "get_version": upgrade.getCfgVersion,
                 "get_version": upgrade.getCfgVersion,
                 "location": {"./quality_changes"}
                 "location": {"./quality_changes"}
             },
             },
+            "quality": {
+                "get_version": upgrade.getCfgVersion,
+                "location": {"./quality"}
+            },
             "user": {
             "user": {
                 "get_version": upgrade.getCfgVersion,
                 "get_version": upgrade.getCfgVersion,
                 "location": {"./user"}
                 "location": {"./user"}

+ 5 - 0
plugins/VersionUpgrade/VersionUpgrade34to35/__init__.py

@@ -13,6 +13,7 @@ def getMetaData():
 
 
             ("definition_changes", 4000004): ("definition_changes", 4000005, upgrade.upgradeInstanceContainer),
             ("definition_changes", 4000004): ("definition_changes", 4000005, upgrade.upgradeInstanceContainer),
             ("quality_changes", 4000004):    ("quality_changes", 4000005,    upgrade.upgradeInstanceContainer),
             ("quality_changes", 4000004):    ("quality_changes", 4000005,    upgrade.upgradeInstanceContainer),
+            ("quality", 4000004):            ("quality", 4000005,            upgrade.upgradeInstanceContainer),
             ("user", 4000004):               ("user", 4000005,               upgrade.upgradeInstanceContainer),
             ("user", 4000004):               ("user", 4000005,               upgrade.upgradeInstanceContainer),
 
 
             ("machine_stack", 4000004):      ("machine_stack", 4000005,      upgrade.upgradeStack),
             ("machine_stack", 4000004):      ("machine_stack", 4000005,      upgrade.upgradeStack),
@@ -39,6 +40,10 @@ def getMetaData():
                 "get_version": upgrade.getCfgVersion,
                 "get_version": upgrade.getCfgVersion,
                 "location": {"./quality_changes"}
                 "location": {"./quality_changes"}
             },
             },
+            "quality": {
+                "get_version": upgrade.getCfgVersion,
+                "location": {"./quality"}
+            },
             "user": {
             "user": {
                 "get_version": upgrade.getCfgVersion,
                 "get_version": upgrade.getCfgVersion,
                 "location": {"./user"}
                 "location": {"./user"}

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