Compare commits

..

No commits in common. "23c3b771c2e6cd03c746d66a2f3c5c1fff3bb06a" and "7ef55e48e827808b210c53917c0f73469898c6b3" have entirely different histories.

256 changed files with 1991 additions and 7546 deletions

27
.gitignore vendored
View file

@ -1,19 +1,13 @@
# Building
build/ build/
dist/ dist/
deb_dist/ deb_dist/
assets/linux/flatpak/AppDir linux/flatpak/AppDir
assets/linux/flatpak/repo linux/flatpak/repo
assets/linux/flatpak/build-dir linux/flatpak/build-dir
assets/linux/flatpak/.flatpak-builder linux/flatpak/.flatpak-builder
*.snap *.snap
*.spec *.spec
*.zip *.zip
*.tar.gz
*.spec
*.egg-info/
# Runtime data
**/**.qmlc **/**.qmlc
**/**.jsc **/**.jsc
**/**.pyc **/**.pyc
@ -26,19 +20,16 @@ assets/linux/flatpak/.flatpak-builder
.DS_Store .DS_Store
**/.DS_Store **/.DS_Store
**/__pycache__/ **/__pycache__/
# IDE Data
.ropeproject .ropeproject
.vscode .vscode
*.kdev4 *.kdev4
.kdev4 .kdev4
.coverage
build
docs/html docs/html
.directory .directory
*.lpf *.lpf
*.lgg *.lgg
*.spec
# npm *.egg-info/
common/node_modules *.tar.gz
common/coverage/
common/.coverage
runtime-pyside6/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/index.mjs*

4
.gitmodules vendored
View file

@ -1,3 +1,3 @@
[submodule "runtime-pyside6/LogarithmPlotter/qml/eu/ad5001/MixedMenu"] [submodule "LogarithmPlotter/qml/eu/ad5001/MixedMenu"]
path = runtime-pyside6/LogarithmPlotter/qml/eu/ad5001/MixedMenu path = LogarithmPlotter/qml/eu/ad5001/MixedMenu
url = https://git.ad5001.eu/Ad5001/MixedMenu url = https://git.ad5001.eu/Ad5001/MixedMenu

View file

