Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.11
- import QtQuick.Layouts 1.1
- import Shared 1.0
- import "controls"
- import "delegates"
- SharedStackPage {
- id: participationDialog
- property ClubTournamentController tc: tournamentController
- pageUrl: "participation-dialog"
- pageTitle: qsTr("Participate in this tournament")
- onPlayerReady: {
- tc.addedPlayers.append({
- "_player": playerAdder.playerModel
- });
- }
- sourceComponent: StackPageContent {
- readonly property bool teamFull: (!tc.teamCompetition
- || tc.addedPlayers.count === tc.teamSize)
- Connections {
- enabled: visible
- target: tournamentController
- onParticipationSuccess: {
- stackView.pop();
- }
- }
- onPageActivating: {
- acceptCheckBox.checked = false;
- switch (tc.paymentOption) {
- case controller.paymentOptionVoluntary:
- footer.infoText = qsTr("Continue to select payment.");
- footer.confirmButtonText = qsTr("Continue");
- break;
- case controller.paymentOptionDisabled:
- footer.infoText = qsTr("Fee will be paid at the club.");
- footer.confirmButtonText = qsTr("Enroll");
- break;
- case controller.paymentOptionRequired:
- footer.infoText = qsTr("Payment required.");
- footer.confirmButtonText = qsTr("Continue to pay");
- break;
- default:
- debug.log("Warning: invalid paymentoption");
- return "";
- }
- }
- onPageDeactivated: {
- organizerText.text = "";
- teamNameInput.text = "";
- }
- SharedFlickable {
- anchors.fill: parent
- contentHeight: contentColumn.height + theme.textMargins
- interactive: contentHeight > height
- Column {
- id: contentColumn
- width: parent.width
- spacing: 20 * scaleFactor
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.margins: theme.textMargins
- // Hidden automatically if there is only one series available
- StyledText {
- width: parent.width
- visible: tc.seriesModel.length > 1
- text: qsTr("* Select series")
- font.pixelSize: theme.smallFontSize
- }
- FlatButton {
- width: parent.width
- visible: tc.seriesModel.length > 1
- buttonModel: tc.seriesModel
- onSelectedValueChanged: {
- tc.selectedSeries = selectedValue;
- tc.updatePrice();
- }
- }
- StyledText {
- width: parent.width
- visible: !tc.startTimeWishDisabled
- text: qsTr("Select preferred starting time")
- font.pixelSize: theme.smallFontSize
- }
- FlatButton {
- width: parent.width
- visible: !tc.startTimeWishDisabled
- buttonModel: [{
- "title": qsTr("No Preference"),
- "value": 0
- }, {
- "title": qsTr("Early"),
- "value": 1
- }, {
- "title": qsTr("Late"),
- "value": 2
- }]
- onSelectedValueChanged: tc.timeHint = selectedValue
- }
- StyledText {
- width: parent.width
- visible: tc.teamCompetition && tc.teamNamingEnabled === true
- text: qsTr("Team name")
- font.pixelSize: theme.smallFontSize
- }
- FlatInput {
- id: teamNameInput
- width: parent.width
- visible: tc.teamNamingEnabled === true
- onTextChanged: tc.teamName = text
- }
- StyledText {
- width: parent.width
- text: qsTr("Message to organizers")
- font.pixelSize: theme.smallFontSize
- visible: !tc.hideOptionalMessage
- }
- FlatTextArea {
- width: parent.width
- id: organizerText
- visible: !tc.hideOptionalMessage
- onTextChanged: {
- tc.note = text;
- }
- }
- StyledText {
- font.pixelSize: theme.smallFontSize
- text: qsTr("Add team participants %1 / %2").arg(tc.addedPlayers.count).arg(
- tc.teamSize)
- visible: tc.teamCompetition
- }
- Column {
- width: parent.width
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.margins: -theme.textMargins
- visible: tc.teamCompetition
- AppMenuSeparator {
- z: 1
- }
- Repeater {
- model: tc.addedPlayers
- PlayerAdderDelegate {
- clickIgnored: true
- alreadyIncluded: false
- SharedButton {
- visible: index > 0
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- color: theme.redColor
- labelColor: "white"
- radius: height / 2
- width: height
- onClicked: tc.addedPlayers.remove(index)
- StyledImage {
- color: "white"
- colorize: true
- source: "qrc:/images/icon_close.png"
- width: parent.height / 3.0
- height: width
- anchors.centerIn: parent
- }
- }
- }
- }
- }
- SharedButton {
- width: parent.width
- text: qsTr("Add player")
- function filterAddedPlayers(id, clubId) {
- if (clubId !== session.clubNumber) {
- return true;
- }
- for (var i in tc.competition.participants) {
- if (tc.competition.participants[i].number === id) {
- return true;
- }
- }
- for (i = 0; i < tc.addedPlayers.count; ++i) {
- if (tc.addedPlayers.get(i)._player.id === id) {
- return true;
- }
- }
- return false;
- }
- onClicked: {
- playerAdder.allowManualPlayers = false;
- playerAdder.hideOtherClubs = true;
- playerAdder.setPlayerFilter(filterAddedPlayers);
- playerAdder.show();
- }
- visible: (tc.teamCompetition && tc.addedPlayers.count < tc.teamSize)
- }
- Item {
- width: 1
- height: 1
- }
- CustomCheckBox {
- id: acceptCheckBox
- width: parent.width
- text: qsTr("I accept the terms, enrollment obligatory and tournament fees regarding this tournaments participation.")
- onCheckedChanged: footer.enabled = checked
- }
- Item {
- width: 1
- height: footer.height
- }
- }
- }
- SharedConfirmationFooter {
- id: footer
- priceLabelText: tc.price
- anchors.bottom: parent.bottom
- priceLabelColor: theme.inverted ? theme.darkSkyBlue : theme.yellowColor
- labelsVisible: true
- optionVisible: false
- confirmationEnabled: acceptCheckBox.checked && teamFull
- headerText: qsTr("Total price")
- onAccepted: {
- if (tc.paymentOption !== controller.paymentOptionDisabled) {
- stackView.push({
- "item": pages.clubTournamentsConfirmPayment,
- "immediate": false
- });
- }
- else {
- tc.requestPayOnJoined = false;
- tc.performJoin();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement