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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
/*
* This file is part of unity-2d
*
* Copyright 2010-2011 Canonical Ltd.
*
* 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; version 3.
*
* 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.0
import Unity2d 1.0
import "launcher"
import "common/units.js" as Units
Item {
id: shell
// Accessible.name: "shell"
width: screen.availableGeometry.width
height: screen.availableGeometry.height
property real volume: 1
function play(uri) {
dashLoader.item.active = false
playerLoader.item.playUri(uri)
playerLoader.focus = true
}
Loader {
id: playerLoader
source: "player/VideoPlayer.qml"
anchors.fill: parent
onLoaded: item.focus = true
}
Connections {
target: playerLoader.item
onStateChanged: {
if (playerLoader.item.state == "playing") {
playerLoader.focus = true
dashLoader.item.active = false
} else if (playerLoader.item.state == "stopped") {
dashLoader.item.active = true
dashLoader.focus = true
}
}
}
Image {
id: wallpaper
anchors.fill: parent
source: visible ? "artwork/wallpaper.png" : ""
visible: unity2dConfiguration.formFactor == "tv"
fillMode: Image.PreserveAspectCrop
opacity: playerLoader.item.state == "stopped" ? 1.0 : 0.0
Behavior on opacity {
NumberAnimation {
duration: 500;
easing.type: Easing.InOutQuad
}
}
}
LauncherLoader {
id: launcherLoader
anchors.top: parent.top
anchors.bottom: parent.bottom
width: Units.dtPx(launcher2dConfiguration.thickness)
x: visibilityController.shown ? 0 : -width
KeyNavigation.right: dashLoader
Binding {
target: launcherLoader.item
property: "showMenus"
value: !dashLoader.item.active && playerLoader.item.state == "stopped"
}
Behavior on x { NumberAnimation { duration: 125 } }
onLoaded: if (declarativeView.dashActive) {
launcherLoader.visibilityController.forceVisibleBegin("dash")
}
Connections {
target: declarativeView
onDashActiveChanged: {
if (declarativeView.dashActive) launcherLoader.visibilityController.beginForceVisible("dash")
else launcherLoader.visibilityController.endForceVisible("dash")
}
}
SpreadMonitor {
id: spread
enabled: true
onShownChanged: if (shown) {
/* The the spread grabs input and Qt can't properly
detect we've lost input, so explicitly hide the menus */
launcherLoader.item.hideMenu()
launcherLoader.visibilityController.beginForceVisible("spread")
}
else launcherLoader.visibilityController.endForceVisible("spread")
}
}
Connections {
target: launcherLoader.item
ignoreUnknownSignals: true
onItemClicked: {
if (unity2dConfiguration.formFactor == "tv") {
if (id.match(/\.lens$/)) {
dashLoader.item.hidePreview()
dashLoader.item.activateLens(id)
dashLoader.focus = true
} else if (id == "player" && (playerLoader.item.playing || playerLoader.item.paused)) {
dashLoader.item.active = false
playerLoader.focus = true
} else if (id == "epg") {
dashLoader.item.activateEPG()
dashLoader.focus = true
}else if (id == "itv") {
dashLoader.item.activateITV()
dashLoader.focus = true
}else if (id == "nokiamaps") {
dashLoader.item.activateNokiaMaps()
dashLoader.focus = true
}else if (id == "weather") {
dashLoader.item.activateWeather()
dashLoader.focus = true
}else if (id == "systemsettings") {
dashLoader.item.activateSystemsettings()
dashLoader.focus = true
}else if (id == "usersettings") {
dashLoader.item.activateUsersettings()
dashLoader.focus = true
}else if (id == "qtvviewer") {
dashLoader.item.activateQtvviewer()
dashLoader.focus = true
}else if (id == "videffect") {
dashLoader.item.activateVideffect()
dashLoader.focus = true
}else if (id == "mythweb") {
dashLoader.item.activateMythweb()
dashLoader.focus = true
}else if (id == "home") {
dashLoader.item.activateHome()
dashLoader.focus = true
}
}
}
}
Binding {
target: launcherLoader.item
property: "activeComponent"
value: {
if ((playerLoader.item.playing || playerLoader.item.paused) && playerLoader.activeFocus) return "player"
if (dashLoader.item.active && dashLoader.item.nokiamapsActive) return "nokiamaps"
if (dashLoader.item.active && dashLoader.item.qtvviewerActive) return "qtvviewer"
if (dashLoader.item.active && dashLoader.item.itvActive) return "itv"
if (dashLoader.item.active && dashLoader.item.videffectActive) return "videffect"
if (dashLoader.item.active && dashLoader.item.systemsettingsActive) return "systemsettings"
if (dashLoader.item.active && dashLoader.item.weatherActive) return "weather"
if (dashLoader.item.active && dashLoader.item.epgActive) return "epg"
if (dashLoader.item.active && dashLoader.item.usersettingsActive) return "usersettings"
if (dashLoader.item.active && dashLoader.item.mythwebActive) return "mythweb"
if (dashLoader.item.active && dashLoader.item.homeActive) return "home"
else if (dashLoader.item.active) return declarativeView.activeLens
}
}
Loader {
id: dashLoader
source: "dash/Dash.qml"
anchors.top: parent.top
x: launcherLoader.width
KeyNavigation.left: launcherLoader
onLoaded: item.focus = true
opacity: item.active ? 1.0 : 0.0
focus: item.active
Behavior on opacity { NumberAnimation { duration: 500; easing.type: Easing.InOutQuad } }
Binding {
target: dashLoader.item
property: "fullscreenWidth"
value: screen.availableGeometry.width - launcherLoader.width
}
Rectangle {
id: darkBackgroundWhenPlaying
anchors.fill: parent
color: "black"
opacity: dashLoader.item.active && (playerLoader.item.state == "playing" || playerLoader.item.state == "paused") ? 0.7 : 0.0
Behavior on opacity { NumberAnimation { duration: 500; easing.type: Easing.InOutQuad } }
}
}
Connections {
target: declarativeView
onLauncherFocusRequested: {
launcherLoader.focus = true
launcherLoader.item.focusBFB()
}
onFocusChanged: {
/* FIXME: The launcher is forceVisible while it has activeFocus. However even though
the documentation says that setting focus=false will make an item lose activeFocus
if it has it, this doesn't happen with FocusScopes (and Launcher is a FocusScope).
Therefore I'm working around this by giving focus to the shell, which is safe since
the shell doesn't react to activeFocus at all.
See: https://bugreports.qt.nokia.com/browse/QTBUG-19688 */
if (!declarativeView.focus && launcherLoader.activeFocus) shell.focus = true
}
}
Component.onCompleted: declarativeView.show()
Keys.onPressed: {
if (event.key == Qt.Key_Escape) {
switch (unity2dConfiguration.formFactor) {
case "desktop":
declarativeView.forceDeactivateWindow()
break
case "tv":
if (!dashLoader.item.active &&
(playerLoader.item.playing || playerLoader.item.paused)) {
playerLoader.focus = true
} else if (playerLoader.item.playing || playerLoader.item.paused) {
dashLoader.item.active = false
playerLoader.focus = true
} else {
dashLoader.focus = true
}
break
}
} else if (event.key == Qt.Key_F1 || event.key == Qt.Key_Comma ||
(event.key == Qt.Key_Return && event.modifiers & Qt.AltModifier && event.modifiers & Qt.MetaModifier)) {
if (!launcherLoader.activeFocus) {
launcherLoader.focus = true
} else {
if (!dashLoader.item.active &&
(playerLoader.item.playing || playerLoader.item.paused)) {
playerLoader.focus = true
} else {
dashLoader.focus = true
}
}
event.accepted = true
/* Forward edge events to currently active component */
} else if (event.key == Qt.Key_F2 || event.key == Qt.Key_Period || event.key == Qt.Key_F3 || event.key == Qt.Key_MediaPlay ||
(event.key == Qt.Key_R && event.modifiers & Qt.ControlModifier)) {
if (!dashLoader.item.active &&
(playerLoader.item.playing || playerLoader.item.paused)) {
playerLoader.item.edgeEvent(event)
} else {
dashLoader.item.edgeEvent(event)
}
}
}
}
|