From a030e4a264e63a4ea19f5feb3b95982936205906 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 4 Apr 2019 15:52:31 +0200 Subject: [PATCH 01/27] Rename WelcomDialog to WelcomeDialogItem CURA-6435 --- resources/qml/Cura.qml | 10 +++++----- .../{WelcomeDialog.qml => WelcomeDialogItem.qml} | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) rename resources/qml/WelcomePages/{WelcomeDialog.qml => WelcomeDialogItem.qml} (88%) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index dd985fe5c3..cd24b8d5d1 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -46,7 +46,7 @@ UM.MainWindow { id: greyOutBackground anchors.fill: parent - visible: welcomeDialog.visible + visible: welcomeDialogItem.visible color: UM.Theme.getColor("window_disabled_background") opacity: 0.7 z: stageMenu.z + 1 @@ -61,9 +61,9 @@ UM.MainWindow } } - WelcomeDialog + WelcomeDialogItem { - id: welcomeDialog + id: welcomeDialogItem visible: true // True, so if somehow no preferences are found/loaded, it's shown anyway. z: greyOutBackground.z + 1 } @@ -86,11 +86,11 @@ UM.MainWindow if (CuraApplication.needToShowUserAgreement) { - welcomeDialog.visible = true + welcomeDialogItem.visible = true } else { - welcomeDialog.visible = false + welcomeDialogItem.visible = false } // TODO: While the new onboarding process contains the user-agreement, // it should probably not entirely rely on 'needToShowUserAgreement' for show/hide. diff --git a/resources/qml/WelcomePages/WelcomeDialog.qml b/resources/qml/WelcomePages/WelcomeDialogItem.qml similarity index 88% rename from resources/qml/WelcomePages/WelcomeDialog.qml rename to resources/qml/WelcomePages/WelcomeDialogItem.qml index c7832e1e56..1ab722598b 100644 --- a/resources/qml/WelcomePages/WelcomeDialog.qml +++ b/resources/qml/WelcomePages/WelcomeDialogItem.qml @@ -11,7 +11,7 @@ import Cura 1.1 as Cura // -// This is a no-frame dialog that shows the welcome process. +// This is an Item that tries to mimic a dialog for showing the welcome process. // Item { @@ -38,7 +38,7 @@ Item WizardPanel { - id: stepPanel + id: wizardPanel anchors.fill: parent model: dialog.model } @@ -48,8 +48,8 @@ Item { id: shadow radius: UM.Theme.getSize("first_run_shadow_radius").width - anchors.fill: stepPanel - source: stepPanel + anchors.fill: wizardPanel + source: wizardPanel horizontalOffset: shadowOffset verticalOffset: shadowOffset color: UM.Theme.getColor("first_run_shadow") From 3ee32944d5e810230b2ed8f030ee872dbe56d913 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 4 Apr 2019 15:53:59 +0200 Subject: [PATCH 02/27] Add a reusable WizardDialog CURA-6435 --- resources/qml/WelcomePages/WizardDialog.qml | 52 +++++++++++++++++++++ resources/qml/qmldir | 6 +++ 2 files changed, 58 insertions(+) create mode 100644 resources/qml/WelcomePages/WizardDialog.qml diff --git a/resources/qml/WelcomePages/WizardDialog.qml b/resources/qml/WelcomePages/WizardDialog.qml new file mode 100644 index 0000000000..1e4abd6e50 --- /dev/null +++ b/resources/qml/WelcomePages/WizardDialog.qml @@ -0,0 +1,52 @@ +// Copyright (c) 2019 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 +import QtQuick.Window 2.2 + +import UM 1.3 as UM +import Cura 1.1 as Cura + + +// +// This is a dialog for showing a set of processes that's defined in a WelcomePagesModel or some other Qt ListModel with +// a compatible interface. +// +Window +{ + UM.I18nCatalog { id: catalog; name: "cura" } + + id: dialog + + flags: Qt.Dialog + + minimumWidth: 580 * screenScaleFactor + minimumHeight: 600 * screenScaleFactor + + color: UM.Theme.getColor("main_background") + + property var model: null // Needs to be set by whoever is using this dialog. + + onVisibilityChanged: + { + if (visible) + { + model.resetState() + } + } + + WizardPanel + { + id: wizardPanel + anchors.fill: parent + model: dialog.model + } + + // Close this dialog when there's no more page to show + Connections + { + target: model + onAllFinished: dialog.hide() + } +} diff --git a/resources/qml/qmldir b/resources/qml/qmldir index eda0411f42..4b0fd335ba 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -19,6 +19,12 @@ CheckBoxWithTooltip 1.0 CheckBoxWithTooltip.qml ToolTip 1.0 ToolTip.qml +# Cura/WelcomePages + +WizardPanel 1.0 WizardPanel.qml +WizardDialog 1.0 WizardDialog.qml + + # Cura/Widgets CheckBox 1.0 CheckBox.qml From 0f62f0c60a2badb0902dfbc8343e27025e6a648e Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 4 Apr 2019 15:56:20 +0200 Subject: [PATCH 03/27] Add next_page_button_text field to WelcomePagesModel CURA-6435 --- cura/UI/WelcomePagesModel.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cura/UI/WelcomePagesModel.py b/cura/UI/WelcomePagesModel.py index b26964bd2e..6063208edd 100644 --- a/cura/UI/WelcomePagesModel.py +++ b/cura/UI/WelcomePagesModel.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, Optional, List, Dict, Any from PyQt5.QtCore import QUrl, Qt, pyqtSlot, pyqtProperty, pyqtSignal +from UM.i18n import i18nCatalog from UM.Logger import Logger from UM.Qt.ListModel import ListModel from UM.Resources import Resources @@ -23,6 +24,9 @@ if TYPE_CHECKING: # - page_url : The QUrl to the QML file that contains the content of this page # - next_page_id : (OPTIONAL) The next page ID to go to when this page finished. This is optional. If this is not # provided, it will go to the page with the current index + 1 +# - next_page_button_text: (OPTIONAL) The text to show for the "next" button, by default it's the translated text of +# "Next". Note that each step QML can decide whether to use this text or not, so it's not +# mandatory. # - should_show_function : (OPTIONAL) An optional function that returns True/False indicating if this page should be # shown. By default all pages should be shown. If a function returns False, that page will # be skipped and its next page will be shown. @@ -34,6 +38,7 @@ class WelcomePagesModel(ListModel): IdRole = Qt.UserRole + 1 # Page ID PageUrlRole = Qt.UserRole + 2 # URL to the page's QML file NextPageIdRole = Qt.UserRole + 3 # The next page ID it should go to + NextPageButtonTextRole = Qt.UserRole + 4 # The text for the next page button def __init__(self, application: "CuraApplication", parent: Optional["QObject"] = None) -> None: super().__init__(parent) @@ -41,8 +46,12 @@ class WelcomePagesModel(ListModel): self.addRoleName(self.IdRole, "id") self.addRoleName(self.PageUrlRole, "page_url") self.addRoleName(self.NextPageIdRole, "next_page_id") + self.addRoleName(self.NextPageButtonTextRole, "next_page_button_text") self._application = application + self._catalog = i18nCatalog("cura") + + self._default_next_button_text = self._catalog.i18nc("@action:button", "Next") self._pages = [] # type: List[Dict[str, Any]] @@ -212,6 +221,14 @@ class WelcomePagesModel(ListModel): self.setItems(self._pages) + # For convenience, inject the default "next" button text to each item if it's not present. + def setItems(self, items: List[Dict[str, Any]]) -> None: + for item in items: + if "next_page_button_text" not in item: + item["next_page_button_text"] = self._default_next_button_text + + super().setItems(items) + # Indicates if the machine action panel should be shown by checking if there's any first start machine actions # available. def shouldShowMachineActions(self) -> bool: From a18bb9d95383e192aed5c2c95ada6d73c8f7b8ff Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 4 Apr 2019 15:57:17 +0200 Subject: [PATCH 04/27] Add AddPrinterPagesModel CURA-6435 --- cura/CuraApplication.py | 8 ++++++++ cura/UI/AddPrinterPagesModel.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 cura/UI/AddPrinterPagesModel.py diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 742ef2fc0b..3a8af2e9f9 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -112,6 +112,7 @@ from cura.UI import CuraSplashScreen, MachineActionManager, PrintInformation from cura.UI.MachineSettingsManager import MachineSettingsManager from cura.UI.ObjectsModel import ObjectsModel from cura.UI.TextManager import TextManager +from cura.UI.AddPrinterPagesModel import AddPrinterPagesModel from cura.UI.WelcomePagesModel import WelcomePagesModel from .SingleInstance import SingleInstance @@ -217,6 +218,7 @@ class CuraApplication(QtApplication): self._discovered_printer_model = DiscoveredPrintersModel(self) self._first_start_machine_actions_model = FirstStartMachineActionsModel(self) self._welcome_pages_model = WelcomePagesModel(self) + self._add_printer_pages_model = AddPrinterPagesModel(self) self._text_manager = TextManager(self) self._quality_profile_drop_down_menu_model = None @@ -762,6 +764,7 @@ class CuraApplication(QtApplication): self._output_device_manager.start() self._welcome_pages_model.initialize() + self._add_printer_pages_model.initialize() # Detect in which mode to run and execute that mode if self._is_headless: @@ -873,6 +876,10 @@ class CuraApplication(QtApplication): def getWelcomePagesModel(self, *args) -> "WelcomePagesModel": return self._welcome_pages_model + @pyqtSlot(result = QObject) + def getAddPrinterPagesModel(self, *args) -> "AddPrinterPagesModel": + return self._add_printer_pages_model + @pyqtSlot(result = QObject) def getMachineSettingsManager(self, *args) -> "MachineSettingsManager": return self._machine_settings_manager @@ -1014,6 +1021,7 @@ class CuraApplication(QtApplication): qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager) qmlRegisterType(WelcomePagesModel, "Cura", 1, 0, "WelcomePagesModel") + qmlRegisterType(AddPrinterPagesModel, "Cura", 1, 0, "AddPrinterPagesModel") qmlRegisterType(TextManager, "Cura", 1, 0, "TextManager") qmlRegisterType(NetworkMJPGImage, "Cura", 1, 0, "NetworkMJPGImage") diff --git a/cura/UI/AddPrinterPagesModel.py b/cura/UI/AddPrinterPagesModel.py new file mode 100644 index 0000000000..55bb1500ba --- /dev/null +++ b/cura/UI/AddPrinterPagesModel.py @@ -0,0 +1,30 @@ +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +from .WelcomePagesModel import WelcomePagesModel + + +# +# This Qt ListModel is more or less the same the WelcomePagesModel, except that this model is only for adding a printer, +# so only the steps for adding a printer is included. +# +class AddPrinterPagesModel(WelcomePagesModel): + + def initialize(self) -> None: + self._pages.append({"id": "add_network_or_local_printer", + "page_url": self._getBuiltinWelcomePagePath("AddNetworkOrLocalPrinterContent.qml"), + "next_page_id": "machine_actions", + "next_page_button_text": self._catalog.i18nc("@action:button", "Add"), + }) + self._pages.append({"id": "add_printer_by_ip", + "page_url": self._getBuiltinWelcomePagePath("AddPrinterByIpContent.qml"), + "next_page_id": "machine_actions", + }) + self._pages.append({"id": "machine_actions", + "page_url": self._getBuiltinWelcomePagePath("FirstStartMachineActionsContent.qml"), + "should_show_function": self.shouldShowMachineActions, + }) + self.setItems(self._pages) + + +__all__ = ["AddPrinterPagesModel"] From 945fa359467109aadb29c808d573ac1ff505f2df Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 4 Apr 2019 15:58:58 +0200 Subject: [PATCH 05/27] Fix incorrect reference in UM2UpgradeSelectionMachineAction CURA-6435 --- .../UM2UpgradeSelectionMachineAction.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UltimakerMachineActions/UM2UpgradeSelectionMachineAction.qml b/plugins/UltimakerMachineActions/UM2UpgradeSelectionMachineAction.qml index 69023d3432..0aef5e08e1 100644 --- a/plugins/UltimakerMachineActions/UM2UpgradeSelectionMachineAction.qml +++ b/plugins/UltimakerMachineActions/UM2UpgradeSelectionMachineAction.qml @@ -23,11 +23,11 @@ Cura.MachineAction Label { id: pageDescription - anchors.top: pageTitle.bottom + anchors.top: parent.top anchors.topMargin: UM.Theme.getSize("default_margin").height width: parent.width wrapMode: Text.WordWrap - text: catalog.i18nc("@label","Please select any upgrades made to this Ultimaker 2.") + text: catalog.i18nc("@label", "Please select any upgrades made to this Ultimaker 2.") font: UM.Theme.getFont("medium") renderType: Text.NativeRendering } From 8f755f8818cabb285a6af190cdc7494500463d79 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 4 Apr 2019 16:00:11 +0200 Subject: [PATCH 06/27] Use next_page_button_text in AddNetworkOrLocalPrinterContent CURA-6435 --- resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml b/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml index c219ba0eca..34e0a58d8f 100644 --- a/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml +++ b/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml @@ -122,7 +122,7 @@ Item } } - text: catalog.i18nc("@button", "Next") + text: base.currentItem.next_page_button_text onClicked: { // Create a network printer or a local printer according to the selection From 8e9a934035b2abce35adba2fa982776c87dabf0f Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 4 Apr 2019 16:00:49 +0200 Subject: [PATCH 07/27] Replace with the new add machine dialog CURA-6435 --- resources/qml/Cura.qml | 79 +++++++++++------------------------------- 1 file changed, 20 insertions(+), 59 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index cd24b8d5d1..ff26655530 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -731,44 +731,6 @@ UM.MainWindow } } - AddMachineDialog - { - id: addMachineDialog - onMachineAdded: - { - machineActionsWizard.firstRun = addMachineDialog.firstRun - machineActionsWizard.start(id) - } - } - - // Dialog to handle first run machine actions - UM.Wizard - { - id: machineActionsWizard; - - title: catalog.i18nc("@title:window", "Add Printer") - property var machine; - - function start(id) - { - var actions = Cura.MachineActionManager.getFirstStartActions(id) - resetPages() // Remove previous pages - - for (var i = 0; i < actions.length; i++) - { - actions[i].displayItem.reset() - machineActionsWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title", actions[i].label)); - } - - //Only start if there are actions to perform. - if (actions.length > 0) - { - machineActionsWizard.currentPage = 0; - show() - } - } - } - MessageDialog { id: messageDialog @@ -812,10 +774,23 @@ UM.MainWindow } } + Cura.WizardDialog + { + id: addMachineDialog + title: catalog.i18nc("@title:window", "Add Printer") + model: CuraApplication.getAddPrinterPagesModel() + } + Connections { target: Cura.Actions.addMachine - onTriggered: addMachineDialog.visible = true; + onTriggered: addMachineDialog.show() + } + + Connections + { + target: CuraApplication + onRequestAddPrinter: addMachineDialog.show() } AboutDialog @@ -829,31 +804,17 @@ UM.MainWindow onTriggered: aboutDialog.visible = true; } - Connections - { - target: CuraApplication - onRequestAddPrinter: - { - addMachineDialog.visible = true - addMachineDialog.firstRun = false - } - } - Timer { - id: startupTimer; - interval: 100; - repeat: false; - running: true; + id: startupTimer + interval: 100 + repeat: false + running: true onTriggered: { - if(!base.visible) + if (!base.visible) { - base.visible = true; - } - if(!CuraApplication.needToShowUserAgreement && Cura.MachineManager.activeMachine == null) - { - addMachineDialog.open(); + base.visible = true } } } From 76947df6c13f7248aa0ad49fba2131fd69881b98 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 08:23:24 +0200 Subject: [PATCH 08/27] Add Cura.TextField CURA-6435 --- resources/qml/Widgets/TextField.qml | 47 +++++++++++++++++++++++++++++ resources/qml/qmldir | 1 + 2 files changed, 48 insertions(+) create mode 100644 resources/qml/Widgets/TextField.qml diff --git a/resources/qml/Widgets/TextField.qml b/resources/qml/Widgets/TextField.qml new file mode 100644 index 0000000000..8161dfe532 --- /dev/null +++ b/resources/qml/Widgets/TextField.qml @@ -0,0 +1,47 @@ +// Copyright (c) 2019 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.10 +import QtQuick.Controls 2.3 + +import UM 1.3 as UM +import Cura 1.1 as Cura + + +// +// Cura-style TextField +// +TextField +{ + id: textField + + UM.I18nCatalog { id: catalog; name: "cura" } + + property int controlWidth: UM.Theme.getSize("setting_control").width + property int controlHeight: UM.Theme.getSize("setting_control").height + + hoverEnabled: true + selectByMouse: true + font: UM.Theme.getFont("default") + renderType: Text.NativeRendering + + background: Rectangle + { + anchors.fill: parent + anchors.margins: Math.round(UM.Theme.getSize("default_lining").width) + radius: UM.Theme.getSize("setting_control_radius").width + + border.color: + { + if (!textField.enabled) + { + return UM.Theme.getColor("setting_control_disabled_border") + } + if (textField.hovered || textField.activeFocus) + { + return UM.Theme.getColor("setting_control_border_highlight") + } + return UM.Theme.getColor("setting_control_border") + } + } +} diff --git a/resources/qml/qmldir b/resources/qml/qmldir index 4b0fd335ba..11ee69766e 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -32,6 +32,7 @@ ComboBox 1.0 ComboBox.qml NotificationIcon 1.0 NotificationIcon.qml RadioButton 1.0 RadioButton.qml TabButton 1.0 TabButton.qml +TextField 1.0 TextField.qml # Cura/MachineSettings From a5259ce22ec2d17195598d30987c7915aa792daf Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 08:25:08 +0200 Subject: [PATCH 09/27] Make progressBar optional in Wizard CURA-6435 --- resources/qml/Cura.qml | 1 + resources/qml/WelcomePages/WizardDialog.qml | 1 + resources/qml/WelcomePages/WizardPanel.qml | 2 ++ 3 files changed, 4 insertions(+) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index ff26655530..3a43c5647f 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -779,6 +779,7 @@ UM.MainWindow id: addMachineDialog title: catalog.i18nc("@title:window", "Add Printer") model: CuraApplication.getAddPrinterPagesModel() + progressBarVisible: false } Connections diff --git a/resources/qml/WelcomePages/WizardDialog.qml b/resources/qml/WelcomePages/WizardDialog.qml index 1e4abd6e50..4f664165c3 100644 --- a/resources/qml/WelcomePages/WizardDialog.qml +++ b/resources/qml/WelcomePages/WizardDialog.qml @@ -27,6 +27,7 @@ Window color: UM.Theme.getColor("main_background") property var model: null // Needs to be set by whoever is using this dialog. + property alias progressBarVisible: wizardPanel.progressBarVisible onVisibilityChanged: { diff --git a/resources/qml/WelcomePages/WizardPanel.qml b/resources/qml/WelcomePages/WizardPanel.qml index 91f351810c..d4ec116d65 100644 --- a/resources/qml/WelcomePages/WizardPanel.qml +++ b/resources/qml/WelcomePages/WizardPanel.qml @@ -25,6 +25,7 @@ Item property var progressValue: model == null ? 0 : model.currentProgress property string pageUrl: currentItem == null ? "" : currentItem.page_url + property alias progressBarVisible: progressBar.visible property alias backgroundColor: panelBackground.color signal showNextPage() @@ -44,6 +45,7 @@ Item anchors.fill: parent radius: UM.Theme.getSize("default_radius").width color: UM.Theme.getColor("main_background") + UM.ProgressBar { id: progressBar From b68b154e59fed2c437efac6f63f15d014cb51d23 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 08:54:20 +0200 Subject: [PATCH 10/27] Use contentLoader.item to determine height CURA-6435 --- resources/qml/WelcomePages/DropDownWidget.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/WelcomePages/DropDownWidget.qml b/resources/qml/WelcomePages/DropDownWidget.qml index bbf5344398..7251e8c520 100644 --- a/resources/qml/WelcomePages/DropDownWidget.qml +++ b/resources/qml/WelcomePages/DropDownWidget.qml @@ -60,7 +60,7 @@ Item anchors.left: header.left anchors.right: header.right // Add 2x lining, because it needs a bit of space on the top and the bottom. - height: contentLoader.height + 2 * UM.Theme.getSize("thick_lining").height + height: contentLoader.item.height + 2 * UM.Theme.getSize("thick_lining").height border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("lining") From 3fefb47426a2398fc5a8ca015e170a79ce39e2b0 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 09:08:07 +0200 Subject: [PATCH 11/27] Add printer name textfield into AddLocalPrinter CURA-6435 --- .../AddLocalPrinterScrollView.qml | 247 +++++++++++------- .../AddNetworkOrLocalPrinterContent.qml | 3 +- 2 files changed, 157 insertions(+), 93 deletions(-) diff --git a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml index ff64cdc33e..157a3262ec 100644 --- a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml +++ b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml @@ -12,9 +12,12 @@ import Cura 1.0 as Cura // This is the scroll view widget for adding a (local) printer. This scroll view shows a list view with printers // categorized into 3 categories: "Ultimaker", "Custom", and "Other". // -ScrollView +Item { + UM.I18nCatalog { id: catalog; name: "cura" } + id: base + height: childrenRect.height // The currently selected machine item in the local machine list. property var currentItem: (machineList.currentIndex >= 0) @@ -25,12 +28,15 @@ ScrollView // By default (when this list shows up) we always expand the "Ultimaker" section. property string preferredCategory: "Ultimaker" - ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - ScrollBar.vertical.policy: ScrollBar.AsNeeded property int maxItemCountAtOnce: 10 // show at max 10 items at once, otherwise you need to scroll. - height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height - clip: true + // User-editable printer name + property alias printerName: printerNameTextField.text + + onCurrentItemChanged: + { + printerName = currentItem == null ? "" : currentItem.name + } function updateCurrentItemUponSectionChange() { @@ -51,103 +57,160 @@ ScrollView updateCurrentItemUponSectionChange() } - ListView + Item { - id: machineList + id: localPrinterSelectionItem + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + height: childrenRect.height - model: UM.DefinitionContainersModel + // ScrollView + ListView for selecting a local printer to add + ScrollView { - id: machineDefinitionsModel - filter: { "visible": true } - sectionProperty: "category" - preferredSectionValue: preferredCategory - } - - section.property: "section" - section.delegate: sectionHeader - delegate: machineButton - } - - Component - { - id: sectionHeader - - Button - { - id: button - width: ListView.view.width - height: UM.Theme.getSize("action_button").height - text: section - - property bool isActive: base.currentSection == section - - background: Rectangle - { - anchors.fill: parent - color: isActive ? UM.Theme.getColor("setting_control_highlight") : "transparent" - } - - contentItem: Item - { - width: childrenRect.width - height: UM.Theme.getSize("action_button").height - - UM.RecolorImage - { - id: arrow - anchors.left: parent.left - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - sourceSize.width: width - sourceSize.height: height - color: UM.Theme.getColor("text") - source: base.currentSection == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right") - } - - Label - { - id: label - anchors.left: arrow.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width - verticalAlignment: Text.AlignVCenter - text: button.text - font.bold: true - renderType: Text.NativeRendering - } - } - - onClicked: - { - base.currentSection = section - base.updateCurrentItemUponSectionChange() - } - } - } - - Component - { - id: machineButton - - Cura.RadioButton - { - id: radioButton + id: scrollView anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("standard_list_lineheight").width anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_margin").width - height: visible ? UM.Theme.getSize("standard_list_lineheight").height : 0 + anchors.top: parent.top - checked: ListView.view.currentIndex == index - onCheckedChanged: + height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height + + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.vertical.policy: ScrollBar.AsNeeded + + clip: true + + ListView { - if(checked) + id: machineList + + model: UM.DefinitionContainersModel { - machineList.currentIndex = index + id: machineDefinitionsModel + filter: { "visible": true } + sectionProperty: "category" + preferredSectionValue: preferredCategory + } + + section.property: "section" + section.delegate: sectionHeader + delegate: machineButton + } + + Component + { + id: sectionHeader + + Button + { + id: button + width: ListView.view.width + height: UM.Theme.getSize("action_button").height + text: section + + property bool isActive: base.currentSection == section + + background: Rectangle + { + anchors.fill: parent + color: isActive ? UM.Theme.getColor("setting_control_highlight") : "transparent" + } + + contentItem: Item + { + width: childrenRect.width + height: UM.Theme.getSize("action_button").height + + UM.RecolorImage + { + id: arrow + anchors.left: parent.left + width: UM.Theme.getSize("standard_arrow").width + height: UM.Theme.getSize("standard_arrow").height + sourceSize.width: width + sourceSize.height: height + color: UM.Theme.getColor("text") + source: base.currentSection == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right") + } + + Label + { + id: label + anchors.left: arrow.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width + verticalAlignment: Text.AlignVCenter + text: button.text + font.bold: true + renderType: Text.NativeRendering + } + } + + onClicked: + { + base.currentSection = section + base.updateCurrentItemUponSectionChange() + } } } - text: name - visible: base.currentSection == section - onClicked: ListView.view.currentIndex = index + + Component + { + id: machineButton + + Cura.RadioButton + { + id: radioButton + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("standard_list_lineheight").width + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + height: visible ? UM.Theme.getSize("standard_list_lineheight").height : 0 + + checked: ListView.view.currentIndex == index + text: name + visible: base.currentSection == section + onClicked: ListView.view.currentIndex = index + } + } + } + } + + // Horizontal line + Rectangle + { + id: horizontalLine + anchors.top: localPrinterSelectionItem.bottom + anchors.left: parent.left + anchors.right: parent.right + height: UM.Theme.getSize("default_lining").height + color: UM.Theme.getColor("lining") + } + + // User-editable printer name row + Row + { + anchors.top: horizontalLine.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.topMargin: UM.Theme.getSize("default_lining").height + anchors.leftMargin: UM.Theme.getSize("default_margin").width + + spacing: UM.Theme.getSize("default_margin").width + + Label + { + text: catalog.i18nc("@label", "Printer Name") + anchors.verticalCenter: parent.verticalCenter + font: UM.Theme.getFont("medium") + verticalAlignment: Text.AlignVCenter + renderType: Text.NativeRendering + } + + Cura.TextField + { + id: printerNameTextField + anchors.verticalCenter: parent.verticalCenter + width: (parent.width / 2) | 0 } } } diff --git a/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml b/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml index 34e0a58d8f..b5484e9916 100644 --- a/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml +++ b/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml @@ -139,7 +139,8 @@ Item { // Create a local printer const localPrinterItem = addLocalPrinterDropDown.contentItem.currentItem - Cura.MachineManager.addMachine(localPrinterItem.id) + const printerName = addLocalPrinterDropDown.contentItem.printerName + Cura.MachineManager.addMachine(localPrinterItem.id, printerName) base.showNextPage() } From b269dc95b06037fec89bbde66314b7405ce505ba Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 09:10:29 +0200 Subject: [PATCH 12/27] Remove old AddMachineDialog CURA-6435 --- resources/qml/Dialogs/AddMachineDialog.qml | 321 --------------------- 1 file changed, 321 deletions(-) delete mode 100644 resources/qml/Dialogs/AddMachineDialog.qml diff --git a/resources/qml/Dialogs/AddMachineDialog.qml b/resources/qml/Dialogs/AddMachineDialog.qml deleted file mode 100644 index d3988155b7..0000000000 --- a/resources/qml/Dialogs/AddMachineDialog.qml +++ /dev/null @@ -1,321 +0,0 @@ -// Copyright (c) 2019 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Layouts 1.1 -import QtQuick.Window 2.1 - -import QtQuick.Controls.Styles 1.1 - -import UM 1.2 as UM -import Cura 1.0 as Cura - - -UM.Dialog -{ - id: base - title: catalog.i18nc("@title:window", "Add Printer") - property bool firstRun: false - property string preferredCategory: "Ultimaker" - property string activeCategory: preferredCategory - - minimumWidth: UM.Theme.getSize("modal_window_minimum").width - minimumHeight: UM.Theme.getSize("modal_window_minimum").height - width: minimumWidth - height: minimumHeight - - flags: - { - var window_flags = Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint; - if (Cura.MachineManager.activeDefinitionId !== "") //Disallow closing the window if we have no active printer yet. You MUST add a printer. - { - window_flags |= Qt.WindowCloseButtonHint; - } - return window_flags; - } - - onVisibilityChanged: - { - // Reset selection and machine name - if (visible) - { - activeCategory = preferredCategory; - machineList.currentIndex = 0; - machineName.text = getMachineName(); - } - } - - signal machineAdded(string id) - - function getMachineName() - { - if (machineList.model.getItem(machineList.currentIndex) != undefined) - { - return machineList.model.getItem(machineList.currentIndex).name; - } - return ""; - } - - function getMachineMetaDataEntry(key) - { - if (machineList.model.getItem(machineList.currentIndex) != undefined) - { - return machineList.model.getItem(machineList.currentIndex).metadata[key]; - } - return ""; - } - - Label - { - id: titleLabel - - anchors - { - top: parent.top - left: parent.left - topMargin: UM.Theme.getSize("default_margin").height - } - text: catalog.i18nc("@title:tab", "Add a printer to Cura") - - font.pointSize: 18 - } - - Label - { - id: captionLabel - anchors - { - left: parent.left - top: titleLabel.bottom - topMargin: UM.Theme.getSize("default_margin").height - } - text: catalog.i18nc("@title:tab", "Select the printer you want to use from the list below.\n\nIf your printer is not in the list, use the \"Custom FFF Printer\" from the \"Custom\" category and adjust the settings to match your printer in the next dialog.") - width: parent.width - wrapMode: Text.WordWrap - } - - ScrollView - { - id: machinesHolder - - anchors - { - top: captionLabel.visible ? captionLabel.bottom : parent.top; - topMargin: captionLabel.visible ? UM.Theme.getSize("default_margin").height : 0; - bottom: addPrinterButton.top; - bottomMargin: UM.Theme.getSize("default_margin").height - } - - width: Math.round(parent.width * 0.45) - - frameVisible: true; - Rectangle - { - parent: viewport - anchors.fill: parent - color: palette.light - } - - ListView - { - id: machineList - - model: UM.DefinitionContainersModel - { - id: machineDefinitionsModel - filter: { "visible": true } - sectionProperty: "category" - preferredSectionValue: preferredCategory - } - - section.property: "section" - section.delegate: Button - { - id: machineSectionButton - text: section - width: machineList.width - style: ButtonStyle - { - background: Item - { - height: UM.Theme.getSize("standard_list_lineheight").height - width: machineList.width - } - label: Label - { - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("standard_arrow").width + UM.Theme.getSize("default_margin").width - text: control.text - color: palette.windowText - font.bold: true - UM.RecolorImage - { - id: downArrow - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - sourceSize.height: width - color: palette.windowText - source: base.activeCategory == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right") - } - } - } - - onClicked: - { - base.activeCategory = section; - if (machineList.model.getItem(machineList.currentIndex).section != section) - { - // Find the first machine from this section - for(var i = 0; i < machineList.model.count; i++) - { - var item = machineList.model.getItem(i); - if (item.section == section) - { - machineList.currentIndex = i; - break; - } - } - } - machineName.text = getMachineName(); - } - } - - delegate: RadioButton - { - id: machineButton - - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("standard_list_lineheight").width - - opacity: 1; - height: UM.Theme.getSize("standard_list_lineheight").height; - - checked: ListView.isCurrentItem; - - exclusiveGroup: printerGroup; - - text: model.name - - onClicked: - { - ListView.view.currentIndex = index; - machineName.text = getMachineName() - } - - states: State - { - name: "collapsed"; - when: base.activeCategory != model.section; - - PropertyChanges { target: machineButton; opacity: 0; height: 0; } - } - } - } - } - - Column - { - anchors - { - top: machinesHolder.top - left: machinesHolder.right - right: parent.right - leftMargin: UM.Theme.getSize("default_margin").width - } - - spacing: UM.Theme.getSize("default_margin").height - Label - { - width: parent.width - wrapMode: Text.WordWrap - text: getMachineName() - font.pointSize: 16 - elide: Text.ElideRight - } - Grid - { - width: parent.width - columns: 2 - rowSpacing: UM.Theme.getSize("default_lining").height - columnSpacing: UM.Theme.getSize("default_margin").width - verticalItemAlignment: Grid.AlignVCenter - - Label - { - wrapMode: Text.WordWrap - text: catalog.i18nc("@label", "Manufacturer") - } - Label - { - width: Math.floor(parent.width * 0.65) - wrapMode: Text.WordWrap - text: getMachineMetaDataEntry("manufacturer") - } - Label - { - wrapMode: Text.WordWrap - text: catalog.i18nc("@label", "Author") - } - Label - { - width: Math.floor(parent.width * 0.75) - wrapMode: Text.WordWrap - text: getMachineMetaDataEntry("author") - } - Label - { - wrapMode: Text.WordWrap - text: catalog.i18nc("@label", "Printer Name") - } - TextField - { - id: machineName - text: getMachineName() - width: Math.floor(parent.width * 0.75) - maximumLength: 40 - //validator: Cura.MachineNameValidator { } //TODO: Gives a segfault in PyQt5.6. For now, we must use a signal on text changed. - validator: RegExpValidator - { - regExp: { - machineName.machine_name_validator.machineNameRegex - } - } - property var machine_name_validator: Cura.MachineNameValidator { } - } - } - } - - Button - { - id: addPrinterButton - text: catalog.i18nc("@action:button", "Add Printer") - anchors.bottom: parent.bottom - anchors.right: parent.right - onClicked: addMachine() - } - - onAccepted: addMachine() - - function addMachine() - { - base.visible = false - var item = machineList.model.getItem(machineList.currentIndex); - Cura.MachineManager.addMachine(item.id, machineName.text) - base.machineAdded(item.id) // Emit signal that the user added a machine. - } - - Item - { - UM.I18nCatalog - { - id: catalog; - name: "cura"; - } - SystemPalette { id: palette } - ExclusiveGroup { id: printerGroup; } - } -} From b0fd6628a588a24981fe728a15b983e247ee34d1 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 09:35:00 +0200 Subject: [PATCH 13/27] Make sure that printer name is not empty CURA-6435 --- .../WelcomePages/AddLocalPrinterScrollView.qml | 5 +++++ .../AddNetworkOrLocalPrinterContent.qml | 5 ++++- resources/qml/Widgets/TextField.qml | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml index 157a3262ec..37934f9ac2 100644 --- a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml +++ b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml @@ -32,6 +32,7 @@ Item // User-editable printer name property alias printerName: printerNameTextField.text + property alias isPrinterNameValid: printerNameTextField.acceptableInput onCurrentItemChanged: { @@ -211,6 +212,10 @@ Item id: printerNameTextField anchors.verticalCenter: parent.verticalCenter width: (parent.width / 2) | 0 + placeholderText: catalog.i18nc("@text", "Please give your printer a name") + + // Make sure that the fill is not empty + validator: RegExpValidator { regExp: /.+/ } } } } diff --git a/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml b/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml index b5484e9916..34ec3b4a24 100644 --- a/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml +++ b/resources/qml/WelcomePages/AddNetworkOrLocalPrinterContent.qml @@ -118,7 +118,10 @@ Item } else { - return addLocalPrinterDropDown.contentItem.currentItem != null + // Printer name cannot be empty + const localPrinterItem = addLocalPrinterDropDown.contentItem.currentItem + const isPrinterNameValid = addLocalPrinterDropDown.contentItem.isPrinterNameValid + return localPrinterItem != null && isPrinterNameValid } } diff --git a/resources/qml/Widgets/TextField.qml b/resources/qml/Widgets/TextField.qml index 8161dfe532..fcdcae53be 100644 --- a/resources/qml/Widgets/TextField.qml +++ b/resources/qml/Widgets/TextField.qml @@ -37,11 +37,28 @@ TextField { return UM.Theme.getColor("setting_control_disabled_border") } + if (!textField.acceptableInput) + { + return UM.Theme.getColor("setting_validation_error") + } if (textField.hovered || textField.activeFocus) { return UM.Theme.getColor("setting_control_border_highlight") } return UM.Theme.getColor("setting_control_border") } + + color: + { + if (!textField.enabled) + { + return UM.Theme.getColor("setting_control_disabled") + } + if (!textField.acceptableInput) + { + return UM.Theme.getColor("setting_validation_error_background") + } + return UM.Theme.getColor("setting_control") + } } } From d5f4fd43dd21325628a404206ba5d8117444d6f5 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 5 Apr 2019 09:42:21 +0200 Subject: [PATCH 14/27] Fix typing CURA-6435 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 4fc4c1f795..a6bc13f3c2 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -356,7 +356,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): properties = device.getProperties().copy() if b"incomplete" in properties: del properties[b"incomplete"] - properties[b"cluster_size"] = len(cluster_printers_list) + properties[b"cluster_size"] = str(len(cluster_printers_list)).encode("utf-8") self._onRemoveDevice(instance_name) self._onAddDevice(instance_name, address, properties) From dfa35bd589cd07e66cd832f719c7bcf69c8bc28c Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 8 Apr 2019 09:20:22 +0200 Subject: [PATCH 15/27] Fix goToPage() when page_id is not found CURA-6435 --- cura/UI/WelcomePagesModel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/UI/WelcomePagesModel.py b/cura/UI/WelcomePagesModel.py index 6063208edd..8f3193e603 100644 --- a/cura/UI/WelcomePagesModel.py +++ b/cura/UI/WelcomePagesModel.py @@ -146,7 +146,8 @@ class WelcomePagesModel(ListModel): page_index = self.getPageIndexById(page_id) if page_index is None: # FIXME: If we cannot find the next page, we cannot do anything here. - Logger.log("e", "Cannot find page with ID [%s]", page_index) + Logger.log("e", "Cannot find page with ID [%s], go to the next page by default", page_index) + self.goToNextPage() return if self._shouldPageBeShown(page_index): From f5ef6aed8da52517c85f38c6d967614644f02c83 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 8 Apr 2019 17:10:36 +0200 Subject: [PATCH 16/27] Make textfield use states CURA-6435 --- .../AddLocalPrinterScrollView.qml | 2 +- resources/qml/Widgets/TextField.qml | 57 +++++++++---------- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml index 37934f9ac2..2feff668e7 100644 --- a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml +++ b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml @@ -141,7 +141,7 @@ Item anchors.leftMargin: UM.Theme.getSize("default_margin").width verticalAlignment: Text.AlignVCenter text: button.text - font.bold: true + font: UM.Theme.getFont("default_bold") renderType: Text.NativeRendering } } diff --git a/resources/qml/Widgets/TextField.qml b/resources/qml/Widgets/TextField.qml index fcdcae53be..bff50fec32 100644 --- a/resources/qml/Widgets/TextField.qml +++ b/resources/qml/Widgets/TextField.qml @@ -17,48 +17,43 @@ TextField UM.I18nCatalog { id: catalog; name: "cura" } - property int controlWidth: UM.Theme.getSize("setting_control").width - property int controlHeight: UM.Theme.getSize("setting_control").height - hoverEnabled: true selectByMouse: true font: UM.Theme.getFont("default") renderType: Text.NativeRendering + states: [ + State + { + name: "disabled" + when: !textField.enabled + PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_control_disabled_border")} + PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_control_disabled")} + }, + State + { + name: "invalid" + when: !textField.acceptableInput + PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_validation_error")} + PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_validation_error_background")} + }, + State + { + name: "hovered" + when: textField.hovered || textField.activeFocus + PropertyChanges { target: backgroundRectangle.border; color: UM.Theme.getColor("setting_control_border_highlight") } + } + ] + background: Rectangle { + id: backgroundRectangle anchors.fill: parent anchors.margins: Math.round(UM.Theme.getSize("default_lining").width) radius: UM.Theme.getSize("setting_control_radius").width - border.color: - { - if (!textField.enabled) - { - return UM.Theme.getColor("setting_control_disabled_border") - } - if (!textField.acceptableInput) - { - return UM.Theme.getColor("setting_validation_error") - } - if (textField.hovered || textField.activeFocus) - { - return UM.Theme.getColor("setting_control_border_highlight") - } - return UM.Theme.getColor("setting_control_border") - } + border.color: UM.Theme.getColor("setting_control_border") - color: - { - if (!textField.enabled) - { - return UM.Theme.getColor("setting_control_disabled") - } - if (!textField.acceptableInput) - { - return UM.Theme.getColor("setting_validation_error_background") - } - return UM.Theme.getColor("setting_control") - } + color: UM.Theme.getColor("setting_control") } } From 61ee2ec85ceb337b8caecdef6feeeec11a1b2aee Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 9 Apr 2019 11:45:28 +0200 Subject: [PATCH 17/27] Simplify code CURA-6447 --- cura/CuraApplication.py | 1 - resources/qml/Cura.qml | 6 ------ resources/qml/Preferences/MachinesPage.qml | 2 +- resources/qml/WelcomePages/WizardDialog.qml | 1 + 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 3a8af2e9f9..1bc55d76f9 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1106,7 +1106,6 @@ class CuraApplication(QtApplication): self._camera_animation.setTarget(Selection.getSelectedObject(0).getWorldPosition()) self._camera_animation.start() - requestAddPrinter = pyqtSignal() activityChanged = pyqtSignal() sceneBoundingBoxChanged = pyqtSignal() diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 55bede1866..267ead1138 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -788,12 +788,6 @@ UM.MainWindow onTriggered: addMachineDialog.show() } - Connections - { - target: CuraApplication - onRequestAddPrinter: addMachineDialog.show() - } - AboutDialog { id: aboutDialog diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 9bb17470c8..cbbb0b80bf 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -45,7 +45,7 @@ UM.ManagementPage { text: catalog.i18nc("@action:button", "Add"); iconName: "list-add"; - onClicked: CuraApplication.requestAddPrinter() + onClicked: Cura.Actions.addMachine.trigger() }, Button { diff --git a/resources/qml/WelcomePages/WizardDialog.qml b/resources/qml/WelcomePages/WizardDialog.qml index 4f664165c3..4a0867c9a2 100644 --- a/resources/qml/WelcomePages/WizardDialog.qml +++ b/resources/qml/WelcomePages/WizardDialog.qml @@ -20,6 +20,7 @@ Window id: dialog flags: Qt.Dialog + modality: Qt.ApplicationModal minimumWidth: 580 * screenScaleFactor minimumHeight: 600 * screenScaleFactor From b692787def22694687c7e8b73dc0d18d38ed4931 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 10 Apr 2019 07:16:06 +0200 Subject: [PATCH 18/27] Fix how onboarding flow is shown CURA-6447 --- cura/UI/WelcomePagesModel.py | 102 ++++++++++++++++++++++++----------- resources/qml/Cura.qml | 4 +- 2 files changed, 73 insertions(+), 33 deletions(-) diff --git a/cura/UI/WelcomePagesModel.py b/cura/UI/WelcomePagesModel.py index 8f3193e603..b465e9f252 100644 --- a/cura/UI/WelcomePagesModel.py +++ b/cura/UI/WelcomePagesModel.py @@ -59,6 +59,10 @@ class WelcomePagesModel(ListModel): # Store all the previous page indices so it can go back. self._previous_page_indices_stack = deque() # type: deque + # If the welcome flow should be shown. It can show the complete flow or just the changelog depending on the + # specific case. See initialize() for how this variable is set. + self._should_show_welcome_flow = False + allFinished = pyqtSignal() # emitted when all steps have been finished currentPageIndexChanged = pyqtSignal() @@ -174,6 +178,12 @@ class WelcomePagesModel(ListModel): self.currentPageIndexChanged.emit() + shouldShowWelcomeFlowChanged = pyqtSignal() + + @pyqtProperty(bool, notify = shouldShowWelcomeFlowChanged) + def shouldShowWelcomeFlow(self) -> bool: + return self._should_show_welcome_flow + # Gets the page index with the given page ID. If the page ID doesn't exist, returns None. def getPageIndexById(self, page_id: str) -> Optional[int]: page_idx = None @@ -189,37 +199,69 @@ class WelcomePagesModel(ListModel): return QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, os.path.join("WelcomePages", page_filename))) - def initialize(self) -> None: - # Add default welcome pages - self._pages.append({"id": "welcome", - "page_url": self._getBuiltinWelcomePagePath("WelcomeContent.qml"), - }) - self._pages.append({"id": "user_agreement", - "page_url": self._getBuiltinWelcomePagePath("UserAgreementContent.qml"), - }) - self._pages.append({"id": "whats_new", - "page_url": self._getBuiltinWelcomePagePath("WhatsNewContent.qml"), - }) - self._pages.append({"id": "data_collections", - "page_url": self._getBuiltinWelcomePagePath("DataCollectionsContent.qml"), - }) - self._pages.append({"id": "add_network_or_local_printer", - "page_url": self._getBuiltinWelcomePagePath("AddNetworkOrLocalPrinterContent.qml"), - "next_page_id": "machine_actions", - }) - self._pages.append({"id": "add_printer_by_ip", - "page_url": self._getBuiltinWelcomePagePath("AddPrinterByIpContent.qml"), - "next_page_id": "machine_actions", - }) - self._pages.append({"id": "machine_actions", - "page_url": self._getBuiltinWelcomePagePath("FirstStartMachineActionsContent.qml"), - "next_page_id": "cloud", - "should_show_function": self.shouldShowMachineActions, - }) - self._pages.append({"id": "cloud", - "page_url": self._getBuiltinWelcomePagePath("CloudContent.qml"), - }) + # FIXME: HACKs for optimization that we don't update the model every time the active machine gets changed. + def _onActiveMachineChanged(self) -> None: + self._application.getMachineManager().globalContainerChanged.disconnect(self._onActiveMachineChanged) + self.initialize() + def initialize(self) -> None: + self._application.getMachineManager().globalContainerChanged.connect(self._onActiveMachineChanged) + self._initialize() + + def _initialize(self) -> None: + has_active_machine = self._application.getMachineManager().activeMachine is not None + has_app_just_upgraded = self._application.hasJustUpgradedToNewVersion() + + # Only show the what's new dialog if there's no machine and we have just upgraded + show_complete_flow = not has_active_machine + show_whatsnew_only = has_active_machine and has_app_just_upgraded + + # FIXME: This is a hack. Because of the circular dependency between MachineManager, ExtruderManager, and + # possibly some others, setting the initial active machine is not done when the MachineManager gets initialized. + # So at this point, we don't know if there will be an active machine or not. It could be that the active machine + # files are corrupted so we cannot rely on Preferences either. This makes sure that once the active machine + # gets changed, this model updates the flags, so it can decide whether to show the welcome flow or not. + should_show_welcome_flow = show_complete_flow or show_whatsnew_only + if should_show_welcome_flow != self._should_show_welcome_flow: + self._should_show_welcome_flow = should_show_welcome_flow + self.shouldShowWelcomeFlowChanged.emit() + + # All pages + all_pages_list = [{"id": "welcome", + "page_url": self._getBuiltinWelcomePagePath("WelcomeContent.qml"), + }, + {"id": "user_agreement", + "page_url": self._getBuiltinWelcomePagePath("UserAgreementContent.qml"), + }, + {"id": "whats_new", + "page_url": self._getBuiltinWelcomePagePath("WhatsNewContent.qml"), + }, + {"id": "data_collections", + "page_url": self._getBuiltinWelcomePagePath("DataCollectionsContent.qml"), + }, + {"id": "add_network_or_local_printer", + "page_url": self._getBuiltinWelcomePagePath("AddNetworkOrLocalPrinterContent.qml"), + "next_page_id": "machine_actions", + }, + {"id": "add_printer_by_ip", + "page_url": self._getBuiltinWelcomePagePath("AddPrinterByIpContent.qml"), + "next_page_id": "machine_actions", + }, + {"id": "machine_actions", + "page_url": self._getBuiltinWelcomePagePath("FirstStartMachineActionsContent.qml"), + "next_page_id": "cloud", + "should_show_function": self.shouldShowMachineActions, + }, + {"id": "cloud", + "page_url": self._getBuiltinWelcomePagePath("CloudContent.qml"), + }, + ] + + pages_to_show = all_pages_list + if show_whatsnew_only: + pages_to_show = list(filter(lambda x: x["id"] == "whats_new", all_pages_list)) + + self._pages = pages_to_show self.setItems(self._pages) # For convenience, inject the default "next" button text to each item if it's not present. diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 267ead1138..bdd016d24c 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -84,7 +84,7 @@ UM.MainWindow Cura.Actions.parent = backgroundItem CuraApplication.purgeWindows() - if (CuraApplication.needToShowUserAgreement) + if (CuraApplication.getWelcomePagesModel().shouldShowWelcomeFlow) { welcomeDialogItem.visible = true } @@ -92,8 +92,6 @@ UM.MainWindow { welcomeDialogItem.visible = false } - // TODO: While the new onboarding process contains the user-agreement, - // it should probably not entirely rely on 'needToShowUserAgreement' for show/hide. } Item From e0e3c9609f499040f43dd3e329831204de0ba6b0 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 10 Apr 2019 10:52:08 +0200 Subject: [PATCH 19/27] Fix update should show logic CURA-6447 --- cura/UI/WelcomePagesModel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/UI/WelcomePagesModel.py b/cura/UI/WelcomePagesModel.py index b465e9f252..be29ed5619 100644 --- a/cura/UI/WelcomePagesModel.py +++ b/cura/UI/WelcomePagesModel.py @@ -202,7 +202,7 @@ class WelcomePagesModel(ListModel): # FIXME: HACKs for optimization that we don't update the model every time the active machine gets changed. def _onActiveMachineChanged(self) -> None: self._application.getMachineManager().globalContainerChanged.disconnect(self._onActiveMachineChanged) - self.initialize() + self._initialize() def initialize(self) -> None: self._application.getMachineManager().globalContainerChanged.connect(self._onActiveMachineChanged) @@ -210,7 +210,7 @@ class WelcomePagesModel(ListModel): def _initialize(self) -> None: has_active_machine = self._application.getMachineManager().activeMachine is not None - has_app_just_upgraded = self._application.hasJustUpgradedToNewVersion() + has_app_just_upgraded = self._application.hasJustUpdatedFromOldVersion() # Only show the what's new dialog if there's no machine and we have just upgraded show_complete_flow = not has_active_machine From 9494173f43ff5dfebd963413083f17d36fd63d57 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 12 Apr 2019 12:10:56 +0200 Subject: [PATCH 20/27] Remove hack in WelcomePagesModel and add WhatsNewPagesModel CURA-6447 --- cura/CuraApplication.py | 26 +++++++ cura/UI/WelcomePagesModel.py | 42 +--------- cura/UI/WhatsNewPagesModel.py | 22 ++++++ resources/qml/Actions.qml | 8 ++ resources/qml/Cura.qml | 78 ++++++++++++++----- resources/qml/MainWindow/ApplicationMenu.qml | 1 + .../qml/WelcomePages/WhatsNewContent.qml | 2 +- 7 files changed, 116 insertions(+), 63 deletions(-) create mode 100644 cura/UI/WhatsNewPagesModel.py diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 1bc55d76f9..d5ab2bd706 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -114,6 +114,7 @@ from cura.UI.ObjectsModel import ObjectsModel from cura.UI.TextManager import TextManager from cura.UI.AddPrinterPagesModel import AddPrinterPagesModel from cura.UI.WelcomePagesModel import WelcomePagesModel +from cura.UI.WhatsNewPagesModel import WhatsNewPagesModel from .SingleInstance import SingleInstance from .AutoSave import AutoSave @@ -219,6 +220,7 @@ class CuraApplication(QtApplication): self._first_start_machine_actions_model = FirstStartMachineActionsModel(self) self._welcome_pages_model = WelcomePagesModel(self) self._add_printer_pages_model = AddPrinterPagesModel(self) + self._whats_new_pages_model = WhatsNewPagesModel(self) self._text_manager = TextManager(self) self._quality_profile_drop_down_menu_model = None @@ -765,6 +767,7 @@ class CuraApplication(QtApplication): self._output_device_manager.start() self._welcome_pages_model.initialize() self._add_printer_pages_model.initialize() + self._whats_new_pages_model.initialize() # Detect in which mode to run and execute that mode if self._is_headless: @@ -880,6 +883,10 @@ class CuraApplication(QtApplication): def getAddPrinterPagesModel(self, *args) -> "AddPrinterPagesModel": return self._add_printer_pages_model + @pyqtSlot(result = QObject) + def getWhatsNewPagesModel(self, *args) -> "WhatsNewPagesModel": + return self._whats_new_pages_model + @pyqtSlot(result = QObject) def getMachineSettingsManager(self, *args) -> "MachineSettingsManager": return self._machine_settings_manager @@ -1021,6 +1028,7 @@ class CuraApplication(QtApplication): qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager) qmlRegisterType(WelcomePagesModel, "Cura", 1, 0, "WelcomePagesModel") + qmlRegisterType(WhatsNewPagesModel, "Cura", 1, 0, "WhatsNewPagesModel") qmlRegisterType(AddPrinterPagesModel, "Cura", 1, 0, "AddPrinterPagesModel") qmlRegisterType(TextManager, "Cura", 1, 0, "TextManager") @@ -1765,3 +1773,21 @@ class CuraApplication(QtApplication): def getSidebarCustomMenuItems(self) -> list: return self._sidebar_custom_menu_items + @pyqtSlot(result = bool) + def shouldShowWelcomeDialog(self) -> bool: + has_active_machine = self._machine_manager.activeMachine is not None + + # Only show the complete flow if there is not printer yet. + show_complete_flow = not has_active_machine + return show_complete_flow + + @pyqtSlot(result = bool) + def shouldShowWhatsNewDialog(self) -> bool: + has_active_machine = self._machine_manager.activeMachine is not None + has_app_just_upgraded = self.hasJustUpdatedFromOldVersion() + + print("!!!!!!!!!!!!! has_active_machine = ", has_active_machine) + + # Only show the what's new dialog if there's no machine and we have just upgraded + show_whatsnew_only = has_active_machine and has_app_just_upgraded + return show_whatsnew_only diff --git a/cura/UI/WelcomePagesModel.py b/cura/UI/WelcomePagesModel.py index be29ed5619..f75082e20d 100644 --- a/cura/UI/WelcomePagesModel.py +++ b/cura/UI/WelcomePagesModel.py @@ -59,10 +59,6 @@ class WelcomePagesModel(ListModel): # Store all the previous page indices so it can go back. self._previous_page_indices_stack = deque() # type: deque - # If the welcome flow should be shown. It can show the complete flow or just the changelog depending on the - # specific case. See initialize() for how this variable is set. - self._should_show_welcome_flow = False - allFinished = pyqtSignal() # emitted when all steps have been finished currentPageIndexChanged = pyqtSignal() @@ -178,12 +174,6 @@ class WelcomePagesModel(ListModel): self.currentPageIndexChanged.emit() - shouldShowWelcomeFlowChanged = pyqtSignal() - - @pyqtProperty(bool, notify = shouldShowWelcomeFlowChanged) - def shouldShowWelcomeFlow(self) -> bool: - return self._should_show_welcome_flow - # Gets the page index with the given page ID. If the page ID doesn't exist, returns None. def getPageIndexById(self, page_id: str) -> Optional[int]: page_idx = None @@ -199,33 +189,7 @@ class WelcomePagesModel(ListModel): return QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, os.path.join("WelcomePages", page_filename))) - # FIXME: HACKs for optimization that we don't update the model every time the active machine gets changed. - def _onActiveMachineChanged(self) -> None: - self._application.getMachineManager().globalContainerChanged.disconnect(self._onActiveMachineChanged) - self._initialize() - def initialize(self) -> None: - self._application.getMachineManager().globalContainerChanged.connect(self._onActiveMachineChanged) - self._initialize() - - def _initialize(self) -> None: - has_active_machine = self._application.getMachineManager().activeMachine is not None - has_app_just_upgraded = self._application.hasJustUpdatedFromOldVersion() - - # Only show the what's new dialog if there's no machine and we have just upgraded - show_complete_flow = not has_active_machine - show_whatsnew_only = has_active_machine and has_app_just_upgraded - - # FIXME: This is a hack. Because of the circular dependency between MachineManager, ExtruderManager, and - # possibly some others, setting the initial active machine is not done when the MachineManager gets initialized. - # So at this point, we don't know if there will be an active machine or not. It could be that the active machine - # files are corrupted so we cannot rely on Preferences either. This makes sure that once the active machine - # gets changed, this model updates the flags, so it can decide whether to show the welcome flow or not. - should_show_welcome_flow = show_complete_flow or show_whatsnew_only - if should_show_welcome_flow != self._should_show_welcome_flow: - self._should_show_welcome_flow = should_show_welcome_flow - self.shouldShowWelcomeFlowChanged.emit() - # All pages all_pages_list = [{"id": "welcome", "page_url": self._getBuiltinWelcomePagePath("WelcomeContent.qml"), @@ -257,11 +221,7 @@ class WelcomePagesModel(ListModel): }, ] - pages_to_show = all_pages_list - if show_whatsnew_only: - pages_to_show = list(filter(lambda x: x["id"] == "whats_new", all_pages_list)) - - self._pages = pages_to_show + self._pages = all_pages_list self.setItems(self._pages) # For convenience, inject the default "next" button text to each item if it's not present. diff --git a/cura/UI/WhatsNewPagesModel.py b/cura/UI/WhatsNewPagesModel.py new file mode 100644 index 0000000000..5b968ae574 --- /dev/null +++ b/cura/UI/WhatsNewPagesModel.py @@ -0,0 +1,22 @@ +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +from .WelcomePagesModel import WelcomePagesModel + + +# +# This Qt ListModel is more or less the same the WelcomePagesModel, except that this model is only for showing the +# "what's new" page. This is also used in the "Help" menu to show the changes log. +# +class WhatsNewPagesModel(WelcomePagesModel): + + def initialize(self) -> None: + self._pages = [] + self._pages.append({"id": "whats_new", + "page_url": self._getBuiltinWelcomePagePath("WhatsNewContent.qml"), + "next_page_button_text": self._catalog.i18nc("@action:button", "Close"), + }) + self.setItems(self._pages) + + +__all__ = ["WhatsNewPagesModel"] diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index 81c14aa01a..ed89eb553e 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -61,6 +61,7 @@ Item property alias documentation: documentationAction; property alias showTroubleshooting: showTroubleShootingAction property alias reportBug: reportBugAction; + property alias whatsNew: whatsNewAction property alias about: aboutAction; property alias toggleFullScreen: toggleFullScreenAction; @@ -229,6 +230,13 @@ Item onTriggered: CuraActions.openBugReportPage(); } + Action + { + id: whatsNewAction; + text: catalog.i18nc("@action:inmenu menubar:help", "What's New"); + iconName: "help-whats-new"; + } + Action { id: aboutAction; diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index bdd016d24c..08fbc95b0e 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -68,32 +68,54 @@ UM.MainWindow z: greyOutBackground.z + 1 } - Component.onCompleted: + Connections { - CuraApplication.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size")) - // Workaround silly issues with QML Action's shortcut property. - // - // Currently, there is no way to define shortcuts as "Application Shortcut". - // This means that all Actions are "Window Shortcuts". The code for this - // implements a rather naive check that just checks if any of the action's parents - // are a window. Since the "Actions" object is a singleton it has no parent by - // default. If we set its parent to something contained in this window, the - // shortcut will activate properly because one of its parents is a window. - // - // This has been fixed for QtQuick Controls 2 since the Shortcut item has a context property. - Cura.Actions.parent = backgroundItem - CuraApplication.purgeWindows() + target: CuraApplication + onInitializationFinished: + { + CuraApplication.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size")) + // Workaround silly issues with QML Action's shortcut property. + // + // Currently, there is no way to define shortcuts as "Application Shortcut". + // This means that all Actions are "Window Shortcuts". The code for this + // implements a rather naive check that just checks if any of the action's parents + // are a window. Since the "Actions" object is a singleton it has no parent by + // default. If we set its parent to something contained in this window, the + // shortcut will activate properly because one of its parents is a window. + // + // This has been fixed for QtQuick Controls 2 since the Shortcut item has a context property. + Cura.Actions.parent = backgroundItem + CuraApplication.purgeWindows() - if (CuraApplication.getWelcomePagesModel().shouldShowWelcomeFlow) - { - welcomeDialogItem.visible = true - } - else - { - welcomeDialogItem.visible = false + if (CuraApplication.shouldShowWelcomeDialog()) + { + welcomeDialogItem.visible = true + } + else + { + welcomeDialogItem.visible = false + } + + if (CuraApplication.shouldShowWhatsNewDialog()) + { + showWhatsNewDialogTimer.start() + } } } + // HACK: Use a timer here because if we call "Cura.Actions.whatsNew.trigger()" or "whatsNewDialog.show()" when + // the component gets completed or when the application finishes its initialization, the main window has not been + // fully initialized yet. If we should the dialog before the main window is fully initialized, you will see the + // dialog first but when the main windows is fully initialized, the dialog will disappear. Adding a timer here is + // to bypass this problem. + Timer + { + id: showWhatsNewDialogTimer + repeat: false + interval: 1000 + onTriggered: Cura.Actions.whatsNew.trigger() + } + Item { id: backgroundItem @@ -780,6 +802,20 @@ UM.MainWindow progressBarVisible: false } + Cura.WizardDialog + { + id: whatsNewDialog + title: catalog.i18nc("@title:window", "What's New") + model: CuraApplication.getWhatsNewPagesModel() + progressBarVisible: false + } + + Connections + { + target: Cura.Actions.whatsNew + onTriggered: whatsNewDialog.show() + } + Connections { target: Cura.Actions.addMachine diff --git a/resources/qml/MainWindow/ApplicationMenu.qml b/resources/qml/MainWindow/ApplicationMenu.qml index 2f18df8914..7f343eb8f4 100644 --- a/resources/qml/MainWindow/ApplicationMenu.qml +++ b/resources/qml/MainWindow/ApplicationMenu.qml @@ -101,6 +101,7 @@ Item MenuItem { action: Cura.Actions.documentation } MenuItem { action: Cura.Actions.reportBug } MenuSeparator { } + MenuItem { action: Cura.Actions.whatsNew } MenuItem { action: Cura.Actions.about } } } diff --git a/resources/qml/WelcomePages/WhatsNewContent.qml b/resources/qml/WelcomePages/WhatsNewContent.qml index 415acae05c..51a347779a 100644 --- a/resources/qml/WelcomePages/WhatsNewContent.qml +++ b/resources/qml/WelcomePages/WhatsNewContent.qml @@ -51,7 +51,7 @@ Item id: getStartedButton anchors.right: parent.right anchors.bottom: parent.bottom - text: catalog.i18nc("@button", "Next") + text: base.currentItem.next_page_button_text onClicked: base.showNextPage() } } From 3794c8f75e9dde99f3cf373a0ab1a95a4cdc786f Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 12 Apr 2019 11:09:10 +0200 Subject: [PATCH 21/27] Remove ChangeLog plugin CURA-6436 CURA-6447 --- plugins/ChangeLogPlugin/ChangeLog.py | 65 --------------------------- plugins/ChangeLogPlugin/ChangeLog.qml | 43 ------------------ plugins/ChangeLogPlugin/__init__.py | 11 ----- plugins/ChangeLogPlugin/plugin.json | 8 ---- resources/bundled_packages/cura.json | 17 ------- 5 files changed, 144 deletions(-) delete mode 100644 plugins/ChangeLogPlugin/ChangeLog.py delete mode 100644 plugins/ChangeLogPlugin/ChangeLog.qml delete mode 100644 plugins/ChangeLogPlugin/__init__.py delete mode 100644 plugins/ChangeLogPlugin/plugin.json diff --git a/plugins/ChangeLogPlugin/ChangeLog.py b/plugins/ChangeLogPlugin/ChangeLog.py deleted file mode 100644 index 241d7a8953..0000000000 --- a/plugins/ChangeLogPlugin/ChangeLog.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2019 Ultimaker B.V. -# Cura is released under the terms of the LGPLv3 or higher. - -import os.path - -from PyQt5.QtCore import QObject - -from UM.i18n import i18nCatalog -from UM.Extension import Extension -from UM.Application import Application -from UM.PluginRegistry import PluginRegistry -from UM.Version import Version - -catalog = i18nCatalog("cura") - - -class ChangeLog(Extension, QObject): - def __init__(self, parent = None): - QObject.__init__(self, parent) - Extension.__init__(self) - self._changelog_window = None - self._changelog_context = None - version_string = Application.getInstance().getVersion() - if version_string is not "master": - self._current_app_version = Version(version_string) - else: - self._current_app_version = None - - Application.getInstance().engineCreatedSignal.connect(self._onEngineCreated) - Application.getInstance().getPreferences().addPreference("general/latest_version_changelog_shown", "2.0.0") #First version of CURA with uranium - self.setMenuName(catalog.i18nc("@item:inmenu", "Changelog")) - self.addMenuItem(catalog.i18nc("@item:inmenu", "Show Changelog"), self.showChangelog) - - def _onEngineCreated(self): - if not self._current_app_version: - return #We're on dev branch. - - if Application.getInstance().getPreferences().getValue("general/latest_version_changelog_shown") == "master": - latest_version_shown = Version("0.0.0") - else: - latest_version_shown = Version(Application.getInstance().getPreferences().getValue("general/latest_version_changelog_shown")) - - Application.getInstance().getPreferences().setValue("general/latest_version_changelog_shown", Application.getInstance().getVersion()) - - # Do not show the changelog when there is no global container stack - # This implies we are running Cura for the first time. - if not Application.getInstance().getGlobalContainerStack(): - return - - if self._current_app_version > latest_version_shown: - self.showChangelog() - - def showChangelog(self): - if not self._changelog_window: - self.createChangelogWindow() - - self._changelog_window.show() - - def hideChangelog(self): - if self._changelog_window: - self._changelog_window.hide() - - def createChangelogWindow(self): - path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "ChangeLog.qml") - self._changelog_window = Application.getInstance().createQmlComponent(path, {"manager": self}) diff --git a/plugins/ChangeLogPlugin/ChangeLog.qml b/plugins/ChangeLogPlugin/ChangeLog.qml deleted file mode 100644 index 7089a56caf..0000000000 --- a/plugins/ChangeLogPlugin/ChangeLog.qml +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2015 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.1 -import QtQuick.Controls 1.3 -import QtQuick.Layouts 1.1 -import QtQuick.Window 2.1 - -import UM 1.3 as UM -import Cura 1.0 as Cura - - -UM.Dialog -{ - id: base - minimumWidth: (UM.Theme.getSize("modal_window_minimum").width * 0.75) | 0 - minimumHeight: (UM.Theme.getSize("modal_window_minimum").height * 0.75) | 0 - width: minimumWidth - height: minimumHeight - title: catalog.i18nc("@label", "Changelog") - - TextArea - { - anchors.fill: parent - text: CuraApplication.getTextManager().getChangeLogText() - readOnly: true; - textFormat: TextEdit.RichText - } - - rightButtons: [ - Button - { - UM.I18nCatalog - { - id: catalog - name: "cura" - } - - text: catalog.i18nc("@action:button", "Close") - onClicked: base.hide() - } - ] -} diff --git a/plugins/ChangeLogPlugin/__init__.py b/plugins/ChangeLogPlugin/__init__.py deleted file mode 100644 index a5452b60c8..0000000000 --- a/plugins/ChangeLogPlugin/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2015 Ultimaker B.V. -# Cura is released under the terms of the LGPLv3 or higher. - -from . import ChangeLog - - -def getMetaData(): - return {} - -def register(app): - return {"extension": ChangeLog.ChangeLog()} diff --git a/plugins/ChangeLogPlugin/plugin.json b/plugins/ChangeLogPlugin/plugin.json deleted file mode 100644 index 92041d1543..0000000000 --- a/plugins/ChangeLogPlugin/plugin.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "Changelog", - "author": "Ultimaker B.V.", - "version": "1.0.1", - "description": "Shows changes since latest checked version.", - "api": "6.0", - "i18n-catalog": "cura" -} diff --git a/resources/bundled_packages/cura.json b/resources/bundled_packages/cura.json index 3dcc02a503..cf8ecfb010 100644 --- a/resources/bundled_packages/cura.json +++ b/resources/bundled_packages/cura.json @@ -33,23 +33,6 @@ } } }, - "ChangeLogPlugin": { - "package_info": { - "package_id": "ChangeLogPlugin", - "package_type": "plugin", - "display_name": "Change Log", - "description": "Shows changes since latest checked version.", - "package_version": "1.0.1", - "sdk_version": "6.0.0", - "website": "https://ultimaker.com", - "author": { - "author_id": "UltimakerPackages", - "display_name": "Ultimaker B.V.", - "email": "plugins@ultimaker.com", - "website": "https://ultimaker.com" - } - } - }, "CuraDrive": { "package_info": { "package_id": "CuraDrive", From f30348559554066b3bfa48a6c3c0cfc8338c19eb Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 12 Apr 2019 11:12:17 +0200 Subject: [PATCH 22/27] Remove changelog preferences entry in version upgrade CURA-6436 CURA-6447 --- .../VersionUpgrade40to41/VersionUpgrade40to41.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/VersionUpgrade/VersionUpgrade40to41/VersionUpgrade40to41.py b/plugins/VersionUpgrade/VersionUpgrade40to41/VersionUpgrade40to41.py index d80e0007aa..ad22bf2ee9 100644 --- a/plugins/VersionUpgrade/VersionUpgrade40to41/VersionUpgrade40to41.py +++ b/plugins/VersionUpgrade/VersionUpgrade40to41/VersionUpgrade40to41.py @@ -62,6 +62,11 @@ class VersionUpgrade40to41(VersionUpgrade): parser["general"]["version"] = "6" if "metadata" not in parser: parser["metadata"] = {} + + # Remove changelog plugin + if "latest_version_changelog_shown" in parser["general"]: + del parser["general"]["latest_version_changelog_shown"] + parser["metadata"]["setting_version"] = "7" result = io.StringIO() From 0fe65558810b1f9d16448dc8561ac9b63cdd8ced Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 15 Apr 2019 13:09:44 +0200 Subject: [PATCH 23/27] Remove debug code CURA-6447 --- cura/CuraApplication.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index d5ab2bd706..60722c4767 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1786,8 +1786,6 @@ class CuraApplication(QtApplication): has_active_machine = self._machine_manager.activeMachine is not None has_app_just_upgraded = self.hasJustUpdatedFromOldVersion() - print("!!!!!!!!!!!!! has_active_machine = ", has_active_machine) - # Only show the what's new dialog if there's no machine and we have just upgraded show_whatsnew_only = has_active_machine and has_app_just_upgraded return show_whatsnew_only From 46fa45768afcad824fd2a893a9100c69e0a1a18e Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 17 Apr 2019 09:34:59 +0200 Subject: [PATCH 24/27] Simplify shouldShowWelcomeDialog() CURA-6447 --- cura/CuraApplication.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 60722c4767..0310526c2e 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1775,11 +1775,8 @@ class CuraApplication(QtApplication): @pyqtSlot(result = bool) def shouldShowWelcomeDialog(self) -> bool: - has_active_machine = self._machine_manager.activeMachine is not None - - # Only show the complete flow if there is not printer yet. - show_complete_flow = not has_active_machine - return show_complete_flow + # Only show the complete flow if there is no printer yet. + return self._machine_manager.activeMachine is None @pyqtSlot(result = bool) def shouldShowWhatsNewDialog(self) -> bool: From 64cb86217e5f74ddb723284ba437bc26e79ef632 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 17 Apr 2019 09:36:01 +0200 Subject: [PATCH 25/27] Remove non-existing icon CURA-6447 --- resources/qml/Actions.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index ed89eb553e..ce9618a560 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -234,7 +234,6 @@ Item { id: whatsNewAction; text: catalog.i18nc("@action:inmenu menubar:help", "What's New"); - iconName: "help-whats-new"; } Action From a49d00c60ee03284dfe67492bfbe2807ae38bc6f Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 17 Apr 2019 09:42:40 +0200 Subject: [PATCH 26/27] Move some code into Component.onCompleted CURA-6447 --- resources/qml/Cura.qml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 08fbc95b0e..1b05b6987a 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -68,12 +68,17 @@ UM.MainWindow z: greyOutBackground.z + 1 } + Component.onCompleted: + { + CuraApplication.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size")) + CuraApplication.purgeWindows() + } + Connections { target: CuraApplication onInitializationFinished: { - CuraApplication.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size")) // Workaround silly issues with QML Action's shortcut property. // // Currently, there is no way to define shortcuts as "Application Shortcut". @@ -85,7 +90,6 @@ UM.MainWindow // // This has been fixed for QtQuick Controls 2 since the Shortcut item has a context property. Cura.Actions.parent = backgroundItem - CuraApplication.purgeWindows() if (CuraApplication.shouldShowWelcomeDialog()) { From 44a0f00f0b32e9f2e78632bc1c8a98551b191fef Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 17 Apr 2019 09:58:05 +0200 Subject: [PATCH 27/27] Reuse welcome dialog item to show whats new upon start CURA-6447 --- resources/qml/Cura.qml | 18 ++++-------------- .../qml/WelcomePages/WelcomeDialogItem.qml | 1 + 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 1b05b6987a..f5cbe8ad53 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -100,26 +100,16 @@ UM.MainWindow welcomeDialogItem.visible = false } + // Reuse the welcome dialog item to show "What's New" only. if (CuraApplication.shouldShowWhatsNewDialog()) { - showWhatsNewDialogTimer.start() + welcomeDialogItem.model = CuraApplication.getWhatsNewPagesModel() + welcomeDialogItem.progressBarVisible = false + welcomeDialogItem.visible = true } } } - // HACK: Use a timer here because if we call "Cura.Actions.whatsNew.trigger()" or "whatsNewDialog.show()" when - // the component gets completed or when the application finishes its initialization, the main window has not been - // fully initialized yet. If we should the dialog before the main window is fully initialized, you will see the - // dialog first but when the main windows is fully initialized, the dialog will disappear. Adding a timer here is - // to bypass this problem. - Timer - { - id: showWhatsNewDialogTimer - repeat: false - interval: 1000 - onTriggered: Cura.Actions.whatsNew.trigger() - } - Item { id: backgroundItem diff --git a/resources/qml/WelcomePages/WelcomeDialogItem.qml b/resources/qml/WelcomePages/WelcomeDialogItem.qml index 1ab722598b..7da4c6e897 100644 --- a/resources/qml/WelcomePages/WelcomeDialogItem.qml +++ b/resources/qml/WelcomePages/WelcomeDialogItem.qml @@ -26,6 +26,7 @@ Item property int shadowOffset: 1 * screenScaleFactor + property alias progressBarVisible: wizardPanel.progressBarVisible property var model: CuraApplication.getWelcomePagesModel() onVisibleChanged: