Adding new behavior for object creation to default on picker when pickable.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
a66ccd1319
commit
4fe1086d68
3 changed files with 46 additions and 5 deletions
|
@ -34,6 +34,22 @@ Column {
|
|||
id: createRow
|
||||
property var objectEditor
|
||||
property var objectLists
|
||||
property var posPicker
|
||||
|
||||
/*!
|
||||
\qmlmethod int ObjectCreationGrid::openEditorDialog(var obj)
|
||||
Opens the editor dialog for an object \c obj.
|
||||
*/
|
||||
function openEditorDialog(obj) {
|
||||
// Open editor
|
||||
console.log(obj, obj.prototype)
|
||||
objectEditor.obj = obj
|
||||
objectEditor.objType = obj.type
|
||||
objectEditor.objIndex = Objects.currentObjects[obj.type].indexOf(obj)
|
||||
objectEditor.open()
|
||||
// Disconnect potential link
|
||||
posPicker.picked.disconnect(openEditorDialog)
|
||||
}
|
||||
|
||||
Label {
|
||||
id: createTitle
|
||||
|
@ -89,13 +105,26 @@ Column {
|
|||
ToolTip.text: label.text
|
||||
|
||||
onClicked: {
|
||||
var newObj = Objects.createNewRegisteredObject(modelData)
|
||||
let newObj = Objects.createNewRegisteredObject(modelData)
|
||||
history.addToHistory(new HistoryLib.CreateNewObject(newObj.name, modelData, newObj.export()))
|
||||
objectLists.update()
|
||||
objectEditor.obj = Objects.currentObjects[modelData][Objects.currentObjects[modelData].length - 1]
|
||||
objectEditor.objType = modelData
|
||||
objectEditor.objIndex = Objects.currentObjects[modelData].length - 1
|
||||
objectEditor.open()
|
||||
|
||||
let hasXProp = newObj.constructor.properties().hasOwnProperty('x')
|
||||
let hasYProp = newObj.constructor.properties().hasOwnProperty('y')
|
||||
if(hasXProp || hasYProp) {
|
||||
// Open picker
|
||||
posPicker.objType = newObj.type
|
||||
posPicker.objName = newObj.name
|
||||
posPicker.pickX = hasXProp
|
||||
posPicker.pickY = hasYProp
|
||||
posPicker.propertyX = 'x'
|
||||
posPicker.propertyY = 'y'
|
||||
posPicker.visible = true
|
||||
posPicker.picked.connect(openEditorDialog)
|
||||
} else {
|
||||
// Open editor
|
||||
openEditorDialog(newObj)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ ScrollView {
|
|||
width: objectsListView.width
|
||||
objectEditor: objEditor
|
||||
objectLists: objectListList
|
||||
posPicker: positionPicker
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,14 @@ Item {
|
|||
visible: false
|
||||
clip: true
|
||||
|
||||
/*!
|
||||
\qmlsignal PickLocationOverlay::picked(var obj)
|
||||
|
||||
Emitted when a location has been picked
|
||||
The corresponding handler is \c onPicked.
|
||||
*/
|
||||
signal picked(var obj)
|
||||
|
||||
/*!
|
||||
\qmlproperty var PickLocationOverlay::canvas
|
||||
logGraphCanvas instance.
|
||||
|
@ -116,6 +124,7 @@ Item {
|
|||
obj[propertyY] = newValueY
|
||||
obj.update()
|
||||
objectLists.update()
|
||||
pickerRoot.picked(obj)
|
||||
} else if(parent.userPickX) {
|
||||
history.addToHistory(new HistoryLib.EditedProperty(
|
||||
objName, objType, propertyX, obj[propertyX], newValueX
|
||||
|
@ -123,6 +132,7 @@ Item {
|
|||
obj[propertyX] = newValueX
|
||||
obj.update()
|
||||
objectLists.update()
|
||||
pickerRoot.picked(obj)
|
||||
} else if(parent.userPickY) {
|
||||
history.addToHistory(new HistoryLib.EditedProperty(
|
||||
objName, objType, propertyY, obj[propertyY], newValueY
|
||||
|
@ -130,6 +140,7 @@ Item {
|
|||
obj[propertyY] = newValueY
|
||||
obj.update()
|
||||
objectLists.update()
|
||||
pickerRoot.picked(obj)
|
||||
}
|
||||
}
|
||||
pickerRoot.visible = false;
|
||||
|
|
Loading…
Reference in a new issue