forked from harry159821/XiamiForLinuxProject
-
Notifications
You must be signed in to change notification settings - Fork 2
/
todayRecommend.qml
229 lines (211 loc) · 7.31 KB
/
todayRecommend.qml
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
import QtQuick 1.0
// http://doc.qt.io/qt-4.8/qml-pathview.html
Rectangle {
id: root
width: globalWidth; height:globalHeight
property int globalWidth;
property int globalHeight;
// width:1000; height:400
color: "transparent"
signal sendClicked(string str);
signal onEntered();
signal onExited();
// onEntered:
// onExited:
Image {
id:backgroundImage
width:root.width; height:root.height*700/1000
source: "test.png"
anchors.horizontalCenter: parent.horizontalCenter
// 平滑过度
smooth:true
}
Rectangle {
y: 0
x: -2
width: backgroundImage.width + 2
height: root.height*700/1000
gradient: Gradient {
GradientStop { position: 0.0; color: Qt.rgba(0,0,0, 0.0) }
GradientStop { position: 1; color: Qt.rgba(255,255,255, 1.0) }
}
}
// // // 列表模型
// ListModel {
// // ID
// id:myModel
// // 成员
// ListElement { picName: "pics/340126.jpg" }
// ListElement { picName: "pics/381815.jpg" }
// ListElement { picName: "pics/485180.jpg" }
// ListElement { picName: "pics/1861261471.jpg" }
// ListElement { picName: "pics/1669845108.jpg" }
// ListElement { picName: "pics/2081821708.jpg" }
// ListElement { picName: "pics/507984.jpg" }
// }
// Model的代表组件构成结构
// 可以理解成Model的每个组件遵循的结构?
Component {
id:myDelegate
Item {
property real scaleValue: PathView.scalePic
width:290; height:290
// 可见性 绑定path?
visible: PathView.onPath
// 层次 绑定path?
z:PathView.zOrder
Image {
id:myImage
width:290; height:290+1
source: picName
anchors.horizontalCenter: parent.horizontalCenter
// 平滑过度
smooth:true
MouseArea {
id:itemMouseArea
anchors.fill: parent
hoverEnabled: true
// focus:true
onPressed:{
// console.log(pathView.currentIndex)
}
onClicked: {
root.sendClicked(picName)
}
onEntered: {
if(parent.parent.z==3){
playButton.source = "img/large_cover_play_normal.png"
}
}
// onReleased:
onExited: {
playButton.source = ""
}
}
Image {
id:playButton
width:70; height:70
source: ""
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter : parent.verticalCenter
smooth:true
MouseArea {
anchors.fill: parent
hoverEnabled: true
onPressed:{
parent.source = "img/large_cover_play_down.png"
}
onEntered:{
parent.source = "img/large_cover_play_hover.png"
}
onReleased:{
parent.source = "img/large_cover_play_normal.png"
}
onExited:{
parent.source = ""
}
}
visible:(parent.parent.z==3)?true:false
}
Text {
width:290
// height:290
text: picText
// font.family: "Helvetica"
font.family: "微软雅黑"
font.pointSize: 12
color: "white"
wrapMode :Text.WordWrap
anchors {
bottom:itemMouseArea.bottom;
bottomMargin:0
}
// opacity:2*(scaleValue-0.5)
visible:(parent.parent.z==3)?true:false
}
}
Image {
id:subImage
width:290-2; height:290
source: picName
anchors.horizontalCenter: parent.horizontalCenter
smooth:true
// 翻转
transform: Rotation {
origin.x:0; origin.y:290
axis{
x:1; y:0; z:0
}
angle:180
}
}
Rectangle {
y: myImage.height;
x: -1
width: myImage.width + 0
height: myImage.height
gradient: Gradient {
GradientStop { position: 0.0; color: Qt.rgba(255,255,255, 0.5) }
GradientStop { position: 0.12; color: Qt.rgba(255,255,255, 1.0) }
}
}
transform: [
Scale {
xScale:scaleValue; yScale:scaleValue
origin.x: 340/2; origin.y: 260/2
}
]
}
}
function decrementCurrentIndex() {
pathView.decrementCurrentIndex()
// root.update()
// pathView.requestPaint()
}
function incrementCurrentIndex() {
return pathView.incrementCurrentIndex()
}
function currentIndex() {
return pathView.currentIndex
}
PathView {
id:pathView
focus:true
model: myModel
delegate: myDelegate
anchors.fill: parent
// path上容纳的Item数量
pathItemCount: 5
// 设置突出选项
preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
highlightRangeMode: PathView.StrictlyEnforceRange
// 属性设置弹簧效果的衰减速率,默认值为 100
flickDeceleration: 200
path: myPath
// 鼠标控制移动
Keys.onLeftPressed: decrementCurrentIndex()
Keys.onRightPressed: incrementCurrentIndex()
}
// 图像行走的路线
Path {
id: myPath
// path的开始位置 及此刻的属性
// startX:50; startY:170
startX:root.width*50/1000; startY:root.height*170/600+60; // 按比例
PathAttribute {name: "scalePic"; value: 0.5}
PathAttribute {name: "zOrder"; value: 1}
// 中心位置
// PathLine{x:500; y:170}
PathLine{x:root.width*500/1000; y:root.height*170/600+60}
PathPercent {value: 0.50}
PathAttribute {name: "scalePic"; value: 1}
PathAttribute {name: "zOrder"; value: 3}
// 结束位置
// PathLine{x:950; y:170}
PathLine{x:root.width*950/1000; y:root.height*170/600+60}
PathPercent {value: 1.00}
PathAttribute {name: "scalePic"; value: 0.5}
PathAttribute {name: "zOrder"; value: 1}
}
}