Add position field to device settings

This commit is contained in:
2023-02-15 20:17:58 +01:00
parent 579eba2b1b
commit e30c5293ed
6 changed files with 66 additions and 6 deletions

View File

@ -27,6 +27,7 @@ qt_add_qml_module(applightcontrol
EditableListView.qml
DeviceTypesSettingsPage.qml
DevicesSettingsPage.qml
Vector3DField.qml
)
set_target_properties(applightcontrol PROPERTIES

View File

@ -22,6 +22,8 @@ ColumnLayout {
onAddClicked: (index) => devicesModel.insertRow(index < 0 ? 0 : index + 1);
onRemoveClicked: (index) => devicesModel.removeRow(index)
onCurrentDataChanged: test.value = currentData.position
}
ColumnLayout {
@ -51,7 +53,7 @@ ColumnLayout {
model: deviceTypesModel
textRole: "name"
valueRole: "id"
// TODO
// TODO make binding for selection
}
Label { text: qsTr("Address:") }
SpinBox {
@ -60,6 +62,12 @@ ColumnLayout {
onValueModified: listView.currentItem.myData.address = value
}
Label { text: qsTr("Position:") }
Vector3DField {
id: test
Layout.fillWidth: true
onValueModified: listView.currentItem.myData.position = value;
// TODO solve without onCurrentDataChanged
}
}
Item {
Layout.fillHeight: true

View File

@ -6,6 +6,7 @@ ColumnLayout {
property alias model: listView.model
property alias currentIndex: listView.currentIndex
property alias currentItem: listView.currentItem
property variant currentData: listView.currentItem ? listView.currentItem.myData : null
signal addClicked(index: int)
signal removeClicked(index: int)

50
Vector3DField.qml Normal file
View File

@ -0,0 +1,50 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls.Material
RowLayout {
property vector3d value
onValueChanged: {
xBox.value = value.x
yBox.value = value.y
zBox.value = value.z
}
signal valueModified
function updateValue() {
const newValue = Qt.vector3d(xBox.value, yBox.value, zBox.value);
console.log(newValue);
if (newValue === value)
return;
value = newValue;
valueModified();
}
Label {
text: qsTr('x:')
}
SpinBox {
id: xBox
onValueModified: updateValue()
}
Label {
text: qsTr('y:')
}
SpinBox {
id: yBox
onValueModified: updateValue()
}
Label {
text: qsTr('z:')
}
SpinBox {
id: zBox
onValueModified: updateValue()
}
}

View File

@ -229,7 +229,7 @@ bool DevicesModel::setData(const QModelIndex &index, const QVariant &value, int
return false;
}
light.position = value.value<QVector3D>();
emit dataChanged(index, index, { AddressRole });
emit dataChanged(index, index, { PositionRole });
return true;
}

View File

@ -18,9 +18,9 @@ DmxController::DmxController(QObject *parent) :
{ .id=3, .name="Nebelmaschine" }
},
.lights {
{ .id=0, .name="Lampe 1", .lightTypeId=1, .address=32 },
{ .id=1, .name="Lampe 2", .lightTypeId=1, .address=0 },
{ .id=2, .name="Lampe 3", .lightTypeId=1, .address=7 },
{ .id=0, .name="Lampe 1", .lightTypeId=1, .address=32, .position{1,0,0} },
{ .id=1, .name="Lampe 2", .lightTypeId=1, .address=0, .position{2,0,0} },
{ .id=2, .name="Lampe 3", .lightTypeId=1, .address=7, .position{3,0,0} },
{ .id=3, .name="Lampe 4", .lightTypeId=1, .address=14 },
{ .id=4, .name="Moving Head 1", .lightTypeId=0, .address=40 },
{ .id=5, .name="Moving Head 2", .lightTypeId=0, .address=43 },
@ -102,7 +102,7 @@ void DmxController::sendDmxBuffer()
if (m_lastInfo.msecsTo(now) >= 1000)
{
qInfo("%i per second ä", m_counter);
qInfo("%i per second", m_counter);
m_counter = 0;
m_lastInfo = now;
}