Compare commits
No commits in common. "23c3b771c2e6cd03c746d66a2f3c5c1fff3bb06a" and "7ef55e48e827808b210c53917c0f73469898c6b3" have entirely different histories.
23c3b771c2
...
7ef55e48e8
27
.gitignore
vendored
|
@ -1,19 +1,13 @@
|
|||
# Building
|
||||
build/
|
||||
dist/
|
||||
deb_dist/
|
||||
assets/linux/flatpak/AppDir
|
||||
assets/linux/flatpak/repo
|
||||
assets/linux/flatpak/build-dir
|
||||
assets/linux/flatpak/.flatpak-builder
|
||||
linux/flatpak/AppDir
|
||||
linux/flatpak/repo
|
||||
linux/flatpak/build-dir
|
||||
linux/flatpak/.flatpak-builder
|
||||
*.snap
|
||||
*.spec
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.spec
|
||||
*.egg-info/
|
||||
|
||||
# Runtime data
|
||||
**/**.qmlc
|
||||
**/**.jsc
|
||||
**/**.pyc
|
||||
|
@ -26,19 +20,16 @@ assets/linux/flatpak/.flatpak-builder
|
|||
.DS_Store
|
||||
**/.DS_Store
|
||||
**/__pycache__/
|
||||
|
||||
# IDE Data
|
||||
.ropeproject
|
||||
.vscode
|
||||
*.kdev4
|
||||
.kdev4
|
||||
.coverage
|
||||
build
|
||||
docs/html
|
||||
.directory
|
||||
*.lpf
|
||||
*.lgg
|
||||
|
||||
# npm
|
||||
common/node_modules
|
||||
common/coverage/
|
||||
common/.coverage
|
||||
runtime-pyside6/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/js/index.mjs*
|
||||
*.spec
|
||||
*.egg-info/
|
||||
*.tar.gz
|
||||
|
|
4
.gitmodules
vendored
|
@ -1,3 +1,3 @@
|
|||
[submodule "runtime-pyside6/LogarithmPlotter/qml/eu/ad5001/MixedMenu"]
|
||||
path = runtime-pyside6/LogarithmPlotter/qml/eu/ad5001/MixedMenu
|
||||
[submodule "LogarithmPlotter/qml/eu/ad5001/MixedMenu"]
|
||||
path = LogarithmPlotter/qml/eu/ad5001/MixedMenu
|
||||
url = https://git.ad5001.eu/Ad5001/MixedMenu
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# specificities so that lupdate doesn't cry out in pain.
|
||||
# See also: https://bugreports.qt.io/browse/QTBUG-123819
|
||||
#
|
||||
|
||||
|
||||
escape() {
|
||||
str="$1"
|
||||
str="${str//\//\\/}" # Escape slashes
|
||||
|
@ -19,20 +19,15 @@ replace() {
|
|||
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)
|
||||
for file in $files; do
|
||||
echo "Moving '$file' to '${file%.*}.js'..."
|
||||
mv "$file" "${file%.*}.js"
|
||||
# Replacements to make it valid js
|
||||
replace "${file%.*}.js" "^import" "/*import"
|
||||
replace "${file%.*}.js" "^export *" "/*export *"
|
||||
replace "${file%.*}.js" '.mjs"$' '.mjs"*/'
|
||||
replace "${file%.*}.js" "^export default" "/*export default*/"
|
||||
replace "${file%.*}.js" "^export" "/*export*/"
|
||||
replace "${file%.*}.js" "async " "/*async */"
|
||||
replace "${file%.*}.js" "await" "/*await */"
|
||||
done
|
||||
|
||||
echo "----------------------------"
|
||||
|
@ -43,6 +38,7 @@ lupdate -extensions js,qs,qml,py -recursive .. -ts lp_*.ts
|
|||
for lp in *.ts; do
|
||||
echo "Replacing locations in $lp..."
|
||||
for file in $files; do
|
||||
echo " > Replacing for file $file..."
|
||||
replace "$lp" "${file%.*}.js" "$file"
|
||||
done
|
||||
done
|
||||
|
@ -51,11 +47,8 @@ for file in $files; do
|
|||
echo "Moving '${file%.*}.js' to '$file'..."
|
||||
mv "${file%.*}.js" "$file"
|
||||
# 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" "^/*export" "export"
|
||||
replace "$file" '.mjs"*/$' '.mjs"'
|
||||
replace "$file" "^/*export default*/" "export default"
|
||||
replace "$file" "^/*export*/" "export"
|
||||
done
|
|
@ -43,7 +43,7 @@ if path.realpath(path.join(getcwd(), "..")) not in sys_path:
|
|||
sys_path.append(path.realpath(path.join(getcwd(), "..")))
|
||||
|
||||
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.helper import Helper
|
||||
from LogarithmPlotter.util.latex import Latex
|
||||
|
@ -130,7 +130,7 @@ def create_engine(helper: Helper, latex: Latex, dep_time: float) -> tuple[QQmlAp
|
|||
global tmpfile
|
||||
engine = QQmlApplicationEngine()
|
||||
js_globals = PyJSValue(engine.globalObject())
|
||||
js_globals.globalThis = engine.globalObject()
|
||||
js_globals.Modules = engine.newObject()
|
||||
js_globals.Helper = engine.newQObject(helper)
|
||||
js_globals.Latex = engine.newQObject(latex)
|
||||
engine.rootContext().setContextProperty("TestBuild", "--test-build" in argv)
|
||||
|
@ -155,7 +155,6 @@ def run():
|
|||
register_icon_directories()
|
||||
app = create_qapp()
|
||||
translator = install_translation(app)
|
||||
debug.setup()
|
||||
|
||||
# Installing macOS file handler.
|
||||
macos_file_open_handler = None
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
@ -20,7 +20,7 @@ import QtQuick
|
|||
import Qt.labs.platform as Native
|
||||
//import QtQuick.Controls 2.15
|
||||
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
|
||||
onTriggered: {
|
||||
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()
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
import QtQuick
|
||||
import QtQml
|
||||
import QtQuick.Window
|
||||
import "../js/index.mjs" as JS
|
||||
import "../js/history/index.mjs" as HistoryLib
|
||||
|
||||
/*!
|
||||
\qmltype History
|
||||
|
@ -97,9 +97,9 @@ Item {
|
|||
function unserialize(undoSt, redoSt) {
|
||||
clear();
|
||||
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++)
|
||||
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;
|
||||
redoCount = redoSt.length;
|
||||
objectLists.update()
|
||||
|
@ -110,7 +110,7 @@ Item {
|
|||
Adds an instance of HistoryLib.Action to history.
|
||||
*/
|
||||
function addToHistory(action) {
|
||||
if(action instanceof JS.HistoryLib.Action) {
|
||||
if(action instanceof HistoryLib.Action) {
|
||||
console.log("Added new entry to history: " + action.getReadableString())
|
||||
undoStack.push(action)
|
||||
undoCount++;
|
|
@ -19,6 +19,7 @@
|
|||
import QtQuick.Controls
|
||||
import QtQuick
|
||||
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
|
||||
import "../js/utils.mjs" as Utils
|
||||
|
||||
|
||||
/*!
|
|
@ -19,6 +19,7 @@
|
|||
import QtQuick.Controls
|
||||
import QtQuick
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import "../js/utils.mjs" as Utils
|
||||
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
|
||||
|
||||
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
import QtQuick
|
||||
import Qt.labs.platform as Native
|
||||
import "js/utils.mjs" as Utils
|
||||
import "js/math/index.mjs" as MathLib
|
||||
|
||||
/*!
|
||||
\qmltype LogGraphCanvas
|
|
@ -23,7 +23,7 @@ import QtQuick.Layouts 1.12
|
|||
import QtQuick
|
||||
|
||||
// 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.ObjectLists 1.0
|
||||
|
@ -259,10 +259,4 @@ ApplicationWindow {
|
|||
function showUpdateMenu() {
|
||||
appMenu.addMenu(updateMenu)
|
||||
}
|
||||
|
||||
// Initializing modules
|
||||
Component.onCompleted: {
|
||||
Modules.IO.initialize({ root, settings, alert })
|
||||
Modules.Latex.initialize({ latex: Latex, helper: Helper })
|
||||
}
|
||||
}
|
|
@ -20,7 +20,9 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import Qt.labs.platform as Native
|
||||
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
|
||||
|
@ -75,12 +77,12 @@ Repeater {
|
|||
height: 30
|
||||
label: propertyLabel
|
||||
icon: `settings/custom/${propertyIcon}.svg`
|
||||
defValue: JS.Utils.simplifyExpression(obj[propertyName].toEditableString())
|
||||
defValue: Utils.simplifyExpression(obj[propertyName].toEditableString())
|
||||
self: obj.name
|
||||
variables: propertyType.variables
|
||||
onChanged: function(newExpr) {
|
||||
if(obj[propertyName].toString() != newExpr.toString()) {
|
||||
history.addToHistory(new JS.HistoryLib.EditedProperty(
|
||||
history.addToHistory(new HistoryLib.EditedProperty(
|
||||
obj.name, objType, propertyName,
|
||||
obj[propertyName], newExpr
|
||||
))
|
||||
|
@ -115,7 +117,7 @@ Repeater {
|
|||
onChanged: function(newValue) {
|
||||
try {
|
||||
var newValueParsed = {
|
||||
"Domain": () => JS.MathLib.parseDomain(newValue),
|
||||
"Domain": () => MathLib.parseDomain(newValue),
|
||||
"string": () => newValue,
|
||||
"number": () => newValue,
|
||||
"int": () => newValue
|
||||
|
@ -123,7 +125,7 @@ Repeater {
|
|||
|
||||
// Ensuring old and new values are different to prevent useless adding to history.
|
||||
if(obj[propertyName] != newValueParsed) {
|
||||
history.addToHistory(new JS.HistoryLib.EditedProperty(
|
||||
history.addToHistory(new HistoryLib.EditedProperty(
|
||||
obj.name, objType, propertyName,
|
||||
obj[propertyName], newValueParsed
|
||||
))
|
||||
|
@ -168,7 +170,7 @@ Repeater {
|
|||
return obj[propertyName]
|
||||
}
|
||||
onClicked: {
|
||||
history.addToHistory(new JS.HistoryLib.EditedProperty(
|
||||
history.addToHistory(new HistoryLib.EditedProperty(
|
||||
obj.name, objType, propertyName,
|
||||
obj[propertyName], this.checked
|
||||
))
|
||||
|
@ -209,7 +211,7 @@ Repeater {
|
|||
if(selectedObj == null) {
|
||||
// Creating new object.
|
||||
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(
|
||||
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)
|
||||
}
|
||||
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[propertyName], selectedObj
|
||||
))
|
||||
obj[propertyName] = selectedObj
|
||||
} else if(baseModel[newIndex] != obj[propertyName]) {
|
||||
// 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[propertyName], baseModel[newIndex]
|
||||
))
|
||||
|
@ -256,10 +258,11 @@ Repeater {
|
|||
|
||||
onChanged: {
|
||||
var exported = exportModel()
|
||||
history.addToHistory(new JS.HistoryLib.EditedProperty(
|
||||
history.addToHistory(new HistoryLib.EditedProperty(
|
||||
obj.name, objType, propertyName,
|
||||
obj[propertyName], exported
|
||||
))
|
||||
//Modules.Objects.currentObjects[objType][objIndex][propertyName] = exported
|
||||
obj[propertyName] = exported
|
||||
root.changed()
|
||||
}
|
||||
|
@ -281,7 +284,7 @@ Repeater {
|
|||
property string propertyName: modelData[0]
|
||||
property var propertyType: modelData[1]
|
||||
property string propertyLabel: qsTranslate('prop',propertyName)
|
||||
property string propertyIcon: JS.Utils.camelCase2readable(propertyName)
|
||||
property string propertyIcon: Utils.camelCase2readable(propertyName)
|
||||
|
||||
sourceComponent: {
|
||||
if(propertyName.startsWith('comment'))
|
|
@ -22,7 +22,9 @@ import QtQuick.Dialogs as D
|
|||
import Qt.labs.platform as Native
|
||||
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
|
||||
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
|
||||
|
@ -107,12 +109,12 @@ Popup.BaseDialog {
|
|||
width: dlgProperties.width
|
||||
value: objEditor.obj.name
|
||||
onChanged: function(newValue) {
|
||||
let newName = JS.Utils.parseName(newValue)
|
||||
let newName = Utils.parseName(newValue)
|
||||
if(newName != '' && objEditor.obj.name != newName) {
|
||||
if(newName in Modules.Objects.currentObjectsByName) {
|
||||
invalidNameDialog.showDialog(newName)
|
||||
} else {
|
||||
history.addToHistory(new JS.HistoryLib.NameChanged(
|
||||
history.addToHistory(new HistoryLib.NameChanged(
|
||||
objEditor.obj.name, objEditor.objType, newName
|
||||
))
|
||||
Modules.Objects.renameObject(obj.name, newName)
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import "../js/history/index.mjs" as HistoryLib
|
||||
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
|
||||
import "../js/index.mjs" as JS
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -104,7 +104,7 @@ Column {
|
|||
|
||||
onClicked: {
|
||||
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()
|
||||
|
||||
let hasXProp = newObj.constructor.properties().hasOwnProperty('x')
|
|
@ -21,7 +21,7 @@ import QtQuick.Dialogs
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Window
|
||||
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.leftMargin: 5
|
||||
onClicked: {
|
||||
history.addToHistory(new JS.HistoryLib.EditedVisibility(
|
||||
history.addToHistory(new HistoryLib.EditedVisibility(
|
||||
obj.name, obj.type, this.checked
|
||||
))
|
||||
obj.visible = this.checked
|
||||
|
@ -212,7 +212,7 @@ Item {
|
|||
selectedColor: obj.color
|
||||
title: qsTr("Pick new color for %1 %2").arg(obj.constructor.displayType()).arg(obj.name)
|
||||
onAccepted: {
|
||||
history.addToHistory(new JS.HistoryLib.ColorChanged(
|
||||
history.addToHistory(new HistoryLib.ColorChanged(
|
||||
obj.name, obj.type, obj.color, selectedColor.toString()
|
||||
))
|
||||
obj.color = selectedColor.toString()
|
||||
|
@ -231,7 +231,7 @@ Item {
|
|||
// Object still exists
|
||||
// Temporary fix for objects require not being propertly updated.
|
||||
object.requiredBy = []
|
||||
history.addToHistory(new JS.HistoryLib.DeleteObject(
|
||||
history.addToHistory(new HistoryLib.DeleteObject(
|
||||
object.name, object.type, object.export()
|
||||
))
|
||||
Modules.Objects.deleteObject(object.name)
|
|
@ -19,7 +19,8 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
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
|
||||
|
@ -115,7 +116,7 @@ Item {
|
|||
let obj = Modules.Objects.currentObjectsByName[objName]
|
||||
// Set values
|
||||
if(parent.userPickX && parent.userPickY) {
|
||||
history.addToHistory(new JS.HistoryLib.EditedPosition(
|
||||
history.addToHistory(new HistoryLib.EditedPosition(
|
||||
objName, objType, obj[propertyX], newValueX, obj[propertyY], newValueY
|
||||
))
|
||||
obj[propertyX] = newValueX
|
||||
|
@ -124,7 +125,7 @@ Item {
|
|||
objectLists.update()
|
||||
pickerRoot.picked(obj)
|
||||
} else if(parent.userPickX) {
|
||||
history.addToHistory(new JS.HistoryLib.EditedProperty(
|
||||
history.addToHistory(new HistoryLib.EditedProperty(
|
||||
objName, objType, propertyX, obj[propertyX], newValueX
|
||||
))
|
||||
obj[propertyX] = newValueX
|
||||
|
@ -132,7 +133,7 @@ Item {
|
|||
objectLists.update()
|
||||
pickerRoot.picked(obj)
|
||||
} else if(parent.userPickY) {
|
||||
history.addToHistory(new JS.HistoryLib.EditedProperty(
|
||||
history.addToHistory(new HistoryLib.EditedProperty(
|
||||
objName, objType, propertyY, obj[propertyY], newValueY
|
||||
))
|
||||
obj[propertyY] = newValueY
|
||||
|
@ -326,6 +327,6 @@ Item {
|
|||
if(Modules.Objects.types[objType].properties()[propertyName] == 'number')
|
||||
return parseFloat(value)
|
||||
else
|
||||
return new JS.MathLib.Expression(value)
|
||||
return new MathLib.Expression(value)
|
||||
}
|
||||
}
|
|
@ -20,7 +20,8 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
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
|
||||
|
@ -76,7 +77,7 @@ Popup {
|
|||
currentIndex: find(setting.value())
|
||||
model: setting.defaultValues
|
||||
onAccepted: function() {
|
||||
editText = JS.Utils.parseName(editText, false)
|
||||
editText = Utils.parseName(editText, false)
|
||||
if(find(editText) === -1) model.append(editText)
|
||||
setting.set(editText)
|
||||
}
|
||||
|
@ -115,7 +116,7 @@ Popup {
|
|||
height: 30
|
||||
label: setting.name
|
||||
icon: `settings/${setting.icon}.svg`
|
||||
defValue: JS.Utils.simplifyExpression(setting.value())
|
||||
defValue: Utils.simplifyExpression(setting.value())
|
||||
variables: setting.variables
|
||||
allowGraphObjects: false
|
||||
property string propertyName: setting.name
|
|
@ -20,7 +20,9 @@ import QtQuick.Controls
|
|||
import QtQuick
|
||||
import Qt.labs.platform as Native
|
||||
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
|
||||
|
||||
readonly property var identifierTokenTypes: [
|
||||
JS.Parsing.TokenType.VARIABLE,
|
||||
JS.Parsing.TokenType.FUNCTION,
|
||||
JS.Parsing.TokenType.CONSTANT
|
||||
Parsing.TokenType.VARIABLE,
|
||||
Parsing.TokenType.FUNCTION,
|
||||
Parsing.TokenType.CONSTANT
|
||||
]
|
||||
property var currentToken: generateTokenInformation(getTokenAt(editor.tokens, editor.cursorPosition))
|
||||
property var previousToken: generateTokenInformation(getPreviousToken(currentToken.token))
|
||||
|
@ -344,7 +346,7 @@ Item {
|
|||
'value': exists ? token.value : null,
|
||||
'type': exists ? token.type : null,
|
||||
'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
|
||||
}
|
||||
}
|
||||
|
@ -383,7 +385,7 @@ Item {
|
|||
*/
|
||||
function getPreviousToken(token) {
|
||||
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 newToken
|
||||
}
|
||||
|
@ -442,9 +444,9 @@ Item {
|
|||
visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot
|
||||
itemStartIndex: variablesList.itemStartIndex + variablesList.model.length
|
||||
itemSelected: parent.itemSelected
|
||||
categoryItems: JS.Parsing.CONSTANTS_LIST
|
||||
categoryItems: Parsing.CONSTANTS_LIST
|
||||
autocompleteGenerator: (item) => {return {
|
||||
'text': item, 'annotation': JS.Parsing.CONSTANTS[item],
|
||||
'text': item, 'annotation': Parsing.CONSTANTS[item],
|
||||
'autocomplete': item + " ", 'cursorFinalOffset': 0
|
||||
}}
|
||||
baseText: parent.visible ? parent.currentToken.value : ""
|
||||
|
@ -457,9 +459,9 @@ Item {
|
|||
visbilityCondition: parent.currentToken.identifier && !parent.previousToken.dot
|
||||
itemStartIndex: constantsList.itemStartIndex + constantsList.model.length
|
||||
itemSelected: parent.itemSelected
|
||||
categoryItems: JS.Parsing.FUNCTIONS_LIST
|
||||
categoryItems: Parsing.FUNCTIONS_LIST
|
||||
autocompleteGenerator: (item) => {return {
|
||||
'text': item, 'annotation': JS.Parsing.FUNCTIONS_USAGE[item].join(', '),
|
||||
'text': item, 'annotation': Parsing.FUNCTIONS_USAGE[item].join(', '),
|
||||
'autocomplete': item+'()', 'cursorFinalOffset': -1
|
||||
}}
|
||||
baseText: parent.visible ? parent.currentToken.value : ""
|
||||
|
@ -536,9 +538,9 @@ Item {
|
|||
function parse(newExpression) {
|
||||
let expr = null
|
||||
try {
|
||||
expr = new JS.MathLib.Expression(value.toString())
|
||||
expr = new MathLib.Expression(value.toString())
|
||||
// Check if the expression is valid, throws error otherwise.
|
||||
if(!expr.allRequirementsFulfilled()) {
|
||||
if(!expr.allRequirementsFullfilled()) {
|
||||
let undefVars = expr.undefinedVariables()
|
||||
if(undefVars.length > 1)
|
||||
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.
|
||||
*/
|
||||
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 token
|
||||
while((token = tokenizer.next()) != null)
|
||||
|
@ -603,28 +605,28 @@ Item {
|
|||
let scheme = colorSchemes[Helper.getSettingInt("expression_editor.color_scheme")]
|
||||
for(let token of tokenList) {
|
||||
switch(token.type) {
|
||||
case JS.Parsing.TokenType.VARIABLE:
|
||||
case Parsing.TokenType.VARIABLE:
|
||||
parsedText += `<font color="${scheme.VARIABLE}">${token.value}</font>`
|
||||
break;
|
||||
case JS.Parsing.TokenType.CONSTANT:
|
||||
case Parsing.TokenType.CONSTANT:
|
||||
parsedText += `<font color="${scheme.CONSTANT}">${token.value}</font>`
|
||||
break;
|
||||
case JS.Parsing.TokenType.FUNCTION:
|
||||
parsedText += `<font color="${scheme.FUNCTION}">${JS.Utils.escapeHTML(token.value)}</font>`
|
||||
case Parsing.TokenType.FUNCTION:
|
||||
parsedText += `<font color="${scheme.FUNCTION}">${Utils.escapeHTML(token.value)}</font>`
|
||||
break;
|
||||
case JS.Parsing.TokenType.OPERATOR:
|
||||
parsedText += `<font color="${scheme.OPERATOR}">${JS.Utils.escapeHTML(token.value)}</font>`
|
||||
case Parsing.TokenType.OPERATOR:
|
||||
parsedText += `<font color="${scheme.OPERATOR}">${Utils.escapeHTML(token.value)}</font>`
|
||||
break;
|
||||
case JS.Parsing.TokenType.NUMBER:
|
||||
parsedText += `<font color="${scheme.NUMBER}">${JS.Utils.escapeHTML(token.value)}</font>`
|
||||
case Parsing.TokenType.NUMBER:
|
||||
parsedText += `<font color="${scheme.NUMBER}">${Utils.escapeHTML(token.value)}</font>`
|
||||
break;
|
||||
case JS.Parsing.TokenType.STRING:
|
||||
parsedText += `<font color="${scheme.STRING}">${token.limitator}${JS.Utils.escapeHTML(token.value)}${token.limitator}</font>`
|
||||
case Parsing.TokenType.STRING:
|
||||
parsedText += `<font color="${scheme.STRING}">${token.limitator}${Utils.escapeHTML(token.value)}${token.limitator}</font>`
|
||||
break;
|
||||
case JS.Parsing.TokenType.WHITESPACE:
|
||||
case JS.Parsing.TokenType.PUNCT:
|
||||
case Parsing.TokenType.WHITESPACE:
|
||||
case Parsing.TokenType.PUNCT:
|
||||
default:
|
||||
parsedText += JS.Utils.escapeHTML(token.value).replace(/ /g, ' ')
|
||||
parsedText += Utils.escapeHTML(token.value).replace(/ /g, ' ')
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ import QtQuick
|
|||
import QtQuick.Controls
|
||||
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
|
||||
import eu.ad5001.LogarithmPlotter.Popup 1.0 as Popup
|
||||
import "js/index.mjs" as JS
|
||||
import "js/utils.mjs" as Utils
|
||||
|
||||
/*!
|
||||
\qmltype Settings
|
||||
|
@ -127,6 +127,10 @@ ScrollView {
|
|||
*/
|
||||
property string saveFilename: ""
|
||||
|
||||
Component.onCompleted: {
|
||||
Modules.IO.initialize({ root, settings, alert })
|
||||
}
|
||||
|
||||
Column {
|
||||
spacing: 10
|
||||
width: parent.width
|
||||
|
@ -326,7 +330,7 @@ ScrollView {
|
|||
currentIndex: find(settings.xlabel)
|
||||
editable: true
|
||||
onAccepted: function(){
|
||||
editText = JS.Utils.parseName(editText, false)
|
||||
editText = Utils.parseName(editText, false)
|
||||
if (find(editText) === -1) model.append({text: editText})
|
||||
settings.xlabel = editText
|
||||
settings.changed()
|
||||
|
@ -355,7 +359,7 @@ ScrollView {
|
|||
currentIndex: find(settings.ylabel)
|
||||
editable: true
|
||||
onAccepted: function(){
|
||||
editText = JS.Utils.parseName(editText, false)
|
||||
editText = Utils.parseName(editText, false)
|
||||
if (find(editText) === -1) model.append({text: editText, yaxisstep: root.yaxisstep})
|
||||
settings.ylabel = editText
|
||||
settings.changed()
|
|
@ -19,6 +19,8 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
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
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 289 B After Width: | Height: | Size: 289 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 620 B |
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 261 B |
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 550 B |
Before Width: | Height: | Size: 273 B After Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 696 B After Width: | Height: | Size: 696 B |
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 370 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |