Sat, 09 Jul 2011 19:14:03 +0200
Remember changed logic in release and refine requirements and design.
michael@3 | 1 | // |
michael@3 | 2 | // Schachuhr - Chess clock graphical user interface client |
michael@3 | 3 | // Copyright © 2011 Michael Schloh von Bennewitz <michael@schloh.com> |
michael@3 | 4 | // |
michael@3 | 5 | // Schachuhr is free software: you can redistribute it and/or modify |
michael@3 | 6 | // it under the terms of the GNU General Public License as published |
michael@3 | 7 | // by the Free Software Foundation, either version 3 of the License, |
michael@3 | 8 | // or (at your option) any later version. |
michael@3 | 9 | // |
michael@3 | 10 | // Schachuhr is distributed in the hope that it will be useful, |
michael@3 | 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty |
michael@3 | 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
michael@3 | 13 | // the GNU General Public License for more details. |
michael@3 | 14 | // |
michael@3 | 15 | // You should have received a copy of the GNU General Public License |
michael@3 | 16 | // along with Schachuhr. If not, see <http://www.gnu.org/licenses/>. |
michael@3 | 17 | // |
michael@3 | 18 | // This file is part of project Schachuhr, a chess clock graphical |
michael@3 | 19 | // user interface client and is found at http://schachuhr.europalab.com/ |
michael@3 | 20 | // |
michael@3 | 21 | // main.qml: QML implementation |
michael@3 | 22 | // |
michael@3 | 23 | |
michael@3 | 24 | import QtQuick 1.0 |
michael@3 | 25 | |
michael@3 | 26 | Rectangle { |
michael@3 | 27 | width: 854; // until better layout design is learned, this hard |
michael@3 | 28 | height: 480; // codes the client surface to fit on MeeGo handheld |
michael@3 | 29 | color: "#7D5C2E" // light cocolate brown background |
michael@3 | 30 | property bool init: true // indicates game clocks in initial state |
michael@3 | 31 | |
michael@3 | 32 | // title bar is flush left and rotated |
michael@3 | 33 | Rectangle { |
michael@3 | 34 | id: progTitle |
michael@3 | 35 | width: 480; height: 90 |
michael@3 | 36 | color: "#503014" |
michael@3 | 37 | Text { |
michael@3 | 38 | id: progLabel |
michael@3 | 39 | text: "Chess Clock" |
michael@3 | 40 | anchors.centerIn: parent |
michael@3 | 41 | color: "#7D5C2E" |
michael@3 | 42 | font.bold: true; font.pixelSize: 72 |
michael@3 | 43 | style: Text.Raised |
michael@3 | 44 | styleColor: "black" |
michael@3 | 45 | } |
michael@3 | 46 | transform: Rotation { origin.x: 240; origin.y: 240; angle: 270} |
michael@3 | 47 | } |
michael@3 | 48 | |
michael@3 | 49 | // aesthetic top corner is rounded to match clock circumference curve |
michael@3 | 50 | Image { x: 90; width: 190; height: 190; source: "cornerl.svg" } |
michael@3 | 51 | //Image { |
michael@3 | 52 | // x: 80 |
michael@3 | 53 | // y: 270 |
michael@3 | 54 | // width: 50 |
michael@3 | 55 | // height: 50 |
michael@3 | 56 | // source: "cornerl.svg" |
michael@3 | 57 | // transform: Rotation { origin.x: 25; origin.y: 25; angle: 270 } |
michael@3 | 58 | //} |
michael@3 | 59 | |
michael@3 | 60 | Row { // space two game subclocks and associated text in a row |
michael@3 | 61 | anchors.top: parent.top; anchors.topMargin: -10; |
michael@3 | 62 | anchors.left: parent.left; anchors.leftMargin: 80; |
michael@3 | 63 | Wecker { |
michael@3 | 64 | id: opponOne |
michael@3 | 65 | opponent: "Oppenent 1" // name of player at left of clock |
michael@3 | 66 | zeitfrist: 15 // opponent's time limit |
michael@3 | 67 | altercolor: false // opponent's clock colour |
michael@3 | 68 | MouseArea { // clicking here is only signaled |
michael@3 | 69 | enabled: true // at start of match when the 'init' |
michael@3 | 70 | id: weckoneArea // variable is set and thus the entire |
michael@3 | 71 | anchors.fill: parent // surface mouse area is disabled |
michael@3 | 72 | acceptedButtons: Qt.LeftButton | Qt.RightButton |
michael@3 | 73 | onClicked: { |
michael@3 | 74 | //if (mouse.button == Qt.RightButton) |
michael@3 | 75 | // aboutDlg.visible = true |
michael@3 | 76 | //else { // left button was pressed |
michael@3 | 77 | init = false |
michael@3 | 78 | //aboutDlg.visible = false |
michael@3 | 79 | entireArea.enabled = true // will take precedence |
michael@3 | 80 | opponOne.toggle() // start opponent one's clock |
michael@3 | 81 | opponTwo.toggle() // toggle opponent two's clock |
michael@3 | 82 | opponTwo.toggle() // twice to force into paused |
michael@3 | 83 | //} |
michael@3 | 84 | } |
michael@3 | 85 | } |
michael@3 | 86 | } |
michael@3 | 87 | Wecker { |
michael@3 | 88 | id: opponTwo |
michael@3 | 89 | opponent: "Opponent 2" // name of player at right of clock |
michael@3 | 90 | zeitfrist: 15 // opponent's time limit |
michael@3 | 91 | altercolor: true // opponent's clock colour |
michael@3 | 92 | MouseArea { // clicking here is only signaled |
michael@3 | 93 | enabled: true // at start of match when the 'init' |
michael@3 | 94 | id: wecktwoArea // variable is set and thus the entire |
michael@3 | 95 | anchors.fill: parent // surface mouse area is disabled |
michael@3 | 96 | acceptedButtons: Qt.LeftButton | Qt.RightButton |
michael@3 | 97 | onClicked: { |
michael@3 | 98 | //if (mouse.button == Qt.RightButton) |
michael@3 | 99 | // aboutDlg.visible = true |
michael@3 | 100 | //else { // left button was pressed |
michael@3 | 101 | init = false |
michael@3 | 102 | //aboutDlg.visible = false |
michael@3 | 103 | entireArea.enabled = true // will take precedence |
michael@3 | 104 | opponTwo.toggle() // start opponent two's clock |
michael@3 | 105 | opponOne.toggle() // toggle opponent one's clock |
michael@3 | 106 | opponOne.toggle() // twice to force into paused |
michael@3 | 107 | //} |
michael@3 | 108 | } |
michael@3 | 109 | } |
michael@3 | 110 | } |
michael@3 | 111 | } |
michael@3 | 112 | |
michael@3 | 113 | //Image { id: aboutDlg; anchors.centerIn: parent; width: 423; height: 386; source: "wikichess.jpeg"; visible: false } |
michael@3 | 114 | |
michael@3 | 115 | // the main area covering the entire client surface |
michael@3 | 116 | MouseArea { |
michael@3 | 117 | enabled: false |
michael@3 | 118 | id: entireArea |
michael@3 | 119 | anchors.fill: parent |
michael@3 | 120 | acceptedButtons: Qt.LeftButton | Qt.RightButton |
michael@3 | 121 | onClicked: { |
michael@3 | 122 | //if (mouse.button == Qt.LeftButton && init == false) { |
michael@3 | 123 | //aboutDlg.visible = false |
michael@3 | 124 | opponOne.toggle() // stop or start opponent one's clock |
michael@3 | 125 | opponTwo.toggle() // stop or start opponent two's clock |
michael@3 | 126 | //} |
michael@3 | 127 | //else if (mouse.button == Qt.RightButton && init == false) |
michael@3 | 128 | // aboutDlg.visible = true |
michael@3 | 129 | //else // assert clicked |
michael@3 | 130 | // console.log("Problem click in initial.") // in init state |
michael@3 | 131 | } |
michael@3 | 132 | } |
michael@3 | 133 | |
michael@3 | 134 | Timer { // just waits a second before moving the arms of |
michael@6 | 135 | interval: 2000 // the game subclocks into their initial position |
michael@3 | 136 | running: true |
michael@3 | 137 | onTriggered: { |
michael@3 | 138 | opponOne.timeInit() |
michael@3 | 139 | opponTwo.timeInit() |
michael@3 | 140 | } |
michael@3 | 141 | } |
michael@3 | 142 | } |