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
|
/*
* This file is part of unity-2d
*
* Copyright 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 "../../common/units.js" as Units
import "../../common/utils.js" as Utils
/* TODO:
The entire support for moving between previews in the original branch was based on a model that
contained a list of all the previews. But in fact the Unity API doesn't work that way:
it just has a method on the Lens that will return a preview of a specified URI.
For now we don't need the support for moving between previews, so it's removed. But when
we will put it back again, I think that when we want to move to the prev/next preview we ask the
dash to select the prev/next item and activate it.
This way we don't have to maintain a separate list model.
*/
FocusScope {
id: previews
property int category
property string uri
property string mimeType
property bool active: false
opacity: 0.0
Behavior on opacity { NumberAnimation { duration: 400 } }
signal exitRequested
Keys.onPressed: {
if (event.key == Qt.Key_Escape || event.key == Qt.Key_Backspace) {
exitRequested()
}
}
Rectangle {
id: background
color: "#3a182b"
opacity: 0.95
anchors.fill: parent
}
Loader {
id: previewLoader
source: {
/* FIXME: For now detect based on MIME type and category of the item we are passed,
but something more flexible is neeeded for the future */
if (mimeType == "") return ""
else if (mimeType.indexOf("video/") == 0) {
switch (category) {
case 0:
return "FeaturedVideoPreview.qml"
case 1:
return "RentedVideoPreview.qml"
case 2:
return "PurchasedVideoPreview.qml"
case 3:
return "RecordedVideoPreview.qml"
default:
return "DefaultVideoPreview.qml"
}
} else if (mimeType.indexOf("music/") == 0) {
switch (category) {
case 0:
return "FeaturedVideoPreview.qml"
case 1:
return "RentedVideoPreview.qml"
case 2:
return "PurchasedVideoPreview.qml"
case 3:
return "RecordedVideoPreview.qml"
default:
return "DefaultVideoPreview.qml"
}
}else {
console.log("WARNING: there is not previewer capable of handling mimetype " + mimeType)
return ""
}
}
anchors.fill: parent
anchors.topMargin: Units.tvPx(25)
anchors.bottomMargin: Units.tvPx(45)
anchors.leftMargin: Units.tvPx(45)
anchors.rightMargin: Units.tvPx(45)
onLoaded: item.focus = true
focus: true
}
Binding {
target: previewLoader.item
property: "uri"
value: previewer.uri
when: previewLoader.status == Loader.Ready
}
Binding {
target: previewLoader.item
property: "mimeType"
value: previewer.mimeType
when: previewLoader.status == Loader.Ready
}
states: State {
name: "shown"
when: previews.active
PropertyChanges { target: previews; opacity: 1.0 }
}
}
|