237 lines
6.6 KiB
QML
237 lines
6.6 KiB
QML
/*
|
|
Speed Climbing Stopwatch - Simple Stopwatch for Climbers
|
|
Copyright (C) 2018 - 2019 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/>.
|
|
*/
|
|
|
|
import QtQuick 2.9
|
|
import QtMultimedia 5.8
|
|
import QtQuick.Window 2.2
|
|
import QtQuick.Controls 2.4
|
|
import QtQuick.Layouts 1.3
|
|
import QtGraphicalEffects 1.0
|
|
import com.itsblue.speedclimbingstopwatch 1.0
|
|
|
|
import "../components"
|
|
|
|
|
|
RemoteDataListView {
|
|
id: profileList
|
|
|
|
property int currentAthlete: -1
|
|
property string title: "profiles"
|
|
property string secondButt: "add"
|
|
|
|
signal opened()
|
|
|
|
onOpened: {
|
|
profileList.loadData()
|
|
}
|
|
|
|
//anchors.fill: parent
|
|
//anchors.topMargin: topContainerItm.height * 0.1
|
|
|
|
loadData: function () {
|
|
status = 905
|
|
//listData = {}
|
|
var retData = speedBackend.getAthletes()
|
|
|
|
if(retData === undefined){
|
|
status = 500
|
|
return
|
|
}
|
|
|
|
listData = retData["allAthletes"]
|
|
currentAthlete = retData["activeAthlete"]
|
|
status = listData.lenght !== false ? 200:0
|
|
}
|
|
|
|
delegate: SwipeDelegate {
|
|
id: swipeDelegate
|
|
|
|
property bool active: profileList.currentAthlete === profileList.listData[index]["id"]
|
|
|
|
text: profileList.listData[index]["fullName"]
|
|
width: profileList.width - (swipeDelegate.x)
|
|
height: profileList.height / 5
|
|
|
|
font.pixelSize: profilesStack.text_pixelSize
|
|
|
|
function remove() {
|
|
removeAnim.start()
|
|
}
|
|
|
|
onClicked: {
|
|
profilesStack.openResults(profileList.listData[index]["userName"])
|
|
}
|
|
|
|
contentItem: Text {
|
|
visible: false
|
|
}
|
|
|
|
Text {
|
|
|
|
anchors {
|
|
verticalCenter: parent.verticalCenter
|
|
left: parent.left
|
|
leftMargin: swipeDelegate.width * 0.05
|
|
right: parent.right
|
|
rightMargin: swipeDelegate.rightPadding
|
|
}
|
|
|
|
text: swipeDelegate.text
|
|
color: appTheme.style.textColor
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.pixelSize: swipeDelegate.height * 0.4
|
|
|
|
minimumPixelSize: 1
|
|
}
|
|
|
|
background: Rectangle {
|
|
color: pressed ? appTheme.style.delegatePressedColor : appTheme.style.delegateBackgroundColor
|
|
|
|
Behavior on color {
|
|
|
|
ColorAnimation {
|
|
duration: 200
|
|
}
|
|
}
|
|
}
|
|
|
|
CheckBox {
|
|
id: control
|
|
|
|
anchors {
|
|
verticalCenter: parent.verticalCenter
|
|
right: parent.right
|
|
rightMargin: 7
|
|
}
|
|
|
|
height: parent.height * 0.6
|
|
|
|
checked: swipeDelegate.active
|
|
|
|
onCheckedChanged: {
|
|
if(checked && !swipeDelegate.active && speedBackend.selectAthlete(profileList.listData[index]["userName"])){
|
|
profileList.loadData()
|
|
}
|
|
}
|
|
|
|
indicator: Rectangle {
|
|
implicitWidth: 26
|
|
implicitHeight: 26
|
|
|
|
height: parent.height
|
|
width: height
|
|
|
|
x: control.leftPadding
|
|
y: parent.height / 2 - height / 2
|
|
|
|
radius: width * 0.2
|
|
border.color: control.down ? "#17a81a" : "#21be2b"
|
|
color: control.down ? appTheme.style.delegatePressedColor : appTheme.style.delegateBackgroundColor
|
|
|
|
Rectangle {
|
|
width: parent.width * 0.65
|
|
height: width
|
|
anchors.centerIn: parent
|
|
radius: control.checked ? width * 0.2:0
|
|
color: control.down ? "#17a81a" : "#21be2b"
|
|
opacity: control.checked ? 1:0
|
|
scale: control.checked ? 0.9:0
|
|
|
|
Behavior on color {
|
|
ColorAnimation {
|
|
duration: 200
|
|
}
|
|
}
|
|
|
|
Behavior on radius {
|
|
NumberAnimation {
|
|
duration: 200
|
|
}
|
|
}
|
|
|
|
Behavior on opacity {
|
|
NumberAnimation {
|
|
duration: 200
|
|
}
|
|
}
|
|
|
|
Behavior on scale {
|
|
NumberAnimation {
|
|
duration: 200
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
color: "grey"
|
|
height: 1
|
|
width: parent.width * 0.9
|
|
visible: index > 0
|
|
anchors {
|
|
horizontalCenter: parent.horizontalCenter
|
|
top: parent.top
|
|
}
|
|
}
|
|
|
|
NumberAnimation {
|
|
id: removeAnim
|
|
target: swipeDelegate
|
|
property: "height"
|
|
to: 0
|
|
easing.type: Easing.InOutQuad
|
|
onStopped: profileModel.model.remove(index)
|
|
}
|
|
|
|
swipe.transition: Transition {
|
|
SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic }
|
|
}
|
|
|
|
swipe.left: Row {
|
|
anchors.left: parent.left
|
|
height: parent.height
|
|
|
|
Label {
|
|
id: deleteLabel
|
|
text: qsTr("Delete")
|
|
color: appTheme.style.textColor
|
|
verticalAlignment: Label.AlignVCenter
|
|
padding: 12
|
|
height: parent.height
|
|
|
|
SwipeDelegate.onClicked: {
|
|
profileList.status = 905
|
|
if(speedBackend.deleteAthlete(profileList.listData[index]["userName"])){
|
|
profileList.loadData()
|
|
return
|
|
}
|
|
profileList.status = 200
|
|
}
|
|
|
|
background: Rectangle {
|
|
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|