@ -4,7 +4,7 @@
# specificities so that lupdate doesn't cry out in pain. # specificities so that lupdate doesn't cry out in pain.
# See also: https://bugreports.qt.io/browse/QTBUG-123819 # See also: https://bugreports.qt.io/browse/QTBUG-123819
# #
escape() { escape() {
str="$1" str="$1"
str="${str//\//\\/}" # Escape slashes str="${str//\//\\/}" # Escape slashes
@ -19,20 +19,15 @@ replace() {
sed -i "s/${from}/${to}/g" "$file" sed -i "s/${from}/${to}/g" "$file"
} }
rm ../qml/eu/ad5001/LogarithmPlotter/js/index.mjs # Remove index which should not be scanned
files=$(find .. -name *.mjs) files=$(find .. -name *.mjs)
for file in $files; do for file in $files; do
echo "Moving '$file' to '${file%.*}.js'..." echo "Moving '$file' to '${file%.*}.js'..."
mv "$file" "${file%.*}.js" mv "$file" "${file%.*}.js"
# Replacements to make it valid js # Replacements to make it valid js
replace "${file%.*}.js" "^import" "/*import" replace "${file%.*}.js" "^import" "/*import"
replace "${file%.*}.js" "^export *" "/*export *"
replace "${file%.*}.js" '.mjs"$' '.mjs"*/' replace "${file%.*}.js" '.mjs"$' '.mjs"*/'
replace "${file%.*}.js" "^export default" "/*export default*/" replace "${file%.*}.js" "^export default" "/*export default*/"
replace "${file%.*}.js" "^export" "/*export*/" replace "${file%.*}.js" "^export" "/*export*/"
replace "${file%.*}.js" "async " "/*async */"
replace "${file%.*}.js" "await" "/*await */"
done done
echo "----------------------------" echo "----------------------------"
@ -43,6 +38,7 @@ lupdate -extensions js,qs,qml,py -recursive .. -ts lp_*.ts
for lp in *.ts; do for lp in *.ts; do
echo "Replacing locations in $lp..." echo "Replacing locations in $lp..."
for file in $files; do for file in $files; do
echo " > Replacing for file $file..."
replace "$lp" "${file%.*}.js" "$file" replace "$lp" "${file%.*}.js" "$file"
done done
done done
@ -51,11 +47,8 @@ for file in $files; do
echo "Moving '${file%.*}.js' to '$file'..." echo "Moving '${file%.*}.js' to '$file'..."
mv "${file%.*}.js" "$file" mv "${file%.*}.js" "$file"
# Resetting changes # Resetting changes
replace "$file" "/*await */" "await"
replace "$file" "/*async */" "async "
replace "$file" "^/*export*/" "export"
replace "$file" "^/*export default*/" "export default"
replace "$file" "^/*import" "import" replace "$file" "^/*import" "import"
replace "$file" "^/*export" "export"
replace "$file" '.mjs"*/$' '.mjs"' replace "$file" '.mjs"*/$' '.mjs"'
replace "$file" "^/*export default*/" "export default"
replace "$file" "^/*export*/" "export"
done done

View file

@ -43,7 +43,7 @@ if path.realpath(path.join(getcwd(), "..")) not in sys_path:
sys_path.append(path.realpath(path.join(getcwd(), ".."))) sys_path.append(path.realpath(path.join(getcwd(), "..")))
from LogarithmPlotter import __VERSION__ from LogarithmPlotter import __VERSION__
from LogarithmPlotter.util import config, native, debug from LogarithmPlotter.util import config, native
from LogarithmPlotter.util.update import check_for_updates from LogarithmPlotter.util.update import check_for_updates
from LogarithmPlotter.util.helper import Helper from LogarithmPlotter.util.helper import Helper
from LogarithmPlotter.util.latex import Latex from LogarithmPlotter.util.latex import Latex
@ -130,7 +130,7 @@ def create_engine(helper: Helper, latex: Latex, dep_time: float) -> tuple[QQmlAp
global tmpfile global tmpfile
engine = QQmlApplicationEngine() engine = QQmlApplicationEngine()
js_globals = PyJSValue(engine.globalObject()) js_globals = PyJSValue(engine.globalObject())
js_globals.globalThis = engine.globalObject() js_globals.Modules = engine.newObject()
js_globals.Helper = engine.newQObject(helper) js_globals.Helper = engine.newQObject(helper)
js_globals.Latex = engine.newQObject(latex) js_globals.Latex = engine.newQObject(latex)
engine.rootContext().setContextProperty("TestBuild", "--test-build" in argv) engine.rootContext().setContextProperty("TestBuild", "--test-build" in argv)
@ -155,7 +155,6 @@ def run():
register_icon_directories() register_icon_directories()
app = create_qapp() app = create_qapp()
translator = install_translation(app) translator = install_translation(app)
debug.setup()
# Installing macOS file handler. # Installing macOS file handler.
macos_file_open_handler = None macos_file_open_handler = None

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -20,7 +20,7 @@ import QtQuick
import Qt.labs.platform as Native import Qt.labs.platform as Native
//import QtQuick.Controls 2.15 //import QtQuick.Controls 2.15
import eu.ad5001.MixedMenu 1.1 import eu.ad5001.MixedMenu 1.1
import "js/index.mjs" as JS import "js/history/index.mjs" as HistoryLib
/*! /*!
@ -119,7 +119,7 @@ MenuBar {
icon.color: sysPalette.buttonText icon.color: sysPalette.buttonText
onTriggered: { onTriggered: {
var newObj = Modules.Objects.createNewRegisteredObject(modelData) var newObj = Modules.Objects.createNewRegisteredObject(modelData)
history.addToHistory(new JS.HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export())) history.addToHistory(new HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export()))
objectLists.update() objectLists.update()
} }
} }

View file

@ -19,7 +19,7 @@
import QtQuick import QtQuick
import QtQml import QtQml
import QtQuick.Window import QtQuick.Window
import "../js/index.mjs" as JS import "../js/history/index.mjs" as HistoryLib
/*! /*!
\qmltype History \qmltype History
@ -97,9 +97,9 @@ Item {
function unserialize(undoSt, redoSt) { function unserialize(undoSt, redoSt) {
clear(); clear();
for(let i = 0; i < undoSt.length; i++) for(let i = 0; i < undoSt.length; i++)
undoStack.push(new JS.HistoryLib.Actions[undoSt[i][0]](...undoSt[i][1])) undoStack.push(new HistoryLib.Actions[undoSt[i][0]](...undoSt[i][1]))
for(let i = 0; i < redoSt.length; i++) for(let i = 0; i < redoSt.length; i++)
redoStack.push(new JS.HistoryLib.Actions[redoSt[i][0]](...redoSt[i][1])) redoStack.push(new HistoryLib.Actions[redoSt[i][0]](...redoSt[i][1]))
undoCount = undoSt.length; undoCount = undoSt.length;
redoCount = redoSt.length; redoCount = redoSt.length;
objectLists.update() objectLists.update()
@ -110,7 +110,7 @@ Item {
Adds an instance of HistoryLib.Action to history. Adds an instance of HistoryLib.Action to history.
*/ */
function addToHistory(action) { function addToHistory(action) {
if(action instanceof JS.HistoryLib.Action) { if(action instanceof HistoryLib.Action) {
console.log("Added new entry to history: " + action.getReadableString()) console.log("Added new entry to history: " + action.getReadableString())
undoStack.push(action) undoStack.push(action)
undoCount++; undoCount++;

View file

@ -19,6 +19,7 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick import QtQuick
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/utils.mjs" as Utils
/*! /*!

View file

@ -19,6 +19,7 @@
import QtQuick.Controls import QtQuick.Controls
import QtQuick import QtQuick
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import "../js/utils.mjs" as Utils
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting

View file

@ -18,6 +18,8 @@
import QtQuick import QtQuick
import Qt.labs.platform as Native import Qt.labs.platform as Native
import "js/utils.mjs" as Utils
import "js/math/index.mjs" as MathLib
/*! /*!
\qmltype LogGraphCanvas \qmltype LogGraphCanvas

View file

@ -23,7 +23,7 @@ import QtQuick.Layouts 1.12
import QtQuick import QtQuick
// Auto loading all modules. // Auto loading all modules.
import "js/index.mjs" as JS import "js/autoload.mjs" as ModulesAutoload
import eu.ad5001.LogarithmPlotter.History 1.0 import eu.ad5001.LogarithmPlotter.History 1.0
import eu.ad5001.LogarithmPlotter.ObjectLists 1.0 import eu.ad5001.LogarithmPlotter.ObjectLists 1.0
@ -259,10 +259,4 @@ ApplicationWindow {
function showUpdateMenu() { function showUpdateMenu() {
appMenu.addMenu(updateMenu) appMenu.addMenu(updateMenu)
} }
// Initializing modules
Component.onCompleted: {
Modules.IO.initialize({ root, settings, alert })
Modules.Latex.initialize({ latex: Latex, helper: Helper })
}
} }

View file

@ -20,7 +20,9 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import Qt.labs.platform as Native import Qt.labs.platform as Native
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../../js/index.mjs" as JS import "../../js/history/index.mjs" as HistoryLib
import "../../js/utils.mjs" as Utils
import "../../js/math/index.mjs" as MathLib
/*! /*!
\qmltype CustomPropertyList \qmltype CustomPropertyList
@ -75,12 +77,12 @@ Repeater {
height: 30 height: 30
label: propertyLabel label: propertyLabel
icon: `settings/custom/${propertyIcon}.svg` icon: `settings/custom/${propertyIcon}.svg`
defValue: JS.Utils.simplifyExpression(obj[propertyName].toEditableString()) defValue: Utils.simplifyExpression(obj[propertyName].toEditableString())
self: obj.name self: obj.name
variables: propertyType.variables variables: propertyType.variables
onChanged: function(newExpr) { onChanged: function(newExpr) {
if(obj[propertyName].toString() != newExpr.toString()) { if(obj[propertyName].toString() != newExpr.toString()) {
history.addToHistory(new JS.HistoryLib.EditedProperty( history.addToHistory(new HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], newExpr obj[propertyName], newExpr
)) ))
@ -115,7 +117,7 @@ Repeater {
onChanged: function(newValue) { onChanged: function(newValue) {
try { try {
var newValueParsed = { var newValueParsed = {
"Domain": () => JS.MathLib.parseDomain(newValue), "Domain": () => MathLib.parseDomain(newValue),
"string": () => newValue, "string": () => newValue,
"number": () => newValue, "number": () => newValue,
"int": () => newValue "int": () => newValue
@ -123,7 +125,7 @@ Repeater {
// Ensuring old and new values are different to prevent useless adding to history. // Ensuring old and new values are different to prevent useless adding to history.
if(obj[propertyName] != newValueParsed) { if(obj[propertyName] != newValueParsed) {
history.addToHistory(new JS.HistoryLib.EditedProperty( history.addToHistory(new HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], newValueParsed obj[propertyName], newValueParsed
)) ))
@ -168,7 +170,7 @@ Repeater {
return obj[propertyName] return obj[propertyName]
} }
onClicked: { onClicked: {
history.addToHistory(new JS.HistoryLib.EditedProperty( history.addToHistory(new HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], this.checked obj[propertyName], this.checked
)) ))
@ -209,7 +211,7 @@ Repeater {
if(selectedObj == null) { if(selectedObj == null) {
// Creating new object. // Creating new object.
selectedObj = Modules.Objects.createNewRegisteredObject(propertyType.objType) selectedObj = Modules.Objects.createNewRegisteredObject(propertyType.objType)
history.addToHistory(new JS.HistoryLib.CreateNewObject(selectedObj.name, propertyType.objType, selectedObj.export())) history.addToHistory(new HistoryLib.CreateNewObject(selectedObj.name, propertyType.objType, selectedObj.export()))
baseModel = Modules.Objects.getObjectsName(propertyType.objType).concat( baseModel = Modules.Objects.getObjectsName(propertyType.objType).concat(
isRealObject ? [qsTr("+ Create new %1").arg(Modules.Objects.types[propertyType.objType].displayType())] : isRealObject ? [qsTr("+ Create new %1").arg(Modules.Objects.types[propertyType.objType].displayType())] :
[]) [])
@ -219,14 +221,14 @@ Repeater {
//Modules.Objects.currentObjects[objType][objIndex].requiredBy = obj[propertyName].filter((obj) => obj.name != obj.name) //Modules.Objects.currentObjects[objType][objIndex].requiredBy = obj[propertyName].filter((obj) => obj.name != obj.name)
} }
obj.requiredBy = obj.requiredBy.filter((obj) => obj.name != obj.name) obj.requiredBy = obj.requiredBy.filter((obj) => obj.name != obj.name)
history.addToHistory(new JS.HistoryLib.EditedProperty( history.addToHistory(new HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], selectedObj obj[propertyName], selectedObj
)) ))
obj[propertyName] = selectedObj obj[propertyName] = selectedObj
} else if(baseModel[newIndex] != obj[propertyName]) { } else if(baseModel[newIndex] != obj[propertyName]) {
// Ensuring new property is different to not add useless history entries. // Ensuring new property is different to not add useless history entries.
history.addToHistory(new JS.HistoryLib.EditedProperty( history.addToHistory(new HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], baseModel[newIndex] obj[propertyName], baseModel[newIndex]
)) ))
@ -256,10 +258,11 @@ Repeater {
onChanged: { onChanged: {
var exported = exportModel() var exported = exportModel()
history.addToHistory(new JS.HistoryLib.EditedProperty( history.addToHistory(new HistoryLib.EditedProperty(
obj.name, objType, propertyName, obj.name, objType, propertyName,
obj[propertyName], exported obj[propertyName], exported
)) ))
//Modules.Objects.currentObjects[objType][objIndex][propertyName] = exported
obj[propertyName] = exported obj[propertyName] = exported
root.changed() root.changed()
} }
@ -281,7 +284,7 @@ Repeater {
property string propertyName: modelData[0] property string propertyName: modelData[0]
property var propertyType: modelData[1] property var propertyType: modelData[1]
property string propertyLabel: qsTranslate('prop',propertyName) property string propertyLabel: qsTranslate('prop',propertyName)
property string propertyIcon: JS.Utils.camelCase2readable(propertyName) property string propertyIcon: Utils.camelCase2readable(propertyName)
sourceComponent: { sourceComponent: {
if(propertyName.startsWith('comment')) if(propertyName.startsWith('comment'))

View file

@ -22,7 +22,9 @@ import QtQuick.Dialogs as D
import Qt.labs.platform as Native import Qt.labs.platform as Native
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup
import "../../js/index.mjs" as JS import "../../js/history/index.mjs" as HistoryLib
import "../../js/utils.mjs" as Utils
import "../../js/math/index.mjs" as MathLib
/*! /*!
\qmltype Dialog \qmltype Dialog
@ -107,12 +109,12 @@ Popup.BaseDialog {
width: dlgProperties.width width: dlgProperties.width
value: objEditor.obj.name value: objEditor.obj.name
onChanged: function(newValue) { onChanged: function(newValue) {
let newName = JS.Utils.parseName(newValue) let newName = Utils.parseName(newValue)
if(newName != '' && objEditor.obj.name != newName) { if(newName != '' && objEditor.obj.name != newName) {
if(newName in Modules.Objects.currentObjectsByName) { if(newName in Modules.Objects.currentObjectsByName) {
invalidNameDialog.showDialog(newName) invalidNameDialog.showDialog(newName)
} else { } else {
history.addToHistory(new JS.HistoryLib.NameChanged( history.addToHistory(new HistoryLib.NameChanged(
objEditor.obj.name, objEditor.objType, newName objEditor.obj.name, objEditor.objType, newName
)) ))
Modules.Objects.renameObject(obj.name, newName) Modules.Objects.renameObject(obj.name, newName)

View file

@ -18,8 +18,8 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import "../js/history/index.mjs" as HistoryLib
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/index.mjs" as JS
/*! /*!
@ -104,7 +104,7 @@ Column {
onClicked: { onClicked: {
let newObj = Modules.Objects.createNewRegisteredObject(modelData) let newObj = Modules.Objects.createNewRegisteredObject(modelData)
history.addToHistory(new JS.HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export())) history.addToHistory(new HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export()))
objectLists.update() objectLists.update()
let hasXProp = newObj.constructor.properties().hasOwnProperty('x') let hasXProp = newObj.constructor.properties().hasOwnProperty('x')

View file

@ -21,7 +21,7 @@ import QtQuick.Dialogs
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Window import QtQuick.Window
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/index.mjs" as JS import "../js/history/index.mjs" as HistoryLib
/*! /*!
@ -72,7 +72,7 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 5 anchors.leftMargin: 5
onClicked: { onClicked: {
history.addToHistory(new JS.HistoryLib.EditedVisibility( history.addToHistory(new HistoryLib.EditedVisibility(
obj.name, obj.type, this.checked obj.name, obj.type, this.checked
)) ))
obj.visible = this.checked obj.visible = this.checked
@ -212,7 +212,7 @@ Item {
selectedColor: obj.color selectedColor: obj.color
title: qsTr("Pick new color for %1 %2").arg(obj.constructor.displayType()).arg(obj.name) title: qsTr("Pick new color for %1 %2").arg(obj.constructor.displayType()).arg(obj.name)
onAccepted: { onAccepted: {
history.addToHistory(new JS.HistoryLib.ColorChanged( history.addToHistory(new HistoryLib.ColorChanged(
obj.name, obj.type, obj.color, selectedColor.toString() obj.name, obj.type, obj.color, selectedColor.toString()
)) ))
obj.color = selectedColor.toString() obj.color = selectedColor.toString()
@ -231,7 +231,7 @@ Item {
// Object still exists // Object still exists
// Temporary fix for objects require not being propertly updated. // Temporary fix for objects require not being propertly updated.
object.requiredBy = [] object.requiredBy = []
history.addToHistory(new JS.HistoryLib.DeleteObject( history.addToHistory(new HistoryLib.DeleteObject(
object.name, object.type, object.export() object.name, object.type, object.export()
)) ))
Modules.Objects.deleteObject(object.name) Modules.Objects.deleteObject(object.name)

View file

@ -19,7 +19,8 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "js/index.mjs" as JS import "js/math/index.mjs" as MathLib
import "js/history/index.mjs" as HistoryLib
/*! /*!
\qmltype PickLocationOverlay \qmltype PickLocationOverlay
@ -115,7 +116,7 @@ Item {
let obj = Modules.Objects.currentObjectsByName[objName] let obj = Modules.Objects.currentObjectsByName[objName]
// Set values // Set values
if(parent.userPickX && parent.userPickY) { if(parent.userPickX && parent.userPickY) {
history.addToHistory(new JS.HistoryLib.EditedPosition( history.addToHistory(new HistoryLib.EditedPosition(
objName, objType, obj[propertyX], newValueX, obj[propertyY], newValueY objName, objType, obj[propertyX], newValueX, obj[propertyY], newValueY
)) ))
obj[propertyX] = newValueX obj[propertyX] = newValueX
@ -124,7 +125,7 @@ Item {
objectLists.update() objectLists.update()
pickerRoot.picked(obj) pickerRoot.picked(obj)
} else if(parent.userPickX) { } else if(parent.userPickX) {
history.addToHistory(new JS.HistoryLib.EditedProperty( history.addToHistory(new HistoryLib.EditedProperty(
objName, objType, propertyX, obj[propertyX], newValueX objName, objType, propertyX, obj[propertyX], newValueX
)) ))
obj[propertyX] = newValueX obj[propertyX] = newValueX
@ -132,7 +133,7 @@ Item {
objectLists.update() objectLists.update()
pickerRoot.picked(obj) pickerRoot.picked(obj)
} else if(parent.userPickY) { } else if(parent.userPickY) {
history.addToHistory(new JS.HistoryLib.EditedProperty( history.addToHistory(new HistoryLib.EditedProperty(
objName, objType, propertyY, obj[propertyY], newValueY objName, objType, propertyY, obj[propertyY], newValueY
)) ))
obj[propertyY] = newValueY obj[propertyY] = newValueY
@ -326,6 +327,6 @@ Item {
if(Modules.Objects.types[objType].properties()[propertyName] == 'number') if(Modules.Objects.types[objType].properties()[propertyName] == 'number')
return parseFloat(value) return parseFloat(value)
else else
return new JS.MathLib.Expression(value) return new MathLib.Expression(value)
} }
} }

View file

@ -20,7 +20,8 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/index.mjs" as JS import "../js/preferences/common.mjs" as S
import "../js/utils.mjs" as Utils
/*! /*!
\qmltype Preferences \qmltype Preferences
@ -76,7 +77,7 @@ Popup {
currentIndex: find(setting.value()) currentIndex: find(setting.value())
model: setting.defaultValues model: setting.defaultValues
onAccepted: function() { onAccepted: function() {
editText = JS.Utils.parseName(editText, false) editText = Utils.parseName(editText, false)
if(find(editText) === -1) model.append(editText) if(find(editText) === -1) model.append(editText)
setting.set(editText) setting.set(editText)
} }
@ -115,7 +116,7 @@ Popup {
height: 30 height: 30
label: setting.name label: setting.name
icon: `settings/${setting.icon}.svg` icon: `settings/${setting.icon}.svg`
defValue: JS.Utils.simplifyExpression(setting.value()) defValue: Utils.simplifyExpression(setting.value())
variables: setting.variables variables: setting.variables
allowGraphObjects: false allowGraphObjects: false
property string propertyName: setting.name property string propertyName: setting.name

View file

@ -20,7 +20,9 @@ import QtQuick.Controls
import QtQuick import QtQuick
import Qt.labs.platform as Native import Qt.labs.platform as Native
import eu.ad5001.LogarithmPlotter.Popup 1.0 as P import eu.ad5001.LogarithmPlotter.Popup 1.0 as P
import "../js/index.mjs" as JS import "../js/math/index.mjs" as MathLib
import "../js/utils.mjs" as Utils
import "../js/parsing/parsing.mjs" as Parsing
/*! /*!
@ -317,9 +319,9 @@ Item {
width: parent.width width: parent.width
readonly property var identifierTokenTypes: [ readonly property var identifierTokenTypes: [
JS.Parsing.TokenType.VARIABLE, Parsing.TokenType.VARIABLE,
JS.Parsing.TokenType.FUNCTION, Parsing.TokenType.FUNCTION,
JS.Parsing.TokenType.CONSTANT Parsing.TokenType.CONSTANT
] ]
property var currentToken: generateTokenInformation(getTokenAt(editor.tokens, editor.cursorPosition)) property var currentToken: generateTokenInformation(getTokenAt(editor.tokens, editor.cursorPosition))
property var previousToken: generateTokenInformation(getPreviousToken(currentToken.token)) property var previousToken: generateTokenInformation(getPreviousToken(currentToken.token))
@ -344,7 +346,7 @@ Item {
'value': exists ? token.value : null, 'value': exists ? token.value : null,
'type': exists ? token.type : null, 'type': exists ? token.type : null,
'startPosition': exists ? token.startPosition : 0, 'startPosition': exists ? token.startPosition : 0,
'dot': exists ? (token.type == JS.Parsing.TokenType.PUNCT && token.value == ".") : false, 'dot': exists ? (token.type == Parsing.TokenType.PUNCT && token.value == ".") : false,
'identifier': exists ? identifierTokenTypes.includes(token.type) : false 'identifier': exists ? identifierTokenTypes.includes(token.type) : false
} }
} }
@ -383,7 +385,7 @@ Item {
*/ */
function getPreviousToken(token) { function getPreviousToken(token) {
let newToken = getTokenAt(editor.tokens, token.startPosition) let newToken = getTokenAt(editor.tokens, token.startPosition)
if(newToken != null && newToken.type == JS.Parsing.TokenType.WHITESPACE) if(newToken != null && newToken.type == Parsing.TokenType.WHITESPACE)
return getPreviousToken(newToken) return getPreviousToken(newToken)
return newToken return newToken
} }
@ -442,9 +444,9 @@ Item {
visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot
itemStartIndex: variablesList.itemStartIndex + variablesList.model.length itemStartIndex: variablesList.itemStartIndex + variablesList.model.length
itemSelected: parent.itemSelected itemSelected: parent.itemSelected
categoryItems: JS.Parsing.CONSTANTS_LIST categoryItems: Parsing.CONSTANTS_LIST
autocompleteGenerator: (item) => {return { autocompleteGenerator: (item) => {return {
'text': item, 'annotation': JS.Parsing.CONSTANTS[item], 'text': item, 'annotation': Parsing.CONSTANTS[item],
'autocomplete': item + " ", 'cursorFinalOffset': 0 'autocomplete': item + " ", 'cursorFinalOffset': 0
}} }}
baseText: parent.visible ? parent.currentToken.value : "" baseText: parent.visible ? parent.currentToken.value : ""
@ -457,9 +459,9 @@ Item {
visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot
itemStartIndex: constantsList.itemStartIndex + constantsList.model.length itemStartIndex: constantsList.itemStartIndex + constantsList.model.length
itemSelected: parent.itemSelected itemSelected: parent.itemSelected
categoryItems: JS.Parsing.FUNCTIONS_LIST categoryItems: Parsing.FUNCTIONS_LIST
autocompleteGenerator: (item) => {return { autocompleteGenerator: (item) => {return {
'text': item, 'annotation': JS.Parsing.FUNCTIONS_USAGE[item].join(', '), 'text': item, 'annotation': Parsing.FUNCTIONS_USAGE[item].join(', '),
'autocomplete': item+'()', 'cursorFinalOffset': -1 'autocomplete': item+'()', 'cursorFinalOffset': -1
}} }}
baseText: parent.visible ? parent.currentToken.value : "" baseText: parent.visible ? parent.currentToken.value : ""
@ -536,9 +538,9 @@ Item {
function parse(newExpression) { function parse(newExpression) {
let expr = null let expr = null
try { try {
expr = new JS.MathLib.Expression(value.toString()) expr = new MathLib.Expression(value.toString())
// Check if the expression is valid, throws error otherwise. // Check if the expression is valid, throws error otherwise.
if(!expr.allRequirementsFulfilled()) { if(!expr.allRequirementsFullfilled()) {
let undefVars = expr.undefinedVariables() let undefVars = expr.undefinedVariables()
if(undefVars.length > 1) if(undefVars.length > 1)
throw new Error(qsTranslate('error', 'No object found with names %1.').arg(undefVars.join(', '))) throw new Error(qsTranslate('error', 'No object found with names %1.').arg(undefVars.join(', ')))
@ -570,7 +572,7 @@ Item {
Generates a list of tokens from the given. Generates a list of tokens from the given.
*/ */
function tokens(text) { function tokens(text) {
let tokenizer = new JS.Parsing.Tokenizer(new JS.Parsing.Input(text), true, false) let tokenizer = new Parsing.Tokenizer(new Parsing.Input(text), true, false)
let tokenList = [] let tokenList = []
let token let token
while((token = tokenizer.next()) != null) while((token = tokenizer.next()) != null)
@ -603,28 +605,28 @@ Item {
let scheme = colorSchemes[Helper.getSettingInt("expression_editor.color_scheme")] let scheme = colorSchemes[Helper.getSettingInt("expression_editor.color_scheme")]
for(let token of tokenList) { for(let token of tokenList) {
switch(token.type) { switch(token.type) {
case JS.Parsing.TokenType.VARIABLE: case Parsing.TokenType.VARIABLE:
parsedText += `<font color="${scheme.VARIABLE}">${token.value}</font>` parsedText += `<font color="${scheme.VARIABLE}">${token.value}</font>`
break; break;
case JS.Parsing.TokenType.CONSTANT: case Parsing.TokenType.CONSTANT:
parsedText += `<font color="${scheme.CONSTANT}">${token.value}</font>` parsedText += `<font color="${scheme.CONSTANT}">${token.value}</font>`
break; break;
case JS.Parsing.TokenType.FUNCTION: case Parsing.TokenType.FUNCTION:
parsedText += `<font color="${scheme.FUNCTION}">${JS.Utils.escapeHTML(token.value)}</font>` parsedText += `<font color="${scheme.FUNCTION}">${Utils.escapeHTML(token.value)}</font>`
break; break;
case JS.Parsing.TokenType.OPERATOR: case Parsing.TokenType.OPERATOR:
parsedText += `<font color="${scheme.OPERATOR}">${JS.Utils.escapeHTML(token.value)}</font>` parsedText += `<font color="${scheme.OPERATOR}">${Utils.escapeHTML(token.value)}</font>`
break; break;
case JS.Parsing.TokenType.NUMBER: case Parsing.TokenType.NUMBER:
parsedText += `<font color="${scheme.NUMBER}">${JS.Utils.escapeHTML(token.value)}</font>` parsedText += `<font color="${scheme.NUMBER}">${Utils.escapeHTML(token.value)}</font>`
break; break;
case JS.Parsing.TokenType.STRING: case Parsing.TokenType.STRING:
parsedText += `<font color="${scheme.STRING}">${token.limitator}${JS.Utils.escapeHTML(token.value)}${token.limitator}</font>` parsedText += `<font color="${scheme.STRING}">${token.limitator}${Utils.escapeHTML(token.value)}${token.limitator}</font>`
break; break;
case JS.Parsing.TokenType.WHITESPACE: case Parsing.TokenType.WHITESPACE:
case JS.Parsing.TokenType.PUNCT: case Parsing.TokenType.PUNCT:
default: default:
parsedText += JS.Utils.escapeHTML(token.value).replace(/ /g, '&nbsp;') parsedText += Utils.escapeHTML(token.value).replace(/ /g, '&nbsp;')
break; break;
} }
} }

View file

@ -20,7 +20,7 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup
import "js/index.mjs" as JS import "js/utils.mjs" as Utils
/*! /*!
\qmltype Settings \qmltype Settings
@ -127,6 +127,10 @@ ScrollView {
*/ */
property string saveFilename: "" property string saveFilename: ""
Component.onCompleted: {
Modules.IO.initialize({ root, settings, alert })
}
Column { Column {
spacing: 10 spacing: 10
width: parent.width width: parent.width
@ -326,7 +330,7 @@ ScrollView {
currentIndex: find(settings.xlabel) currentIndex: find(settings.xlabel)
editable: true editable: true
onAccepted: function(){ onAccepted: function(){
editText = JS.Utils.parseName(editText, false) editText = Utils.parseName(editText, false)
if (find(editText) === -1) model.append({text: editText}) if (find(editText) === -1) model.append({text: editText})
settings.xlabel = editText settings.xlabel = editText
settings.changed() settings.changed()
@ -355,7 +359,7 @@ ScrollView {
currentIndex: find(settings.ylabel) currentIndex: find(settings.ylabel)
editable: true editable: true
onAccepted: function(){ onAccepted: function(){
editText = JS.Utils.parseName(editText, false) editText = Utils.parseName(editText, false)
if (find(editText) === -1) model.append({text: editText, yaxisstep: root.yaxisstep}) if (find(editText) === -1) model.append({text: editText, yaxisstep: root.yaxisstep})
settings.ylabel = editText settings.ylabel = editText
settings.changed() settings.changed()

View file

@ -19,6 +19,8 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "js/math/index.mjs" as MathLib
import "js/history/index.mjs" as HistoryLib
/*! /*!
\qmltype ViewPositionChangeOverlay \qmltype ViewPositionChangeOverlay

View file

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B

View file

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

View file

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 289 B

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 620 B

After

Width:  |  Height:  |  Size: 620 B

View file

Before

Width:  |  Height:  |  Size: 261 B

After

Width:  |  Height:  |  Size: 261 B

View file

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 251 B

View file

Before

Width:  |  Height:  |  Size: 550 B

After

Width:  |  Height:  |  Size: 550 B

View file

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 273 B

View file

Before

Width:  |  Height:  |  Size: 696 B

After

Width:  |  Height:  |  Size: 696 B

View file

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View file

Before

Width:  |  Height:  |  Size: 370 B

After

Width:  |  Height:  |  Size: 370 B

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View file

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Some files were not shown because too many files have changed in this diff Show more