on 2c34dfd help sign in
unity8/qml/Tutorial/InactivityTimer.qml
62 lines 1.6 kB history raw
1/*
2 * Copyright (C) 2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
20Item {
21 readonly property alias running: internalTimer.running
22 property alias interval: internalTimer.interval
23 property var page
24 property int lastInputTimestamp
26 function start() {
27 internalTimer.start();
28 }
30 ////
32 onLastInputTimestampChanged: {
33 if (internalTimer.running) {
34 internalTimer.restart();
35 }
36 }
38 Connections {
39 target: page
40 onIsReadyChanged: {
41 if (page.isReady && internalTimer.running) {
42 internalTimer.restart();
43 }
44 }
45 }
47 Timer {
48 id: internalTimer
50 interval: 3000
52 onTriggered: {
53 if (page.isReady) {
54 if (!page.shown) {
55 page.show();
56 }
57 } else if (!page.skipped) {
58 restart();
59 }
60 }
61 }