app/resources/qml/main.qml

281 lines
6.7 KiB
QML
Raw Normal View History

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
import QtQuick.Controls 2.12
2019-03-08 15:36:32 +01:00
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.0
import "."
import "./components"
import "./ProfilesDialog"
import "./SettingsDialog"
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
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 {
id: app
2018-07-17 19:17:25 +02:00
anchors.fill: parent
state: scStwRemoteRace.state
2018-07-22 16:47:55 +02:00
Rectangle {
id: backgroundRect
anchors.fill: parent
2020-05-19 12:43:32 +02:00
color: appTheme.theme.colors.background
Behavior on color {
ColorAnimation {
duration: 200
}
}
}
ScStw {
id: scStw
}
ScStwClient {
id: scStwClient
property ScStwSetting ipSetting: scStwAppSettings.getSetting(ScStwAppSettings.BaseStationIpSetting, ScStwAppSettings.KeyLevel)
ipAddress: ipSetting.value
}
ScStwAppSettings {
id: scStwAppSettings
scStwClient: scStwClient
}
ScStwTimer {
id: defaultTimer
}
ScStwRemoteRace {
id: scStwRemoteRace
autoRefreshTimerText: true
settings: scStwAppSettings
scStwClient: scStwClient
Component.onCompleted: {
scStwRemoteRace.addTimer(defaultTimer)
}
onStateChanged: {
if(scStwRemoteRace.state !== ScStwRace.IDLE) {
2020-10-02 19:58:25 +02:00
settingsDialog.close()
profilesDialog.close()
}
}
}
SpeedBackend {
id: speedBackend
scStwClient: scStwClient
}
2020-05-19 12:43:32 +02:00
ScStwAppThemeManager {
2019-03-08 18:03:27 +01:00
id: appTheme
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
}
// ---------------
// - Main layout -
// ---------------
GridLayout {
id: mainLayout
anchors.fill: parent
columns: app.landscape() ? 3:1
rows: app.landscape() ? 1:3
TopToolBar {
id: topToolBar
state: app.state
sizeMode: "large"
2018-07-17 19:17:25 +02:00
}
2018-08-29 18:33:39 +02:00
CenterContent {
id: centerContent
state: app.state
Layout.fillWidth: true
Layout.fillHeight: true
}
BottomToolBar {
id: bottomToolBar
sizeMode: "tiny"
}
}
states: [
State {
name: ScStwRace.IDLE
PropertyChanges {
target: topToolBar
sizeMode: "small"
}
PropertyChanges {
target: bottomToolBar
sizeMode: "small"
}
},
2018-07-17 19:17:25 +02:00
State {
name: ScStwRace.PREPAIRING
2018-07-22 16:47:55 +02:00
PropertyChanges {
target: topToolBar
sizeMode: "medium"
}
PropertyChanges {
target: bottomToolBar
sizeMode: "tiny"
2018-07-22 16:47:55 +02:00
}
},
State {
name: ScStwRace.WAITING
PropertyChanges {
target: topToolBar
sizeMode: "medium"
}
PropertyChanges {
target: bottomToolBar
sizeMode: "tiny"
}
},
State {
name: ScStwRace.STARTING
PropertyChanges {
target: topToolBar
sizeMode: "medium"
}
2020-10-01 14:19:47 +02:00
PropertyChanges {
target: bottomToolBar
sizeMode: "tiny"
}
},
State {
name: ScStwRace.RUNNING
PropertyChanges {
target: topToolBar
sizeMode: "medium"
}
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"
}
PropertyChanges {
target: bottomToolBar
sizeMode: "tiny"
2018-07-22 16:47:55 +02:00
}
}
]
2019-03-08 15:36:32 +01:00
/*------
Popups
2020-10-01 14:19:47 +02:00
------*/
SettingsDialog{
2018-08-02 12:50:55 +02:00
id: settingsDialog
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 {
id: profilesDialog
property int margin: app.landscape() ? app.height * 0.05:app.width * 0.05
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-22 16:47:55 +02:00
function landscape(){
return(app.height < app.width)
2018-07-22 16:47:55 +02:00
}
2018-07-17 19:17:25 +02:00
}
}