From 97e09d4ec907ed04e86bedc70d151e01d96894fe Mon Sep 17 00:00:00 2001 From: Michael Ehrenreich Date: Wed, 15 Feb 2023 23:33:22 +0100 Subject: [PATCH] Split pane with sliders for each light off into separate QML file --- CMakeLists.txt | 1 + HomePage.qml | 60 ++------------------------------------ LightSliderPane.qml | 70 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 58 deletions(-) create mode 100644 LightSliderPane.qml diff --git a/CMakeLists.txt b/CMakeLists.txt index 32a31fc..a5cbead 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ qt_add_qml_module(applightcontrol HomePage.qml SettingsPage.qml LightControlWindow.qml + LightSliderPane.qml EditableListView.qml DeviceTypesSettingsPage.qml DevicesSettingsPage.qml diff --git a/HomePage.qml b/HomePage.qml index 03d2d9a..4fa2c31 100644 --- a/HomePage.qml +++ b/HomePage.qml @@ -17,66 +17,10 @@ RowLayout { Repeater { model: devicesModel - delegate: Pane { - property int deviceAddress: model.address - property int myDeviceTypeId: model.deviceTypeId + delegate: LightSliderPane { + light: model - Material.elevation: 6 - - //width: 75 height: 250 - - ColumnLayout { - anchors.fill: parent - - Label { - Layout.fillWidth: true - text: model.name - horizontalAlignment: Text.AlignHCenter - } - - RowLayout { - Layout.fillWidth: true - Layout.fillHeight: true - - Repeater { - model: DeviceTypeRegistersModel { - controller: __controller - deviceTypeId: myDeviceTypeId - } - - delegate: ColumnLayout { - property int registerAddress: deviceAddress + index - - Layout.fillHeight: true - - Label { - Layout.fillWidth: true - text: model.registerTypeName - horizontalAlignment: Text.AlignHCenter - } - - Slider { - id: slider - Layout.fillWidth: true - Layout.fillHeight: true - - orientation: Qt.Vertical - from: 0 - to: 255 - - onValueChanged: __controller.setChannel(registerAddress, value) - } - - Label { - Layout.fillWidth: true - text: Math.round(slider.value) - horizontalAlignment: Text.AlignHCenter - } - } - } - } - } } } } diff --git a/LightSliderPane.qml b/LightSliderPane.qml new file mode 100644 index 0000000..9e0145f --- /dev/null +++ b/LightSliderPane.qml @@ -0,0 +1,70 @@ +import QtQuick +import QtQuick.Controls.Material +import QtQuick.Layouts +import QtQuick.Window +import QtQuick.VirtualKeyboard + +import com.büro 1.0 + + +Pane { + property variant light + + Material.elevation: 6 + + ColumnLayout { + + anchors.fill: parent + + Label { + Layout.fillWidth: true + text: light.name + horizontalAlignment: Text.AlignHCenter + } + + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + + Repeater { + model: DeviceTypeRegistersModel { + controller: __controller + deviceTypeId: light.deviceTypeId + } + + delegate: ColumnLayout { + property int registerAddress: light.address + index + + Layout.fillHeight: true + + Label { + Layout.fillWidth: true + text: model.registerTypeName + horizontalAlignment: Text.AlignHCenter + } + + Slider { + id: slider + Layout.fillWidth: true + Layout.fillHeight: true + + orientation: Qt.Vertical + from: 0 + to: 255 + + snapMode: Slider.SnapAlways + stepSize: 1 + + onValueChanged: __controller.setChannel(registerAddress, value) + } + + Label { + Layout.fillWidth: true + text: Math.round(slider.value) + horizontalAlignment: Text.AlignHCenter + } + } + } + } + } +}