# HG changeset patch # User Michael Schloh von Bennewitz # Date 1310157708 -7200 # Node ID c5c9ba04c01a984cc5a822b2ee59ac2b018ce300 # Parent 57bc4d78e5cd21fb9689a01a99ab4010a0203659 Import first revisions of new project SchachUhr. diff -r 57bc4d78e5cd -r c5c9ba04c01a qml/Wecker.qml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qml/Wecker.qml Fri Jul 08 22:41:48 2011 +0200 @@ -0,0 +1,163 @@ +// +// Schachuhr - Chess clock graphical user interface client +// Copyright © 2011 Michael Schloh von Bennewitz +// +// Schachuhr is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// Schachuhr is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +// the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Schachuhr. If not, see . +// +// This file is part of project Schachuhr, a chess clock graphical +// user interface client and is found at http://schachuhr.europalab.com/ +// +// Wecker.qml: QML implementation +// + +import QtQuick 1.0 + +Item { // unsure if this should be a generic item + id: wecker // or be rewritten as a QML component + width: 365; height: 360 // roughly the size of a single clockface + + property alias opponent: playName.text // opponent name + property int hours // displayed hour hand + property int minutes // displayed minute hand + property int seconds // displayed second hand + property real zeitfrist // opponent time allowance + property bool altercolor: false // opponent clock colour choice + property bool running: true // indicates wecker state + + // called once when hands are initialized + function timeInit() { + seconds = 0 + minutes = 60 - zeitfrist % 60 + hours = 11 - zeitfrist / 60 + } + + // called constantly as match progresses + function timeChanged() { + seconds = seconds + 1 + if (seconds % 60 == 0) { + if (minutes == 59) + hours++ + minutes++ + } + } + + // starts the timer of the next opponent, + // and stops the timer of the current one + // as well as indicating the running clock + // using text color and clockface size + function toggle() { + if (wecker.state == "playing") { + wecker.state = "waiting" + timeLeft.running = false + playName.color = "#A08050" + playName.style = Text.Sunken + } + else { + wecker.state = "playing" + timeLeft.running = true + playName.color = "white" + playName.style = Text.Raised + } + } + + // the match timer + Timer { + id: timeLeft + interval: 1000; running: false; repeat: true; triggeredOnStart: true + onTriggered: wecker.timeChanged() + } + + // a series of mutually exclusive clockface colours and sizes, + // in which only one is used for each opponent at a given time + Image { id: bgbraunlit; x: 50; y: 50; width: 320; height: 320; source: "clock-braun.png"; visible: wecker.altercolor == false && wecker.running == false } + Image { id: bgbraunbig; width: 420; height: 420; source: "clock-brexp.png"; visible: wecker.altercolor == false && wecker.running == true } + Image { id: bgbleuelit; x: 50; y: 50; width: 320; height: 320; source: "clock-bleu.png"; visible: wecker.altercolor == true && wecker.running == false } + Image { id: bgbleuebig; width: 420; height: 420; source: "clock-blexp.png"; visible: wecker.altercolor == true && wecker.running == true } + + // animated second hand is placed under the center graphic + Image { + x: 202; y: 80 + width: 15; height: 130 + source: "seconds.svg" + smooth: true + transform: Rotation { + id: secondRotation + origin.x: 7.5; origin.y: 130; + angle: wecker.seconds * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + // the center graphic which covers or connects to various hands + Image { + width: 34; height: 34; anchors.centerIn: bgbraunbig; source: "centre.png" + } + + // animated hour hand is placed over the center graphic + Image { + x: 200; y: 130 + width: 20; height: 70 + source: "hourmin.svg" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 10; origin.y: 80; + angle: (wecker.hours * 30) + (wecker.minutes * 0.5) + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + // animated minute hand is placed over the center graphic + Image { + x: 202; y: 90 + width: 16; height: 110 + source: "hourmin.svg" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 8; origin.y: 120; + angle: wecker.minutes * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + // opponent name like 'Vladimir KRAMNIK', + // is sunken and dimmed when not active + // due to toggle function taking action + Text { + id: playName + y: 400; anchors.horizontalCenter: bgbraunbig.horizontalCenter + color: "white" + font.bold: true; font.pixelSize: 54 + style: Text.Raised; styleColor: "black" + } + + // two state definitions, opponent take turns waiting or playing + states: [ + State { + name: "playing" + PropertyChanges { target: wecker; running: true } + }, + State { + name: "waiting" + PropertyChanges { target: wecker; running: false } + } + ] +} diff -r 57bc4d78e5cd -r c5c9ba04c01a qml/main.qml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qml/main.qml Fri Jul 08 22:41:48 2011 +0200 @@ -0,0 +1,142 @@ +// +// Schachuhr - Chess clock graphical user interface client +// Copyright © 2011 Michael Schloh von Bennewitz +// +// Schachuhr is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, +// or (at your option) any later version. +// +// Schachuhr is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +// the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Schachuhr. If not, see . +// +// This file is part of project Schachuhr, a chess clock graphical +// user interface client and is found at http://schachuhr.europalab.com/ +// +// main.qml: QML implementation +// + +import QtQuick 1.0 + +Rectangle { + width: 854; // until better layout design is learned, this hard + height: 480; // codes the client surface to fit on MeeGo handheld + color: "#7D5C2E" // light cocolate brown background + property bool init: true // indicates game clocks in initial state + + // title bar is flush left and rotated + Rectangle { + id: progTitle + width: 480; height: 90 + color: "#503014" + Text { + id: progLabel + text: "Chess Clock" + anchors.centerIn: parent + color: "#7D5C2E" + font.bold: true; font.pixelSize: 72 + style: Text.Raised + styleColor: "black" + } + transform: Rotation { origin.x: 240; origin.y: 240; angle: 270} + } + + // aesthetic top corner is rounded to match clock circumference curve + Image { x: 90; width: 190; height: 190; source: "cornerl.svg" } + //Image { + // x: 80 + // y: 270 + // width: 50 + // height: 50 + // source: "cornerl.svg" + // transform: Rotation { origin.x: 25; origin.y: 25; angle: 270 } + //} + + Row { // space two game subclocks and associated text in a row + anchors.top: parent.top; anchors.topMargin: -10; + anchors.left: parent.left; anchors.leftMargin: 80; + Wecker { + id: opponOne + opponent: "Oppenent 1" // name of player at left of clock + zeitfrist: 15 // opponent's time limit + altercolor: false // opponent's clock colour + MouseArea { // clicking here is only signaled + enabled: true // at start of match when the 'init' + id: weckoneArea // variable is set and thus the entire + anchors.fill: parent // surface mouse area is disabled + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + //if (mouse.button == Qt.RightButton) + // aboutDlg.visible = true + //else { // left button was pressed + init = false + //aboutDlg.visible = false + entireArea.enabled = true // will take precedence + opponOne.toggle() // start opponent one's clock + opponTwo.toggle() // toggle opponent two's clock + opponTwo.toggle() // twice to force into paused + //} + } + } + } + Wecker { + id: opponTwo + opponent: "Opponent 2" // name of player at right of clock + zeitfrist: 15 // opponent's time limit + altercolor: true // opponent's clock colour + MouseArea { // clicking here is only signaled + enabled: true // at start of match when the 'init' + id: wecktwoArea // variable is set and thus the entire + anchors.fill: parent // surface mouse area is disabled + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + //if (mouse.button == Qt.RightButton) + // aboutDlg.visible = true + //else { // left button was pressed + init = false + //aboutDlg.visible = false + entireArea.enabled = true // will take precedence + opponTwo.toggle() // start opponent two's clock + opponOne.toggle() // toggle opponent one's clock + opponOne.toggle() // twice to force into paused + //} + } + } + } + } + + //Image { id: aboutDlg; anchors.centerIn: parent; width: 423; height: 386; source: "wikichess.jpeg"; visible: false } + + // the main area covering the entire client surface + MouseArea { + enabled: false + id: entireArea + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + //if (mouse.button == Qt.LeftButton && init == false) { + //aboutDlg.visible = false + opponOne.toggle() // stop or start opponent one's clock + opponTwo.toggle() // stop or start opponent two's clock + //} + //else if (mouse.button == Qt.RightButton && init == false) + // aboutDlg.visible = true + //else // assert clicked + // console.log("Problem click in initial.") // in init state + } + } + + Timer { // just waits a second before moving the arms of + interval: 1000 // the game subclocks into their initial position + running: true + onTriggered: { + opponOne.timeInit() + opponTwo.timeInit() + } + } +}