From 20ffca467043fe94c5261b4632af4e4b7b6f7aa0 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Tue, 29 Jun 2021 17:44:35 +0200 Subject: [PATCH] - Fixed registration widget issues - Added share button to registration, startlist and profile widget --- resources/qml/Components/SelectorPopup.qml | 7 +-- resources/qml/Pages/WidgetPage.qml | 1 - resources/qml/Widgets/CalendarWidget.qml | 4 ++ resources/qml/Widgets/ProfileWidget.qml | 9 +++ resources/qml/Widgets/RankingWidget.qml | 11 +++- resources/qml/Widgets/RegistrationWidget.qml | 61 +++++++++++++++----- resources/qml/Widgets/StartlistWidget.qml | 20 ++++++- resources/qml/main.qml | 1 + 8 files changed, 91 insertions(+), 23 deletions(-) diff --git a/resources/qml/Components/SelectorPopup.qml b/resources/qml/Components/SelectorPopup.qml index 6cdf282..3e7c058 100644 --- a/resources/qml/Components/SelectorPopup.qml +++ b/resources/qml/Components/SelectorPopup.qml @@ -9,6 +9,7 @@ Dialog { property string subTitle: "" signal selectionFinished(int index, var data) + signal linkActivated(string link) parent: Overlay.overlay @@ -50,8 +51,7 @@ Dialog { text: control.title onLinkActivated: { - console.log("Opening " + link) - Qt.openUrlExternally(link) + control.linkActivated(link) } } @@ -72,8 +72,7 @@ Dialog { text: control.subTitle onLinkActivated: { - console.log("Opening " + link) - Qt.openUrlExternally(link) + control.linkActivated(link) } } diff --git a/resources/qml/Pages/WidgetPage.qml b/resources/qml/Pages/WidgetPage.qml index ecaf211..ee303af 100644 --- a/resources/qml/Pages/WidgetPage.qml +++ b/resources/qml/Pages/WidgetPage.qml @@ -296,7 +296,6 @@ Page { leftMargin: 3 bottom: selectorLv.bottom } - } delegate: Button { diff --git a/resources/qml/Widgets/CalendarWidget.qml b/resources/qml/Widgets/CalendarWidget.qml index 10140fa..c82baae 100644 --- a/resources/qml/Widgets/CalendarWidget.qml +++ b/resources/qml/Widgets/CalendarWidget.qml @@ -404,6 +404,10 @@ DataListView { app.openWidget({cup: data.cup, cat: data.cat}) } } + + function onLinkActivated(link) { + Qt.openUrlExternally(link) + } } header: Item { diff --git a/resources/qml/Widgets/ProfileWidget.qml b/resources/qml/Widgets/ProfileWidget.qml index fc7d442..f7a6745 100644 --- a/resources/qml/Widgets/ProfileWidget.qml +++ b/resources/qml/Widgets/ProfileWidget.qml @@ -35,6 +35,15 @@ Page { property var widgetData: currentWidgetData + property Component headerComponent: ToolButton { + id: shareToolBt + + onClicked: shareWidget(control.title) + + text: "\uf1e0" + font.family: fa5solid.name + } + Component.onCompleted: { control.ready = true control.status = 200 diff --git a/resources/qml/Widgets/RankingWidget.qml b/resources/qml/Widgets/RankingWidget.qml index a294491..c63a9b4 100644 --- a/resources/qml/Widgets/RankingWidget.qml +++ b/resources/qml/Widgets/RankingWidget.qml @@ -34,6 +34,15 @@ DataListView { property var widgetData: currentWidgetData signal closeAll() + property Component headerComponent: ToolButton { + id: shareToolBt + + onClicked: shareWidget(control.title) + + text: "\uf1e0" + font.family: fa5solid.name + } + Connections { target: selector function onSelectionFinished(index, data) { @@ -81,7 +90,7 @@ DataListView { } onPressAndHold: { - app.openWidget({person:thisData["PerId"]}) + app.openWidget({person:thisData["PerId"]}) } ParallelAnimation { diff --git a/resources/qml/Widgets/RegistrationWidget.qml b/resources/qml/Widgets/RegistrationWidget.qml index 2c024e3..ddb04e7 100644 --- a/resources/qml/Widgets/RegistrationWidget.qml +++ b/resources/qml/Widgets/RegistrationWidget.qml @@ -18,6 +18,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.12 import "../Components" @@ -30,15 +31,30 @@ DataListView { property string subTitle: getSubtitle() property bool titleIsPageTitle: true - property Component headerComponent: ToolButton { - id: moreToolBt + property Component headerComponent: RowLayout { - onClicked: { - control.changeCat() + height: parent.height + spacing: 0 + + ToolButton { + id: shareToolBt + + onClicked: shareWidget(control.title) + + text: "\uf1e0" + font.family: fa5solid.name } - text: "\uf142" - font.family: fa5solid.name + ToolButton { + id: moreToolBt + + onClicked: { + control.changeCat() + } + + text: "\uf142" + font.family: fa5solid.name + } } property var widgetData: currentWidgetData @@ -69,7 +85,7 @@ DataListView { } - function getText(index){ + function getText(athleteData){ var fedName // federation name @@ -78,7 +94,7 @@ DataListView { for(var i = 0; i < widgetData["federations"].length; i ++ ){ //console.log("checking " + i + ": cat: " + parseInt(widgetData["categorys"][i]["GrpId"]) + " searched cat: " + root.catId) - if(widgetData["federations"][i]["fed_id"] === widgetData[ 'athletes' ][index]["reg_fed_id"]){ + if(widgetData["federations"][i]["fed_id"] === athleteData["reg_fed_id"]){ fedName = widgetData["federations"][i]["shortcut"] } } @@ -86,10 +102,10 @@ DataListView { else { // an international competition -> get nation - fedName = widgetData[ 'athletes' ][index]["nation"] + fedName = athleteData["nation"] } - return widgetData[ "athletes" ][index]["firstname"] + " " + widgetData[ "athletes" ][index]["lastname"] + " (" + fedName + ")" + return athleteData["firstname"] + " " + athleteData["lastname"] + " (" + fedName + ")" } function changeCat() { @@ -109,12 +125,17 @@ DataListView { } } - selector.appear(selectOptions, qsTrId("#selectCategory")) + selector.appear(selectOptions, qsTrId("#selectCategory"), "Show results") } function filterAthletes(athletes) { + if(!params.cat) { + params.cat = control.widgetData["categorys"][0]["GrpId"] + } + var filtered = athletes.filter(function(athlete){ - return parseInt(athlete.cat) === parseInt(params.cat) + var res = String(athlete.cat).toLowerCase() === String(params.cat).toLowerCase() + return res }) return filtered @@ -127,6 +148,13 @@ DataListView { updateData({cat: data.cat}, true) } } + + function onLinkActivated(link) { + selector.close() + var tmpParams = params + tmpParams.type = "" + app.openWidget(tmpParams) + } } Component.onCompleted: { @@ -143,6 +171,9 @@ DataListView { onRefresh: { updateData({}, false) + } + + onWidgetDataChanged: { athletes = [] athletes = filterAthletes(widgetData["athletes"]) } @@ -155,11 +186,11 @@ DataListView { property int thisIndex: index property var thisData: modelData - width: parseInt(thisData.cat) === parseInt(params.cat) ? control.width:control.width * 0.2 - opacity: 0 scale: 0.9 + width: control.width + onThisDataChanged: { fadeInPa.start() } @@ -189,7 +220,7 @@ DataListView { elide: "ElideRight" - text: control.getText(index) + text: control.getText(partDel.thisData) } } diff --git a/resources/qml/Widgets/StartlistWidget.qml b/resources/qml/Widgets/StartlistWidget.qml index 585b51b..2c1e1e9 100644 --- a/resources/qml/Widgets/StartlistWidget.qml +++ b/resources/qml/Widgets/StartlistWidget.qml @@ -19,6 +19,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.4 import QtGraphicalEffects 1.0 +import QtQuick.Layouts 1.12 import "../Components" @@ -31,7 +32,21 @@ DataListView { property string subTitle: getSubtitle() property bool titleIsPageTitle: true - property Component headerComponent: ToolButton { + property Component headerComponent: RowLayout { + + height: parent.height + spacing: 0 + + ToolButton { + id: shareToolBt + + onClicked: shareWidget(control.title) + + text: "\uf1e0" + font.family: fa5solid.name + } + + ToolButton { id: moreToolBt onClicked: { @@ -40,6 +55,7 @@ DataListView { text: "\uf142" font.family: fa5solid.name + } } function getSubtitle() { @@ -52,7 +68,7 @@ DataListView { } } - //% "(Startlist)" + //% "(Startlist)"https://l.bluerock.dev/?comp=11601&type=starters var addition = qsTrId("#startlistHeadline") return addition + " " + titleString diff --git a/resources/qml/main.qml b/resources/qml/main.qml index fb74f84..f826d88 100644 --- a/resources/qml/main.qml +++ b/resources/qml/main.qml @@ -198,6 +198,7 @@ Window { //openWidget({comp: 11651, cat: 26}) //openWidget({person: 6623}) //console.log(JSON.stringify(serverConn.getParamsFromUrl(""))) + openWidgetFromUrl("https://l.bluerock.dev/?comp=11601&type=starters") } FontLoader {