- finished up athlete stuff
This commit is contained in:
parent
33ae172038
commit
a0a3d8cfe6
8 changed files with 237 additions and 139 deletions
|
@ -51,6 +51,8 @@ private:
|
||||||
QTcpSocket *socket;
|
QTcpSocket *socket;
|
||||||
//socket for communication with the extention
|
//socket for communication with the extention
|
||||||
|
|
||||||
|
QString readBuffer;
|
||||||
|
|
||||||
QSemaphore remoteSessions;
|
QSemaphore remoteSessions;
|
||||||
|
|
||||||
int nextConnectionId;
|
int nextConnectionId;
|
||||||
|
|
|
@ -87,6 +87,10 @@ Popup {
|
||||||
Connections {
|
Connections {
|
||||||
target: root
|
target: root
|
||||||
onOpened: {
|
onOpened: {
|
||||||
|
if(profiles_stack.depth > 0){
|
||||||
|
profiles_stack.clear()
|
||||||
|
}
|
||||||
|
|
||||||
profiles_stack.openAthletes()
|
profiles_stack.openAthletes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,143 +113,188 @@ Popup {
|
||||||
Component {
|
Component {
|
||||||
id: profileListComp
|
id: profileListComp
|
||||||
|
|
||||||
RemoteDataListView {
|
RemoteDataListView {
|
||||||
id: profileList
|
id: profileList
|
||||||
|
|
||||||
property string title: "profiles"
|
property int currentAthlete: -1
|
||||||
property string secondButt: "add"
|
property string title: "profiles"
|
||||||
|
property string secondButt: "add"
|
||||||
|
|
||||||
signal opened()
|
signal opened()
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
loadData()
|
profileList.loadData()
|
||||||
}
|
|
||||||
|
|
||||||
loadData: function () {
|
|
||||||
status = 905
|
|
||||||
listData = {}
|
|
||||||
listData = speedBackend.getAthletes()
|
|
||||||
status = listData.lenght !== false ? 200:0
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: SwipeDelegate {
|
|
||||||
id: swipeDelegate
|
|
||||||
|
|
||||||
property bool active: profileList.listData[index]["active"]
|
|
||||||
|
|
||||||
text: profileList.listData[index]["fullName"]
|
|
||||||
width: profileList.width - (swipeDelegate.x)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
font.pixelSize: profiles_stack.text_pixelSize
|
|
||||||
|
|
||||||
function remove() {
|
|
||||||
removeAnim.start()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
anchors.fill: parent
|
||||||
profiles_stack.openResults(profileList.listData[index]["userName"])
|
anchors.topMargin: topContainerItm.height * 0.1
|
||||||
}
|
|
||||||
|
|
||||||
background: Rectangle {
|
loadData: function () {
|
||||||
color: Qt.darker( pressed ? Qt.darker("white", 1.1):"white", swipeDelegate.active ? 1.1:0 )
|
status = 905
|
||||||
}
|
listData = {}
|
||||||
|
var retData = speedBackend.getAthletes()
|
||||||
|
|
||||||
CheckBox {
|
if(retData === undefined){
|
||||||
id: control
|
status = 500
|
||||||
|
return
|
||||||
anchors {
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
right: parent.right
|
|
||||||
}
|
}
|
||||||
|
|
||||||
height: parent.height * 0.6
|
listData = retData["allAthletes"]
|
||||||
|
currentAthlete = retData["activeAthlete"]
|
||||||
|
status = listData.lenght !== false ? 200:0
|
||||||
|
}
|
||||||
|
|
||||||
checked: swipeDelegate.active
|
delegate: SwipeDelegate {
|
||||||
|
id: swipeDelegate
|
||||||
|
|
||||||
onCheckedChanged: {
|
property bool active: profileList.currentAthlete === profileList.listData[index]["id"]
|
||||||
if(checked && !swipeDelegate.active && speedBackend.selectAthlete(profileList.listData[index]["userName"])){
|
|
||||||
profileList.loadData()
|
text: profileList.listData[index]["fullName"]
|
||||||
}
|
width: profileList.width - (swipeDelegate.x)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
font.pixelSize: profiles_stack.text_pixelSize
|
||||||
|
|
||||||
|
function remove() {
|
||||||
|
removeAnim.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
indicator: Rectangle {
|
onClicked: {
|
||||||
implicitWidth: 26
|
profiles_stack.openResults(profileList.listData[index]["userName"])
|
||||||
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"
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: parent.width * 0.65
|
|
||||||
height: width
|
|
||||||
anchors.centerIn: parent
|
|
||||||
radius: width * 0.2
|
|
||||||
color: control.down ? "#17a81a" : "#21be2b"
|
|
||||||
visible: control.checked
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
background: Rectangle {
|
||||||
color: "grey"
|
color: Qt.darker( pressed ? Qt.darker("white", 1.1):"white", swipeDelegate.active ? 1.1:0 )
|
||||||
height: 1
|
|
||||||
width: parent.width * 0.9
|
|
||||||
visible: index > 0
|
|
||||||
anchors {
|
|
||||||
horizontalCenter: parent.horizontalCenter
|
|
||||||
top: parent.top
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NumberAnimation {
|
Behavior on color {
|
||||||
id: removeAnim
|
|
||||||
target: swipeDelegate
|
|
||||||
property: "height"
|
|
||||||
to: 0
|
|
||||||
easing.type: Easing.InOutQuad
|
|
||||||
onStopped: profileModel.model.remove(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
swipe.transition: Transition {
|
ColorAnimation {
|
||||||
SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic }
|
duration: 200
|
||||||
}
|
|
||||||
|
|
||||||
swipe.left: Row {
|
|
||||||
anchors.left: parent.left
|
|
||||||
height: parent.height
|
|
||||||
|
|
||||||
Label {
|
|
||||||
id: deleteLabel
|
|
||||||
text: qsTr("Delete")
|
|
||||||
color: "white"
|
|
||||||
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
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: control
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
right: parent.right
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Rectangle {
|
height: parent.height * 0.6
|
||||||
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
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: "white"
|
||||||
|
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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----Option to add a profile-----*/
|
/*-----Option to add a profile-----*/
|
||||||
|
@ -263,7 +312,7 @@ Popup {
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(speedBackend.createAthlete(userNameTf.text, fullNameTf.text)){
|
if(speedBackend.createAthlete(userNameTf.text, fullNameTf.text)){
|
||||||
profiles_stack.get(profiles_stack.depth - 2 ).loadData()
|
profiles_stack.get(profiles_stack.depth - 2 ).opened()
|
||||||
profiles_stack.pop()
|
profiles_stack.pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,9 +594,9 @@ Popup {
|
||||||
height: parent.height * 0.1
|
height: parent.height * 0.1
|
||||||
width:height
|
width:height
|
||||||
|
|
||||||
opacity: profiles_stack.currentItem.secondButt !== "none" ? 1:0
|
opacity: root.opacity < 1 ? root.opacity : profiles_stack.currentItem.secondButt !== "none" ? 1:0
|
||||||
|
|
||||||
glowOpacity: Math.pow( root.opacity, 100 )
|
//glowOpacity: Math.pow( root.opacity, 100 )
|
||||||
|
|
||||||
backgroundColor: appTheme.style.buttonColor
|
backgroundColor: appTheme.style.buttonColor
|
||||||
|
|
||||||
|
|
|
@ -29,21 +29,42 @@ SequentialAnimation {
|
||||||
property alias outEasingType: outAnimation.easing.type
|
property alias outEasingType: outAnimation.easing.type
|
||||||
property alias inEasingType: inAnimation.easing.type
|
property alias inEasingType: inAnimation.easing.type
|
||||||
property string easingType: "Quad"
|
property string easingType: "Quad"
|
||||||
|
ParallelAnimation {
|
||||||
NumberAnimation { // in the default case, fade scale to 0
|
NumberAnimation { // in the default case, fade scale to 0
|
||||||
id: outAnimation
|
id: outAnimation
|
||||||
target: root.target
|
target: root.target
|
||||||
property: root.fadeProperty
|
property: "scale"
|
||||||
|
duration: root.fadeDuration_in
|
||||||
|
to: 0.9
|
||||||
|
easing.type: Easing["In"+root.easingType]
|
||||||
|
}
|
||||||
|
NumberAnimation { // in the default case, fade scale to 0
|
||||||
|
id: outAnimation2
|
||||||
|
target: root.target
|
||||||
|
property: "opacity"
|
||||||
duration: root.fadeDuration_in
|
duration: root.fadeDuration_in
|
||||||
to: 0
|
to: 0
|
||||||
easing.type: Easing["In"+root.easingType]
|
easing.type: Easing["In"+root.easingType]
|
||||||
}
|
}
|
||||||
PropertyAction { } // actually change the property targeted by the Behavior between the 2 other animations
|
|
||||||
NumberAnimation { // in the default case, fade scale back to 1
|
|
||||||
id: inAnimation
|
|
||||||
target: root.target
|
|
||||||
property: root.fadeProperty
|
|
||||||
duration: root.fadeDuration_out
|
|
||||||
to: 1
|
|
||||||
easing.type: Easing["Out"+root.easingType]
|
|
||||||
}
|
}
|
||||||
|
PropertyAction { } // actually change the property targeted by the Behavior between the 2 other animations
|
||||||
|
ParallelAnimation {
|
||||||
|
NumberAnimation { // in the default case, fade scale back to 1
|
||||||
|
id: inAnimation
|
||||||
|
target: root.target
|
||||||
|
property: root.fadeProperty
|
||||||
|
duration: root.fadeDuration_out
|
||||||
|
to: 1
|
||||||
|
easing.type: Easing["Out"+root.easingType]
|
||||||
|
}
|
||||||
|
NumberAnimation { // in the default case, fade scale to 0
|
||||||
|
id: inAnimation2
|
||||||
|
target: root.target
|
||||||
|
property: "opacity"
|
||||||
|
duration: root.fadeDuration_in
|
||||||
|
to: 1
|
||||||
|
easing.type: Easing["In"+root.easingType]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ Button {
|
||||||
property double glowSpread: 0.2
|
property double glowSpread: 0.2
|
||||||
property bool glowVisible: true
|
property bool glowVisible: true
|
||||||
property double glowScale: 0.75
|
property double glowScale: 0.75
|
||||||
property double glowOpacity: 1
|
property double glowOpacity: Math.pow( control.opacity, 100 )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,10 @@ Item {
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
//enabled: status === 200 || status === 902
|
||||||
|
//opacity: enabled ? 1:0
|
||||||
|
|
||||||
enabled: status === 200 || status === 902
|
boundsBehavior: ListView.StopAtBounds
|
||||||
opacity: enabled ? 1:0
|
|
||||||
|
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
parent: listView.parent
|
parent: listView.parent
|
||||||
|
@ -62,16 +62,16 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on contentY {
|
|
||||||
NumberAnimation {
|
|
||||||
duration: 200
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FancyBusyIndicator {
|
FancyBusyIndicator {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
opacity: listView.opacity === 1 ? 0:1
|
opacity: !(status === 200 || status === 902) ? 1:0
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 200
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -689,7 +689,10 @@ Window {
|
||||||
anchors.rightMargin: root.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.rightMargin: root.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: root.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)
|
anchors.bottomMargin: root.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)
|
||||||
}
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target: topLa
|
||||||
|
text: ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
State {
|
State {
|
||||||
|
@ -707,6 +710,10 @@ Window {
|
||||||
anchors.rightMargin: root.landscape() ? 0-startButt.width/2:undefined
|
anchors.rightMargin: root.landscape() ? 0-startButt.width/2:undefined
|
||||||
anchors.bottomMargin: root.landscape() ? undefined:0-startButt.height/2
|
anchors.bottomMargin: root.landscape() ? undefined:0-startButt.height/2
|
||||||
}
|
}
|
||||||
|
PropertyChanges {
|
||||||
|
target: topLa
|
||||||
|
text: ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -186,12 +186,30 @@ QVariantMap BaseConn::sendCommand(int header, QJsonValue data){
|
||||||
|
|
||||||
void BaseConn::readyRead() {
|
void BaseConn::readyRead() {
|
||||||
|
|
||||||
|
//qDebug() << "ready to ready " << socket->bytesAvailable() << " bytes" ;
|
||||||
QString reply = socket->readAll();
|
QString reply = socket->readAll();
|
||||||
|
|
||||||
|
if(!reply.endsWith("</message>")){
|
||||||
|
this->readBuffer += reply;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(!this->readBuffer.isEmpty()){
|
||||||
|
reply = readBuffer + reply;
|
||||||
|
readBuffer.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reply.replace("<message>", "");
|
||||||
|
reply.replace("</message>", "");
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
QJsonDocument jsonReply = QJsonDocument::fromJson(reply.toUtf8());
|
QJsonDocument jsonReply = QJsonDocument::fromJson(reply.toUtf8());
|
||||||
QJsonObject replyObj = jsonReply.object();
|
QJsonObject replyObj = jsonReply.object();
|
||||||
|
|
||||||
|
//qDebug() << "got: " << reply;
|
||||||
|
|
||||||
if(!replyObj.isEmpty()){
|
if(!replyObj.isEmpty()){
|
||||||
id = replyObj.value("id").toInt();
|
id = replyObj.value("id").toInt();
|
||||||
|
|
||||||
|
@ -206,6 +224,7 @@ void BaseConn::readyRead() {
|
||||||
|
|
||||||
latestReadReply = reply;
|
latestReadReply = reply;
|
||||||
emit gotUnexpectedReply(reply);
|
emit gotUnexpectedReply(reply);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseConn::writeRemoteSetting(QString key, QString value) {
|
int BaseConn::writeRemoteSetting(QString key, QString value) {
|
||||||
|
|
|
@ -457,9 +457,9 @@ QVariant ClimbingRace::getAthletes() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList tmpAthletes = reply["data"].toList();
|
QVariantMap tmpAthletes = reply["data"].toMap();
|
||||||
|
|
||||||
//qDebug() << tmpAthletes;
|
qDebug() << tmpAthletes;
|
||||||
|
|
||||||
return tmpAthletes;
|
return tmpAthletes;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue