From e98be96b0d3677cfa250505adc91fb22a8ea2bd3 Mon Sep 17 00:00:00 2001 From: Ad5001 Date: Wed, 19 Oct 2022 17:29:35 +0200 Subject: [PATCH] Latex rendering for property edition history action! --- .../js/history/editproperty.js | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/editproperty.js b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/editproperty.js index 3fca7b6..b2862a2 100644 --- a/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/editproperty.js +++ b/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/history/editproperty.js @@ -19,6 +19,7 @@ .pragma library .import "../objects.js" as Objects +.import "../math/latex.js" as Latex .import "../mathlib.js" as MathLib .import "../objs/common.js" as Common .import "common.js" as C @@ -77,30 +78,37 @@ class EditedProperty extends C.Action { } setReadableValues() { - this.prev = ""; - this.next = ""; + this.prevString = ""; + this.nextString = ""; if(this.propertyType instanceof Object) { switch(this.propertyType.type) { case "Enum": - this.prev = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.previousValue)] - this.next = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.newValue)] + this.prevString = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.previousValue)] + this.nextString = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.newValue)] break; case "ObjectType": - this.prev = this.previousValue == null ? "null" : this.previousValue.name - this.next = this.newValue == null ? "null" : this.newValue.name + this.prevString = this.previousValue == null ? "null" : this.previousValue.name + this.nextString = this.newValue == null ? "null" : this.newValue.name break; case "List": - this.prev = this.previousValue.join(",") - this.next = this.newValue.name.join(",") + this.prevString = this.previousValue.join(",") + this.nextString = this.newValue.name.join(",") break; case "Dict": - this.prev = JSON.stringify(this.previousValue) - this.next = JSON.stringify(this.newValue) + this.prevString = JSON.stringify(this.previousValue) + this.nextString = JSON.stringify(this.newValue) break; } } else { - this.prev = this.previousValue == null ? "null" : this.previousValue.toString() - this.next = this.newValue == null ? "null" : this.newValue.toString() + this.prevString = this.previousValue == null ? "null" : this.previousValue.toString() + this.nextString = this.newValue == null ? "null" : this.newValue.toString() + } + // HTML + this.prevHTML = ' '+this.prevString+' ' + this.nextHTML = ' '+this.nextString+' ' + if(Latex.enabled && this.propertyType == "Expression") { + this.prevHTML= this.renderLatexAsHtml(this.previousValue.latexMarkup) + this.nextHTML= this.renderLatexAsHtml(this.newValue.latexMarkup) } } @@ -108,16 +116,14 @@ class EditedProperty extends C.Action { return qsTr('%1 of %2 %3 changed from "%4" to "%5".') .arg(this.targetPropertyReadable) .arg(Objects.types[this.targetType].displayType()) - .arg(this.targetName).arg(this.prev).arg(this.next) + .arg(this.targetName).arg(this.prevString).arg(this.nextString) } getHTMLString() { return qsTr('%1 of %2 changed from %3 to %4.') .arg(this.targetPropertyReadable) .arg(' ' + this.targetName + ' ') - .arg(' '+this.prev+' ') - .arg(' '+this.next+' ') -// .arg('' + Objects.types[this.targetType].displayType()) - + .arg(this.prevHTML) + .arg(this.nextHTML) } }