From 98b7df790d3d2d59a08a061a3353c5b41ef13aba Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 26 Mar 2019 15:18:54 +0100 Subject: [PATCH 1/2] Implement More-info button on Data Collection page --- .../WelcomePages/DataCollectionsContent.qml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/resources/qml/WelcomePages/DataCollectionsContent.qml b/resources/qml/WelcomePages/DataCollectionsContent.qml index 2990b16795..23d3ad85a5 100644 --- a/resources/qml/WelcomePages/DataCollectionsContent.qml +++ b/resources/qml/WelcomePages/DataCollectionsContent.qml @@ -36,11 +36,12 @@ Item anchors.bottom: getStartedButton.top anchors.left: parent.left anchors.right: parent.right - anchors.margins: UM.Theme.getSize("default_margin").width + anchors.margins: UM.Theme.getSize("welcome_pages_default_margin").width Column { anchors.centerIn: parent + width: parent.width spacing: UM.Theme.getSize("welcome_pages_default_margin").height @@ -54,12 +55,29 @@ Item Label { id: textLabel + width: parent.width anchors.horizontalCenter: parent.horizontalCenter horizontalAlignment: Text.AlignHCenter - text: catalog.i18nc("@text", "Ultimaker Cura collects anonymous data to improve print quality
and user experience. More information") + text: + { + var t = catalog.i18nc("@text", "Ultimaker Cura collects anonymous data to improve print quality and user experience.") + var t2 = catalog.i18nc("@text", "More information") + t += " " + t2 + "" + return t + } textFormat: Text.RichText + wrapMode: Text.WordWrap font: UM.Theme.getFont("medium") renderType: Text.NativeRendering + + MouseArea + { + anchors.fill: parent + onClicked: + { + CuraApplication.showMoreInformationDialogForAnonymousDataCollection() + } + } } } } From 6843fb1ffb7091df767123cbeb350a68233d4104 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 26 Mar 2019 15:46:02 +0100 Subject: [PATCH 2/2] Load change log from file for on-boarding page --- cura/CuraApplication.py | 7 ++ cura/UI/TextManager.py | 64 +++++++++++++++++++ plugins/ChangeLogPlugin/ChangeLog.py | 58 ++--------------- plugins/ChangeLogPlugin/ChangeLog.qml | 6 +- .../qml/WelcomePages/WhatsNewContent.qml | 13 +--- .../texts/change_log.txt | 0 6 files changed, 83 insertions(+), 65 deletions(-) create mode 100644 cura/UI/TextManager.py rename plugins/ChangeLogPlugin/ChangeLog.txt => resources/texts/change_log.txt (100%) mode change 100755 => 100644 diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 951f1460d2..2f73d88481 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -109,6 +109,7 @@ import cura.Settings.cura_empty_instance_containers from cura.Settings.CuraFormulaFunctions import CuraFormulaFunctions from cura.UI.ObjectsModel import ObjectsModel +from cura.UI.TextManager import TextManager from cura.Machines.Models.DiscoveredPrintersModel import DiscoveredPrintersModel @@ -211,6 +212,7 @@ class CuraApplication(QtApplication): self._discovered_printer_model = DiscoveredPrintersModel(self) self._welcome_pages_model = WelcomePagesModel(self) + self._text_manager = TextManager(self) self._quality_profile_drop_down_menu_model = None self._custom_quality_profile_drop_down_menu_model = None @@ -862,6 +864,10 @@ class CuraApplication(QtApplication): def getWelcomePagesModel(self, *args) -> "WelcomePagesModel": return self._welcome_pages_model + @pyqtSlot(result = QObject) + def getTextManager(self, *args) -> "TextManager": + return self._text_manager + def getCuraFormulaFunctions(self, *args) -> "CuraFormulaFunctions": if self._cura_formula_functions is None: self._cura_formula_functions = CuraFormulaFunctions(self) @@ -995,6 +1001,7 @@ class CuraApplication(QtApplication): qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager) qmlRegisterType(WelcomePagesModel, "Cura", 1, 0, "WelcomePagesModel") + qmlRegisterType(TextManager, "Cura", 1, 0, "TextManager") qmlRegisterType(NetworkMJPGImage, "Cura", 1, 0, "NetworkMJPGImage") diff --git a/cura/UI/TextManager.py b/cura/UI/TextManager.py new file mode 100644 index 0000000000..a2708801bb --- /dev/null +++ b/cura/UI/TextManager.py @@ -0,0 +1,64 @@ +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +import collections +from typing import Optional + +from PyQt5.QtCore import QObject, pyqtSlot + +from UM.Resources import Resources +from UM.Version import Version + + +# +# This manager provides means to load texts to QML. +# +class TextManager(QObject): + + def __init__(self, parent: Optional["QObject"] = None) -> None: + super().__init__(parent) + + self._change_log_text = "" + + @pyqtSlot(result = str) + def getChangeLogText(self) -> str: + if not self._change_log_text: + self._change_log_text = self._loadChangeLogText() + return self._change_log_text + + def _loadChangeLogText(self) -> str: + # Load change log texts and organize them with a dict + file_path = Resources.getPath(Resources.Texts, "change_log.txt") + change_logs_dict = {} + with open(file_path, "r", encoding = "utf-8") as f: + open_version = None + open_header = "" # Initialise to an empty header in case there is no "*" in the first line of the changelog + for line in f: + line = line.replace("\n", "") + if "[" in line and "]" in line: + line = line.replace("[", "") + line = line.replace("]", "") + open_version = Version(line) + open_header = "" + change_logs_dict[open_version] = collections.OrderedDict() + elif line.startswith("*"): + open_header = line.replace("*", "") + change_logs_dict[open_version][open_header] = [] + elif line != "": + if open_header not in change_logs_dict[open_version]: + change_logs_dict[open_version][open_header] = [] + change_logs_dict[open_version][open_header].append(line) + + # Format changelog text + content = "" + for version in change_logs_dict: + content += "

" + str(version) + "


" + content += "" + for change in change_logs_dict[version]: + if str(change) != "": + content += "" + str(change) + "
" + for line in change_logs_dict[version][change]: + content += str(line) + "
" + content += "
" + + return content diff --git a/plugins/ChangeLogPlugin/ChangeLog.py b/plugins/ChangeLogPlugin/ChangeLog.py index eeec5edf9b..241d7a8953 100644 --- a/plugins/ChangeLogPlugin/ChangeLog.py +++ b/plugins/ChangeLogPlugin/ChangeLog.py @@ -1,20 +1,20 @@ -# Copyright (c) 2018 Ultimaker B.V. +# 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 -from PyQt5.QtCore import pyqtSlot, QObject - -import os.path -import collections - catalog = i18nCatalog("cura") -class ChangeLog(Extension, QObject,): + +class ChangeLog(Extension, QObject): def __init__(self, parent = None): QObject.__init__(self, parent) Extension.__init__(self) @@ -26,55 +26,11 @@ class ChangeLog(Extension, QObject,): else: self._current_app_version = None - self._change_logs = 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 getChangeLogs(self): - if not self._change_logs: - self.loadChangeLogs() - return self._change_logs - - @pyqtSlot(result = str) - def getChangeLogString(self): - logs = self.getChangeLogs() - result = "" - for version in logs: - result += "

" + str(version) + "


" - result += "" - for change in logs[version]: - if str(change) != "": - result += "" + str(change) + "
" - for line in logs[version][change]: - result += str(line) + "
" - result += "
" - - pass - return result - - def loadChangeLogs(self): - self._change_logs = collections.OrderedDict() - with open(os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "ChangeLog.txt"), "r", encoding = "utf-8") as f: - open_version = None - open_header = "" # Initialise to an empty header in case there is no "*" in the first line of the changelog - for line in f: - line = line.replace("\n","") - if "[" in line and "]" in line: - line = line.replace("[","") - line = line.replace("]","") - open_version = Version(line) - open_header = "" - self._change_logs[open_version] = collections.OrderedDict() - elif line.startswith("*"): - open_header = line.replace("*","") - self._change_logs[open_version][open_header] = [] - elif line != "": - if open_header not in self._change_logs[open_version]: - self._change_logs[open_version][open_header] = [] - self._change_logs[open_version][open_header].append(line) - def _onEngineCreated(self): if not self._current_app_version: return #We're on dev branch. diff --git a/plugins/ChangeLogPlugin/ChangeLog.qml b/plugins/ChangeLogPlugin/ChangeLog.qml index 512687f15a..7089a56caf 100644 --- a/plugins/ChangeLogPlugin/ChangeLog.qml +++ b/plugins/ChangeLogPlugin/ChangeLog.qml @@ -6,7 +6,9 @@ import QtQuick.Controls 1.3 import QtQuick.Layouts 1.1 import QtQuick.Window 2.1 -import UM 1.1 as UM +import UM 1.3 as UM +import Cura 1.0 as Cura + UM.Dialog { @@ -20,7 +22,7 @@ UM.Dialog TextArea { anchors.fill: parent - text: manager.getChangeLogString() + text: CuraApplication.getTextManager().getChangeLogText() readOnly: true; textFormat: TextEdit.RichText } diff --git a/resources/qml/WelcomePages/WhatsNewContent.qml b/resources/qml/WelcomePages/WhatsNewContent.qml index 097470e444..8e545d237f 100644 --- a/resources/qml/WelcomePages/WhatsNewContent.qml +++ b/resources/qml/WelcomePages/WhatsNewContent.qml @@ -50,18 +50,7 @@ Item TextArea { id: whatsNewTextArea - text: catalog.i18nc("@text", "

Ultimaker Cura 4.0

- -

New features

- -

Brand new user interface. Ultimaker Cura is a very powerful tool with many features to support users’ needs. In the new UI, we present these features in a better, more intuitive way based on the workflow of our users. The Marketplace and user account control have been integrated into the main interface to easily access material profiles and plugins. Within the UI, three stages are shown in the header to give a clear guidance of the flow. The stage menu is populated with collapsible panels that allow users to focus on the 3D view when needed, while still showing important information at the same time, such as slicing configuration and settings. Users can now easily go to the preview stage to examine the layer view after slicing the model, which previously was less obvious or hidden. The new UI also creates more distinction between recommended and custom mode. Novice users or users who are not interested in all the settings can easily prepare a file without diving into details. Expert users can use custom mode with a resizable settings panel to make more settings visible, and the set position will persist between sessions.

- -

Cloud printing. Pair your Ultimaker printer with an Ultimaker account so you can send and monitor print jobs from outside your local network.

- -

Redesigned "Add Printer" dialog. Updated one of the first dialogs a new user is presented with. The layout is loosely modeled on the layout of the Ultimaker 3/Ultimaker S5 "Connect to Network" dialog, and adds some instructions and intention to the dialog. Contributed by fieldOfView.

- -

Integrated backups. Cura backups has been integrated into Ultimaker Cura and can be found in the 'extensions' menu. With this feature, users can backup their Ultimaker Cura configurations to the cloud.

- ") + text: CuraApplication.getTextManager().getChangeLogText() textFormat: Text.RichText wrapMode: Text.WordWrap readOnly: true diff --git a/plugins/ChangeLogPlugin/ChangeLog.txt b/resources/texts/change_log.txt old mode 100755 new mode 100644 similarity index 100% rename from plugins/ChangeLogPlugin/ChangeLog.txt rename to resources/texts/change_log.txt