Warning, /education/gcompris/src/activities/chess/GCTimerButton.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - GCTimerButton.qml
0002  *
0003  * SPDX-FileCopyrightText: 2021 Samarth Raj <mailforsamarth@gmail.com>
0004  *
0005  * Authors:
0006  *   Samarth Raj <mailforsamarth@gmail.com>
0007  *
0008  *   SPDX-License-Identifier: GPL-3.0-or-later
0009  */
0010 
0011 import QtQuick 2.12
0012 import GCompris 1.0
0013 
0014 import "../../core"
0015 
0016 ControlButton {
0017     property bool enabled: true
0018     property int holdTime: 3000
0019 
0020     signal pressAndHold
0021     signal stop
0022 
0023     Component.onCompleted: {
0024         activity.stop.connect(stop);
0025     }
0026 
0027     onStop: {
0028         buttonTimer.stop()
0029     }
0030 
0031     Timer {
0032         id: buttonTimer
0033         interval: holdTime
0034         onTriggered: pressAndHold()
0035     }
0036 
0037     onPressed: {
0038         buttonTimer.restart()
0039     }
0040 
0041     onReleased: {
0042         buttonTimer.stop()
0043     }
0044 }