diff --git a/cura/ApplicationMetadata.py b/cura/ApplicationMetadata.py index daa937197c..024219e1f3 100644 --- a/cura/ApplicationMetadata.py +++ b/cura/ApplicationMetadata.py @@ -9,7 +9,11 @@ DEFAULT_CURA_DISPLAY_NAME = "Ultimaker Cura" DEFAULT_CURA_VERSION = "master" DEFAULT_CURA_BUILD_TYPE = "" DEFAULT_CURA_DEBUG_MODE = False -DEFAULT_CURA_SDK_VERSION = "7.0.0" + +# Each release has a fixed SDK version coupled with it. It doesn't make sense to make it configurable because, for +# example Cura 3.2 with SDK version 6.1 will not work. So the SDK version is hard-coded here and left out of the +# CuraVersion.py.in template. +CuraSDKVersion = "7.0.0" try: from cura.CuraVersion import CuraAppName # type: ignore @@ -32,6 +36,9 @@ try: except ImportError: CuraVersion = DEFAULT_CURA_VERSION # [CodeStyle: Reflecting imported value] +# CURA-6569 +# This string indicates what type of version it is. For example, "enterprise". By default it's empty which indicates +# a default/normal Cura build. try: from cura.CuraVersion import CuraBuildType # type: ignore except ImportError: @@ -42,7 +49,8 @@ try: except ImportError: CuraDebugMode = DEFAULT_CURA_DEBUG_MODE -# Each release has a fixed SDK version coupled with it. It doesn't make sense to make it configurable because, for -# example Cura 3.2 with SDK version 6.1 will not work. So the SDK version is hard-coded here and left out of the -# CuraVersion.py.in template. -CuraSDKVersion = "7.0.0" + +# CURA-6569 +# Various convenience flags indicating what kind of Cura build it is. +__ENTERPRISE_VERSION_TYPE = "enterprise" +IsEnterpriseVersion = CuraBuildType.lower() == __ENTERPRISE_VERSION_TYPE diff --git a/plugins/Toolbox/resources/qml/Toolbox.qml b/plugins/Toolbox/resources/qml/Toolbox.qml index f70dab03d8..03fd3468f6 100644 --- a/plugins/Toolbox/resources/qml/Toolbox.qml +++ b/plugins/Toolbox/resources/qml/Toolbox.qml @@ -1,11 +1,17 @@ // Copyright (c) 2018 Ultimaker B.V. // Toolbox is released under the terms of the LGPLv3 or higher. +// Main window for the Toolbox + import QtQuick 2.2 import QtQuick.Dialogs 1.1 import QtQuick.Window 2.2 import UM 1.1 as UM +import "./pages" +import "./dialogs" +import "./components" + Window { id: base @@ -29,9 +35,16 @@ Window Item { anchors.fill: parent + + WelcomePage + { + visible: toolbox.viewPage === "welcome" + } + ToolboxHeader { id: header + visible: toolbox.viewPage !== "welcome" } Item diff --git a/plugins/Toolbox/resources/qml/RatingWidget.qml b/plugins/Toolbox/resources/qml/components/RatingWidget.qml similarity index 100% rename from plugins/Toolbox/resources/qml/RatingWidget.qml rename to plugins/Toolbox/resources/qml/components/RatingWidget.qml diff --git a/plugins/Toolbox/resources/qml/SmallRatingWidget.qml b/plugins/Toolbox/resources/qml/components/SmallRatingWidget.qml similarity index 100% rename from plugins/Toolbox/resources/qml/SmallRatingWidget.qml rename to plugins/Toolbox/resources/qml/components/SmallRatingWidget.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxActionButtonStyle.qml b/plugins/Toolbox/resources/qml/components/ToolboxActionButtonStyle.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxActionButtonStyle.qml rename to plugins/Toolbox/resources/qml/components/ToolboxActionButtonStyle.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxBackColumn.qml b/plugins/Toolbox/resources/qml/components/ToolboxBackColumn.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxBackColumn.qml rename to plugins/Toolbox/resources/qml/components/ToolboxBackColumn.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml b/plugins/Toolbox/resources/qml/components/ToolboxCompatibilityChart.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml rename to plugins/Toolbox/resources/qml/components/ToolboxCompatibilityChart.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailList.qml b/plugins/Toolbox/resources/qml/components/ToolboxDetailList.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxDetailList.qml rename to plugins/Toolbox/resources/qml/components/ToolboxDetailList.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml b/plugins/Toolbox/resources/qml/components/ToolboxDetailTile.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxDetailTile.qml rename to plugins/Toolbox/resources/qml/components/ToolboxDetailTile.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTileActions.qml b/plugins/Toolbox/resources/qml/components/ToolboxDetailTileActions.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxDetailTileActions.qml rename to plugins/Toolbox/resources/qml/components/ToolboxDetailTileActions.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml b/plugins/Toolbox/resources/qml/components/ToolboxDownloadsGrid.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml rename to plugins/Toolbox/resources/qml/components/ToolboxDownloadsGrid.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml b/plugins/Toolbox/resources/qml/components/ToolboxDownloadsGridTile.qml similarity index 97% rename from plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml rename to plugins/Toolbox/resources/qml/components/ToolboxDownloadsGridTile.qml index 73dd593336..78cdf1562a 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml +++ b/plugins/Toolbox/resources/qml/components/ToolboxDownloadsGridTile.qml @@ -67,7 +67,7 @@ Item width: UM.Theme.getSize("toolbox_thumbnail_small").width - UM.Theme.getSize("wide_margin").width height: UM.Theme.getSize("toolbox_thumbnail_small").height - UM.Theme.getSize("wide_margin").width fillMode: Image.PreserveAspectFit - source: model.icon_url || "../images/logobot.svg" + source: model.icon_url || "../../images/logobot.svg" mipmap: true } UM.RecolorImage @@ -82,7 +82,7 @@ Item sourceSize.height: height visible: installedPackages != 0 color: (installedPackages >= packageCount) ? UM.Theme.getColor("primary") : UM.Theme.getColor("border") - source: "../images/installed_check.svg" + source: "../../images/installed_check.svg" } } Item diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcase.qml b/plugins/Toolbox/resources/qml/components/ToolboxDownloadsShowcase.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxDownloadsShowcase.qml rename to plugins/Toolbox/resources/qml/components/ToolboxDownloadsShowcase.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml b/plugins/Toolbox/resources/qml/components/ToolboxDownloadsShowcaseTile.qml similarity index 97% rename from plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml rename to plugins/Toolbox/resources/qml/components/ToolboxDownloadsShowcaseTile.qml index 89348b18de..f6e32b2d84 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml +++ b/plugins/Toolbox/resources/qml/components/ToolboxDownloadsShowcaseTile.qml @@ -23,7 +23,7 @@ Rectangle height: UM.Theme.getSize("toolbox_thumbnail_large").height - 4 * UM.Theme.getSize("default_margin").height width: UM.Theme.getSize("toolbox_thumbnail_large").height - 4 * UM.Theme.getSize("default_margin").height fillMode: Image.PreserveAspectFit - source: model.icon_url || "../images/logobot.svg" + source: model.icon_url || "../../images/logobot.svg" mipmap: true anchors { @@ -62,7 +62,7 @@ Rectangle } visible: installedPackages != 0 color: (installedPackages >= packageCount) ? UM.Theme.getColor("primary") : UM.Theme.getColor("border") - source: "../images/installed_check.svg" + source: "../../images/installed_check.svg" } SmallRatingWidget diff --git a/plugins/Toolbox/resources/qml/ToolboxFooter.qml b/plugins/Toolbox/resources/qml/components/ToolboxFooter.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxFooter.qml rename to plugins/Toolbox/resources/qml/components/ToolboxFooter.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxHeader.qml b/plugins/Toolbox/resources/qml/components/ToolboxHeader.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxHeader.qml rename to plugins/Toolbox/resources/qml/components/ToolboxHeader.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml b/plugins/Toolbox/resources/qml/components/ToolboxInstalledTile.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml rename to plugins/Toolbox/resources/qml/components/ToolboxInstalledTile.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml b/plugins/Toolbox/resources/qml/components/ToolboxInstalledTileActions.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml rename to plugins/Toolbox/resources/qml/components/ToolboxInstalledTileActions.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxProgressButton.qml b/plugins/Toolbox/resources/qml/components/ToolboxProgressButton.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxProgressButton.qml rename to plugins/Toolbox/resources/qml/components/ToolboxProgressButton.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxShadow.qml b/plugins/Toolbox/resources/qml/components/ToolboxShadow.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxShadow.qml rename to plugins/Toolbox/resources/qml/components/ToolboxShadow.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxTabButton.qml b/plugins/Toolbox/resources/qml/components/ToolboxTabButton.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxTabButton.qml rename to plugins/Toolbox/resources/qml/components/ToolboxTabButton.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxConfirmUninstallResetDialog.qml b/plugins/Toolbox/resources/qml/dialogs/ToolboxConfirmUninstallResetDialog.qml similarity index 96% rename from plugins/Toolbox/resources/qml/ToolboxConfirmUninstallResetDialog.qml rename to plugins/Toolbox/resources/qml/dialogs/ToolboxConfirmUninstallResetDialog.qml index 81649fdfef..1b5e4d1d46 100644 --- a/plugins/Toolbox/resources/qml/ToolboxConfirmUninstallResetDialog.qml +++ b/plugins/Toolbox/resources/qml/dialogs/ToolboxConfirmUninstallResetDialog.qml @@ -14,7 +14,7 @@ import Cura 1.0 as Cura UM.Dialog { - // This dialog asks the user whether he/she wants to open a project file as a project or import models. + // This dialog asks the user to confirm he/she wants to uninstall materials/pprofiles which are currently in use id: base title: catalog.i18nc("@title:window", "Confirm uninstall") + toolbox.pluginToUninstall diff --git a/plugins/Toolbox/resources/qml/ToolboxLicenseDialog.qml b/plugins/Toolbox/resources/qml/dialogs/ToolboxLicenseDialog.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxLicenseDialog.qml rename to plugins/Toolbox/resources/qml/dialogs/ToolboxLicenseDialog.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/pages/ToolboxAuthorPage.qml similarity index 98% rename from plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml rename to plugins/Toolbox/resources/qml/pages/ToolboxAuthorPage.qml index 08ac1f83a5..d1abe48de1 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/pages/ToolboxAuthorPage.qml @@ -6,6 +6,8 @@ import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import UM 1.1 as UM +import "../components" + Item { id: page @@ -31,7 +33,7 @@ Item width: UM.Theme.getSize("toolbox_thumbnail_medium").width height: UM.Theme.getSize("toolbox_thumbnail_medium").height fillMode: Image.PreserveAspectFit - source: details.icon_url || "../images/logobot.svg" + source: details.icon_url || "../../images/logobot.svg" mipmap: true anchors { diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml b/plugins/Toolbox/resources/qml/pages/ToolboxDetailPage.qml similarity index 99% rename from plugins/Toolbox/resources/qml/ToolboxDetailPage.qml rename to plugins/Toolbox/resources/qml/pages/ToolboxDetailPage.qml index 1773ef9053..6d34e23f42 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml +++ b/plugins/Toolbox/resources/qml/pages/ToolboxDetailPage.qml @@ -8,6 +8,8 @@ import UM 1.1 as UM import Cura 1.1 as Cura +import "../components" + Item { id: page @@ -44,7 +46,7 @@ Item { anchors.fill: parent fillMode: Image.PreserveAspectFit - source: details === null ? "" : (details.icon_url || "../images/logobot.svg") + source: details === null ? "" : (details.icon_url || "../../images/logobot.svg") mipmap: true } } diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsPage.qml b/plugins/Toolbox/resources/qml/pages/ToolboxDownloadsPage.qml similarity index 98% rename from plugins/Toolbox/resources/qml/ToolboxDownloadsPage.qml rename to plugins/Toolbox/resources/qml/pages/ToolboxDownloadsPage.qml index 57fb3a9279..9be8cbe2b9 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsPage.qml +++ b/plugins/Toolbox/resources/qml/pages/ToolboxDownloadsPage.qml @@ -5,6 +5,8 @@ import QtQuick 2.10 import QtQuick.Controls 2.3 import UM 1.1 as UM +import "../components" + ScrollView { clip: true diff --git a/plugins/Toolbox/resources/qml/ToolboxErrorPage.qml b/plugins/Toolbox/resources/qml/pages/ToolboxErrorPage.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxErrorPage.qml rename to plugins/Toolbox/resources/qml/pages/ToolboxErrorPage.qml diff --git a/plugins/Toolbox/resources/qml/ToolboxInstalledPage.qml b/plugins/Toolbox/resources/qml/pages/ToolboxInstalledPage.qml similarity index 99% rename from plugins/Toolbox/resources/qml/ToolboxInstalledPage.qml rename to plugins/Toolbox/resources/qml/pages/ToolboxInstalledPage.qml index f4a9e634c4..99590c712c 100644 --- a/plugins/Toolbox/resources/qml/ToolboxInstalledPage.qml +++ b/plugins/Toolbox/resources/qml/pages/ToolboxInstalledPage.qml @@ -6,6 +6,8 @@ import QtQuick.Controls 2.3 import UM 1.1 as UM +import "../components" + ScrollView { id: page diff --git a/plugins/Toolbox/resources/qml/ToolboxLoadingPage.qml b/plugins/Toolbox/resources/qml/pages/ToolboxLoadingPage.qml similarity index 100% rename from plugins/Toolbox/resources/qml/ToolboxLoadingPage.qml rename to plugins/Toolbox/resources/qml/pages/ToolboxLoadingPage.qml diff --git a/plugins/Toolbox/resources/qml/pages/WelcomePage.qml b/plugins/Toolbox/resources/qml/pages/WelcomePage.qml new file mode 100644 index 0000000000..cbfdf8f402 --- /dev/null +++ b/plugins/Toolbox/resources/qml/pages/WelcomePage.qml @@ -0,0 +1,53 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.1 +import QtQuick.Window 2.2 + +import UM 1.3 as UM +import Cura 1.1 as Cura + +Column +{ + id: welcomePage + spacing: UM.Theme.getSize("wide_margin").height + width: parent.width + height: childrenRect.height + anchors.centerIn: parent + + Image + { + id: profileImage + fillMode: Image.PreserveAspectFit + source: "../../images/logobot.svg" + anchors.horizontalCenter: parent.horizontalCenter + width: Math.round(parent.width / 4) + } + + Label + { + id: welcomeTextLabel + text: catalog.i18nc("@description", "Get plugins and materials verified by Ultimaker") + width: Math.round(parent.width / 2) + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + anchors.horizontalCenter: parent.horizontalCenter + wrapMode: Label.WordWrap + renderType: Text.NativeRendering + } + + Cura.PrimaryButton + { + id: loginButton + width: UM.Theme.getSize("account_button").width + height: UM.Theme.getSize("account_button").height + anchors.horizontalCenter: parent.horizontalCenter + text: catalog.i18nc("@button", "Sign in") + onClicked: Cura.API.account.login() + fixedWidthMode: true + } +} + diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 869ac6ab5e..c8c809cc82 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -86,7 +86,7 @@ class Toolbox(QObject, Extension): # View page defines which type of page layout to use. For example, # possible values include "overview", "detail" or "author". - self._view_page = "loading" # type: str + self._view_page = "welcome" # type: str # Active package refers to which package is currently being downloaded, # installed, or otherwise modified. @@ -105,7 +105,6 @@ class Toolbox(QObject, Extension): self._restart_dialog_message = "" # type: str self._application.initializationFinished.connect(self._onAppInitialized) - self._application.getCuraAPI().account.loginStateChanged.connect(self._updateRequestHeader) self._application.getCuraAPI().account.accessTokenChanged.connect(self._updateRequestHeader) # Signals: @@ -126,6 +125,16 @@ class Toolbox(QObject, Extension): showLicenseDialog = pyqtSignal() uninstallVariablesChanged = pyqtSignal() + ## Go back to the start state (welcome screen or loading if no login required) + def _restart(self): + self._updateRequestHeader() + # For an Essentials build, login is mandatory + if not self._application.getCuraAPI().account.isLoggedIn and ApplicationMetadata.IsEnterpriseVersion: + self.setViewPage("welcome") + else: + self.setViewPage("loading") + self._fetchPackageData() + def _updateRequestHeader(self): self._request_headers = [ (b"User-Agent", @@ -191,6 +200,8 @@ class Toolbox(QObject, Extension): "packages": QUrl("{base_url}/packages".format(base_url = self._api_url)) } + self._application.getCuraAPI().account.loginStateChanged.connect(self._restart) + if CuraApplication.getInstance().getPreferences().getValue("info/automatic_update_check"): # Request the latest and greatest! self._fetchPackageData() @@ -213,9 +224,9 @@ class Toolbox(QObject, Extension): # Gather installed packages: self._updateInstalledModels() + # Displays the toolbox @pyqtSlot() - def browsePackages(self) -> None: - self._fetchPackageData() + def launch(self) -> None: if not self._dialog: self._dialog = self._createDialog("Toolbox.qml") @@ -224,6 +235,8 @@ class Toolbox(QObject, Extension): Logger.log("e", "Unexpected error trying to create the 'Marketplace' dialog.") return + self._restart() + self._dialog.show() # Apply enabled/disabled state to installed plugins @@ -329,7 +342,7 @@ class Toolbox(QObject, Extension): self._package_used_qualities = package_used_qualities # Ask change to default material / profile if self._confirm_reset_dialog is None: - self._confirm_reset_dialog = self._createDialog("ToolboxConfirmUninstallResetDialog.qml") + self._confirm_reset_dialog = self._createDialog("dialogs/ToolboxConfirmUninstallResetDialog.qml") self.uninstallVariablesChanged.emit() if self._confirm_reset_dialog is None: Logger.log("e", "ToolboxConfirmUninstallResetDialog should have been initialized, but it is not. Not showing dialog and not uninstalling package.") diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 70d7cd422c..30e44d7d3b 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -160,7 +160,7 @@ Item target: Cura.Actions.browsePackages onTriggered: { - curaExtensions.callExtensionMethod("Toolbox", "browsePackages") + curaExtensions.callExtensionMethod("Toolbox", "launch") } } } \ No newline at end of file