From afbbd6b645ac93202efed3ec39af28871db32d18 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 7 Oct 2020 11:58:42 +0200 Subject: [PATCH] - some layout fixes - added incident page details --- resources/qml/MainPage/CenterContent.qml | 27 ++++- .../qml/SettingsDialog/SettingsStack.qml | 6 +- .../qml/components/ExtensionOverview.qml | 110 ++++++++++++++++++ .../qml/components/SmoothItemDelegate.qml | 3 +- resources/qml/qml.qrc | 2 +- shared-libraries | 2 +- 6 files changed, 142 insertions(+), 8 deletions(-) create mode 100644 resources/qml/components/ExtensionOverview.qml diff --git a/resources/qml/MainPage/CenterContent.qml b/resources/qml/MainPage/CenterContent.qml index 1a8605a..e868a37 100644 --- a/resources/qml/MainPage/CenterContent.qml +++ b/resources/qml/MainPage/CenterContent.qml @@ -178,6 +178,16 @@ Item { } } + Component { + id: incidentDetailsComp + + ExtensionOverview { + opacity: 0 + backgroundColor: appTheme.theme.colors.background + delegateHeight: centerExtraContentTopStack.height / 5 + } + } + Component { id: emptyComp Item {} @@ -363,10 +373,21 @@ Item { } PropertyChanges { - target: centerLayout + target: centerExtraContentTop - height: app.landscape() ? control.height : Math.max(control.height, app.height * 0.4) - width: app.landscape() ? Math.max(control.width, app.width * 0.4) : control.width + size: speedBackend.race.competitionMode ? 0.7:0 + } + + PropertyChanges { + target: centerExtraContentBottom + + size: speedBackend.race.competitionMode ? 0.05:0 + } + + PropertyChanges { + target: centerExtraContentTopStack + + newItem: speedBackend.race.competitionMode ? incidentDetailsComp:emptyComp } } diff --git a/resources/qml/SettingsDialog/SettingsStack.qml b/resources/qml/SettingsDialog/SettingsStack.qml index e63725a..d2c2567 100644 --- a/resources/qml/SettingsDialog/SettingsStack.qml +++ b/resources/qml/SettingsDialog/SettingsStack.qml @@ -50,8 +50,10 @@ StackView { Component { id: extensions - SettingsExtensionsPage { - parentObj: control + ExtensionOverview { + property string title: qsTr("extensions") + delegateHeight: control.delegateHeight + backgroundColor: appTheme.theme.colors.view } } diff --git a/resources/qml/components/ExtensionOverview.qml b/resources/qml/components/ExtensionOverview.qml new file mode 100644 index 0000000..b435cd6 --- /dev/null +++ b/resources/qml/components/ExtensionOverview.qml @@ -0,0 +1,110 @@ +import QtQuick 2.9 +import QtMultimedia 5.8 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 +import QtGraphicalEffects 1.0 +import QtQuick.Controls.Styles 1.4 +import "../components" + +ListView { + id: control + + property int delegateHeight: 40 + property color backgroundColor: "transparent" + + spacing: control.delegateHeight * 0.3 + boundsBehavior: Flickable.StopAtBounds + + clip: true + + model: Object.keys(speedBackend.scStwClient.extensions) + + header: Rectangle { + // for top spacing + width: parent.width + height: control.spacing + color: control.backgroundColor + } + + delegate: Rectangle { + id: laneContainerRect + + property string thisLane: modelData + + anchors.horizontalCenter: parent.horizontalCenter + + width: parent.width * 0.98 + height: control.delegateHeight * extensionsList.model + + radius: width * 0.05 + + border.width: 1 + border.color: appTheme.theme.colors.line + + color: control.backgroundColor + + Rectangle { + id: laneLabelRect + + anchors { + left: parent.left + leftMargin: parent.radius * 1 + verticalCenter: parent.top + } + + height: control.delegateHeight * 0.5 + width: laneLabel.font.pixelSize * 4 + + color: control.backgroundColor + + Label { + id: laneLabel + + height: parent.height + width: parent.width + + leftPadding: laneContainerRect.width * 0.02 + rightPadding: laneContainerRect.width * 0.02 + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + fontSizeMode: Text.Fit + font.pixelSize: height * 0.5 + + color: appTheme.theme.colors.text + + text: "Lane " + laneContainerRect.thisLane + } + + } + + ListView { + id: extensionsList + + anchors.fill: parent + anchors.margins: width * 0.04 + + interactive: false + + model: speedBackend.scStwClient.extensions[parent.thisLane].length + + delegate: ConnectionDelegate { + property var thisExtension: speedBackend.scStwClient.extensions[laneContainerRect.thisLane][index] + property var stateTranslations: ["disconnected", "connecting", "connecting", "connected"] + property var batteryStateStrings: ["critical", "warning", "fine", "charging"] + color: control.backgroundColor + + batteryState: thisExtension["batteryState"] === -1 ? "unknown":batteryStateStrings[thisExtension["batteryState"]] + + height: extensionsList.height / extensionsList.model + + enabled: true + + text: thisExtension["type"] === 0 ? "StartPad":"TopPad" // TODO: make dynamic with ScStw::extensionTypeToString() + status: {'status': stateTranslations[thisExtension["state"]]} + } + } + } +} diff --git a/resources/qml/components/SmoothItemDelegate.qml b/resources/qml/components/SmoothItemDelegate.qml index d85d85d..e79c30b 100644 --- a/resources/qml/components/SmoothItemDelegate.qml +++ b/resources/qml/components/SmoothItemDelegate.qml @@ -6,6 +6,7 @@ ItemDelegate { text: "" property color textColor: appTheme.theme.colors.text property alias backgroundRect: backgroundRect + property color color: appTheme.theme.colors.delegateBackground font.pixelSize: height * 0.4 @@ -42,7 +43,7 @@ ItemDelegate { background: Rectangle { id: backgroundRect - color: control.down ? appTheme.theme.colors.delegatePressed : appTheme.theme.colors.delegateBackground + color: control.down ? Qt.darker(control.color, 1.3) : control.color radius: height * 0.3 diff --git a/resources/qml/qml.qrc b/resources/qml/qml.qrc index 8e0b577..338755b 100644 --- a/resources/qml/qml.qrc +++ b/resources/qml/qml.qrc @@ -21,7 +21,6 @@ SettingsDialog/StartPage.qml SettingsDialog/SettingsStartSequencePage.qml SettingsDialog/SettingsBaseStationPage.qml - SettingsDialog/SettingsExtensionsPage.qml main.old.qml components/layout/ToolBar.qml MainPage/TopToolBar.qml @@ -30,5 +29,6 @@ components/MainActionButton.qml components/StateIndicator.qml components/BatteryIndicator.qml + components/ExtensionOverview.qml diff --git a/shared-libraries b/shared-libraries index 10645e9..f8cc236 160000 --- a/shared-libraries +++ b/shared-libraries @@ -1 +1 @@ -Subproject commit 10645e9eb80f64c259d4c007dbb13319fec05887 +Subproject commit f8cc23646cd77c85b4d86b145e4da3779a4766aa