1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/qml/main.qml Fri Jul 08 22:41:48 2011 +0200 1.3 @@ -0,0 +1,142 @@ 1.4 +// 1.5 +// Schachuhr - Chess clock graphical user interface client 1.6 +// Copyright © 2011 Michael Schloh von Bennewitz <michael@schloh.com> 1.7 +// 1.8 +// Schachuhr is free software: you can redistribute it and/or modify 1.9 +// it under the terms of the GNU General Public License as published 1.10 +// by the Free Software Foundation, either version 3 of the License, 1.11 +// or (at your option) any later version. 1.12 +// 1.13 +// Schachuhr is distributed in the hope that it will be useful, 1.14 +// but WITHOUT ANY WARRANTY; without even the implied warranty 1.15 +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 1.16 +// the GNU General Public License for more details. 1.17 +// 1.18 +// You should have received a copy of the GNU General Public License 1.19 +// along with Schachuhr. If not, see <http://www.gnu.org/licenses/>. 1.20 +// 1.21 +// This file is part of project Schachuhr, a chess clock graphical 1.22 +// user interface client and is found at http://schachuhr.europalab.com/ 1.23 +// 1.24 +// main.qml: QML implementation 1.25 +// 1.26 + 1.27 +import QtQuick 1.0 1.28 + 1.29 +Rectangle { 1.30 + width: 854; // until better layout design is learned, this hard 1.31 + height: 480; // codes the client surface to fit on MeeGo handheld 1.32 + color: "#7D5C2E" // light cocolate brown background 1.33 + property bool init: true // indicates game clocks in initial state 1.34 + 1.35 + // title bar is flush left and rotated 1.36 + Rectangle { 1.37 + id: progTitle 1.38 + width: 480; height: 90 1.39 + color: "#503014" 1.40 + Text { 1.41 + id: progLabel 1.42 + text: "Chess Clock" 1.43 + anchors.centerIn: parent 1.44 + color: "#7D5C2E" 1.45 + font.bold: true; font.pixelSize: 72 1.46 + style: Text.Raised 1.47 + styleColor: "black" 1.48 + } 1.49 + transform: Rotation { origin.x: 240; origin.y: 240; angle: 270} 1.50 + } 1.51 + 1.52 + // aesthetic top corner is rounded to match clock circumference curve 1.53 + Image { x: 90; width: 190; height: 190; source: "cornerl.svg" } 1.54 + //Image { 1.55 + // x: 80 1.56 + // y: 270 1.57 + // width: 50 1.58 + // height: 50 1.59 + // source: "cornerl.svg" 1.60 + // transform: Rotation { origin.x: 25; origin.y: 25; angle: 270 } 1.61 + //} 1.62 + 1.63 + Row { // space two game subclocks and associated text in a row 1.64 + anchors.top: parent.top; anchors.topMargin: -10; 1.65 + anchors.left: parent.left; anchors.leftMargin: 80; 1.66 + Wecker { 1.67 + id: opponOne 1.68 + opponent: "Oppenent 1" // name of player at left of clock 1.69 + zeitfrist: 15 // opponent's time limit 1.70 + altercolor: false // opponent's clock colour 1.71 + MouseArea { // clicking here is only signaled 1.72 + enabled: true // at start of match when the 'init' 1.73 + id: weckoneArea // variable is set and thus the entire 1.74 + anchors.fill: parent // surface mouse area is disabled 1.75 + acceptedButtons: Qt.LeftButton | Qt.RightButton 1.76 + onClicked: { 1.77 + //if (mouse.button == Qt.RightButton) 1.78 + // aboutDlg.visible = true 1.79 + //else { // left button was pressed 1.80 + init = false 1.81 + //aboutDlg.visible = false 1.82 + entireArea.enabled = true // will take precedence 1.83 + opponOne.toggle() // start opponent one's clock 1.84 + opponTwo.toggle() // toggle opponent two's clock 1.85 + opponTwo.toggle() // twice to force into paused 1.86 + //} 1.87 + } 1.88 + } 1.89 + } 1.90 + Wecker { 1.91 + id: opponTwo 1.92 + opponent: "Opponent 2" // name of player at right of clock 1.93 + zeitfrist: 15 // opponent's time limit 1.94 + altercolor: true // opponent's clock colour 1.95 + MouseArea { // clicking here is only signaled 1.96 + enabled: true // at start of match when the 'init' 1.97 + id: wecktwoArea // variable is set and thus the entire 1.98 + anchors.fill: parent // surface mouse area is disabled 1.99 + acceptedButtons: Qt.LeftButton | Qt.RightButton 1.100 + onClicked: { 1.101 + //if (mouse.button == Qt.RightButton) 1.102 + // aboutDlg.visible = true 1.103 + //else { // left button was pressed 1.104 + init = false 1.105 + //aboutDlg.visible = false 1.106 + entireArea.enabled = true // will take precedence 1.107 + opponTwo.toggle() // start opponent two's clock 1.108 + opponOne.toggle() // toggle opponent one's clock 1.109 + opponOne.toggle() // twice to force into paused 1.110 + //} 1.111 + } 1.112 + } 1.113 + } 1.114 + } 1.115 + 1.116 + //Image { id: aboutDlg; anchors.centerIn: parent; width: 423; height: 386; source: "wikichess.jpeg"; visible: false } 1.117 + 1.118 + // the main area covering the entire client surface 1.119 + MouseArea { 1.120 + enabled: false 1.121 + id: entireArea 1.122 + anchors.fill: parent 1.123 + acceptedButtons: Qt.LeftButton | Qt.RightButton 1.124 + onClicked: { 1.125 + //if (mouse.button == Qt.LeftButton && init == false) { 1.126 + //aboutDlg.visible = false 1.127 + opponOne.toggle() // stop or start opponent one's clock 1.128 + opponTwo.toggle() // stop or start opponent two's clock 1.129 + //} 1.130 + //else if (mouse.button == Qt.RightButton && init == false) 1.131 + // aboutDlg.visible = true 1.132 + //else // assert clicked 1.133 + // console.log("Problem click in initial.") // in init state 1.134 + } 1.135 + } 1.136 + 1.137 + Timer { // just waits a second before moving the arms of 1.138 + interval: 1000 // the game subclocks into their initial position 1.139 + running: true 1.140 + onTriggered: { 1.141 + opponOne.timeInit() 1.142 + opponTwo.timeInit() 1.143 + } 1.144 + } 1.145 +}