Warning, /education/gcompris/src/core/VirtualKey.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - VirtualKey.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Holger Kaelberer <holger.k@elberer.de> 0004 * 0005 * Authors: 0006 * Holger Kaelberer <holger.k@elberer.de> 0007 * 0008 * SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 import QtQuick 2.12 0011 import GCompris 1.0 0012 import QtGraphicalEffects 1.0 0013 import QtQuick.Controls 2.12 0014 0015 Item { 0016 id: virtualKey 0017 0018 property alias text: button.text 0019 property var modifiers: 0 /* Supposed to hold any active key modifiers 0020 * in a bitmask from the Qt namespace: 0021 * Qt.ShiftModifier/MetaModifier/ControlModifier. 0022 * 0 if none. */ 0023 0024 property var specialKey: 0 /* Supposed to hold special key values from the 0025 * Qt namespace like Qt.Key_Shift/Key_Control/ 0026 * Key_Alt if VirtualKey is a special key. 0027 * 0 Otherwise */ 0028 0029 signal pressed(var virtualKey); 0030 0031 Button { 0032 id: button 0033 text: ((modifiers & Qt.ShiftModifier) && (shiftLabel !== undefined)) ? shiftLabel : label 0034 0035 width: parent.width 0036 height: virtualKey.height 0037 0038 background: Rectangle { 0039 border.width: button.activeFocus ? 2 : 1 0040 border.color: "black" 0041 radius: 4 0042 gradient: Gradient { 0043 GradientStop { 0044 position: 0; 0045 color: (button.pressed 0046 || ( virtualKey.specialKey == Qt.Key_Shift 0047 && virtualKey.modifiers & Qt.ShiftModifier)) 0048 ? "#ccc" : "#eee"; 0049 } 0050 GradientStop { 0051 position: 1; 0052 color: (button.pressed 0053 || ( virtualKey.specialKey == Qt.Key_Shift 0054 && virtualKey.modifiers & Qt.ShiftModifier)) 0055 ? "#aaa" : "#ccc"; 0056 } 0057 } 0058 } 0059 contentItem: Item { 0060 GCText { 0061 //renderType: Text.NativeRendering 0062 anchors.centerIn: parent 0063 text: button.text 0064 fontSize: 20 0065 font.bold: false 0066 color: "black" 0067 //antialiasing: true 0068 } 0069 } 0070 0071 SequentialAnimation { 0072 id: anim 0073 PropertyAction { target: virtualKey; property: 'z'; value: 1 } 0074 NumberAnimation { target: button; properties: "scale"; to: 1.3; duration: 100; easing.type: Easing.OutCubic } 0075 NumberAnimation { target: button; properties: "scale"; to: 1.0; duration: 100; easing.type: Easing.OutCubic } 0076 PropertyAction { target: virtualKey; property: 'z'; value: 0 } 0077 } 0078 0079 onClicked: { 0080 //console.log("### virtualKey.onClicked text=" + virtualKey.text 0081 // + " specialKey="+ virtualKey.specialKey 0082 // + " modifiers= "+ virtualKey.modifiers); 0083 anim.start() 0084 virtualKey.pressed(virtualKey); 0085 button.focus = false; 0086 } 0087 } 0088 0089 DropShadow { 0090 anchors.fill: button 0091 cached: false 0092 horizontalOffset: 3 0093 verticalOffset: 3 0094 radius: 8.0 0095 samples: 16 0096 color: "#80000000" 0097 source: button 0098 scale: button.scale 0099 } 0100 }