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

GCompris-qt

  • src
  • core
VirtualKey.qml
1 /* GCompris - VirtualKey.qml
2  *
3  * Copyright (C) 2014 Holger Kaelberer <holger.k@elberer.de>
4  *
5  * Authors:
6  * Holger Kaelberer <holger.k@elberer.de>
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.0
22 import GCompris 1.0
23 import QtGraphicalEffects 1.0
24 import QtQuick.Controls 1.0
25 import QtQuick.Controls.Styles 1.0
26 
27 Item {
28  id: virtualKey
29 
30  z: (button.pressed || (!ApplicationInfo.isMobile && button.hovered)) ? 1 : -1
31 
32 
33  property alias text: button.text
34  property var modifiers: 0 /* Supposed to hold any active key modifiers
35  * in a bitmask from the Qt namespace:
36  * Qt.ShiftModifier/MetaModifier/ControlModifier.
37  * 0 if none. */
38 
39  property var specialKey: 0 /* Supposed to hold special key values from the
40  * Qt namespace like Qt.Key_Shift/Key_Control/
41  * Key_Alt if VirtualKey is a special key.
42  * 0 Otherwise */
43 
44  signal pressed(var virtualKey);
45 
46  Button {
47  id: button
48  text: ((modifiers & Qt.ShiftModifier) && (shiftLabel !== undefined)) ? shiftLabel : label
49 
50  width: parent.width
51  height: virtualKey.height
52 
53  style: ButtonStyle {
54  background: Rectangle {
55  border.width: control.activeFocus ? 2 : 1
56  border.color: "black"
57  radius: 4
58  gradient: Gradient {
59  GradientStop {
60  position: 0;
61  color: (control.pressed
62  || ( virtualKey.specialKey == Qt.Key_Shift
63  && virtualKey.modifiers & Qt.ShiftModifier))
64  ? "#ccc" : "#eee";
65  }
66  GradientStop {
67  position: 1;
68  color: (control.pressed
69  || ( virtualKey.specialKey == Qt.Key_Shift
70  && virtualKey.modifiers & Qt.ShiftModifier))
71  ? "#aaa" : "#ccc";
72  }
73  }
74  }
75  label: Item {
76  GCText {
77  //renderType: Text.NativeRendering
78  anchors.centerIn: parent
79  text: control.text
80  fontSize: 20
81  font.bold: false
82  color: "black"
83  //antialiasing: true
84  }
85  }
86  }
87 
88  states: State {
89  name: "hover"; when: (button.pressed || !ApplicationInfo.isMobile && button.hovered)
90  PropertyChanges { target: button; scale: 1.5 }
91  }
92 
93  transitions: Transition {
94  NumberAnimation { properties: "scale"; duration: 100; easing.type: Easing.OutCubic }
95  }
96 
97  onClicked: {
98  //console.log("### virtualKey.onClicked text=" + virtualKey.text
99  // + " specialKey="+ virtualKey.specialKey
100  // + " modifiers= "+ virtualKey.modifiers);
101  virtualKey.pressed(virtualKey);
102  button.focus = false;
103  }
104  }
105 
106  DropShadow {
107  anchors.fill: button
108  cached: false
109  horizontalOffset: 3
110  verticalOffset: 3
111  radius: 8.0
112  samples: 16
113  color: "#80000000"
114  source: button
115  scale: button.scale
116  }
117 }
GCText
A QML component unifying text presentation in GCompris.
Definition: GCText.qml:47
QtQuick
GCompris
ApplicationInfo::isMobile
bool isMobile
Whether the application is currently running on a mobile platform.
Definition: ApplicationInfo.h:65
QtGraphicalEffects
ApplicationInfo
A general purpose singleton that exposes miscellaneous native functions to the QML layer...
Definition: ApplicationInfo.h:43
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