Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.15
- import QtQuick.Window 2.15
- import QtQuick.Controls 2.12
- import QtQml 2.2
- Window {
- id: mw
- width: 1800
- height: 700
- visible: true
- title: qsTr("Heads Up Display")
- signal knopfMotorEinAus()
- signal knopfGasHoch()
- signal knopfGasRunter()
- signal knopfGang0()
- signal knopfRechneAlles()
- signal knopfGang(int x)
- signal knopfBremsen()
- Rectangle{
- anchors.fill: parent
- color: "lightgrey"
- }
- // ++++ INTERACTION ++++
- Item {
- id: keyInput
- focus: true
- Keys.onPressed: {
- // ++++ START MOTOR ++++
- if(event.key === Qt.Key_S)
- {
- if(!dash.visible){
- timer.start();
- mw.knopfMotorEinAus();
- dash.visible = true;
- event.accepted = true;
- }
- else if(dash.visible)
- {
- timer.stop();
- mw.knopfMotorEinAus();
- dash.closeRearView();
- dash.visible = false;
- event.accepted = true;
- }
- }
- // ++++ BREAK & ACCELERATION ++++
- else if(event.key === Qt.Key_PageUp)
- {
- mw.knopfGasHoch()
- }
- else if(event.key === Qt.Key_PageDown)
- {
- mw.knopfGasRunter()
- }
- else if(event.key === Qt.Key_Space)
- {
- mw.knopfBremsen()
- }
- // ++++ SHIFTING GEARS ++++
- if(event.key === Qt.Key_0)
- {
- if(dash.visible)
- {
- mw.knopfGang(0)
- dash.closeRearView();
- setVisualGear("0")
- }
- else if(!dash.visible){
- return;
- }
- }
- if(event.key === Qt.Key_1)
- {
- if(dash.visible)
- {
- mw.knopfGang(1)
- dash.closeRearView();
- setVisualGear("1")
- }
- else if(!dash.visible){
- return;
- }
- }
- if(event.key === Qt.Key_2)
- {
- if(dash.visible)
- {
- mw.knopfGang(2)
- dash.closeRearView();
- setVisualGear("2")
- }
- else if(!dash.visible){
- return;
- }
- }
- if(event.key === Qt.Key_3)
- {
- if(dash.visible)
- {
- mw.knopfGang(3)
- dash.closeRearView();
- setVisualGear("3")
- }
- else if(!dash.visible){
- return;
- }
- }
- if(event.key === Qt.Key_4)
- {
- if(dash.visible)
- {
- mw.knopfGang(4)
- dash.closeRearView();
- setVisualGear("4")
- }
- else if(!dash.visible){
- return;
- }
- }
- if(event.key === Qt.Key_5)
- {
- if(dash.visible)
- {
- mw.knopfGang(5)
- dash.closeRearView();
- setVisualGear("5")
- }
- else if(!dash.visible){
- return;
- }
- }
- // ++++ USE BLINKERS ++++
- if(event.key === Qt.Key_Left){
- if(!dash.visible){
- return;}
- else if(dash.visible)
- {
- dash.blinkLeft();
- }
- }
- if(event.key === Qt.Key_Right){
- if(!dash.visible){
- return;}
- else if(dash.visible)
- {
- dash.blinkRight();
- }
- }
- // ++++ REAR VIEW ++++
- if(event.key === Qt.Key_R)
- if(!dash.visible){
- return;
- }
- else if(dash.m_speed > 0.1)
- {
- dash.m_error = "Rückfahrt nicht möglich!";
- }
- else{
- mw.knopfGang(-1);
- setVisualGear("R")
- dash.openRearView()
- }
- }
- function setVisualGear(g)
- {
- dash.m_gear = g;
- }
- }
- Text{
- anchors.centerIn: parent
- color: "black"
- text:
- "Willkommen bei unserem tollen Abschlussprojekt!
- Bitte verwenden Sie das Kit: Desktop Qt 5.15.2 MinGW 64-bit
- Die Tasten haben folgende Funktionen:
- S Motor starten/stoppen
- 1,2,3,4,5 Gänge einlegen
- 0 Leerlauf einlegen
- R Rückwärtsgang einlegen
- Bild hoch Gaspedal stufenweise drücken
- Bild runter Gas stufenweise verringern
- Leertaste Bremsen
- Pfeil rechts Blinker rechts
- Pfeil links Blinker links
- Don't drink and drive!"
- }
- Dashboard{
- id: dash
- visible: false
- }
- Connections{
- target: sender
- function onGeschwindigkeitSenden(speed)
- {
- dash.m_speed = speed * 3.6
- }
- }
- Connections{
- target: sender
- function onDrehzahlSenden(rpm)
- {
- dash.m_rpm = rpm
- }
- }
- Connections{
- target: sender
- function onVerbrauchSenden(verbrauch)
- {
- dash.m_consumption = verbrauch
- }
- }
- Connections{
- target: sender
- function onKmZahlSenden(kmZahl)
- {
- dash.m_odometer = kmZahl
- }
- }
- Connections{
- target: sender
- function onErrorSenden(errorString)
- {
- dash.m_error = errorString
- }
- }
- Connections{
- target: sender
- function onTankSenden(tankinhalt)
- {
- dash.m_tankanz = tankinhalt
- }
- }
- Timer{
- id: timer
- interval: 200
- running: false
- repeat: true
- onTriggered: mw.knopfRechneAlles()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement