forked from POOOOOOOON/qt-for-wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSideBar.qml
429 lines (396 loc) · 12.4 KB
/
SideBar.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
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
import QtQuick 2.12
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.13
Rectangle {
id: sideBar
width: 56
height: parent.height
color: "#323232"
property var flag : 0
ColumnLayout{
id: column
anchors.fill: parent
anchors.top: parent.top
anchors.topMargin: 15
anchors.horizontalCenter: parent.horizontalCenter
spacing: 5
Button{
id: headButton
width: parent.width
height: 50
icon.source:"qrc:/images/head.jpg"
icon.color: "transparent"
icon.width: 40
icon.height: 40
background: Rectangle{
anchors.fill: parent
color: "transparent"
}
}
Button{
id: chatButton
width: parent.width
height: 40
icon.source: flag === 0 ? "qrc:/images/chat1.png":"qrc:/images/chat.png"
icon.color: (flag !== 0 && chatButton.hovered) ? "white":"transparent"
icon.width: 30
icon.height: 30
background: Rectangle{
anchors.fill: parent
color: "transparent"
}
ToolTip{
visible: chatButton.hovered
delay: 500
text:qsTr("聊天")
background: Rectangle{
border.color: "#7f7f7f"
radius: 3
}
}
}
Button{
id: mailListButton
width: parent.width
height: 40
icon.source: flag === 1 ? "qrc:/images/mailList1.png":"qrc:/images/mailList.png"
icon.color: (flag !== 1 && mailListButton.hovered) ? "white":"transparent"
icon.width: 30
icon.height: 30
background: Rectangle{
anchors.fill: parent
color: "transparent"
}
ToolTip{
visible: mailListButton.hovered
delay: 500
text:qsTr("通讯录")
background: Rectangle{
border.color: "#7f7f7f"
radius: 3
}
}
}
Button{
id: collectButton
width: parent.width
height: 40
icon.source: flag === 2 ? "qrc:/images/collect1.png":"qrc:/images/collect.png"
icon.color: (flag !== 2 && collectButton.hovered) ? "white":"transparent"
icon.width: 30
icon.height: 30
background: Rectangle{
anchors.fill: parent
color: "transparent"
}
ToolTip{
visible: collectButton.hovered
delay: 500
text:qsTr("收藏")
background: Rectangle{
border.color: "#7f7f7f"
radius: 3
}
}
}
Item{
Layout.fillHeight: true
}
Button{
id: moreButton
width: parent.width
height: 40
icon.source: "qrc:/images/more.png"
icon.color: moreButton.hovered ? "white":"transparent"
icon.width: 30
icon.height: 30
background: Rectangle{
anchors.fill: parent
color: "transparent"
}
ToolTip{
visible: moreButton.hovered
delay: 500
text:qsTr("更多")
background: Rectangle{
border.color: "#7f7f7f"
radius: 3
}
}
}
}
Popup{
id: introduction
x: headButton.x + headButton.width/2
y: headButton.y + headButton.height/2
width: 300
height: 220
//focus: true
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnReleaseOutside
background: Rectangle{
anchors.fill: parent
border.color: "white"
radius: 5
}
TextField{
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: 20
anchors.topMargin: 20
text: "POON"
font.family: "NSimSun"
font.pointSize: 20
selectByMouse:true
selectedTextColor: "white"
selectionColor: "#5772ff"
readOnly: true
background: Rectangle{
anchors.fill: parent
border.color: "transparent"
}
}
Image {
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: 90
anchors.topMargin: 30
width: 20
height: 20
source: "qrc:/images/sex.png"
}
Label{
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: 30
anchors.topMargin: 60
text: "微信号:"
font.family: "NSimSun"
font.pointSize: 10
color: "gray"
}
TextField{
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: 75
anchors.topMargin: 55
text: "P1234567"
font.family: "NSimSun"
font.pointSize: 10
color: "gray"
selectByMouse:true
selectedTextColor: "white"
selectionColor: "#5772ff"
readOnly: true
background: Rectangle{
anchors.fill: parent
color: "transparent"
border.color: "transparent"
}
}
Button{
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: 15
anchors.topMargin: 20
width: 70
height: 70
icon.source:"qrc:/images/head.jpg"
icon.color: "transparent"
icon.width: 70
icon.height: 70
background: Rectangle{
anchors.fill: parent
color: "transparent"
}
}
Rectangle{
anchors.top: parent.top
anchors.right: parent.right
anchors.rightMargin: 15
anchors.topMargin: 110
width: parent.width - 45
height: 1
color: "#f7f7f9"
}
Label{
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: 30
anchors.topMargin: 130
text: qsTr("地 区")
font.family: "NSimSun"
font.pointSize: 10
color: "gray"
}
TextField{
anchors.top: parent.top
anchors.left: parent.left
anchors.leftMargin: 75
anchors.topMargin: 120
text: qsTr("山东 青岛")
font.family: "NSimSun"
font.pointSize: 12
color: "#000000"
selectByMouse:true
selectedTextColor: "white"
selectionColor: "#5772ff"
readOnly: true
background: Rectangle{
anchors.fill: parent
color: "transparent"
border.color: "transparent"
}
}
Button{
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.rightMargin: 50
anchors.bottomMargin: 5
width: 50
height: 50
icon.source:"qrc:/images/share.png"
icon.color: hovered ? "black":"transparent"
icon.width: 50
icon.height: 50
background: Rectangle{
anchors.fill: parent
color: "transparent"
}
ToolTip{
visible: parent.hovered
delay: 500
text:qsTr("发送名片")
background: Rectangle{
border.color: "#7f7f7f"
radius: 3
}
}
}
Button{
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.rightMargin: 10
anchors.bottomMargin: 5
width: 50
height: 50
icon.source:"qrc:/images/chat.png"
icon.color: hovered ? "black":"#bfbfbf"
icon.width: 50
icon.height: 50
background: Rectangle{
anchors.fill: parent
color: "transparent"
}
ToolTip{
visible: parent.hovered
delay: 500
text:qsTr("发消息")
background: Rectangle{
border.color: "#7f7f7f"
radius: 3
}
}
}
}
Menu{
id: moreMenu
width: 110
height: 120
background: Rectangle{
anchors.fill:parent
color: "#323232"
}
MenuItem{
Text {
text: "意见反馈"
color: "white"
font.family: "NSimSun"
font.pixelSize: 15
anchors.left: parent.left
anchors.leftMargin: 5
anchors.verticalCenter: parent.verticalCenter
}
height: 40
background: Rectangle{
anchors.fill: parent
color: parent.hovered ? "#444444":"transparent"
}
}
MenuItem{
Text {
text: "备份与恢复"
color: "white"
font.family: "NSimSun"
font.pixelSize: 15
anchors.left: parent.left
anchors.leftMargin: 5
anchors.verticalCenter: parent.verticalCenter
}
height: 40
background: Rectangle{
anchors.fill: parent
color: parent.hovered ? "#444444":"transparent"
}
}
MenuItem{
Text {
text: "设置"
color: "white"
font.family: "NSimSun"
font.pixelSize: 15
anchors.left: parent.left
anchors.leftMargin: 5
anchors.verticalCenter: parent.verticalCenter
}
height: 40
background: Rectangle{
anchors.fill: parent
color: parent.hovered ? "#444444":"transparent"
}
}
}
function getButtonStatus(){
if(collectButton.hovered | mailListButton.hovered | chatButton.hovered | headButton.hovered | moreButton.hovered)
return true
else
return false
}
MouseArea{
anchors.fill: parent
acceptedButtons: Qt.LeftButton
property point clickPos: "0,0"
cursorShape: getButtonStatus() ? Qt.PointingHandCursor:Qt.ArrowCursor
onPressed: { //接收鼠标按下事件
clickPos = Qt.point(mouse.x,mouse.y)
}
onPositionChanged: { //鼠标按下后改变位置
//鼠标偏移量
var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
//如果mainwindow继承自QWidget,用setPos
root.setX(root.x+delta.x)
root.setY(root.y+delta.y)
}
onClicked: {
if(mouseY >= chatButton.y+column.y && mouseY <= chatButton.y+column.y + chatButton.height){
flag = 0
emit: listBar.switchStachView(flag)
}
else if(mouseY >= mailListButton.y+column.y && mouseY <= mailListButton.y+column.y + mailListButton.height){
flag = 1
emit: listBar.switchStachView(flag)
}
else if(mouseY >= collectButton.y+column.y && mouseY <= collectButton.y+column.y + collectButton.height){
flag = 2
emit: listBar.switchStachView(flag)
}
else if(mouseY >= headButton.y+column.y && mouseY <= headButton.y+column.y + headButton.height){
introduction.open()
}
else if(mouseY >= moreButton.y+column.y && mouseY <= moreButton.y+column.y + moreButton.height){
moreMenu.x = sideBar.x + sideBar.width
moreMenu.y = sideBar.y + sideBar.height - moreMenu.height - 20
moreMenu.open()
}
}
}
}