- finished up athlete stuff

This commit is contained in:
Dorian Zedler 2019-05-19 14:06:05 +02:00
parent 33ae172038
commit a0a3d8cfe6
8 changed files with 237 additions and 139 deletions

View file

@ -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;

View file

@ -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()
} }
} }
@ -112,26 +116,38 @@ Popup {
RemoteDataListView { RemoteDataListView {
id: profileList id: profileList
property int currentAthlete: -1
property string title: "profiles" property string title: "profiles"
property string secondButt: "add" property string secondButt: "add"
signal opened() signal opened()
onOpened: { onOpened: {
loadData() profileList.loadData()
} }
anchors.fill: parent
anchors.topMargin: topContainerItm.height * 0.1
loadData: function () { loadData: function () {
status = 905 status = 905
listData = {} listData = {}
listData = speedBackend.getAthletes() var retData = speedBackend.getAthletes()
if(retData === undefined){
status = 500
return
}
listData = retData["allAthletes"]
currentAthlete = retData["activeAthlete"]
status = listData.lenght !== false ? 200:0 status = listData.lenght !== false ? 200:0
} }
delegate: SwipeDelegate { delegate: SwipeDelegate {
id: swipeDelegate id: swipeDelegate
property bool active: profileList.listData[index]["active"] property bool active: profileList.currentAthlete === profileList.listData[index]["id"]
text: profileList.listData[index]["fullName"] text: profileList.listData[index]["fullName"]
width: profileList.width - (swipeDelegate.x) width: profileList.width - (swipeDelegate.x)
@ -150,6 +166,13 @@ Popup {
background: Rectangle { background: Rectangle {
color: Qt.darker( pressed ? Qt.darker("white", 1.1):"white", swipeDelegate.active ? 1.1:0 ) color: Qt.darker( pressed ? Qt.darker("white", 1.1):"white", swipeDelegate.active ? 1.1:0 )
Behavior on color {
ColorAnimation {
duration: 200
}
}
} }
CheckBox { CheckBox {
@ -187,9 +210,34 @@ Popup {
width: parent.width * 0.65 width: parent.width * 0.65
height: width height: width
anchors.centerIn: parent anchors.centerIn: parent
radius: width * 0.2 radius: control.checked ? width * 0.2:0
color: control.down ? "#17a81a" : "#21be2b" color: control.down ? "#17a81a" : "#21be2b"
visible: control.checked 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
}
}
} }
} }
} }
@ -246,6 +294,7 @@ Popup {
} }
} }
} }
} }
/*-----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

View file

@ -29,15 +29,26 @@ 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 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 NumberAnimation { // in the default case, fade scale back to 1
id: inAnimation id: inAnimation
target: root.target target: root.target
@ -46,4 +57,14 @@ SequentialAnimation {
to: 1 to: 1
easing.type: Easing["Out"+root.easingType] 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]
}
}
} }

View file

@ -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 )

View file

@ -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
}
}
} }
} }

View file

@ -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: ""
}
} }
] ]

View file

@ -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) {

View file

@ -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;
} }