Adding picker for properties (x,y,labelX)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adsooi 2023-05-24 03:51:42 +02:00
parent 5cef8e23fa
commit 6abbbe5e61
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
4 changed files with 84 additions and 33 deletions

View file

@ -18,6 +18,7 @@
import QtQuick
import QtQuick.Controls
import Qt.labs.platform as Native
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../../js/objects.js" as Objects
import "../../js/historylib.js" as HistoryLib
@ -43,6 +44,11 @@ Repeater {
Object whose properties to list and edit.
*/
property var obj
/*!
\qmlproperty var CustomPropertyList::positionPicker
Reference to the global PositionPicker QML object.
*/
property var positionPicker
readonly property var textTypes: ['Domain', 'string', 'number']
readonly property var comboBoxTypes: ['ObjectType', 'Enum']
@ -123,15 +129,15 @@ Repeater {
}
// D.MessageDialog {
// id: parsingErrorDialog
// title: qsTranslate("expression", "LogarithmPlotter - Parsing error")
// text: ""
// function showDialog(propName, propValue, error) {
// text = qsTranslate("error", "Error while parsing expression for property %1:\n%2\n\nEvaluated expression: %3").arg(propName).arg(error).arg(propValue)
// open()
// }
// }
Native.MessageDialog {
id: parsingErrorDialog
title: qsTranslate("expression", "LogarithmPlotter - Parsing error")
text: ""
function showDialog(propName, propValue, error) {
text = qsTranslate("error", "Error while parsing expression for property %1:\n%2\n\nEvaluated expression: %3").arg(propName).arg(error).arg(propValue)
open()
}
}
}
}
@ -255,9 +261,13 @@ Repeater {
}
delegate: Component {
Loader {
//height: customPropComment.height + customPropText.height + customPropCheckBox.height + customPropCombo.height + customPropListDict.height
Row {
width: dlgProperties.width
spacing: 5
Loader {
id: propertyEditor
width: dlgProperties.width - pointerButton.width
property string propertyName: modelData[0]
property var propertyType: modelData[1]
property string propertyLabel: qsTranslate('prop',propertyName)
@ -280,5 +290,40 @@ Repeater {
return {}
}
}
Button {
id: pointerButton
height: parent.height
width: visible ? height : 0
anchors.verticalCenter: parent.verticalCenter
property bool isXProp: ['labelX', 'x'].includes(propertyEditor.propertyName)
property bool isYProp: ['y'].includes(propertyEditor.propertyName)
visible: isXProp || isYProp
ToolTip.visible: hovered
ToolTip.text: qsTr("Pick on graph")
Setting.Icon {
id: icon
width: 18
height: 18
anchors.centerIn: parent
color: sysPalette.windowText
source: '../icons/common/position.svg'
}
onClicked: {
positionPicker.objType = objType
positionPicker.objName = obj.name
positionPicker.pickX = isXProp
positionPicker.pickY = isYProp
positionPicker.propertyX = propertyEditor.propertyName
positionPicker.propertyY = propertyEditor.propertyName
positionPicker.visible = true
objEditor.close()
}
}
}
}
}

View file

@ -55,6 +55,11 @@ Popup.BaseDialog {
Instance of the object being edited.
*/
property var obj: Objects.currentObjects[objType][objIndex]
/*!
\qmlproperty var EditorDialog::posPicker
Reference to the global PositionPicker QML object.
*/
property var posPicker
title: "LogarithmPlotter"
width: 350
@ -106,7 +111,6 @@ Popup.BaseDialog {
value: objEditor.obj.name
onChanged: function(newValue) {
let newName = Utils.parseName(newValue)
console.log(newValue, newName)
if(newName != '' && objEditor.obj.name != newName) {
if(newName in Objects.currentObjectsByName) {
invalidNameDialog.showDialog(newName)
@ -144,6 +148,7 @@ Popup.BaseDialog {
CustomPropertyList {
id: dlgCustomProperties
obj: objEditor.obj
positionPicker: posPicker
onChanged: {
obj.update()

View file

@ -116,6 +116,8 @@ ScrollView {
// Object editor
Editor.Dialog {
id: objEditor
posPicker: positionPicker
}
/*!

View file

@ -125,7 +125,6 @@ Item {
if(control.isInt) value = Math.max(control.min,parseInt(value).toString()=="NaN"?control.min:parseInt(value))
if(control.isDouble) value = Math.max(control.min,parseFloat(value).toString()=="NaN"?control.min:parseFloat(value))
if(value != "" && value.toString() != defValue) {
console.log(value, value.toString())
control.changed(value)
defValue = value.toString()
}