• Skip to content
  • Skip to link menu
KDE API Documentation - GCDialog.qml Source File (GCompris-qt)
  • KDE Home
  • Contact Us
 

GCompris-qt

  • src
  • core
GCDialog.qml
1 /* GCompris - GCDialog.qml
2  *
3  * Copyright (C) 2014 Bruno Coudoin <bruno.coudoin@gcompris.net>
4  *
5  * Authors:
6  * Bruno Coudoin <bruno.coudoin@gcompris.net>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21 import QtQuick 2.2
22 import QtQuick.Controls 1.0
23 import GCompris 1.0
24 
44 Item {
45  id: gcdialog
46 
51  property alias message: instructionTxt.textIn
52 
57  property alias button1Text: button1.text
58 
63  property alias button2Text: button2.text
64 
70  signal start
71 
77  signal stop
78 
82  signal close
83 
87  signal button1Hit
88 
92  signal button2Hit
93 
94  focus: true
95  opacity: 0
96 
97  anchors {
98  fill: parent
99  }
100 
101  onStart: opacity = 1
102  onStop: opacity = 0
103  onClose: destroy()
104 
105  Behavior on opacity { NumberAnimation { duration: 200 } }
106  onOpacityChanged: opacity === 0 ? close() : null
107 
108  Rectangle {
109  anchors.fill: parent
110  opacity: 0.8
111  color: "grey"
112  }
113 
114  MultiPointTouchArea {
115  // Just to catch mouse events
116  anchors.fill: parent
117  }
118 
119  /* Message */
120  Item {
121  id: instruction
122  anchors {
123  horizontalCenter: parent.horizontalCenter
124  top: parent.top
125  topMargin: buttonCancel.height
126  }
127  width: parent.width * 0.8
128 
129  Rectangle {
130  id: instructionTxtBg
131  anchors.top: instruction.top
132  z: 1
133  width: parent.width
134  height: gcdialog.height - button1.height * 5
135  opacity: 0.9
136  radius: 10
137  border.width: 2
138  border.color: "white"
139  gradient: Gradient {
140  GradientStop { position: 0.0; color: "#fff" }
141  GradientStop { position: 0.9; color: "#fff" }
142  GradientStop { position: 1.0; color: "#ddd" }
143  }
144 
145  Flickable {
146  id: flick
147  anchors.margins: 8
148  anchors.fill: parent
149  contentWidth: instructionTxt.contentWidth
150  contentHeight: instructionTxt.contentHeight
151  flickableDirection: Flickable.VerticalFlick
152  clip: true
153 
154  GCText {
155  id: instructionTxt
156  fontSize: regularSize
157  color: "black"
158  // @FIXME This property breaks the wrapping
159 // horizontalAlignment: Text.AlignHCenter
160  width: instruction.width
161  wrapMode: TextEdit.WordWrap
162  textFormat: TextEdit.RichText
163  z: 2
164  text: style + "<body>" + textIn + "</body>"
165  Component.onCompleted: ApplicationInfo.isDownloadAllowed ?
166  linkActivated.connect(Qt.openUrlExternally) : null
167 
168  property string textIn
169  property string style: ApplicationInfo.isDownloadAllowed ?
170  "<HEAD><STYLE type='text/css'>A {color: blue;}</STYLE></HEAD>" :
171  "<HEAD><STYLE type='text/css'>A {color: black;}</STYLE></HEAD>"
172  }
173  }
174  }
175 
176  Button {
177  id: button1
178  width: parent.width
179  height: 60 * ApplicationInfo.ratio
180  anchors {
181  horizontalCenter: parent.horizontalCenter
182  top: instructionTxtBg.bottom
183  topMargin: 10
184  }
185  style: GCButtonStyle {
186  }
187  visible: text != ""
188  onClicked: {
189  gcdialog.button1Hit()
190  gcdialog.stop()
191  }
192  }
193 
194  Button {
195  id: button2
196  width: parent.width
197  height: 60 * ApplicationInfo.ratio
198  anchors {
199  horizontalCenter: parent.horizontalCenter
200  top: button1.bottom
201  topMargin: 10
202  }
203  style: GCButtonStyle {
204  }
205  visible: text != ""
206  onClicked: {
207  gcdialog.button2Hit()
208  gcdialog.stop()
209  }
210  }
211  }
212 
213 
214  // Fixme not working, need to properly get the focus on this dialog
215  Keys.onEscapePressed: {
216  stop()
217  event.accepted = true;
218  }
219 
220  // The cancel button
221  GCButtonCancel {
222  id: buttonCancel
223  onClose: parent.stop()
224  }
225 }
GCButtonCancel
A QML component representing GCompris' cancel button.
Definition: GCButtonCancel.qml:30
GCText
A QML component unifying text presentation in GCompris.
Definition: GCText.qml:47
QtQuick
ApplicationInfo::isDownloadAllowed
bool isDownloadAllowed
Download allowed.
Definition: ApplicationInfo.h:137
GCompris
GCButtonStyle
Provides styling for GCompris' Buttons.
Definition: GCButtonStyle.qml:31
ApplicationInfo
A general purpose singleton that exposes miscellaneous native functions to the QML layer...
Definition: ApplicationInfo.h:43
ApplicationInfo::ratio
qreal ratio
Ratio factor used for scaling of sizes on high-dpi devices.
Definition: ApplicationInfo.h:91
This file is part of the KDE documentation.
Documentation copyright © 1996-2015 The KDE developers.
Generated on Tue Jun 2 2015 21:47:47 by doxygen 1.8.9.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

GCompris-qt

Skip menu "GCompris-qt"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Modules

Class Picker

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