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
|
/*
* Copyright (C) 2014 Canonical Ltd
*
* This file is part of Ubuntu Clock App
*
* Ubuntu Clock App is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* Ubuntu Clock App 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 2.0
import U1db 1.0 as U1db
import Ubuntu.Components 1.1
import "clock"
import "alarm"
import "components"
import "components/Utils.js" as Utils
MainView {
id: clockApp
// Property to store the state of an application (active or suspended)
property bool applicationState: Qt.application.active
// Property to enable/disable the debug mode to show more console output
property bool debugMode: true
// objectName for functional testing purposes (autopilot-qt5)
objectName: "clock"
// applicationName for click packages (used as an unique app identifier)
applicationName: "com.ubuntu.clock.devel"
/*
This property enables the application to change orientation when the
device is rotated. This has been set to false since we are currently
only focussing on the phone interface.
*/
automaticOrientation: false
/*
The width and height defined below are the same dimension used by the
designers in the clock visual spec.
*/
width: units.gu(40)
height: units.gu(70)
backgroundColor: "#F5F5F5"
useDeprecatedToolbar: false
onApplicationStateChanged: {
/*
Update Clock time immediately when the clock app is brought from
suspend instead of waiting for the next minute to update.
*/
if(applicationState)
clockPage.updateTime()
}
Background {}
Timer {
id: clockTimer
interval: 1000
repeat: true
running: true
onTriggered: clockPage.updateTime()
}
// Database to store the user preferences locally
U1db.Database {
id: clockDB
path: "user-preferences"
}
// Document to store clock mode chosen by user
U1db.Document {
id: clockModeDocument
create: true
database: clockDB
docId: "clockModeDocument"
defaults: { "digitalMode": false }
}
AlarmModel {
id: alarmModel
Component.onCompleted: Utils.log(debugMode, "Alarm Database loaded")
}
PageStack {
id: mainStack
Component.onCompleted: push(clockPage)
ClockPage {
id: clockPage
/*
#FIXME: When the SDK support hiding the header, then enable the
clock page title. This will then set the correct window title on
the desktop.
title: "Clock"
*/
/*
#TODO: The bottom edge title should reflect the time to the next
alarm. For instance it should read "Next alarm in 9h23m".
*/
bottomEdgeTitle: i18n.tr("Next Alarm in ..")
bottomEdgePageComponent: AlarmPage {}
}
}
}
|