/* GCompris - ReadyButton.qml * * Copyright (C) 2014 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 Rectangle { id: iAmReady /** * type: var * Existing themes for the button. * A theme is composed of: * The button's border color * The text color */ property var themes: { "dark": { borderColor: "#FF373737", fillColor0: "#A8FFFFFF", fillColor1: "#68FFFFFF", textColor: "#FF373737" }, "light": { borderColor: "white", fillColor0: "#42FFFFFF", fillColor1: "#23FFFFFF", textColor: "white" } } /** * type: string * Defines the theme of the ReadyButton - dark or light. * * Default theme is dark. */ property string theme: "dark" /** * Emitted when the ReadyButton is clicked */ signal clicked anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter border.color: themes[theme].borderColor visible: true radius: 10 smooth: true border.width: 4 width: iAmReadyText.width + 50 * ApplicationInfo.ratio height: iAmReadyText.height + 50 * ApplicationInfo.ratio gradient: Gradient { GradientStop { position: 0 ; color: themes[theme].fillColor0 } GradientStop { position: 1 ; color: themes[theme].fillColor1 } } GCText { id: iAmReadyText color: themes[theme].textColor anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter font.bold: true fontSize: mediumSize text: qsTr("I am Ready") visible: iAmReady.visible } MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true onClicked: { iAmReady.visible = false iAmReady.clicked() } } states: [ State { name: "notClicked" PropertyChanges { target: iAmReady scale: 1.0 } }, State { name: "clicked" when: mouseArea.pressed PropertyChanges { target: iAmReady scale: 0.9 } }, State { name: "hover" when: mouseArea.containsMouse PropertyChanges { target: iAmReady scale: 1.1 } } ] Behavior on scale { NumberAnimation { duration: 70 } } }