/* GCompris - Bar.qml * * Copyright (C) 2014-2016 Bruno Coudoin * * Authors: * Bruno Coudoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.6 import GCompris 1.0 import "qrc:/gcompris/src/core/core.js" as Core /** * A QML component for GCompris' navigation bar. * @ingroup components * * The Bar is visible in all activities and the main menu screen. It can be * hidden by clicking on the 'toggle' region. * * It can consist of a couple of child-elements, mostly buttons, defined * in the BarEnumContent container. An activity can define which elements its bar should * present using the content property. In most cases it contains at least * BarEnumContent.help, BarEnumContent.home and BarEnumContent.level. * * Cf. the BarEnumContent container for a full list of available Bar elements. * * Cf. the Bar object used in Template.qml as an example of how a minimal * Bar implementation should look like. * * @sa BarButton, BarEnumContent * @inherit QtQuick.Item */ Item { id: bar /** * type: real * Minimum size for BarZoom */ readonly property real minWidth: (parent.width - 20 - 10 * ApplicationInfo.ratio) / (totalWidth + textLength) /** * type: real * Maximum size for barZoom */ readonly property real maxWidth: 1.2 * ApplicationInfo.ratio /** * type: real * Length of level String */ property real textLength /** * type: real * The maximum size allowed for the bar */ readonly property real maxBarWidth: (totalWidth+textLength) * maxWidth + (numberOfButtons - 1) * 5 + 10 * ApplicationInfo.ratio /** * type: real * Font size for text level */ readonly property real textSize: (parent.width9) textLength = fullButtonScaled else textLength = halfButtonScaled } } } Component { id: next BarButton { source: "qrc:/gcompris/src/core/resource/bar_next.svg"; sourceSize.width: halfButtonScaled onClicked: bar.nextLevelClicked() } } Component { id: repeat BarButton { source: "qrc:/gcompris/src/core/resource/bar_repeat.svg"; sourceSize.width: fullButtonScaled onClicked: bar.repeatClicked() } } Component { id: hint BarButton { source: "qrc:/gcompris/src/core/resource/bar_hint.svg"; sourceSize.width: fullButtonScaled onClicked: bar.hintClicked() } } Component { id: reload BarButton { source: "qrc:/gcompris/src/core/resource/bar_reload.svg"; sourceSize.width: fullButtonScaled onClicked: bar.reloadClicked() } } Component { id: config BarButton { source: "qrc:/gcompris/src/core/resource/bar_config.svg"; sourceSize.width: fullButtonScaled onClicked: bar.configClicked() } } Component { id: home BarButton { source: "qrc:/gcompris/src/core/resource/bar_home.svg"; sourceSize.width: fullButtonScaled onClicked: bar.homeClicked() } } Component { id: downloadImage AnimatedImage { source: "qrc:/gcompris/src/core/resource/loader.gif" MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true onClicked: { var downloadDialog = Core.showDownloadDialog(bar.parent, {}); } } } } /// @endcond }