qml/main.qml

Thu, 28 Jul 2011 12:26:06 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 28 Jul 2011 12:26:06 +0200
changeset 15
af9725334e07
parent 3
c5c9ba04c01a
permissions
-rw-r--r--

Modify AppUp RPM according to wishes of Intel AppUp validation group.

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

mercurial