From f6a03e15654eb2c0f067835d31eaa5872a19de4d Mon Sep 17 00:00:00 2001 From: "Denis V. Dedkov" Date: Tue, 24 Jul 2018 12:02:04 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D1=83=20=D1=81=20=D0=B3=D1=80?= =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D0=B5=D0=BD=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GradientButton.qml | 32 +++++++++++++++++++++++++++++++ HomeForm.qml | 2 ++ LightGroup.qml | 44 +++++++++++++++++++++++++++++++++++-------- qml.qrc | 1 + qtquickcontrols2.conf | 4 ++-- 5 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 GradientButton.qml diff --git a/GradientButton.qml b/GradientButton.qml new file mode 100644 index 0000000..af2902d --- /dev/null +++ b/GradientButton.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 +import QtQuick.Controls.Material 2.2 + +Rectangle { + id: root + + signal clicked() + + Gradient { + id: pressedGradient + + GradientStop {position: 0.0; color: Material.color(Material.Grey, Material.Shade300)} + GradientStop {position: 0.5; color: Material.color(Material.BlueGrey, Material.Shade300)} + GradientStop {position: 1.0; color: Material.color(Material.Brown, Material.Shade300)} + } + + Gradient { + id: normalGradient + + GradientStop {position: 0.0; color: Material.color(Material.Grey)} + GradientStop {position: 0.5; color: Material.color(Material.BlueGrey)} + GradientStop {position: 1.0; color: Material.color(Material.Brown)} + } + + MouseArea { + id: ma + + anchors.fill: parent + } + + gradient: ma.pressed ? pressedGradient : normalGradient +} diff --git a/HomeForm.qml b/HomeForm.qml index ba72a28..f43d794 100644 --- a/HomeForm.qml +++ b/HomeForm.qml @@ -14,6 +14,7 @@ Page { ListView { anchors.fill: parent + anchors.margins: 5 model: lightsModel spacing: 5 @@ -23,6 +24,7 @@ Page { height: childrenRect.height title: groupName || "" + lights: channels } } } diff --git a/LightGroup.qml b/LightGroup.qml index 02e2be6..465a67b 100644 --- a/LightGroup.qml +++ b/LightGroup.qml @@ -5,17 +5,45 @@ Item { id: root property string title: "" - property var lights: [] + property QtObject lights: undefined - Rectangle { - width: parent.width - height: 20 + Column { + width: root.width - color: "green" + spacing: 5 - Label { - text: root.title - anchors.centerIn: parent + GradientButton { + width: root.width + height: 40 + + visible: Boolean(root.title) + radius: 5 + + Label { + text: root.title + anchors.centerIn: parent + } + } + + Row { + id: buttonsRow + + width: root.width + height: childrenRect.height + + spacing: 5 + + Repeater { + model: root.lights + + width: root.width + + GradientButton { + width: (root.width - buttonsRow.spacing * (root.lights.count - 1)) / root.lights.count + height: width / 2 + radius: 5 + } + } } } } diff --git a/qml.qrc b/qml.qrc index ff00483..f6d169e 100644 --- a/qml.qrc +++ b/qml.qrc @@ -8,5 +8,6 @@ SubtitledItemDelegate.qml LightsModel.qml LightGroup.qml + GradientButton.qml diff --git a/qtquickcontrols2.conf b/qtquickcontrols2.conf index 613ab74..5a7d1ec 100644 --- a/qtquickcontrols2.conf +++ b/qtquickcontrols2.conf @@ -7,7 +7,7 @@ Style=Material [Material] Theme=Dark -Primary=#3C3C3C -Accent=BlueGrey +Primary=BlueGrey +Accent=Grey ;Foreground=Brown ;Background=Steel