• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kanagram

  • sources
  • kde-4.14
  • kdeedu
  • kanagram
  • src
  • package
  • contents
  • ui
main.qml
Go to the documentation of this file.
1 /******************************************************************************
2  * This file is part of the Kanagram project
3  * Copyright 2014 Debjit Mondal <debjitmondal05@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 import QtQuick 1.1
21 
22 Rectangle {
23 
24  id:screen
25 
26  width: 1366 ; height: 768
27 
28  Item {
29  width: parent.width
30  height: parent.height
31 
32  Image {
33  id: background
34  anchors.fill : parent
35  source: "../ui/images/background.jpg"
36  smooth:true
37  fillMode: Image.PreserveAspectCrop
38  }
39  }
40 
41  Rectangle {
42  id: toolBarTop
43  width: parent.width; height: parent.height/6
44  opacity: .25
45  color: "black"
46  anchors.top: screen.top
47  }
48 
49  Image {
50  id: header
51  width:toolBarTop.width/3.5
52  height:toolBarTop.height/1.5
53  anchors{verticalCenter: toolBarTop.verticalCenter;horizontalCenter: toolBarTop.horizontalCenter }
54  source: "../ui/images/header.png"
55  smooth:true
56  fillMode: Image.PreserveAspectCrop
57  }
58 
59  Image{
60  id: powerButton
61  smooth:true
62  height:toolBarTop.height/3
63  anchors{verticalCenter: toolBarTop.verticalCenter;right:toolBarTop.right;rightMargin: toolBarTop.width/24}
64  source: "../ui/icons/on-off-light.svgz"
65  fillMode: Image.PreserveAspectFit
66 
67  MouseArea {
68  anchors.fill: parent
69  hoverEnabled: true
70  onEntered:powerButton.state="onEntered"
71  onExited:powerButton.state="onExited"
72  onClicked:Qt.quit()
73  }
74 
75  states: State {
76  name: "onEntered"
77  PropertyChanges {
78  target: quitText
79  opacity:1
80  }
81  }
82  State{
83  name:"onExited"
84  }
85 
86  transitions: Transition {
87  //AnchorAnimation { duration: 200 }
88  PropertyAnimation { properties: "x,y,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
89  }
90  }
91 
92  Text{
93  id:quitText
94  anchors{top:powerButton.bottom;horizontalCenter:powerButton.horizontalCenter}
95  color:"white"
96  text:i18n("Quit")
97  opacity:0
98  font.pixelSize: parent.width/91
99  }
100 
101  Rectangle{
102  id: nextAnagramButton
103  width:blackboard.width/9;height:blackboard.height/7
104  anchors{top:blackboard.top;topMargin:blackboard.height/7;left:blackboard.right}
105  radius:8
106  color:"black"
107  opacity:0.5
108 
109  MouseArea {
110  anchors.fill: parent
111  hoverEnabled: true
112  onEntered:nextAnagramButton.state="onEntered"
113  onExited:nextAnagramButton.state="onExited";
114  onClicked:{
115  if(blackboard.activeTimer)
116  {
117  kanagramEngineHelper.increaseScore(kanagramEngineHelper.skippedWordScore());
118  blackboard.totalScore=i18n("Score : ")+kanagramEngineHelper.totalScore();
119  }
120  blackboard.anagramText=kanagramEngineHelper.createNextAnagram();
121  blackboard.hint=kanagramEngineHelper.showHint();
122  if(kanagramEngineHelper.hintHideTime())
123  blackboard.showHintTimeInterval=1;
124  }
125  }
126 
127  states: State {
128  name: "onEntered"
129  PropertyChanges {
130  target: nextAnagramButton
131  width:blackboard.width/2.5
132  }
133  PropertyChanges {
134  target: nextAnagramText
135  opacity:1
136  }
137  AnchorChanges{target:nextAnagramIcon;
138  anchors.horizontalCenter: undefined;
139  anchors.right:nextAnagramButton.right
140  }
141  PropertyChanges{target:nextAnagramIcon
142  anchors.rightMargin:blackboard.width/50
143  }
144  }
145  State{
146  name:"onExited"
147  }
148 
149  transitions: Transition {
150  AnchorAnimation { duration: 250 }
151  PropertyAnimation { properties: "x,y,width,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
152  }
153  }
154 
155  Text{
156  id:nextAnagramText
157  anchors{verticalCenter: nextAnagramButton.verticalCenter;horizontalCenter:nextAnagramButton.horizontalCenter}
158  color:"white"
159  text: i18n("Next Anagram")
160  opacity: 0
161  font.pixelSize: parent.width/68.5
162  }
163 
164  Image{
165  id: nextAnagramIcon
166  smooth:true
167  height:nextAnagramButton.height/2; width:nextAnagramText.width/4
168  anchors{verticalCenter: nextAnagramButton.verticalCenter;horizontalCenter: nextAnagramButton.horizontalCenter}
169  source: "../ui/icons/arrow-light.svgz"
170  fillMode: Image.PreserveAspectFit
171  }
172 
173  Rectangle{
174  id: configureButton
175  width:blackboard.width/9;height:blackboard.height/7
176  anchors{verticalCenter:blackboard.verticalCenter;left:blackboard.right}
177  radius:8
178  color:"black"
179  opacity:0.5
180 
181  MouseArea {
182  anchors.fill: parent
183  hoverEnabled: true
184  onEntered:configureButton.state="onEntered"
185  onExited:configureButton.state="onExited";
186  onClicked:{kanagramEngineHelper.slotShowSettings();}
187  }
188 
189  states: State {
190  name: "onEntered"
191  PropertyChanges {
192  target: configureButton
193  width:blackboard.width/2.5
194  }
195  PropertyChanges {
196  target: configureText
197  opacity:1
198  }
199  AnchorChanges{target:configureIcon;
200  anchors.horizontalCenter: undefined;
201  anchors.right:configureButton.right}
202  PropertyChanges{target:configureIcon
203  anchors.rightMargin:blackboard.width/50
204  }
205  }
206  State{
207  name:"onExited"
208  }
209 
210  transitions: Transition {
211  AnchorAnimation { duration: 250 }
212  PropertyAnimation { properties: "x,y,width,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
213  }
214  }
215 
216  Text{
217  id:configureText
218  anchors{verticalCenter: configureButton.verticalCenter;horizontalCenter:configureButton.horizontalCenter}
219  color:"white"
220  text:i18n("Configure")
221  opacity:0
222  font.pixelSize: parent.width/68.5
223  }
224 
225  Image{
226  id: configureIcon
227  smooth:true
228  height:configureButton.height/2;width:configureText.width/3
229  anchors{verticalCenter: configureButton.verticalCenter;horizontalCenter: configureButton.horizontalCenter}
230  source: "../ui/icons/spanner-light.svgz"
231  fillMode: Image.PreserveAspectFit
232  }
233 
234  Rectangle{
235  id: helpButton
236  width:blackboard.width/9;height:blackboard.height/7
237  anchors{bottom:blackboard.bottom;bottomMargin: blackboard.height/7;left:blackboard.right}
238  radius:8
239  color:"black"
240  opacity:0.5
241 
242  property bool flag:true
243 
244  function toggleMoreOptions()
245  {
246  if(flag)
247  {
248  moreOptionsButton.opacity=0.5;
249  moreOptionsButton.width=blackboard.width/2.5;
250  kanagramHandbookIcon.visible=true;
251  aboutKdeIcon.visible=true;
252  aboutKanagramIcon.visible=true;
253  flag=false;
254  }
255  else
256  {
257  moreOptionsButton.opacity=0;
258  moreOptionsTextBar.opacity=0;
259  moreOptionsText.opacity=0;
260  kanagramHandbookIcon.visible=false;
261  aboutKdeIcon.visible=false;
262  aboutKanagramIcon.visible=false;
263  flag=true;
264  }
265  }
266 
267  MouseArea {
268  anchors.fill: parent
269  hoverEnabled: true
270  onEntered:helpButton.state="onEntered"
271  onExited:helpButton.state="onExited";
272  onClicked:helpButton.toggleMoreOptions();
273  }
274 
275  states: State {
276  name: "onEntered"
277  PropertyChanges {
278  target: helpButton
279  width:blackboard.width/2.5
280  }
281  PropertyChanges{
282  target:helpText
283  text:i18n("About")
284  opacity:1
285  }
286  AnchorChanges{target:helpIcon;
287  anchors.horizontalCenter: undefined;
288  anchors.right:helpButton.right}
289  PropertyChanges{target:helpIcon
290  anchors.rightMargin:blackboard.width/50
291  }
292  }
293  State{
294  name:"onExited"
295  }
296 
297  transitions: Transition {
298  AnchorAnimation { duration: 250 }
299  PropertyAnimation { properties: "x,y,width,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
300  }
301  }
302 
303  Rectangle{
304  id: moreOptionsButton
305  width:blackboard.width/9;height:blackboard.height/7
306  anchors{top:helpButton.bottom;topMargin: blackboard.height/50;left:blackboard.right}
307  radius:8
308  color:"black"
309  opacity:0
310  }
311 
312  Rectangle{
313  id: moreOptionsTextBar
314  width:blackboard.width/4;height:blackboard.height/16
315  anchors{top:moreOptionsButton.bottom;horizontalCenter:moreOptionsButton.horizontalCenter}
316  radius:8
317  color:"black"
318  opacity:0
319  }
320 
321  Text{
322  id:moreOptionsText
323  anchors{verticalCenter: moreOptionsTextBar.verticalCenter;horizontalCenter:moreOptionsTextBar.horizontalCenter}
324  color:"white"
325  text: i18n(" ")
326  opacity: 0
327  font.pixelSize: parent.width/91
328  }
329 
330  Text{
331  id:helpText
332  anchors{verticalCenter: helpButton.verticalCenter;horizontalCenter:helpButton.horizontalCenter}
333  color:"white"
334  text: i18n("About")
335  opacity: 0
336  font.pixelSize: parent.width/68.5
337  }
338 
339  Image{
340  id: helpIcon
341  smooth:true
342  height:blackboard.height/14
343  anchors{verticalCenter: helpButton.verticalCenter;horizontalCenter:helpButton.horizontalCenter}
344  source: "../ui/icons/question-light.svgz"
345  visible:true
346  fillMode: Image.PreserveAspectFit
347  }
348 
349  Image{
350  id: aboutKdeIcon
351  smooth:true
352  height:blackboard.height/14;
353  anchors{verticalCenter: moreOptionsButton.verticalCenter;right:moreOptionsButton.right;rightMargin:moreOptionsButton.width/8}
354  source: "../ui/icons/about-kde.png"
355  visible:false
356  fillMode: Image.PreserveAspectFit
357 
358  MouseArea {
359  anchors.fill: parent
360  hoverEnabled: true
361  onEntered:aboutKdeIcon.state="onEntered"
362  onExited:aboutKdeIcon.state="onExited"
363  onClicked:kanagramEngineHelper.aboutKDE();
364  preventStealing:true
365  }
366 
367  states: State {
368  name: "onEntered"
369  PropertyChanges {
370  target: moreOptionsTextBar
371  opacity:0.5
372  }
373  PropertyChanges {
374  target: moreOptionsText
375  text:i18n("About KDE")
376  opacity:1
377  }
378  }
379  State{
380  name:"onExited"
381  }
382 
383  transitions: Transition {
384  AnchorAnimation { duration: 250 }
385  PropertyAnimation { properties: "x,y,width,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
386  }
387  }
388 
389  Image{
390  id: aboutKanagramIcon
391  height:blackboard.height/14
392  anchors{verticalCenter: moreOptionsButton.verticalCenter;horizontalCenter:moreOptionsButton.horizontalCenter}
393  source: "../ui/icons/about-kanagram.png"
394  smooth:true
395  visible:false
396  fillMode: Image.PreserveAspectFit
397 
398  MouseArea {
399  anchors.fill: parent
400  hoverEnabled: true
401  onEntered:aboutKanagramIcon.state="onEntered"
402  onExited:aboutKanagramIcon.state="onExited"
403  onClicked:kanagramEngineHelper.aboutKanagram();
404  preventStealing:true
405  }
406 
407  states: State {
408  name: "onEntered"
409  PropertyChanges {
410  target: moreOptionsTextBar
411  opacity:0.5
412  }
413  PropertyChanges {
414  target: moreOptionsText
415  text:i18n("About Kanagram")
416  opacity:1
417  }
418  }
419  State{
420  name:"onExited"
421  }
422 
423  transitions: Transition {
424  AnchorAnimation { duration: 250 }
425  PropertyAnimation { properties: "x,y,width,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
426  }
427  }
428 
429  Image{
430  id: kanagramHandbookIcon
431  smooth:true
432  height:blackboard.height/14
433  anchors{verticalCenter: moreOptionsButton.verticalCenter;left:moreOptionsButton.left;leftMargin:moreOptionsButton.width/8}
434  source: "../ui/icons/kanagram-handbook.png"
435  visible:false
436  fillMode: Image.PreserveAspectFit
437 
438  MouseArea {
439  anchors.fill: parent
440  hoverEnabled: true
441  onEntered:kanagramHandbookIcon.state="onEntered"
442  onExited:kanagramHandbookIcon.state="onExited"
443  onClicked:kanagramEngineHelper.kanagramHandbook();
444  preventStealing:true
445  }
446 
447  states: State {
448  name: "onEntered"
449  PropertyChanges {
450  target:moreOptionsTextBar
451  opacity:0.5
452  }
453  PropertyChanges {
454  target: moreOptionsText
455  text:i18n("Kanagram Handbook")
456  opacity:1
457  }
458  }
459  State{
460  name:"onExited"
461  }
462 
463  transitions: Transition {
464  AnchorAnimation { duration: 250 }
465  PropertyAnimation { properties: "x,y,width,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
466  }
467  }
468 
469  Blackboard{
470  id:blackboard
471  border{width:parent.width/68.5;color:"#613529"}
472  width:parent.width/2; height: parent.height/1.5
473  anchors {horizontalCenter:parent.horizontalCenter; top:toolBarTop.bottom}
474  }
475 
476  Rectangle{
477  id: inputField
478  width:blackboard.width;height:parent.height/10
479  anchors{horizontalCenter: blackboard.horizontalCenter;bottom:parent.bottom;bottomMargin:parent.height/35}
480  radius:8
481  border.color:"white"
482  border.width:0
483  color:"black"
484  opacity:0.35
485  }
486 
487  TextInput{
488  id: input
489  color: "white"; selectionColor: "white";selectedTextColor: "black"
490  font.pixelSize: parent.width/40; font.bold: true
491  width: inputField.width
492  anchors.centerIn: inputField
493  focus: true
494  property int countDownTimerValue:0
495  property bool flagCorrectAnswer:true;
496  onAccepted:{
497  if(kanagramEngineHelper.checkWord(text))
498  {
499  input.color="green";
500  input.countDownTimerValue=1;
501  input.flagCorrectAnswer=true;
502  if(blackboard.activeTimer)
503  {
504  kanagramEngineHelper.increaseScore(kanagramEngineHelper.correctAnswerScore());
505  blackboard.totalScore=i18n("Score : ")+kanagramEngineHelper.totalScore();
506  }
507  showAnswerTimer.repeat=true;
508  showAnswerTimer.start();
509  }
510  else
511  {
512  input.color="red";
513  input.countDownTimerValue=1;
514  input.flagCorrectAnswer=false;
515  if(blackboard.activeTimer)
516  {
517  kanagramEngineHelper.increaseScore(kanagramEngineHelper.incorrectAnswerScore());
518  blackboard.totalScore=i18n("Score : ")+kanagramEngineHelper.totalScore();
519  }
520  showAnswerTimer.repeat=true;
521  showAnswerTimer.start();
522  }
523  }
524  }
525 
526  Timer {
527  id: showAnswerTimer;
528  interval: 1000;
529  repeat: true;
530  running: false;
531  triggeredOnStart: false;
532 
533  onTriggered: {
534  if (--input.countDownTimerValue == 0) {
535  input.color="white";
536  if(input.flagCorrectAnswer){
537  blackboard.anagramText=kanagramEngineHelper.createNextAnagram();
538  blackboard.hint=kanagramEngineHelper.showHint();
539  if(kanagramEngineHelper.hintHideTime())
540  blackboard.showHintTimeInterval=1;
541  }
542  input.text="";
543  stop();
544  }
545  }
546  }
547 }
Blackboard
Definition: Blackboard.qml:20
Blackboard::totalScore
alias totalScore
Definition: Blackboard.qml:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:12:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kanagram

Skip menu "kanagram"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal