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

GCompris-qt

  • src
  • core
Bar.qml
1 /* GCompris - Bar.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 GCompris 1.0
23 import "qrc:/gcompris/src/core/core.js" as Core
24 
45 Item {
46  id: bar
47 
52  property real barZoom: 1.2 * ApplicationInfo.ratio
53 
60  property BarEnumContent content
61 
68  property int level: 0
69 
73  signal aboutClicked
74 
80  signal helpClicked
81 
88  signal configClicked
89 
95  signal nextLevelClicked
96 
102  signal previousLevelClicked
103 
109  signal repeatClicked
110 
116  signal reloadClicked
117 
124  signal homeClicked
125 
127 
128  /*
129  * A list of all our possible buttons.
130  *
131  * bid = Button ID. And references the Component object of the button
132  * This way we can have any visual object in the bar.
133  */
134  property variant buttonList: [
135  {
136  'bid': exit,
137  'contentId': content.exit,
138  'allowed': true
139  },
140  {
141  'bid': about,
142  'contentId': content.about,
143  'allowed': true
144  },
145  {
146  'bid': help,
147  'contentId': content.help,
148  'allowed': true
149  },
150  {
151  'bid': home,
152  'contentId': content.home,
153  'allowed': true
154  },
155  {
156  'bid': previous,
157  'contentId': content.level,
158  'allowed': true
159  },
160  {
161  'bid': levelText,
162  'contentId': content.level,
163  'allowed': true
164  },
165  {
166  'bid': next,
167  'contentId': content.level,
168  'allowed': true
169  },
170  {
171  'bid': repeat,
172  'contentId': content.repeat,
173  'allowed': true
174  },
175  {
176  'bid': reload,
177  'contentId': content.reload,
178  'allowed': true
179  },
180  {
181  'bid': config,
182  'contentId': content.config,
183  'allowed': !ApplicationSettings.isKioskMode
184  },
185  {
186  'bid': downloadImage,
187  'contentId': content.download,
188  'allowed': true
189  }
190  ]
191 
192  /* internal? */
193  property var buttonModel
194 
195  x: 0
196  anchors.bottom: parent.bottom
197  width: openBar.width
198  height: openBar.height
199  z: 1000
200 
201  function show(newContent) {
202  content.value = newContent
203  }
204 
205  Connections {
206  target: DownloadManager
207 
208  onDownloadStarted: content.value |= content.download
209  onDownloadFinished: content.value &= ~content.download
210  onError: content.value &= ~content.download
211  }
212 
213  Image {
214  id: openBar
215  source: "qrc:/gcompris/src/core/resource/bar_open.svg";
216  anchors.bottom: parent.bottom
217  anchors.left: parent.left
218  sourceSize.width: 66 * barZoom
219  MouseArea {
220  anchors.fill: parent
221 
222  onClicked: {
223  ApplicationSettings.isBarHidden = !ApplicationSettings.isBarHidden;
224  }
225  }
226  }
227 
228  function updateContent() {
229  var newButtonModel = new Array()
230  for(var def in buttonList) {
231  if((content.value & buttonList[def].contentId) &&
232  buttonList[def].allowed) {
233  newButtonModel.push(buttonList[def])
234  }
235  }
236  buttonModel = newButtonModel
237  }
238 
239  Connections {
240  target: content
241  onValueChanged: updateContent()
242  }
243 
244  onContentChanged: {
245  updateContent()
246  }
247 
248  Row {
249  id: barRow
250  spacing: 5
251  anchors.bottom: parent.bottom
252  anchors.bottomMargin: 10
253  anchors.left: openBar.right
254  anchors.leftMargin: 10 * ApplicationInfo.ratio
255  Repeater {
256  model: buttonModel
257  Loader {
258  sourceComponent: modelData.bid
259  }
260  }
261 
262  state: ApplicationSettings.isBarHidden ? "hidden" : "shown"
263 
264  states: [
265  State {
266  name: "shown"
267 
268  AnchorChanges {
269  target: barRow
270  anchors.top: undefined
271  anchors.bottom: parent.bottom
272  }
273  },
274  State {
275  name: "hidden"
276 
277  AnchorChanges {
278  target: barRow
279  anchors.bottom: undefined
280  anchors.top: parent.bottom
281  }
282  }
283  ]
284 
285  transitions: Transition {
286  AnchorAnimation { duration: 800; easing.type: Easing.OutBounce }
287  }
288  populate: Transition {
289  NumberAnimation {
290  properties: "x,y"; from: 200;
291  duration: 1500; easing.type: Easing.OutBounce
292  }
293  }
294  add: Transition {
295  NumberAnimation {
296  properties: "x,y"; from: 200;
297  duration: 1500; easing.type: Easing.OutBounce
298  }
299  }
300  move: Transition {
301  NumberAnimation {
302  properties: "x,y"
303  duration: 1500; easing.type: Easing.OutBounce
304  }
305  }
306  }
307 
308  // All the possible bar buttons are defined here
309  // ---------------------------------------------
310  Component {
311  id: exit
312  BarButton {
313  source: "qrc:/gcompris/src/core/resource/bar_exit.svg";
314  sourceSize.width: 66 * barZoom
315  onClicked: Core.quit(bar.parent.parent);
316  }
317  }
318  Component {
319  id: about
320  BarButton {
321  source: "qrc:/gcompris/src/core/resource/bar_about.svg";
322  sourceSize.width: 66 * barZoom
323  onClicked: bar.aboutClicked()
324  }
325  }
326  Component {
327  id: help
328  BarButton {
329  source: "qrc:/gcompris/src/core/resource/bar_help.svg";
330  sourceSize.width: 66 * barZoom
331  onClicked: bar.helpClicked()
332  }
333  }
334  Component {
335  id: previous
336  BarButton {
337  source: "qrc:/gcompris/src/core/resource/bar_previous.svg";
338  sourceSize.width: 30 * barZoom
339  onClicked: bar.previousLevelClicked()
340  }
341  }
342  Component {
343  id: levelText
344  GCText {
345  id: levelTextId
346  text: "" + level
347  fontSize: hugeSize
348  font.weight: Font.DemiBold
349  style: Text.Outline
350  styleColor: "black"
351  color: "white"
352  visible: content.level & content.value
353  }
354  }
355  Component {
356  id: next
357  BarButton {
358  source: "qrc:/gcompris/src/core/resource/bar_next.svg";
359  sourceSize.width: 30 * barZoom
360  onClicked: bar.nextLevelClicked()
361  }
362  }
363  Component {
364  id: repeat
365  BarButton {
366  source: "qrc:/gcompris/src/core/resource/bar_repeat.svg";
367  sourceSize.width: 66 * barZoom
368  onClicked: bar.repeatClicked()
369  }
370  }
371  Component {
372  id: reload
373  BarButton {
374  source: "qrc:/gcompris/src/core/resource/bar_reload.svg";
375  sourceSize.width: 66 * barZoom
376  onClicked: bar.reloadClicked()
377  }
378  }
379  Component {
380  id: config
381  BarButton {
382  source: "qrc:/gcompris/src/core/resource/bar_config.svg";
383  sourceSize.width: 66 * barZoom
384  onClicked: bar.configClicked()
385  }
386  }
387  Component {
388  id: home
389  BarButton {
390  source: "qrc:/gcompris/src/core/resource/bar_home.svg";
391  sourceSize.width: 66 * barZoom
392  onClicked: bar.homeClicked()
393  }
394  }
395  Component {
396  id: downloadImage
397  AnimatedImage {
398  source: "qrc:/gcompris/src/core/resource/loader.gif"
399  MouseArea {
400  id: mouseArea
401  anchors.fill: parent
402  hoverEnabled: true
403  onClicked: {
404  var downloadDialog = Core.showDownloadDialog(bar.parent, {});
405  }
406  }
407  }
408  }
409 
411 }
BarEnumContent
QML container for defining all visible child elements of a Bar.
Definition: BarEnumContent.qml:31
GCText
A QML component unifying text presentation in GCompris.
Definition: GCText.qml:47
QtQuick
DownloadManager
A singleton class responsible for downloading, updating and maintaining remote resources.
Definition: DownloadManager.h:81
ApplicationSettings::isKioskMode
bool isKioskMode
Whether kiosk mode is currently active.
Definition: ApplicationSettings.h:149
GCompris
BarButton
Helper QML component for a button shown on the Bar.
Definition: BarButton.qml:31
ApplicationSettings
Singleton that contains GCompris' persistent settings.
Definition: ApplicationSettings.h:63
BarEnumContent::value
int value
Bitmask defininig all visible elements of a bar.
Definition: BarEnumContent.qml:37
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