2019-04-20 22:57:40 +02:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Window 2.2
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
|
|
|
|
import com.itsblue.digitalRockRanking 1.0
|
|
|
|
|
|
|
|
import "./Pages"
|
|
|
|
import "./Components"
|
|
|
|
|
|
|
|
Window {
|
|
|
|
visible: true
|
|
|
|
width: 540
|
|
|
|
height: 960
|
|
|
|
title: qsTr("Digital Rock Ranking")
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: app
|
|
|
|
|
|
|
|
property var competitionCategoryColors: {
|
|
|
|
"61": "lightgrey",
|
|
|
|
"58": "lightgreen",
|
|
|
|
|
|
|
|
"69": "#B8C8FF",
|
|
|
|
"70": "#F0F0F0",
|
|
|
|
"71": "#D8E8FF",
|
|
|
|
"256": "#D8E8FF"
|
|
|
|
}
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
sequences: ["Esc", "Back"]
|
|
|
|
enabled: mainStack.depth > 1
|
|
|
|
onActivated: {
|
|
|
|
if(!mainStack.currentItem.locked){
|
|
|
|
mainStack.pop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ServerConn {
|
|
|
|
id: serverConn
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
//serverConn.refreshFoodplan()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackView {
|
|
|
|
id: mainStack
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
top: toolBar.bottom
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
bottom: parent.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
initialItem: startPgComp
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: startPgComp
|
|
|
|
StartPage {}
|
|
|
|
}
|
|
|
|
|
|
|
|
popEnter: Transition {
|
|
|
|
XAnimator {
|
|
|
|
from: (mainStack.mirrored ? -1 : 1) * -mainStack.width
|
|
|
|
to: 0
|
|
|
|
duration: 500
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
popExit: Transition {
|
|
|
|
XAnimator {
|
|
|
|
from: 0
|
|
|
|
to: (mainStack.mirrored ? -1 : 1) * mainStack.width
|
|
|
|
duration: 500
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pushEnter: Transition {
|
|
|
|
XAnimator {
|
|
|
|
from: (mainStack.mirrored ? -1 : 1) * mainStack.width
|
|
|
|
to: 0
|
|
|
|
duration: 500
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pushExit: Transition {
|
|
|
|
XAnimator {
|
|
|
|
from: 0
|
|
|
|
to: (mainStack.mirrored ? -1 : 1) * -mainStack.width
|
|
|
|
duration: 500
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AppToolBar {
|
|
|
|
id: toolBar
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
topMargin: -60
|
|
|
|
}
|
|
|
|
|
|
|
|
height: 50
|
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
Row {
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
spacing: width * 0.02
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: spacer
|
|
|
|
width: 1
|
|
|
|
height: parent.height
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
Button {
|
|
|
|
id:toolButton
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
verticalCenter: parent.verticalCenter
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
height: parent.height * 0.5
|
|
|
|
width: height
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
onClicked: {
|
|
|
|
if(!mainStack.currentItem.locked){
|
|
|
|
mainStack.pop()
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
onPressed: toolButton.scale = 0.9
|
|
|
|
onReleased: toolButton.scale = 1.0
|
|
|
|
|
|
|
|
background: Image {
|
|
|
|
source: "qrc:/icons/backDark.png"
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
height: parent.height
|
|
|
|
width: height
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
Behavior on scale {
|
|
|
|
PropertyAnimation {
|
|
|
|
duration: 100
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
Column {
|
|
|
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
height: childrenRect.height
|
|
|
|
width: parent.width * 0.7
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: toolBarTitleLa
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
elide: "ElideRight"
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
font.bold: true
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
color: "black"
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
text: getText()
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
function getText(){
|
|
|
|
var titleString = "";
|
|
|
|
|
|
|
|
if(!mainStack.currentItem.titleIsPageTitle){
|
|
|
|
for(var i=1; i<mainStack.depth; i++){
|
|
|
|
if(i > 1){
|
|
|
|
titleString += " > "
|
|
|
|
}
|
|
|
|
|
|
|
|
titleString += mainStack.get(i).title
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
titleString = mainStack.currentItem.title
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
return(titleString)
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
Label {
|
|
|
|
id: toolBarSubTitleLa
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
elide: "ElideRight"
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
font.bold: false
|
|
|
|
|
|
|
|
color: "black"
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
text: getText()
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
function getText(){
|
|
|
|
var titleString = "";
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
if(mainStack.currentItem.subTitle !== undefined){
|
|
|
|
titleString = mainStack.currentItem.subTitle
|
|
|
|
}
|
|
|
|
|
|
|
|
return(titleString)
|
|
|
|
}
|
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: extraComponentLoader
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
height: parent.height
|
|
|
|
width: parent.width * 0.2 - toolButton.width
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
bottom: parent.bottom
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
|
2019-04-21 18:35:28 +02:00
|
|
|
sourceComponent: mainStack.currentItem.headerComponent
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
2019-04-21 18:35:28 +02:00
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on anchors.topMargin {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 500
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "closed"
|
|
|
|
when: mainStack.depth === 1
|
|
|
|
PropertyChanges {
|
|
|
|
target: toolBar
|
|
|
|
anchors.topMargin: -60
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "open"
|
|
|
|
when: mainStack.depth > 1
|
|
|
|
PropertyChanges {
|
|
|
|
target: toolBar
|
|
|
|
anchors.topMargin: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
id: loadingDl
|
|
|
|
|
|
|
|
x: ( app.width - width ) / 2
|
|
|
|
y: ( app.height - height ) / 2
|
|
|
|
|
|
|
|
modal: true
|
|
|
|
closePolicy: Dialog.NoAutoClose
|
|
|
|
|
|
|
|
contentItem: Column {
|
|
|
|
FancyBusyIndicator {
|
|
|
|
running: true
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
font.bold: true
|
|
|
|
|
|
|
|
text: "loading..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function landscape(){
|
|
|
|
return app.height < app.width
|
|
|
|
}
|
|
|
|
|
|
|
|
function openCalendar(nation){
|
|
|
|
loadingDl.open()
|
|
|
|
mainStack.push(Qt.createComponent("qrc:/Pages/CompetitionCalendarPage.qml").createObject(null, {"nation": nation}))
|
|
|
|
loadingDl.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
function openResults(comp, cat, reg){
|
|
|
|
// comp: (int) competiotion ID
|
|
|
|
// cat: (int) category ID
|
|
|
|
// reg: (bool) false: results; true: registrations
|
|
|
|
|
|
|
|
//loadingDl.open()
|
|
|
|
mainStack.push(Qt.createComponent("qrc:/Pages/RankingPage.qml").createObject(null, {"comId": comp, "catId": cat, "reg": reg}))
|
|
|
|
//loadingDl.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
function getErrorInfo(errorCode) {
|
|
|
|
|
|
|
|
var infoLevel
|
|
|
|
// 0 - ok
|
|
|
|
// 1 - info
|
|
|
|
// 2 - error
|
|
|
|
|
|
|
|
var errorString
|
|
|
|
var errorDescription
|
|
|
|
|
|
|
|
switch(errorCode) {
|
|
|
|
case 0:
|
|
|
|
infoLevel = 2
|
|
|
|
errorString = "No connection to server"
|
|
|
|
errorDescription = "Please check your internet connection and try again."
|
|
|
|
break
|
|
|
|
case 401:
|
|
|
|
infoLevel = 2
|
|
|
|
errorString = "Authentication required"
|
|
|
|
errorDescription = "The server asked for user credentinals, please chack them and try again"
|
|
|
|
break
|
|
|
|
case 500:
|
|
|
|
infoLevel = 2
|
|
|
|
errorString = "Internal server error"
|
|
|
|
errorDescription = "The server was unable to process this request, this is probaply the servers vault. Please try again later."
|
|
|
|
break
|
|
|
|
case 900:
|
|
|
|
infoLevel = 2
|
|
|
|
errorString = "Internal processing error"
|
|
|
|
errorDescription = "The server has sent some data that could ot be processed. Please try again later"
|
|
|
|
break
|
|
|
|
case 901:
|
|
|
|
infoLevel = 1
|
|
|
|
errorString = "No Data"
|
|
|
|
errorDescription = "There is currently no data available. Please try again later."
|
|
|
|
break
|
|
|
|
case 902:
|
|
|
|
infoLevel = 1
|
|
|
|
errorString = "Alte Daten"
|
|
|
|
errorDescription = "Es konnte keine Verbindung zum Server hergestellt werden, aber es sind noch alte Daten gespeichert."
|
|
|
|
break
|
|
|
|
case 903:
|
|
|
|
infoLevel = 1
|
|
|
|
errorString = "Ungültiger Aufruf"
|
|
|
|
errorDescription = "Die aufgerufene Funktion ist momentan nicht verfügbar, bitte versuche es später erneut."
|
|
|
|
break
|
|
|
|
case 904:
|
|
|
|
infoLevel = 2
|
|
|
|
errorString = "Incompatible API"
|
|
|
|
errorDescription = "Please make shure that you are using the latest version of this app and try again."
|
|
|
|
break
|
2019-04-21 12:35:11 +02:00
|
|
|
case 905:
|
|
|
|
infoLevel = 1
|
|
|
|
errorString = "Loading..."
|
|
|
|
errorDescription = "Please wait while we're loading some data"
|
|
|
|
break
|
2019-04-20 22:57:40 +02:00
|
|
|
default:
|
|
|
|
infoLevel = 2
|
|
|
|
errorString = "Unexpected error ("+errorCode+")"
|
|
|
|
errorDescription = "Unexpected error while getting data from the server. Please try again later."
|
|
|
|
}
|
|
|
|
|
|
|
|
return([infoLevel, errorString, errorDescription])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|