From 99ebdaa9927622873c614b830b608c4b4de87e65 Mon Sep 17 00:00:00 2001 From: dorian Date: Wed, 2 Oct 2019 19:12:06 +0200 Subject: [PATCH] - changed some spelling - the button to cancel a remote race is a delay button now, to prevent canceling a race by accident --- qml/SettingsDialog.qml | 30 +++++++------- qml/main.qml | 89 ++++++++++++++++++++++++++++++++++++------ sources/speedtimer.cpp | 6 +-- 3 files changed, 95 insertions(+), 30 deletions(-) diff --git a/qml/SettingsDialog.qml b/qml/SettingsDialog.qml index 0a5634c..77a062b 100644 --- a/qml/SettingsDialog.qml +++ b/qml/SettingsDialog.qml @@ -208,7 +208,7 @@ Popup { Column { id: settings_col - property string title: qsTr("Options") + property string title: qsTr("options") spacing: options_stack.rowSpacing /*----Connect to external devices----*/ @@ -217,7 +217,7 @@ Popup { height: options_stack.delegateHeight - text: qsTr("Base Station") + text: qsTr("base station") onClicked: { options_stack.push(connect) } @@ -229,7 +229,7 @@ Popup { height: options_stack.delegateHeight - text: qsTr("Start sequence") + text: qsTr("start sequence") onClicked: { options_stack.push(autostart) @@ -239,7 +239,7 @@ Popup { /*----Style Settings----*/ SmoothSwitchDelegate { id: styleDel - text: qsTr("Dark mode") + text: qsTr("dark mode") width: parent.width height: options_stack.delegateHeight @@ -262,7 +262,7 @@ Popup { spacing: options_stack.rowSpacing - property string title: "Autostart" + property string title: "autostart" function updateSetting(key, val, del){ speedBackend.writeSetting(key, val) @@ -278,7 +278,7 @@ Popup { width: parent.width height: options_stack.delegateHeight - text: qsTr("Say 'ready'") + text: qsTr("say 'ready'") checked: parent.loadSetting("ready_en", ready_del) === "true" @@ -295,7 +295,7 @@ Popup { enabled: ready_del.checked - text: qsTr("Delay (ms)") + text: qsTr("delay (ms)") inputHint: qsTr("time") inputMethodHints: Qt.ImhFormattedNumbersOnly @@ -312,7 +312,7 @@ Popup { width: parent.width height: options_stack.delegateHeight - text: qsTr("Say 'at your marks'") + text: qsTr("say 'at your marks'") checked: autostart_col.loadSetting("at_marks_en", ready_del) === "true" @@ -327,7 +327,7 @@ Popup { width: parent.width height: options_stack.delegateHeight - text: qsTr("Delay (ms)") + text: qsTr("delay (ms)") inputHint: qsTr("time") inputMethodHints: Qt.ImhFormattedNumbersOnly @@ -347,15 +347,17 @@ Popup { id: connect Column { id: connectCol - property string title: qsTr("Base Station") + property string title: qsTr("base station") spacing: options_stack.rowSpacing property bool baseConnected: speedBackend.baseStationState === "connected" + opacity: 0 + ConnectionDelegate { id: connectToBaseDel - text: status.status === "connected" ? qsTr("Disconnect"): status.status === "disconnected" ? qsTr("Connect"):qsTr("Connecting...") + text: status.status === "connected" ? qsTr("disconnect"): status.status === "disconnected" ? qsTr("connect"):qsTr("connecting...") status: { "status": speedBackend.baseStationState, "progress": 100 } connect: speedBackend.connectBaseStation @@ -475,7 +477,7 @@ Popup { width: parent.width height: options_stack.delegateHeight - text: qsTr("What is this for?") + text: qsTr("what is this for?") onClicked: { Qt.openUrlExternally("https://itsblue.de/index.php/speed-climbing?ref=ScStwApp") @@ -499,7 +501,7 @@ Popup { SmoothSliderDelegate { id: baseStationVolumeDel - text: qsTr("Volume") + text: qsTr("volume") width: parent.width height: options_stack.delegateHeight @@ -528,7 +530,7 @@ Popup { NextPageDelegate { id: baseStationConnectionsDel - text: qsTr("Connected extensions") + text: qsTr("connected extensions") width: parent.width height: options_stack.delegateHeight diff --git a/qml/main.qml b/qml/main.qml index cb1e1a1..6a290ff 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -137,7 +137,7 @@ Window { width: parent.width * 0.7 - text: "Click Start to start" + text: "click start to start" color: appTheme.style.textColor @@ -189,8 +189,8 @@ Window { elide: "ElideRight" color: ["WON"].includes(speedBackend.timers[index]["state"]) ? appTheme.style.successColor : - ["LOST", "FAILED"].includes(speedBackend.timers[index]["state"]) ? appTheme.style.errorColor: - appTheme.style.textColor + ["LOST", "FAILED"].includes(speedBackend.timers[index]["state"]) ? appTheme.style.errorColor: + appTheme.style.textColor enabled: speedBackend.timers[index]["state"] !== "DISABLED" @@ -355,20 +355,22 @@ Window { // ---------------------------------- // -- Start / Stop / Reset button --- // ---------------------------------- - FancyButton { + DelayButton { id : startButt text: "start" property int size: app.landscape() ? parent.width * 0.5:parent.height * 0.5 + property color backgroundColor: appTheme.style.buttonColor + property bool progressControlActivated: speedBackend.baseStationState === "connected" && app.state === "RUNNING" + delay: progressControlActivated ? 2000:0 + anchors { bottom: parent.bottom bottomMargin: app.height * 0.5 - height * 0.5 right: parent.right rightMargin: app.width * 0.5 - width * 0.5 } - contentItem: Text { - //make text disappear - } + height: app.landscape() ? (size > parent.height * 0.9 ? parent.height * 0.9:size) : (size > parent.width * 0.9 ? parent.width * 0.9:size) width: height @@ -381,8 +383,6 @@ Window { color: enabled ? appTheme.style.textColor:appTheme.style.disabledTextColor } - backgroundColor: appTheme.style.buttonColor - Behavior on text { //animate a text change enabled: true @@ -392,6 +392,9 @@ Window { } onClicked: { + if(startButt.progressControlActivated && progress < 1.0) + return + startButt.progress = 0 switch(app.state) { case "IDLE": app.start() @@ -404,7 +407,67 @@ Window { break } } - } + + contentItem: Text { + } + + background: Item { + RectangularGlow { + glowRadius: 0.001 + spread: 0.2 + color: "black" + + visible: true + + cornerRadius: startButtBackground.radius + anchors.fill: startButtBackground + scale: 0.75 + opacity: Math.pow( control.opacity, 100 ) + } + + Rectangle { + id: startButtBackground + implicitWidth: 100 + implicitHeight: 100 + color: startButt.down ? Qt.darker(startButt.backgroundColor, 1.2) : startButt.backgroundColor + radius: size / 2 + + readonly property real size: Math.min(startButt.width, startButt.height) + width: size + height: size + anchors.fill: parent + + Behavior on color { + ColorAnimation { + duration: 200 + } + } + + Canvas { + id: canvas + anchors.fill: parent + + visible: startButt.progressControlActivated + + Connections { + target: startButt + onProgressChanged: canvas.requestPaint() + } + + onPaint: { + var ctx = getContext("2d") + ctx.clearRect(0, 0, width, height) + ctx.strokeStyle = "grey" + ctx.lineWidth = parent.width * 0.02 + ctx.beginPath() + var startAngle = Math.PI * 0.5 + var endAngle = startAngle + startButt.progress * Math.PI * 2 + ctx.arc(width / 2, height / 2, width / 2 - ctx.lineWidth / 2 - 2, startAngle, endAngle) + ctx.stroke() + } + } + } + }} ProgressCircle { id: prog @@ -413,7 +476,7 @@ Window { scale: startButt.scale - lineWidth: 5 + lineWidth: prog.width * 0.02 arcBegin: 0 arcEnd: 360 * speedBackend.nextStartActionDelayProgress @@ -663,7 +726,7 @@ Window { } PropertyChanges { target: topLa - text: "Click Start to start" + text: "click start to start" } }, @@ -701,7 +764,7 @@ Window { name: "RUNNING" //state when the timer is running PropertyChanges { target: startButt; enabled: true; - text: "stop" + text: speedBackend.baseStationState === "connected" ? "cancel":"stop" anchors.rightMargin: app.landscape() ? parent.width * 0.05:parent.width * 0.5 - startButt.width * 0.5 //put the button more to the right to hide the menu (only in landscape mode) anchors.bottomMargin: app.landscape() ? parent.height * 0.5 - startButt.height * 0.5:parent.height * 0.1 //put the button lower to hide the menu (only in portrait mode) } diff --git a/sources/speedtimer.cpp b/sources/speedtimer.cpp index 3a45358..40c9392 100644 --- a/sources/speedtimer.cpp +++ b/sources/speedtimer.cpp @@ -140,7 +140,7 @@ QString SpeedTimer::getText() { newText = "0.000 sec"; break; case SpeedTimer::WAITING: - newText = "Please wait..."; + newText = "please wait..."; break; case SpeedTimer::RUNNING: newText = QString::number( this->getCurrTime() / 1000.0, 'f', 3 ) + " sec"; @@ -152,10 +152,10 @@ QString SpeedTimer::getText() { newText = QString::number( this->stoppedTime / 1000.0, 'f', 3 ) + " sec"; break; case SpeedTimer::FAILED: - newText = "False Start"; + newText = "false start"; break; case SpeedTimer::CANCELLED: - newText = "Cancelled"; + newText = "cancelled"; break; case SpeedTimer::DISABLED: newText = "---";