blob: 19cad065e4903affab378c53109db97a64a56fd1 (
plain)
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
|
import Qt 4.6
Flipable {
id: container
property var frontContainer: containerFront
property string photoTitle: ""
property string photoDescription: ""
property string photoTags: ""
property int photoWidth
property int photoHeight
property string photoType
property string photoAuthor
property string photoDate
property string photoUrl
property int rating: 2
property var prevScale: 1.0
signal closed
transform: Rotation {
id: detailsRotation
origin.y: container.height / 2;
origin.x: container.width / 2;
axis.y: 1; axis.z: 0
}
front: Item {
id: containerFront; anchors.fill: container
Rectangle {
anchors.fill: parent
color: "black"; opacity: 0.4
border.color: "white"; border.width: 2
}
MediaButton {
id: backButton; x: 630; y: 370; text: "Back"
onClicked: { container.closed() }
}
MediaButton {
id: moreButton; x: 530; y: 370; text: "View..."
onClicked: { container.state='Back' }
}
Text { id: titleText; style: Text.Raised; styleColor: "black"; color: "white"; elide: Text.ElideRight
x: 220; y: 30; width: parent.width - 240; text: container.photoTitle; font.pointSize: 22 }
LikeOMeter { x: 40; y: 250; rating: container.rating }
Flickable { id: flickable; x: 220; width: 480; height: 210; y: 130; clip: true
viewportWidth: 480; viewportHeight: descriptionText.height
WebView { id: descriptionText; width: parent.width
html: "<style TYPE=\"text/css\">body {color: white;} a:link {color: cyan; text-decoration: underline; }</style>" + container.photoDescription }
}
Text { id: size; color: "white"; width: 300; x: 40; y: 300
text: "<b>Size:</b> " + container.photoWidth + 'x' + container.photoHeight }
Text { id: type; color: "white"; width: 300; x: 40; anchors.top: size.bottom
text: "<b>Type:</b> " + container.photoType }
Text { id: author; color: "white"; width: 300; x: 220; y: 80
text: "<b>Author:</b> " + container.photoAuthor }
Text { id: date; color: "white"; width: 300; x: 220; anchors.top: author.bottom
text: "<b>Published:</b> " + container.photoDate }
Text { id: tagsLabel; color: "white"; x: 220; anchors.top: date.bottom;
text: container.photoTags == "" ? "" : "<b>Tags:</b> " }
Text { id: tags; color: "white"; width: parent.width-x-20;
anchors.left: tagsLabel.right; anchors.top: date.bottom;
elide: Text.ElideRight; text: container.photoTags }
ScrollBar { id: scrollBar; x: 720; y: flickable.y; width: 7; height: flickable.height; opacity: 0;
flickableArea: flickable; clip: true }
}
back: Item {
anchors.fill: container
Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4; border.color: "white"; border.width: 2 }
Progress { anchors.centerIn: parent; width: 200; height: 18; progress: bigImage.progress; visible: bigImage.status!=1 }
Flickable {
id: flick; width: container.width - 10; height: container.height - 10
x: 5; y: 5; clip: true;
viewportWidth: imageContainer.width; viewportHeight: imageContainer.height
Item {
id: imageContainer
width: Math.max(bigImage.width * bigImage.scale, flick.width);
height: Math.max(bigImage.height * bigImage.scale, flick.height);
Image {
id: bigImage; source: container.photoUrl; scale: slider.value
// Center image if it is smaller than the flickable area.
x: imageContainer.width > width*scale ? (imageContainer.width - width*scale) / 2 : 0
y: imageContainer.height > height*scale ? (imageContainer.height - height*scale) / 2 : 0
smooth: !flick.moving
onStatusChanged : {
// Default scale shows the entire image.
if (status == 1 && width != 0) {
slider.minimum = Math.min(flick.width / width, flick.height / height);
prevScale = Math.min(slider.minimum, 1);
slider.value = prevScale;
}
}
}
}
}
MediaButton {
id: backButton2; x: 630; y: 370; text: "Back"; onClicked: { container.state = '' }
}
Text {
text: "Image Unavailable"
visible: bigImage.status == 'Error'
anchors.centerIn: parent; color: "white"; font.bold: true
}
Slider {
id: slider; x: 25; y: 374; visible: { bigImage.status == 1 && maximum > minimum }
onValueChanged: {
if (bigImage.width * value > flick.width) {
var xoff = (flick.width/2 + flick.viewportX) * value / prevScale;
flick.viewportX = xoff - flick.width/2;
}
if (bigImage.height * value > flick.height) {
var yoff = (flick.height/2 + flick.viewportY) * value / prevScale;
flick.viewportY = yoff - flick.height/2;
}
prevScale = value;
}
}
}
states: [
State {
name: "Back"
PropertyChanges { target: detailsRotation; angle: 180 }
}
]
transitions: [
Transition {
SequentialAnimation {
PropertyAction {
target: bigImage
property: "smooth"
value: false
}
NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 }
PropertyAction {
target: bigImage
property: "smooth"
value: !flick.moving
}
}
}
]
}
|