From 3ddfa6486b3d45ba16be1e059c2d6613ce905bde Mon Sep 17 00:00:00 2001 From: casper Date: Fri, 26 Nov 2021 14:49:00 +0100 Subject: [PATCH] Remove banners when clicking close button --- cura/CuraApplication.py | 31 +++++++++++++++++++ .../resources/qml/ManagedPackages.qml | 10 +++++- .../Marketplace/resources/qml/Marketplace.qml | 5 ++- .../Marketplace/resources/qml/Materials.qml | 10 +++++- .../resources/qml/OnboardBanner.qml | 28 ++++++----------- .../Marketplace/resources/qml/Packages.qml | 5 ++- plugins/Marketplace/resources/qml/Plugins.qml | 10 +++++- 7 files changed, 76 insertions(+), 23 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 3d4ec1209f..6cf2593bbf 100755 --- a/cura/CuraApplication.py +++ b/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() diff --git a/plugins/Marketplace/resources/qml/ManagedPackages.qml b/plugins/Marketplace/resources/qml/ManagedPackages.qml index c53384bf77..a329d992e5 100644 --- a/plugins/Marketplace/resources/qml/ManagedPackages.qml +++ b/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 { } diff --git a/plugins/Marketplace/resources/qml/Marketplace.qml b/plugins/Marketplace/resources/qml/Marketplace.qml index 7293a61a80..14de458e95 100644 --- a/plugins/Marketplace/resources/qml/Marketplace.qml +++ b/plugins/Marketplace/resources/qml/Marketplace.qml @@ -50,7 +50,10 @@ Window OnboardBanner { - bannerType: content.item && content.item.bannerType + bannerVisible: content.item && content.item.bannerVisible + bannerBody: content.item && content.item.bannerBody + bannerIcon: content.item && content.item.bannerIcon + onRemoveBanner: content.item && content.item.onRemoveBanner } // Page title. diff --git a/plugins/Marketplace/resources/qml/Materials.qml b/plugins/Marketplace/resources/qml/Materials.qml index dff63305bf..32d2c2213a 100644 --- a/plugins/Marketplace/resources/qml/Materials.qml +++ b/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" diff --git a/plugins/Marketplace/resources/qml/OnboardBanner.qml b/plugins/Marketplace/resources/qml/OnboardBanner.qml index 8a1048018c..8a29030514 100644 --- a/plugins/Marketplace/resources/qml/OnboardBanner.qml +++ b/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 } } \ No newline at end of file diff --git a/plugins/Marketplace/resources/qml/Packages.qml b/plugins/Marketplace/resources/qml/Packages.qml index 345aecf822..91f6448994 100644 --- a/plugins/Marketplace/resources/qml/Packages.qml +++ b/plugins/Marketplace/resources/qml/Packages.qml @@ -11,7 +11,10 @@ ListView id: packages property string pageTitle - property string bannerType + property bool bannerVisible + property string bannerIcon + property string bannerBody + property var onRemoveBanner width: parent.width diff --git a/plugins/Marketplace/resources/qml/Plugins.qml b/plugins/Marketplace/resources/qml/Plugins.qml index 24381e3027..b9d38c6e2b 100644 --- a/plugins/Marketplace/resources/qml/Plugins.qml +++ b/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"