This file is indexed.

/usr/share/kde4/apps/ktouch/qml/TrainingWidget.qml is in ktouch-data 4:4.13.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
 *  Copyright 2013  Sebastian Gottfried <sebastiangottfried@web.de>
 *
 *  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 2 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 <http://www.gnu.org/licenses/>.
 */

import QtQuick 1.1
import ktouch 1.0
import org.kde.plasma.components 0.1 as PlasmaComponents

FocusScope {
    id: trainingWidget

    property Lesson lesson
    property KeyboardLayout keyboardLayout
    property TrainingStats trainingStats
    property Item overlayContainer

    property alias nextChar: trainingLine.nextCharacter
    property alias isCorrect: trainingLine.isCorrect
    property int position: -1
    signal finished
    signal keyPressed(variant event)
    signal keyReleased(variant event)

    function reset() {
        stats.reset()
        lessonPainter.reset()
        sheetFlick.scrollToCurrentLine()
        trainingLine.active = true
    }

    Timer {
        id: stopTimer
        interval: 5000
        onTriggered: {
            stats.stopTraining()
        }
    }

    Flickable
    {
        id: sheetFlick
        anchors.fill: parent
        contentWidth: parent.width
        contentHeight: sheet.height + 60
        clip: true
        flickableDirection: Flickable.VerticalFlick

        function currentLineY() {
            var cursorRect = lessonPainter.cursorRectangle
            var y = cursorRect.y + sheet.y + (cursorRect.height / 2)
            return Math.max(Math.min((y - (height / 2)), contentHeight - height), 0)
        }

        function scrollToCurrentLine() {
            scrollAnimation.to = currentLineY()
            scrollAnimation.start()
        }

        onHeightChanged: {
            contentY = currentLineY()
        }

        NumberAnimation {
            target: sheetFlick
            id: scrollAnimation
            duration: 150
            property: "contentY"
        }

        Rectangle {
            id: sheet
            color: "#fff"
            anchors.centerIn: parent
            width: parent.width - 60
            height: lessonPainter.height

            border {
                width: 1
                color: "#000"
            }

            LessonPainter {
                id: lessonPainter
                anchors.centerIn: sheet
                lesson: trainingWidget.lesson
                maximumWidth: parent.width
                trainingLineCore: trainingLine

                onDone: {
                    trainingLine.active = false
                    trainingWidget.finished();
                    stats.stopTraining();
                }

                TrainingLineCore {
                    id: trainingLine
                    anchors.fill: parent
                    focus: true
                    trainingStats: stats
                    cursorItem: cursor

                    onFocusChanged: {
                        if (!trainingLine.activeFocus) {
                            trainingStats.stopTraining()
                        }
                    }

                    Keys.onPressed: {
                        if (!trainingLine.active)
                            return

                        cursorAnimation.restart()
                        trainingStats.startTraining()
                        stopTimer.restart()

                        if (!event.isAutoRepeat) {
                            trainingWidget.keyPressed(event)
                        }
                    }

                    Keys.onReleased: {
                        if (!trainingLine.active)
                            return

                        if (!event.isAutoRepeat) {
                            trainingWidget.keyReleased(event)
                        }
                    }
                }

                Rectangle {
                    id: cursor
                    color: "#000"
                    x: Math.floor(lessonPainter.cursorRectangle.x)
                    y: lessonPainter.cursorRectangle.y
                    width: lessonPainter.cursorRectangle.width
                    height: lessonPainter.cursorRectangle.height

                    onYChanged: sheetFlick.scrollToCurrentLine()

                    SequentialAnimation {
                        id: cursorAnimation
                        running: trainingLine.active && trainingLine.activeFocus && Qt.application.active
                        loops: Animation.Infinite
                        PropertyAction {
                            target: cursor
                            property: "opacity"
                            value: 1
                        }
                        PauseAnimation {
                            duration: 500
                        }
                        PropertyAction {
                            target: cursor
                            property: "opacity"
                            value: 0
                        }
                        PauseAnimation {
                            duration: 500
                        }
                    }
                }
            }
        }

        MouseArea {
            anchors.fill: parent
            onClicked: trainingLine.forceActiveFocus()
        }
    }

    KeyItem {
        id: hintKey
        parent: trainingWidget.overlayContainer
        anchors.horizontalCenter: parent.horizontalCenter
        y: Math.max(height, Math.min(parent.height - 2 * height,
            sheetFlick.mapToItem(parent, 0, cursor.y + 3 * cursor.height - sheetFlick.contentY).y))

        property real horizontalScaleFactor: 1
        property real verticalScaleFactor: 1
        property Key defaultKey: Key {}
        property KeyboardLayout defaultKeyboardLayout: KeyboardLayout {}

        key: {
            var specialKeyType

            switch (trainingLine.hintKey) {
            case Qt.Key_Return:
                specialKeyType = SpecialKey.Return
                break
            case Qt.Key_Backspace:
                specialKeyType =  SpecialKey.Backspace
                break
            case Qt.Key_Space:
                specialKeyType =  SpecialKey.Space
                break
            default:
                specialKeyType =  -1
            }

            for (var i = 0; i < keyboardLayout.keyCount; i++) {
                var key = keyboardLayout.key(i)

                if (key.keyType() === "specialKey" && key.type === specialKeyType) {
                    return key;
                }
            }

            return defaultKey
        }

        opacity: trainingLine.hintKey !== -1? 1: 0
        isHighlighted: opacity == 1
        keyboardLayout: screen.keyboardLayout || defaultKeyboardLayout
        Behavior on opacity {
            NumberAnimation { duration: 150 }
        }
    }

    PlasmaComponents.ScrollBar {
        flickableItem: sheetFlick
    }
}