Browse Source

Remove banners when clicking close button

casper 3 years ago
parent
commit
748101ce69

+ 31 - 0
cura/CuraApplication.py

@@ -572,6 +572,10 @@ class CuraApplication(QtApplication):
 
         preferences.addPreference("general/accepted_user_agreement", False)
 
+        preferences.addPreference("cura/market_place_show_plugin_banner", True)
+        preferences.addPreference("cura/market_place_show_material_banner", True)
+        preferences.addPreference("cura/market_place_show_manage_packages_banner", True)
+
         for key in [
             "dialog_load_path",  # dialog_save_path is in LocalFileOutputDevicePlugin
             "dialog_profile_path",
@@ -2011,6 +2015,33 @@ class CuraApplication(QtApplication):
         show_whatsnew_only = has_active_machine and has_app_just_upgraded
         return show_whatsnew_only
 
+    @pyqtSlot(result = bool)
+    def shouldShowMarketPlacePluginBanner(self) -> bool:
+        return self._preferences.getValue("cura/market_place_show_plugin_banner")
+
+    @pyqtSlot(result = bool)
+    def shouldShowMarketPlaceMaterialBanner(self) -> bool:
+        return self._preferences.getValue("cura/market_place_show_material_banner")
+
+    @pyqtSlot(result = bool)
+    def shouldShowMarketPlaceManagePackagesBanner(self) -> bool:
+        return self._preferences.getValue("cura/market_place_show_manage_packages_banner")
+
+    @pyqtSlot()
+    def closeMarketPlacePluginBanner(self) -> None:
+        Logger.log("i", "Close market place plugin banner")
+        self._preferences.setValue("cura/market_place_show_plugin_banner", False)
+
+    @pyqtSlot()
+    def closeMarketPlaceMaterialBanner(self) -> None:
+        Logger.log("i", "Close market place material banner")
+        self._preferences.setValue("cura/market_place_show_material_banner", False)
+
+    @pyqtSlot()
+    def closeMarketPlaceManagePackagesBanner(self) -> None:
+        Logger.log("i", "Close market place manage packages banner")
+        self._preferences.setValue("cura/market_place_show_manage_packages_banner", False)
+
     @pyqtSlot(result = int)
     def appWidth(self) -> int:
         main_window = QtApplication.getInstance().getMainWindow()

+ 9 - 1
plugins/Marketplace/resources/qml/ManagedPackages.qml

@@ -10,7 +10,15 @@ import UM 1.4 as UM
 Packages
 {
     pageTitle: catalog.i18nc("@header", "Manage packages")
-    bannerType: "__MANAGE_PACKAGES__"
+
+    bannerVisible: CuraApplication.shouldShowMarketPlaceManagePackagesBanner()
+    bannerIcon: "ArrowDoubleCircleRight"
+    bannerBody: 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.")
+    onRemoveBanner: function() {
+        CuraApplication.closeMarketPlaceManagePackagesBanner();
+        bannerVisible = false;
+    }
+
     model: Marketplace.LocalPackageList
     {
     }

+ 9 - 1
plugins/Marketplace/resources/qml/Materials.qml

@@ -6,7 +6,15 @@ import Marketplace 1.0 as Marketplace
 Packages
 {
     pageTitle: catalog.i18nc("@header", "Install Materials")
-    bannerType: "__MATERIALS__"
+
+    bannerVisible: CuraApplication.shouldShowMarketPlaceMaterialBanner()
+    bannerIcon: "Spool"
+    bannerBody: catalog.i18nc("@text", "Streamline your workflow and customize your Ultimaker Cura experience with plugins contributed by our amazing community of users.")
+    onRemoveBanner: function() {
+        CuraApplication.closeMarketPlaceMaterialBanner();
+        bannerVisible = false;
+    }
+
     model: Marketplace.RemotePackageList
     {
         packageTypeFilter: "material"

+ 10 - 18
plugins/Marketplace/resources/qml/OnboardBanner.qml

@@ -11,7 +11,12 @@ import Cura 1.6 as Cura
 // Onboarding banner.
 Rectangle
 {
-    property var bannerType
+    property bool bannerVisible
+    property string bannerIcon
+    property string bannerBody
+    property var onRemoveBanner
+
+    visible: bannerVisible
 
     Layout.preferredHeight: childrenRect.height + 2 * UM.Theme.getSize("default_margin").height
     anchors
@@ -41,14 +46,7 @@ Rectangle
         {
             anchors.fill: parent
             color: UM.Theme.getColor("primary_text")
-            source: {
-                switch (bannerType) {
-                    case "__PLUGINS__" : return UM.Theme.getIcon("Shop");
-                    case "__MATERIALS__" : return UM.Theme.getIcon("Spool");
-                    case "__MANAGE_PACKAGES__" : return UM.Theme.getIcon("ArrowDoubleCircleRight");
-                    default: return "";
-                }
-            }
+            source: UM.Theme.getIcon(bannerIcon)
         }
     }
 
@@ -67,7 +65,8 @@ Rectangle
         color: UM.Theme.getColor("primary_text")
         hoverColor: UM.Theme.getColor("primary_text_hover")
         iconSource: UM.Theme.getIcon("Cancel")
-        onClicked: confirmDeleteDialog.visible = true
+
+        onClicked: onRemoveBanner()
     }
 
     // Body
@@ -83,13 +82,6 @@ Rectangle
         font: UM.Theme.getFont("medium")
         color: UM.Theme.getColor("primary_text")
         wrapMode: Text.WordWrap
-        text: {
-            switch (bannerType) {
-                case "__PLUGINS__" : return catalog.i18nc("@text", "Streamline your workflow and customize your Ultimaker Cura experience with plugins contributed by our amazing community of users.");
-                case "__MATERIALS__" : return catalog.i18nc("@text", "Select and install material profiles optimised for your Ultimaker 3D printers.");
-                case "__MANAGE_PACKAGES__" : return 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.");
-                default: return "";
-            }
-        }
+        text: bannerBody
     }
 }

+ 9 - 1
plugins/Marketplace/resources/qml/Plugins.qml

@@ -6,7 +6,15 @@ import Marketplace 1.0 as Marketplace
 Packages
 {
     pageTitle: catalog.i18nc("@header", "Install Plugins")
-    bannerType: "__PLUGINS__"
+
+    bannerVisible: CuraApplication.shouldShowMarketPlacePluginBanner()
+    bannerIcon: "Shop"
+    bannerBody: catalog.i18nc("@text", "Select and install material profiles optimised for your Ultimaker 3D printers.")
+    onRemoveBanner: function() {
+        CuraApplication.closeMarketPlacePluginBanner();
+        bannerVisible = false;
+    }
+
     model: Marketplace.RemotePackageList
     {
         packageTypeFilter: "plugin"