2018-08-12 20:51:57 +02:00
|
|
|
/*
|
|
|
|
Speed Climbing Stopwatch - Simple Stopwatch for Climbers
|
|
|
|
Copyright (C) 2018 Itsblue Development - Dorian Zeder
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, version 3 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-07-17 19:17:25 +02:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtMultimedia 5.8
|
2020-10-01 01:54:38 +02:00
|
|
|
import QtQuick.Controls 2.12
|
2019-03-08 15:36:32 +01:00
|
|
|
import QtGraphicalEffects 1.0
|
2020-10-01 01:54:38 +02:00
|
|
|
import QtQuick.Layouts 1.0
|
|
|
|
|
2018-08-28 23:03:35 +02:00
|
|
|
import "."
|
|
|
|
import "./components"
|
2019-06-08 11:14:18 +02:00
|
|
|
import "./ProfilesDialog"
|
2019-10-18 16:10:41 +02:00
|
|
|
import "./SettingsDialog"
|
2020-10-01 01:54:38 +02:00
|
|
|
import "./components/layout"
|
|
|
|
import "./MainPage"
|
2018-07-22 21:08:11 +02:00
|
|
|
//import QtQuick.Layouts 1.11
|
2018-07-22 16:47:55 +02:00
|
|
|
|
2020-05-26 17:57:54 +02:00
|
|
|
import de.itsblue.ScStw 2.0
|
|
|
|
import de.itsblue.ScStw.Styling 2.0
|
|
|
|
import de.itsblue.ScStw.Styling.Components 1.0
|
|
|
|
import de.itsblue.ScStwApp 2.0
|
2018-07-17 19:17:25 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
ApplicationWindow {
|
2018-07-17 19:17:25 +02:00
|
|
|
visible: true
|
2020-10-01 14:19:47 +02:00
|
|
|
width: 540
|
|
|
|
height: 960
|
2020-10-01 02:27:00 +02:00
|
|
|
|
2020-07-10 15:20:41 +02:00
|
|
|
title: "ScStwApp"
|
2018-07-17 19:17:25 +02:00
|
|
|
|
|
|
|
Page {
|
2020-10-01 01:54:38 +02:00
|
|
|
id: app
|
2018-07-17 19:17:25 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
|
2020-10-09 15:44:24 +02:00
|
|
|
state: scStwRemoteRace.state
|
2018-07-22 16:47:55 +02:00
|
|
|
|
2023-05-14 22:33:44 +02:00
|
|
|
Keys.onPressed: {
|
|
|
|
if (!scStwAppSettings.readSetting(ScStwAppSettings.KeyboardControlSetting) || scStwRemoteRace.state !== ScStwRace.RUNNING) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event.key === Qt.Key_A) {
|
|
|
|
defaultTimerA.stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
if(event.key === Qt.Key_L) {
|
|
|
|
defaultTimerB.stop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-28 23:03:35 +02:00
|
|
|
Rectangle {
|
|
|
|
id: backgroundRect
|
|
|
|
anchors.fill: parent
|
2020-05-19 12:43:32 +02:00
|
|
|
color: appTheme.theme.colors.background
|
2019-03-24 21:31:59 +01:00
|
|
|
|
|
|
|
Behavior on color {
|
|
|
|
ColorAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
2018-07-25 00:32:20 +02:00
|
|
|
}
|
|
|
|
|
2020-04-17 19:57:33 +02:00
|
|
|
ScStw {
|
|
|
|
id: scStw
|
|
|
|
}
|
|
|
|
|
2020-10-09 15:44:24 +02:00
|
|
|
ScStwClient {
|
|
|
|
id: scStwClient
|
|
|
|
|
|
|
|
property ScStwSetting ipSetting: scStwAppSettings.getSetting(ScStwAppSettings.BaseStationIpSetting, ScStwAppSettings.KeyLevel)
|
|
|
|
ipAddress: ipSetting.value
|
2020-04-15 21:47:55 +02:00
|
|
|
}
|
2019-03-07 17:18:24 +01:00
|
|
|
|
2020-10-09 15:44:24 +02:00
|
|
|
ScStwAppSettings {
|
|
|
|
id: scStwAppSettings
|
|
|
|
|
|
|
|
scStwClient: scStwClient
|
|
|
|
}
|
|
|
|
|
|
|
|
ScStwTimer {
|
2023-05-14 22:33:44 +02:00
|
|
|
id: defaultTimerA
|
|
|
|
letter: "A"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ScStwTimer {
|
|
|
|
id: defaultTimerB
|
|
|
|
letter: "B"
|
2020-10-09 15:44:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ScStwRemoteRace {
|
|
|
|
id: scStwRemoteRace
|
|
|
|
|
|
|
|
autoRefreshTimerText: true
|
|
|
|
settings: scStwAppSettings
|
|
|
|
scStwClient: scStwClient
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
2023-05-14 22:33:44 +02:00
|
|
|
scStwRemoteRace.addTimer(defaultTimerA)
|
|
|
|
scStwRemoteRace.addTimer(defaultTimerB)
|
2020-10-09 15:44:24 +02:00
|
|
|
}
|
2020-10-01 01:54:38 +02:00
|
|
|
|
2020-10-09 15:44:24 +02:00
|
|
|
onStateChanged: {
|
|
|
|
if(scStwRemoteRace.state !== ScStwRace.IDLE) {
|
2020-10-02 19:58:25 +02:00
|
|
|
settingsDialog.close()
|
|
|
|
profilesDialog.close()
|
2019-03-07 17:18:24 +01:00
|
|
|
}
|
2018-10-04 18:35:29 +02:00
|
|
|
}
|
2018-08-28 23:03:35 +02:00
|
|
|
}
|
|
|
|
|
2020-10-09 15:44:24 +02:00
|
|
|
SpeedBackend {
|
|
|
|
id: speedBackend
|
|
|
|
scStwClient: scStwClient
|
|
|
|
}
|
|
|
|
|
2020-05-19 12:43:32 +02:00
|
|
|
ScStwAppThemeManager {
|
2019-03-08 18:03:27 +01:00
|
|
|
id: appTheme
|
2020-10-09 15:44:24 +02:00
|
|
|
property ScStwSetting setting: scStwAppSettings.getSetting(ScStwAppSettings.AppThemeSetting, ScStwAppSettings.KeyLevel)
|
2020-08-09 12:20:04 +02:00
|
|
|
themeName: setting.value
|
2019-03-08 18:03:27 +01:00
|
|
|
}
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
// ---------------
|
|
|
|
// - Main layout -
|
|
|
|
// ---------------
|
2019-04-15 13:33:31 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
GridLayout {
|
|
|
|
id: mainLayout
|
2019-10-13 16:42:38 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
anchors.fill: parent
|
2019-04-15 13:33:31 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
columns: app.landscape() ? 3:1
|
|
|
|
rows: app.landscape() ? 1:3
|
2019-04-15 13:33:31 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
TopToolBar {
|
|
|
|
id: topToolBar
|
2018-10-14 18:39:39 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
state: app.state
|
2018-10-04 18:35:29 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
sizeMode: "large"
|
2018-07-17 19:17:25 +02:00
|
|
|
}
|
2018-08-29 18:33:39 +02:00
|
|
|
|
2019-09-08 00:50:03 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
CenterContent {
|
|
|
|
id: centerContent
|
2019-04-15 13:33:31 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
state: app.state
|
2019-04-15 13:33:31 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2019-04-15 13:33:31 +02:00
|
|
|
}
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
BottomToolBar {
|
|
|
|
id: bottomToolBar
|
2019-03-24 21:16:16 +01:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
sizeMode: "tiny"
|
2019-03-24 21:16:16 +01:00
|
|
|
}
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
}
|
2020-09-22 15:44:57 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: ScStwRace.IDLE
|
2020-09-22 15:44:57 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: topToolBar
|
|
|
|
sizeMode: "small"
|
2019-03-24 21:16:16 +01:00
|
|
|
}
|
2020-06-13 17:11:26 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: bottomToolBar
|
|
|
|
sizeMode: "small"
|
2020-06-13 17:11:26 +02:00
|
|
|
}
|
2020-10-01 01:54:38 +02:00
|
|
|
},
|
2018-07-17 19:17:25 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
State {
|
|
|
|
name: ScStwRace.PREPAIRING
|
2018-07-22 16:47:55 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: topToolBar
|
|
|
|
sizeMode: "medium"
|
2018-08-14 17:07:42 +02:00
|
|
|
}
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: bottomToolBar
|
|
|
|
sizeMode: "tiny"
|
2018-07-22 16:47:55 +02:00
|
|
|
}
|
2020-10-01 01:54:38 +02:00
|
|
|
},
|
2019-10-02 19:12:06 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
State {
|
|
|
|
name: ScStwRace.WAITING
|
2019-10-02 19:12:06 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: topToolBar
|
|
|
|
sizeMode: "medium"
|
2019-10-02 19:12:06 +02:00
|
|
|
}
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: bottomToolBar
|
|
|
|
sizeMode: "tiny"
|
2019-10-02 19:12:06 +02:00
|
|
|
}
|
2020-10-01 01:54:38 +02:00
|
|
|
},
|
2018-07-28 21:17:41 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
State {
|
|
|
|
name: ScStwRace.STARTING
|
2018-07-28 21:17:41 +02:00
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: topToolBar
|
|
|
|
sizeMode: "medium"
|
2018-07-28 21:17:41 +02:00
|
|
|
}
|
2019-03-07 17:18:24 +01:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: bottomToolBar
|
|
|
|
sizeMode: "tiny"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
State {
|
|
|
|
name: ScStwRace.RUNNING
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: topToolBar
|
2023-05-14 22:33:44 +02:00
|
|
|
sizeMode: scStwAppSettings.readSetting(ScStwAppSettings.KeyboardControlSetting) ? "large":"medium"
|
2020-10-01 14:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: bottomToolBar
|
|
|
|
sizeMode: "tiny"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
State {
|
|
|
|
name: ScStwRace.STOPPED
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: topToolBar
|
|
|
|
sizeMode: "large"
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: bottomToolBar
|
|
|
|
sizeMode: "tiny"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
State {
|
|
|
|
name: ScStwRace.INCIDENT
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: topToolBar
|
|
|
|
sizeMode: "small"
|
|
|
|
}
|
|
|
|
|
2020-10-01 01:54:38 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: bottomToolBar
|
|
|
|
sizeMode: "tiny"
|
2018-07-22 16:47:55 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-01 01:54:38 +02:00
|
|
|
]
|
2019-03-08 15:36:32 +01:00
|
|
|
|
2018-07-25 00:32:20 +02:00
|
|
|
|
|
|
|
/*------
|
|
|
|
Popups
|
2020-10-01 14:19:47 +02:00
|
|
|
------*/
|
2018-07-25 00:32:20 +02:00
|
|
|
SettingsDialog{
|
2018-08-02 12:50:55 +02:00
|
|
|
id: settingsDialog
|
2019-08-19 15:14:11 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
x: centerContent.x + (centerContent.width - width) * 0.5
|
|
|
|
y: centerContent.y + (centerContent.height - height) * 0.5
|
|
|
|
|
|
|
|
width: Math.min(centerContent.width * 0.9, centerContent.height * 0.9)
|
|
|
|
height: width
|
2018-07-22 16:47:55 +02:00
|
|
|
}
|
|
|
|
|
2020-10-02 19:58:25 +02:00
|
|
|
ProfilesDialog {
|
2019-04-30 23:44:04 +02:00
|
|
|
id: profilesDialog
|
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
property int margin: app.landscape() ? app.height * 0.05:app.width * 0.05
|
2019-04-30 23:44:04 +02:00
|
|
|
|
2020-10-02 19:58:25 +02:00
|
|
|
x: centerContent.x + margin
|
|
|
|
y: centerContent.y + margin
|
|
|
|
width: centerContent.width - margin * 2
|
|
|
|
height: centerContent.height - margin * 2
|
|
|
|
}
|
2018-07-25 00:32:20 +02:00
|
|
|
|
2018-07-22 16:47:55 +02:00
|
|
|
function landscape(){
|
2019-09-08 15:08:50 +02:00
|
|
|
return(app.height < app.width)
|
2018-07-22 16:47:55 +02:00
|
|
|
}
|
2018-07-17 19:17:25 +02:00
|
|
|
}
|
|
|
|
}
|