From d31125cf178a55f40816119ea6a8d1be97ec4a8a Mon Sep 17 00:00:00 2001 From: Tilak Patel Date: Wed, 30 Oct 2024 04:19:33 -0400 Subject: [PATCH 1/2] Update thermometer component in QML --- NERODesign/content/Thermometer.qml | 132 +++++++++++++++++++++-------- 1 file changed, 99 insertions(+), 33 deletions(-) diff --git a/NERODesign/content/Thermometer.qml b/NERODesign/content/Thermometer.qml index 8bf80d9..2398a57 100644 --- a/NERODesign/content/Thermometer.qml +++ b/NERODesign/content/Thermometer.qml @@ -6,74 +6,140 @@ Item { id: thermometer property bool regen: false property int value: 0 - property int horizontalPadding: width / 20 property int maxValue: 65 property int minValue: -15 property string color: regen ? "red" : value > maxValue - ((Math.abs(maxValue) + Math.abs( minValue)) / 5) ? "red" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 2) ? "orange" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 3) ? "#FFF500" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 4) ? "blue" : "purple" height: 500 - width: 600 + width: 200 + + property real intersectPoint: 0.2 + property real totalFillPercentage: (Math.max(0, value - minValue) / (maxValue - minValue)) + property real circleFillPercentage: Math.min(1, totalFillPercentage / intersectPoint) + property real tubeFillPercentage: Math.max(0, (totalFillPercentage - intersectPoint) / (1 - intersectPoint)) + property bool increasing: value > previousValue + property int previousValue: value + + onValueChanged: { + increasing = value > previousValue; + previousValue = value; + } Rectangle { visible: thermometer.regen id: lightningBackground width: parent.width / 3 - height: parent.height / 4 - color: "white" + height: parent.height / 3 + color: "black" anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter anchors.verticalCenterOffset: -parent.height / 20 - radius: 20 + radius: 0 rotation: -45 anchors.centerIn: parent } Rectangle { id: topSemiCircle - anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenter: outerRectangle.horizontalCenter anchors.top: parent.top - width: parent.width / 4 - height: parent.width / 4 - radius: parent.width / 4 - color: "white" - } - - Rectangle { - id: outerRectangle - anchors.top: topSemiCircle.verticalCenter - anchors.bottom: bottomOuterCircle.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width / 4 - height: parent.height / 2 - color: "white" + width: parent.width / 3 + height: parent.width / 5 + radius: parent.width / 10 + color: thermometer.color } Rectangle { - id: bottomOuterCircle + id: bottomCircle anchors.horizontalCenter: parent.horizontalCenter + anchors.baselineOffset: outerRectangle.bottom - 400 y: parent.height / 2 width: thermometer.width / 2 height: thermometer.width / 2 - radius: thermometer.width / 2 - color: "white" + radius: width / 2 + color: "black" + border.width: width * 0.15 + border.color: thermometer.color + clip: true Rectangle { - id: fillBottomCircle + id: innerFillCircle + width: parent.width - parent.border.width * 2 + height: parent.height - parent.border.width * 2 + radius: (parent.width - parent.border.width * 2) / 2 anchors.centerIn: parent - width: parent.width * 0.8 - height: parent.height * 0.8 - radius: parent.radius - color: thermometer.color + color: "black" + clip: true + + Rectangle { + id: gradientFill + width: parent.width + height: innerFillCircle.height * circleFillPercentage + anchors.bottom: innerFillCircle.bottom + radius: innerFillCircle.radius + gradient: Gradient { + GradientStop { position: 0.0; color: thermometer.color } + GradientStop { position: 0.5; color: Qt.darker(thermometer.color, 1.5) } + GradientStop { position: 1.0; color: Qt.darker(thermometer.color, 2.5) } + } + } } } Rectangle { - id: fillRectangle - anchors.fill: outerRectangle - - anchors.leftMargin: thermometer.horizontalPadding - anchors.rightMargin: thermometer.horizontalPadding + id: outerRectangle + anchors.top: topSemiCircle.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width / 3 + height: parent.height * .5 color: thermometer.color + + Rectangle { + id: innerRectangle + width: parent.width / 1.75 + height: parent.height + anchors { + centerIn: parent + verticalCenterOffset: topSemiCircle.height / 100 + } + color: "black" + clip: true + } + + Rectangle { + id: thermometerFill + width: innerRectangle.width + height: innerRectangle.height + anchors { + centerIn: innerRectangle + } + clip: true + color: "black" + + Rectangle { + id: fillElement + width: parent.width + height: parent.height * tubeFillPercentage + anchors.bottom: parent.bottom + color: thermometer.color + + Behavior on height { + NumberAnimation { + duration: 1000 + easing.type: Easing.OutQuad + running: thermometer.totalFillPercentage > thermometer.intersectPoint && increasing + } + } + + Behavior on height { + NumberAnimation { + duration: 1000 + easing.type: Easing.InOutQuad + running: thermometer.totalFillPercentage <= thermometer.intersectPoint && !increasing + } + } + } + } } Lightning { From 9c23f32eab574eceb97e7551215fa070f833cbea Mon Sep 17 00:00:00 2001 From: Tilak Patel Date: Sun, 17 Nov 2024 05:57:24 -0500 Subject: [PATCH 2/2] fixed changes for pull request --- NERODesign/NERO.qmlproject.qtds | 11 +- NERODesign/NERO.qmlproject.qtds.3cfc90f | 116 ++++++++++++++++++ NERODesign/content/App.qml | 10 +- NERODesign/content/Pit.qml | 2 +- NERODesign/content/Thermometer.qml | 3 +- .../content/ThermometerValueComponent.qml | 5 +- 6 files changed, 131 insertions(+), 16 deletions(-) create mode 100644 NERODesign/NERO.qmlproject.qtds.3cfc90f diff --git a/NERODesign/NERO.qmlproject.qtds b/NERODesign/NERO.qmlproject.qtds index 98c1ee8..fd58ed2 100644 --- a/NERODesign/NERO.qmlproject.qtds +++ b/NERODesign/NERO.qmlproject.qtds @@ -1,10 +1,10 @@ - + EnvironmentId - {3cfc90f2-223d-425b-80aa-55ae979292b1} + {8cc7a412-b525-49ef-bbee-0b31ae85f947} ProjectExplorer.Project.ActiveTarget @@ -41,7 +41,7 @@ false true false - 0 + 2 true true 0 @@ -62,8 +62,8 @@ ProjectExplorer.Project.Target.0 Desktop - Desktop Qt 6.6.0 - Desktop Qt 6.6.0 + Desktop Qt 6.7.1 + Desktop Qt 6.7.1 {63f87550-2541-4163-9631-08b7fea781da} -1 0 @@ -83,7 +83,6 @@ 1 - true 0 diff --git a/NERODesign/NERO.qmlproject.qtds.3cfc90f b/NERODesign/NERO.qmlproject.qtds.3cfc90f new file mode 100644 index 0000000..98c1ee8 --- /dev/null +++ b/NERODesign/NERO.qmlproject.qtds.3cfc90f @@ -0,0 +1,116 @@ + + + + + + EnvironmentId + {3cfc90f2-223d-425b-80aa-55ae979292b1} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + 0 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.6.0 + Desktop Qt 6.6.0 + {63f87550-2541-4163-9631-08b7fea781da} + -1 + 0 + 0 + 0 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + + 0 + + false + QML Runtime + QmlProjectManager.QmlRunConfiguration.Qml + + false + en + CurrentFile + true + true + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/NERODesign/content/App.qml b/NERODesign/content/App.qml index 39234a1..87d3093 100644 --- a/NERODesign/content/App.qml +++ b/NERODesign/content/App.qml @@ -17,11 +17,11 @@ Window { source: "fonts/Roboto-Black.ttf" } - // Pit { - // id: pitScreen - // } - // EfficiencyScreen {} - OffScreen {} + Pit { + id: pitScreen + } + //EfficiencyScreen {} + // OffScreen {} Timeline { id: appTimeline animations: [ diff --git a/NERODesign/content/Pit.qml b/NERODesign/content/Pit.qml index 3441205..9b0e495 100644 --- a/NERODesign/content/Pit.qml +++ b/NERODesign/content/Pit.qml @@ -56,7 +56,7 @@ Rectangle { anchors.top: parent.top anchors.bottom: parent.bottom width: parent.width / 2 - + thermometerColor: "#FF0000" thermometerValue: pit.packTempValue title: "PACK TEMP" } diff --git a/NERODesign/content/Thermometer.qml b/NERODesign/content/Thermometer.qml index 2398a57..056cd34 100644 --- a/NERODesign/content/Thermometer.qml +++ b/NERODesign/content/Thermometer.qml @@ -8,8 +8,7 @@ Item { property int value: 0 property int maxValue: 65 property int minValue: -15 - property string color: regen ? "red" : value > maxValue - ((Math.abs(maxValue) + Math.abs( - minValue)) / 5) ? "red" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 2) ? "orange" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 3) ? "#FFF500" : value > maxValue - (((Math.abs(maxValue) + Math.abs(minValue)) / 5) * 4) ? "blue" : "purple" + property string color height: 500 width: 200 diff --git a/NERODesign/content/ThermometerValueComponent.qml b/NERODesign/content/ThermometerValueComponent.qml index 1e8def8..8772661 100644 --- a/NERODesign/content/ThermometerValueComponent.qml +++ b/NERODesign/content/ThermometerValueComponent.qml @@ -8,8 +8,8 @@ Rectangle { property int horizontalIconSpacing: width * 0.1 property int labelVerticalSpacing: height * 0.1 property bool regen: false - - color: 'transparent' + color: "transparent" + property string thermometerColor: "#FF0000" height: 100 width: 100 @@ -29,6 +29,7 @@ Rectangle { anchors.top: parent.top anchors.right: parent.horizontalCenter regen: thermometerComponent.regen + color: thermometerComponent.thermometerColor } ValueText {