-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update Button Inputs for Old Steering Wheel * Setup Speed Mode * Lower SIze of Menu Items * Set Previous Max Speed in Model
- Loading branch information
1 parent
c661614
commit 45f317b
Showing
22 changed files
with
545 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ Rectangle { | |
LabelText { | ||
id: label | ||
padding: 8 | ||
font.pixelSize: 16 | ||
text: parent.text | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
import QtQuick.Layouts 1.3 | ||
|
||
Rectangle { | ||
id: background | ||
|
||
property int dimension: 200 | ||
|
||
width: dimension | ||
height: dimension | ||
|
||
color: "transparent" | ||
|
||
property int value: 130 | ||
|
||
Canvas { | ||
id: canvas | ||
anchors.fill: parent | ||
onPaint: { | ||
var ctx = getContext("2d") | ||
var centerX = dimension / 2 | ||
var centerY = dimension / 2 | ||
var radius = Math.min(dimension, dimension) / 2 - 25 | ||
var startAngle = -Math.PI / 2 | ||
var endAngle = startAngle + (value / 300) * 2 * Math.PI | ||
|
||
ctx.beginPath() | ||
ctx.arc(centerX, centerY, radius, startAngle, endAngle, false) | ||
ctx.strokeStyle = '#14f804' | ||
ctx.lineWidth = 0.06 * background.dimension | ||
ctx.stroke() | ||
} | ||
} | ||
|
||
RowLayout { | ||
spacing: 0 | ||
anchors.centerIn: parent | ||
LabelText { | ||
text: value.toString() | ||
font.pixelSize: 0.25 * background.dimension | ||
font.bold: true | ||
color: "white" | ||
} | ||
|
||
LabelText { | ||
text: "A" | ||
font.pixelSize: 0.15 * background.dimension | ||
font.bold: true | ||
color: "white" | ||
Layout.topMargin: 0.06 * background.dimension | ||
} | ||
} | ||
|
||
onValueChanged: canvas.requestPaint() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
|
||
Rectangle { | ||
id: maxSpeedComparator | ||
property int dimension: 100 | ||
property int maxSpeed: 100 | ||
property int lowestSpeed: 0 | ||
property int previousTopSpeed: 40 | ||
property int currentSpeed: 50 //change to 0 | ||
|
||
width: dimension | ||
height: dimension * 3 | ||
radius: 5 | ||
color: "black" | ||
border.color: "white" | ||
|
||
Text { | ||
id: maxSpeed | ||
text: maxSpeedComparator.maxSpeed | ||
font.pixelSize: parent.width * 0.2 | ||
color: "white" | ||
x: -(width + dimension / 20) | ||
} | ||
|
||
Text { | ||
id: lowestSpeed | ||
text: maxSpeedComparator.lowestSpeed | ||
font.pixelSize: parent.width * 0.2 | ||
color: "white" | ||
x: -(width + dimension / 20) | ||
y: maxSpeedComparator.height - height | ||
} | ||
|
||
Rectangle { | ||
id: bar | ||
y: (maxSpeedComparator.height - height) - 5 | ||
anchors.horizontalCenter: parent.horizontalCenter | ||
width: topSpeedBar.width | ||
height: maxSpeedComparator.height * percentageHeight - 10 | ||
radius: 5 | ||
property real percentageHeight: parseFloat( | ||
(maxSpeedComparator.currentSpeed | ||
/ maxSpeedComparator.maxSpeed).toFixed( | ||
2)) // Calculate percentage of height relative to maxSpeedComparator | ||
|
||
gradient: Gradient { | ||
GradientStop { | ||
position: -5 * (1 - bar.percentageHeight | ||
+ 0.1) // Start of gradient relative to parent's height | ||
color: "red" | ||
} | ||
GradientStop { | ||
position: 1.0 // End of gradient relative to parent's height | ||
color: "#55FF00" | ||
} | ||
} | ||
transformOrigin: Item.BottomLeft | ||
Behavior on rotation { | ||
SpringAnimation { | ||
spring: 1.4 | ||
damping: .15 | ||
} | ||
} | ||
} | ||
|
||
Text { | ||
id: topSpeed | ||
text: qsTr("TOP SPEED") | ||
color: "white" | ||
x: -(width + dimension / 20) | ||
y: maxSpeedComparator.height * (1 - maxSpeedComparator.previousTopSpeed | ||
/ maxSpeedComparator.maxSpeed) | ||
font.pixelSize: parent.width * 0.2 | ||
Text { | ||
id: topSpeedNumber | ||
text: maxSpeedComparator.previousTopSpeed + qsTr("MPH") | ||
color: "white" | ||
y: -height | ||
font.pixelSize: parent.width * 0.2 | ||
|
||
x: (topSpeed.width - width) | ||
} | ||
} | ||
|
||
onCurrentSpeedChanged: { | ||
console.log("Speededd", maxSpeedComparator.currentSpeed) | ||
} | ||
|
||
Rectangle { | ||
id: topSpeedBar | ||
y: maxSpeedComparator.height * (1 - maxSpeedComparator.previousTopSpeed | ||
/ maxSpeedComparator.maxSpeed) | ||
width: maxSpeedComparator.width - dimension / 6 | ||
anchors.horizontalCenter: parent.horizontalCenter | ||
height: 2 | ||
color: "white" | ||
} | ||
|
||
function setCurrentSpeed(speed) { | ||
maxSpeedComparator.currentSpeed = speed | ||
} | ||
|
||
function setTopSpeed(top_speed) { | ||
topSpeedNumber.text = top_speed + "MPH" | ||
topSpeed.y = top_speed | ||
} | ||
|
||
Behavior on currentSpeed { | ||
NumberAnimation { | ||
duration: 100 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
|
||
Item { | ||
id: runInfo | ||
|
||
property int widthValue: 200 | ||
property int heightValue: 40 | ||
|
||
width: widthValue | ||
height: heightValue | ||
|
||
property string backgroundColor: "white" | ||
property string label: "" | ||
property int value: 0 | ||
property int topRadius: 0 | ||
property int radius: 0 | ||
property bool isTop: false | ||
property bool isBottom: false | ||
|
||
Rectangle { | ||
id: bottomRect | ||
visible: runInfo.isTop | ||
width: runInfo.width | ||
height: runInfo.radius | ||
color: runInfo.backgroundColor | ||
|
||
anchors { | ||
left: runInfo.left | ||
bottom: runInfo.bottom | ||
} | ||
} | ||
|
||
Rectangle { | ||
id: topRect | ||
visible: runInfo.isBottom | ||
width: runInfo.width | ||
height: runInfo.radius | ||
color: runInfo.backgroundColor | ||
|
||
anchors { | ||
left: runInfo.left | ||
top: runInfo.top | ||
} | ||
} | ||
|
||
Rectangle { | ||
height: runInfo.height | ||
width: runInfo.width | ||
color: backgroundColor | ||
radius: runInfo.radius | ||
|
||
anchors { | ||
left: runInfo.left | ||
top: runInfo.top | ||
} | ||
|
||
Rectangle { | ||
id: rightBlackRectangle | ||
width: runInfo.width / 4 | ||
height: runInfo.height * 0.8 | ||
color: "black" | ||
|
||
x: parent.width * 0.7 | ||
y: parent.height / 10 | ||
|
||
ValueText { | ||
id: valueText | ||
text: value | ||
font.pixelSize: rightBlackRectangle.height * 0.8 | ||
x: rightBlackRectangle.width * 0.5 - rightBlackRectangle.height / 4.5 | ||
y: rightBlackRectangle.height * -0.1 | ||
color: "white" | ||
font.bold: true | ||
} | ||
} | ||
|
||
LabelText { | ||
id: labelText | ||
text: label | ||
x: runInfo.width * 0.05 | ||
y: runInfo.isTop ? runInfo.height * 0.6 - font.pixelSize + topRect.height | ||
* 0.1 : (runInfo.isBottom ? runInfo.height * 0.6 - font.pixelSize + bottomRect.height * 0.15 : runInfo.height * 0.6 - font.pixelSize) | ||
font.pixelSize: Math.min(runInfo.height * 0.6, runInfo.width * 0.08) | ||
color: "black" | ||
font.bold: true | ||
} | ||
} | ||
} |
Oops, something went wrong.