Files
scheincommander/DevicesSettingsPage.qml

147 lines
5.0 KiB
QML
Raw Permalink Normal View History

2023-02-15 01:12:19 +01:00
import QtQuick
import QtQuick.Controls
2023-02-15 01:12:19 +01:00
import QtQuick.Controls.Material
import QtQuick.Layouts
2023-02-21 20:28:53 +01:00
import scheincommander
2023-02-15 01:12:19 +01:00
ColumnLayout {
Label {
text: qsTr("Devices Settings")
}
RowLayout {
//Layout.fillWidth: true
Layout.fillHeight: true
EditableListView {
id: listView
2023-02-23 01:15:59 +01:00
iconSourceRole: "iconUrl"
2023-02-15 01:12:19 +01:00
Layout.preferredWidth: 300
Layout.maximumWidth: 300
Layout.fillHeight: true
2023-02-19 21:22:45 +01:00
model: DevicesModel {
id: model
controller: __controller
}
2023-02-15 01:12:19 +01:00
2023-02-19 21:22:45 +01:00
onAddClicked: (index) => { const newIndex = index < 0 ? 0 : index + 1; if (model.insertRow(newIndex)) currentIndex = newIndex; else console.warn('failed'); }
onRemoveClicked: (index) => {
const dialog = dialogComponent.createObject(Overlay.overlay);
dialog.index = index;
dialog.open();
}
2023-02-15 20:17:58 +01:00
onCurrentDataChanged: if (currentData) positionField.value = currentData.position
Component {
id: dialogComponent
Dialog {
property int index
anchors.centerIn: parent
standardButtons: DialogButtonBox.Yes | DialogButtonBox.Cancel
modal: true
title: qsTr('Confirmation')
2023-03-04 20:19:10 +01:00
onAccepted: if (!model.removeRow(index)) console.warn('failed');
Label {
id: textContainer
anchors.fill: parent
horizontalAlignment: Qt.AlignLeft
verticalAlignment: Qt.AlignTop
text: qsTr('Are you sure you want to remove row %0').arg(index)
}
}
}
2023-02-15 01:12:19 +01:00
}
ColumnLayout {
enabled: listView.currentIndex !== -1
2023-02-23 01:15:59 +01:00
Layout.preferredWidth: 400
Layout.maximumWidth: 400
2023-02-15 01:12:19 +01:00
GridLayout {
2023-02-23 01:15:59 +01:00
Layout.fillWidth: true
// Layout.preferredWidth: 300
// Layout.maximumWidth: 300
2023-02-15 01:12:19 +01:00
columns: 2
Label { text: qsTr("Id:") }
SpinBox {
2023-02-15 22:27:57 +01:00
enabled: false
2023-02-15 01:12:19 +01:00
Layout.fillWidth: true
2023-02-18 21:42:50 +01:00
value: listView.currentData ? listView.currentData.id : -1
2023-03-04 20:19:10 +01:00
onValueModified: if (listView.currentData) listView.currentData.id = value; else console.warn('discarded');
2023-02-15 01:12:19 +01:00
}
Label { text: qsTr("Name:") }
TextField {
Layout.fillWidth: true
2023-02-18 21:42:50 +01:00
text: listView.currentData ? listView.currentData.name : ''
2023-03-04 20:19:10 +01:00
onTextEdited: if (listView.currentData) listView.currentData.name = text; else console.warn('discarded');
2023-02-15 01:12:19 +01:00
}
Label { text: qsTr("DeviceType:") }
2023-02-23 01:15:59 +01:00
IconComboBox {
2023-02-15 22:45:18 +01:00
id: deviceTypeCombobox
2023-02-15 01:12:19 +01:00
Layout.fillWidth: true
Layout.preferredHeight: 64
model: DeviceTypesModel {
controller: __controller
}
2023-02-15 01:12:19 +01:00
textRole: "name"
valueRole: "id"
2023-02-23 01:15:59 +01:00
iconSourceRole: "iconUrl"
iconSourceRoleInt: DeviceTypesModel.IconUrlRole
currentIndex: listView.currentData ? deviceTypeCombobox.indexOfValue(listView.currentData.deviceTypeId) : -1
onActivated: if (listView.currentData) listView.currentData.deviceTypeId = currentValue; else console.warn('discarded');
2023-02-15 01:12:19 +01:00
}
Label { text: qsTr("Address:") }
SpinBox {
2023-02-18 22:49:27 +01:00
to: 512
2023-02-15 01:12:19 +01:00
Layout.fillWidth: true
2023-02-18 21:42:50 +01:00
value: listView.currentData ? listView.currentData.address : -1
2023-03-04 20:19:10 +01:00
onValueModified: if (listView.currentData) listView.currentData.address = value; else console.warn('discarded');
2023-02-15 01:12:19 +01:00
}
Label {
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
text: qsTr("Position:")
}
2023-02-15 20:17:58 +01:00
Vector3DField {
2023-02-18 21:42:50 +01:00
id: positionField
2023-02-15 20:17:58 +01:00
Layout.fillWidth: true
2023-03-04 20:19:10 +01:00
onValueModified: if (listView.currentData) listView.currentData.position = value; else console.warn('discarded');
2023-02-15 20:17:58 +01:00
// TODO solve without onCurrentDataChanged
}
2023-02-15 01:12:19 +01:00
}
Item {
Layout.fillHeight: true
}
}
2023-02-22 00:23:45 +01:00
Devices3dView {
id: devices3dView
2023-02-22 00:23:45 +01:00
Layout.fillWidth: true
Layout.fillHeight: true
2023-02-23 01:15:59 +01:00
// Layout.preferredWidth: 300
Layout.minimumWidth: 300
model: model
selectedItem: listView.currentIndex
onSelectedItemChanged: if (selectedItem != -1) listView.currentIndex = selectedItem;
2023-02-22 00:23:45 +01:00
}
2023-02-15 01:12:19 +01:00
}
}