From 654cd8e645722e2cdcd2c45eb70acf1f8b7e3499 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Thu, 24 Jan 2019 18:08:02 +0100 Subject: [PATCH 1/7] MaterialInfo: Begin replace HTML-text with QML-elements for 'by material-type'. [CURA-6141] --- .../qml/ActionPanel/PrintJobInformation.qml | 65 +++++++++++-------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/resources/qml/ActionPanel/PrintJobInformation.qml b/resources/qml/ActionPanel/PrintJobInformation.qml index 8bd5d5a0d3..7b6d70d80b 100644 --- a/resources/qml/ActionPanel/PrintJobInformation.qml +++ b/resources/qml/ActionPanel/PrintJobInformation.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2019 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -85,31 +85,18 @@ Column Label { + id: byMaterialType + property var printMaterialLengths: PrintInformation.materialLengths property var printMaterialWeights: PrintInformation.materialWeights property var printMaterialCosts: PrintInformation.materialCosts property var printMaterialNames: PrintInformation.materialNames + property var columnWidthMultipliers: [ 0.4, 0.2, 0.2, 0.2 ] - function formatRow(items) + function getMaterialTable() { - var rowHTML = "" - for(var item = 0; item < items.length; item++) - { - if (item == 0) - { - rowHTML += "%1".arg(items[item]) - } - else - { - rowHTML += "  %1".arg(items[item]) - } - } - rowHTML += "" - return rowHTML - } + var result = [] - text: - { var lengths = [] var weights = [] var costs = [] @@ -135,20 +122,42 @@ Column costs = ["0.00"] } - var text = "" for(var index = 0; index < lengths.length; index++) { - text += formatRow([ - "%1:".arg(names[index]), - catalog.i18nc("@label m for meter", "%1m").arg(lengths[index]), - catalog.i18nc("@label g for grams", "%1g").arg(weights[index]), - "%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]), - ]) + var row = [] + row.push("%1:".arg(names[index])) + row.push(catalog.i18nc("@label m for meter", "%1m").arg(lengths[index])) + row.push(catalog.i18nc("@label g for grams", "%1g").arg(weights[index])) + row.push("%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index])) + result.push(row) } - text += "
" - return text + return result } + + Column + { + Repeater + { + model: byMaterialType.getMaterialTable() + + Row + { + //property var rowLength: modelData.length + Repeater + { + model: modelData + Text + { + width: Math.round(byMaterialType.width * byMaterialType.columnWidthMultipliers[index]) + wrapMode: Text.WrapAnywhere + text: modelData + } + } + } + } + } + width: parent.width - 2 * UM.Theme.getSize("default_margin").width color: UM.Theme.getColor("text") font: UM.Theme.getFont("default") From 7fdbb11f492e00ec75dfcf8037a00aad75b94799 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Thu, 24 Jan 2019 21:56:22 +0100 Subject: [PATCH 2/7] MaterialInfo: Put height and fonts by QML-elements for 'by material-type'. [CURA-6141] --- resources/qml/ActionPanel/PrintJobInformation.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/qml/ActionPanel/PrintJobInformation.qml b/resources/qml/ActionPanel/PrintJobInformation.qml index 7b6d70d80b..daac6e0a19 100644 --- a/resources/qml/ActionPanel/PrintJobInformation.qml +++ b/resources/qml/ActionPanel/PrintJobInformation.qml @@ -140,16 +140,16 @@ Column Repeater { model: byMaterialType.getMaterialTable() - Row { - //property var rowLength: modelData.length Repeater { model: modelData Text { width: Math.round(byMaterialType.width * byMaterialType.columnWidthMultipliers[index]) + height: contentHeight + font: UM.Theme.getFont("default") wrapMode: Text.WrapAnywhere text: modelData } @@ -159,6 +159,7 @@ Column } width: parent.width - 2 * UM.Theme.getSize("default_margin").width + height: childrenRect.height color: UM.Theme.getColor("text") font: UM.Theme.getFont("default") renderType: Text.NativeRendering From e7ff70870f046df820c676791aec4aecc6daf78e Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Sat, 26 Jan 2019 11:25:38 +0100 Subject: [PATCH 3/7] MaterialInfo: Also replace HTML-text with QML-elements for 'by line-type'. [CURA-6141] --- .../qml/ActionPanel/PrintJobInformation.qml | 48 +++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/resources/qml/ActionPanel/PrintJobInformation.qml b/resources/qml/ActionPanel/PrintJobInformation.qml index daac6e0a19..50e4343626 100644 --- a/resources/qml/ActionPanel/PrintJobInformation.qml +++ b/resources/qml/ActionPanel/PrintJobInformation.qml @@ -36,30 +36,60 @@ Column Label { - property var printDuration: PrintInformation.currentPrintTime + id: byLineType - text: + property var printDuration: PrintInformation.currentPrintTime + property var columnWidthMultipliers: [ 0.4, 0.3, 0.3 ] + + function getMaterialTable() { + var result = [] + // All the time information for the different features is achieved var printTime = PrintInformation.getFeaturePrintTimes() var totalSeconds = parseInt(printDuration.getDisplayString(UM.DurationFormat.Seconds)) // A message is created and displayed when the user hover the time label - var text = "" for(var feature in printTime) { if(!printTime[feature].isTotalDurationZero) { - text += "" + - "".arg(printTime[feature].getDisplayString(UM.DurationFormat.ISO8601).slice(0,-3)) + - "".arg(Math.round(100 * parseInt(printTime[feature].getDisplayString(UM.DurationFormat.Seconds)) / totalSeconds)) + - "" + var row = [] + row.push(feature + ":") + row.push("%1".arg(printTime[feature].getDisplayString(UM.DurationFormat.ISO8601).slice(0,-3))) + row.push("%1%".arg(Math.round(100 * parseInt(printTime[feature].getDisplayString(UM.DurationFormat.Seconds)) / totalSeconds))) + result.push(row) } } - text += "
" + feature + ":  %1  %1%
" - return text + + return result } + + Column + { + Repeater + { + model: byLineType.getMaterialTable() + Row + { + Repeater + { + model: modelData + Text + { + width: Math.round(byLineType.width * byLineType.columnWidthMultipliers[index]) + height: contentHeight + font: UM.Theme.getFont("default") + wrapMode: Text.WrapAnywhere + text: modelData + } + } + } + } + } + width: parent.width - 2 * UM.Theme.getSize("default_margin").width + height: childrenRect.height color: UM.Theme.getColor("text") font: UM.Theme.getFont("default") renderType: Text.NativeRendering From 3d413ceb2c33dcea49287dcb9a258f7dc6eb78a5 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Sat, 26 Jan 2019 11:43:15 +0100 Subject: [PATCH 4/7] MaterialInfo: Tweak text-alignment/layout. [CURA-6141] --- resources/qml/ActionPanel/PrintJobInformation.qml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/qml/ActionPanel/PrintJobInformation.qml b/resources/qml/ActionPanel/PrintJobInformation.qml index 50e4343626..483fe76812 100644 --- a/resources/qml/ActionPanel/PrintJobInformation.qml +++ b/resources/qml/ActionPanel/PrintJobInformation.qml @@ -40,6 +40,7 @@ Column property var printDuration: PrintInformation.currentPrintTime property var columnWidthMultipliers: [ 0.4, 0.3, 0.3 ] + property var columnHorizontalAligns: [ TextInput.AlignLeft, TextInput.AlignHCenter, TextInput.AlignHCenter ] function getMaterialTable() { @@ -55,7 +56,7 @@ Column if(!printTime[feature].isTotalDurationZero) { var row = [] - row.push(feature + ":") + row.push(feature + ": ") row.push("%1".arg(printTime[feature].getDisplayString(UM.DurationFormat.ISO8601).slice(0,-3))) row.push("%1%".arg(Math.round(100 * parseInt(printTime[feature].getDisplayString(UM.DurationFormat.Seconds)) / totalSeconds))) result.push(row) @@ -79,6 +80,7 @@ Column { width: Math.round(byLineType.width * byLineType.columnWidthMultipliers[index]) height: contentHeight + horizontalAlignment: byLineType.columnHorizontalAligns[index] font: UM.Theme.getFont("default") wrapMode: Text.WrapAnywhere text: modelData @@ -122,6 +124,7 @@ Column property var printMaterialCosts: PrintInformation.materialCosts property var printMaterialNames: PrintInformation.materialNames property var columnWidthMultipliers: [ 0.4, 0.2, 0.2, 0.2 ] + property var columnHorizontalAligns: [ TextInput.AlignLeft, TextInput.AlignHCenter, TextInput.AlignHCenter, TextInput.AlignHCenter ] function getMaterialTable() { @@ -155,7 +158,7 @@ Column for(var index = 0; index < lengths.length; index++) { var row = [] - row.push("%1:".arg(names[index])) + row.push("%1: ".arg(names[index])) row.push(catalog.i18nc("@label m for meter", "%1m").arg(lengths[index])) row.push(catalog.i18nc("@label g for grams", "%1g").arg(weights[index])) row.push("%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index])) @@ -179,6 +182,7 @@ Column { width: Math.round(byMaterialType.width * byMaterialType.columnWidthMultipliers[index]) height: contentHeight + horizontalAlignment: byLineType.columnHorizontalAligns[index] font: UM.Theme.getFont("default") wrapMode: Text.WrapAnywhere text: modelData From 71b2787d0de0ab18054109fc284f3b8b53271f47 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 28 Jan 2019 08:47:58 +0100 Subject: [PATCH 5/7] Use Label CURA-6141 --- resources/qml/ActionPanel/PrintJobInformation.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/ActionPanel/PrintJobInformation.qml b/resources/qml/ActionPanel/PrintJobInformation.qml index 483fe76812..45b3846f38 100644 --- a/resources/qml/ActionPanel/PrintJobInformation.qml +++ b/resources/qml/ActionPanel/PrintJobInformation.qml @@ -76,7 +76,7 @@ Column Repeater { model: modelData - Text + Label { width: Math.round(byLineType.width * byLineType.columnWidthMultipliers[index]) height: contentHeight @@ -178,7 +178,7 @@ Column Repeater { model: modelData - Text + Label { width: Math.round(byMaterialType.width * byMaterialType.columnWidthMultipliers[index]) height: contentHeight From c6ff8149f6a6730e482f169908a323a4de5d1f1c Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 28 Jan 2019 09:04:04 +0100 Subject: [PATCH 6/7] Remove colon according to design CURA-6141 --- resources/qml/ActionPanel/PrintJobInformation.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/ActionPanel/PrintJobInformation.qml b/resources/qml/ActionPanel/PrintJobInformation.qml index 45b3846f38..a8d3dad164 100644 --- a/resources/qml/ActionPanel/PrintJobInformation.qml +++ b/resources/qml/ActionPanel/PrintJobInformation.qml @@ -158,7 +158,7 @@ Column for(var index = 0; index < lengths.length; index++) { var row = [] - row.push("%1: ".arg(names[index])) + row.push("%1".arg(names[index])) row.push(catalog.i18nc("@label m for meter", "%1m").arg(lengths[index])) row.push(catalog.i18nc("@label g for grams", "%1g").arg(weights[index])) row.push("%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index])) From 1f21eed14f5dae0383d353f96d1b17327b1f0d72 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 28 Jan 2019 09:05:40 +0100 Subject: [PATCH 7/7] Add Text.NativeRendering for Labels CURA-6141 --- resources/qml/ActionPanel/PrintJobInformation.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/qml/ActionPanel/PrintJobInformation.qml b/resources/qml/ActionPanel/PrintJobInformation.qml index a8d3dad164..7cd466c33f 100644 --- a/resources/qml/ActionPanel/PrintJobInformation.qml +++ b/resources/qml/ActionPanel/PrintJobInformation.qml @@ -84,6 +84,7 @@ Column font: UM.Theme.getFont("default") wrapMode: Text.WrapAnywhere text: modelData + renderType: Text.NativeRendering } } } @@ -186,6 +187,7 @@ Column font: UM.Theme.getFont("default") wrapMode: Text.WrapAnywhere text: modelData + renderType: Text.NativeRendering } } }