michael@3: // michael@3: // Schachuhr - Chess clock graphical user interface client michael@3: // Copyright © 2011 Michael Schloh von Bennewitz michael@3: // michael@3: // Schachuhr is free software: you can redistribute it and/or modify michael@3: // it under the terms of the GNU General Public License as published michael@3: // by the Free Software Foundation, either version 3 of the License, michael@3: // or (at your option) any later version. michael@3: // michael@3: // Schachuhr is distributed in the hope that it will be useful, michael@3: // but WITHOUT ANY WARRANTY; without even the implied warranty michael@3: // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See michael@3: // the GNU General Public License for more details. michael@3: // michael@3: // You should have received a copy of the GNU General Public License michael@3: // along with Schachuhr. If not, see . michael@3: // michael@3: // This file is part of project Schachuhr, a chess clock graphical michael@3: // user interface client and is found at http://schachuhr.europalab.com/ michael@3: // michael@3: // main.qml: QML implementation michael@3: // michael@3: michael@3: import QtQuick 1.0 michael@3: michael@3: Rectangle { michael@3: width: 854; // until better layout design is learned, this hard michael@3: height: 480; // codes the client surface to fit on MeeGo handheld michael@3: color: "#7D5C2E" // light cocolate brown background michael@3: property bool init: true // indicates game clocks in initial state michael@3: michael@3: // title bar is flush left and rotated michael@3: Rectangle { michael@3: id: progTitle michael@3: width: 480; height: 90 michael@3: color: "#503014" michael@3: Text { michael@3: id: progLabel michael@3: text: "Chess Clock" michael@3: anchors.centerIn: parent michael@3: color: "#7D5C2E" michael@3: font.bold: true; font.pixelSize: 72 michael@3: style: Text.Raised michael@3: styleColor: "black" michael@3: } michael@3: transform: Rotation { origin.x: 240; origin.y: 240; angle: 270} michael@3: } michael@3: michael@3: // aesthetic top corner is rounded to match clock circumference curve michael@3: Image { x: 90; width: 190; height: 190; source: "cornerl.svg" } michael@3: //Image { michael@3: // x: 80 michael@3: // y: 270 michael@3: // width: 50 michael@3: // height: 50 michael@3: // source: "cornerl.svg" michael@3: // transform: Rotation { origin.x: 25; origin.y: 25; angle: 270 } michael@3: //} michael@3: michael@3: Row { // space two game subclocks and associated text in a row michael@3: anchors.top: parent.top; anchors.topMargin: -10; michael@3: anchors.left: parent.left; anchors.leftMargin: 80; michael@3: Wecker { michael@3: id: opponOne michael@3: opponent: "Oppenent 1" // name of player at left of clock michael@3: zeitfrist: 15 // opponent's time limit michael@3: altercolor: false // opponent's clock colour michael@3: MouseArea { // clicking here is only signaled michael@3: enabled: true // at start of match when the 'init' michael@3: id: weckoneArea // variable is set and thus the entire michael@3: anchors.fill: parent // surface mouse area is disabled michael@3: acceptedButtons: Qt.LeftButton | Qt.RightButton michael@3: onClicked: { michael@3: //if (mouse.button == Qt.RightButton) michael@3: // aboutDlg.visible = true michael@3: //else { // left button was pressed michael@3: init = false michael@3: //aboutDlg.visible = false michael@3: entireArea.enabled = true // will take precedence michael@3: opponOne.toggle() // start opponent one's clock michael@3: opponTwo.toggle() // toggle opponent two's clock michael@3: opponTwo.toggle() // twice to force into paused michael@3: //} michael@3: } michael@3: } michael@3: } michael@3: Wecker { michael@3: id: opponTwo michael@3: opponent: "Opponent 2" // name of player at right of clock michael@3: zeitfrist: 15 // opponent's time limit michael@3: altercolor: true // opponent's clock colour michael@3: MouseArea { // clicking here is only signaled michael@3: enabled: true // at start of match when the 'init' michael@3: id: wecktwoArea // variable is set and thus the entire michael@3: anchors.fill: parent // surface mouse area is disabled michael@3: acceptedButtons: Qt.LeftButton | Qt.RightButton michael@3: onClicked: { michael@3: //if (mouse.button == Qt.RightButton) michael@3: // aboutDlg.visible = true michael@3: //else { // left button was pressed michael@3: init = false michael@3: //aboutDlg.visible = false michael@3: entireArea.enabled = true // will take precedence michael@3: opponTwo.toggle() // start opponent two's clock michael@3: opponOne.toggle() // toggle opponent one's clock michael@3: opponOne.toggle() // twice to force into paused michael@3: //} michael@3: } michael@3: } michael@3: } michael@3: } michael@3: michael@3: //Image { id: aboutDlg; anchors.centerIn: parent; width: 423; height: 386; source: "wikichess.jpeg"; visible: false } michael@3: michael@3: // the main area covering the entire client surface michael@3: MouseArea { michael@3: enabled: false michael@3: id: entireArea michael@3: anchors.fill: parent michael@3: acceptedButtons: Qt.LeftButton | Qt.RightButton michael@3: onClicked: { michael@3: //if (mouse.button == Qt.LeftButton && init == false) { michael@3: //aboutDlg.visible = false michael@3: opponOne.toggle() // stop or start opponent one's clock michael@3: opponTwo.toggle() // stop or start opponent two's clock michael@3: //} michael@3: //else if (mouse.button == Qt.RightButton && init == false) michael@3: // aboutDlg.visible = true michael@3: //else // assert clicked michael@3: // console.log("Problem click in initial.") // in init state michael@3: } michael@3: } michael@3: michael@3: Timer { // just waits a second before moving the arms of michael@6: interval: 2000 // the game subclocks into their initial position michael@3: running: true michael@3: onTriggered: { michael@3: opponOne.timeInit() michael@3: opponTwo.timeInit() michael@3: } michael@3: } michael@3: }