Fixing a LOT of issues stemming from X cursor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adsooi 2022-01-26 12:02:10 +01:00
parent 92594f5af3
commit 0075c03c9d
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
6 changed files with 50 additions and 20 deletions

View file

@ -224,8 +224,6 @@ ApplicationWindow {
settings.linewidth = data["linewidth"]
if("textsize" in data)
settings.textsize = data["textsize"]
if("history" in data)
history.unserialize(...data["history"])
root.height = data["height"]
root.width = data["width"]
@ -242,6 +240,11 @@ ApplicationWindow {
error += qsTr("Unknown object type: %1.").arg(objType) + "\n";
}
}
// Importing history
if("history" in data)
history.unserialize(...data["history"])
// Refreshing sidebar
if(sidebarSelector.currentIndex == 0) {
// For some reason, if we load a file while the tab is on object,

View file

@ -179,9 +179,13 @@ D.Dialog {
icon: visible ? `icons/settings/custom/${parent.label}.svg` : ''
// True to select an object of type, false for enums.
property bool selectObjMode: paramTypeIn(modelData[1], ['ObjectType'])
property bool isRealObject: !selectedObj || (modelData[1].objType != "ExecutableObject" && modelData[1].objType != "DrawableObject")
property var baseModel: visible ?
(selectObjMode ? Objects.getObjectsName(modelData[1].objType).concat([qsTr("+ Create new %1").arg(modelData[1].objType)]) : modelData[1].values)
(selectObjMode ? Objects.getObjectsName(modelData[1].objType)
.concat(
isRealObject ? [qsTr("+ Create new %1").arg(modelData[1].objType)] : [])
: modelData[1].values)
: []
// Translate the model if necessary.
model: selectObjMode ? baseModel : baseModel.map(x => qsTr(x))
@ -193,16 +197,20 @@ D.Dialog {
// This is only done when what we're selecting are Objects.
// Setting object property.
var selectedObj = Objects.getObjectByName(baseModel[newIndex], modelData[1].objType)
if(newIndex != 0) {
// Make sure we don't set the object to null.
if(selectedObj == null) {
// Creating new object.
selectedObj = Objects.createNewRegisteredObject(modelData[1].objType)
history.addToHistory(new HistoryLib.CreateNewObject(selectedObj.name, modelData[1].objType, selectedObj.export()))
baseModel = Objects.getObjectsName(modelData[1].objType).concat([qsTr("+ Create new %1").arg(Objects.types[modelData[1].objType].displayType())])
baseModel = Objects.getObjectsName(modelData[1].objType).concat(
isRealObject ? [qsTr("+ Create new %1").arg(modelData[1].objType)] : [])
currentIndex = baseModel.indexOf(selectedObj.name)
}
//Objects.currentObjects[objEditor.objType][objEditor.objIndex].requiredBy = objEditor.obj[modelData[0]].filter((obj) => objEditor.obj.name != obj.name)
objEditor.obj.requiredBy = objEditor.obj.requiredBy.filter((obj) => objEditor.obj.name != obj.name)
selectedObj.requiredBy.push(Objects.currentObjects[objEditor.objType][objEditor.objIndex])
//Objects.currentObjects[objEditor.objType][objEditor.objIndex].requiredBy = objEditor.obj[modelData[0]].filter((obj) => objEditor.obj.name != obj.name)
}
objEditor.obj.requiredBy = objEditor.obj.requiredBy.filter((obj) => objEditor.obj.name != obj.name)
history.addToHistory(new HistoryLib.EditedProperty(
objEditor.obj.name, objEditor.objType, modelData[0],
objEditor.obj[modelData[0]], selectedObj

View file

@ -21,6 +21,7 @@
.pragma library
.import "objects.js" as Objects
.import "objs/common.js" as Common
.import "utils.js" as Utils
.import "mathlib.js" as MathLib
@ -106,8 +107,17 @@ class EditedProperty extends Action {
this.previousValue = previousValue
this.newValue = newValue
if(valueIsExpressionNeedingImport) {
if(targetType == "Expression") {
this.previousValue = new MathLib.Expression(this.previousValue);
this.newValue = new MathLib.Expression(this.newValue);
} else if(targetType == "Domain") {
this.previousValue = MathLib.parseDomain(this.previousValue);
this.newValue = MathLib.parseDomain(this.newValue);
} else {
// Objects
this.previousValue = Objects.getObjectByName(this.previousValue);
this.newValue = Objects.getObjectByName(this.newValue);
}
}
}
@ -122,6 +132,9 @@ class EditedProperty extends Action {
export() {
if(this.previousValue instanceof MathLib.Expression) {
return [this.targetName, this.targetType, this.targetProperty, this.previousValue.toEditableString(), this.newValue.toEditableString(), true]
} else if(this.previousValue instanceof Common.DrawableObject) {
return [this.targetName, this.targetType, this.targetProperty, this.previousValue.name, this.newValue.name, true]
} else {
return [this.targetName, this.targetType, this.targetProperty, this.previousValue, this.newValue, false]
}

View file

@ -28,7 +28,7 @@ var currentObjects = {}
function getObjectByName(objName, objType = null) {
var objectTypes = Object.keys(currentObjects)
if(typeof objType == 'string') {
if(typeof objType == 'string' && objType != "") {
if(objType == "ExecutableObject") {
objectTypes = getExecutableTypes()
} else if(currentObjects[objType] != undefined) {
@ -37,12 +37,14 @@ function getObjectByName(objName, objType = null) {
}
if(Array.isArray(objType)) objectTypes = objType
var retObj = null
if(objName != "" && objName != null) {
objectTypes.forEach(function(objType){
if(currentObjects[objType] == undefined) return null
currentObjects[objType].forEach(function(obj){
if(obj.name == objName) retObj = obj
})
})
}
return retObj
}

View file

@ -110,6 +110,10 @@ class DrawableObject {
}
draw(canvas, ctx) {}
toString() {
return this.name;
}
}
class ExecutableObject extends DrawableObject {

View file

@ -6,7 +6,7 @@ bash release.sh
cd ../../
# Deb
python3 setup.py --remove-git-version --command-packages=stdeb.command sdist_dsc \
sudo python3 setup.py --remove-git-version --command-packages=stdeb.command sdist_dsc \
--package logarithmplotter --copyright-file linux/debian/copyright --suite impish --depends3 "$(cat linux/debian/depends)" --section science \
bdist_deb