-
Notifications
You must be signed in to change notification settings - Fork 2
/
TopToolbar.qml
113 lines (110 loc) · 3.43 KB
/
TopToolbar.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
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
Rectangle {
id: topToolbar
anchors.top: parent.top
anchors.topMargin: 0
width: parent.width
height: 80
color: "#ffffff"
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: 3
color: "red"
}
Image {
id: icon
width: 72
height: 72
anchors.verticalCenter: parent.verticalCenter
source: "images/netease-cloud-music.svg"
Label {
color: "#000000"
anchors.left: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: 4
text: qsTr("网易云音乐")
font.pointSize: 20
}
}
Rectangle {
anchors.bottom: icon.bottom
anchors.bottomMargin: 4
anchors.horizontalCenter: parent.horizontalCenter
width: window.width/5
height: textMask.contentHeight
radius: 4
color: "#dddddd"
TextInput {
id: searchInput
anchors.fill: parent
font.pointSize: 18
clip: true
Timer {
id: timer
interval: 200
onTriggered: {
var searchSuggest = neteaseAPI.searchSuggest(searchInput.text)
var json = JSON.parse(searchSuggest)
if (json.code !== 400) {
searchSuggestListView.model.clear()
for (var i in json.result.allMatch) {
searchSuggestListView.model.append({
"keyword": json.result.allMatch[i].keyword
})
}
}
else {
searchSuggestListView.model.clear()
}
}
}
onTextEdited: {
timer.restart()
}
onAccepted: {
focus = false
if (stackView.currentItem.objectName === "searchPage") {
stackView.replace(searchPage,{"keyword":searchInput.text})
}
else {
stackView.push(searchPage,{"keyword":searchInput.text})
}
}
}
TextInput { // Label's text has a position error
id: textMask
anchors.fill: searchInput
text: qsTr("搜索")
font.pointSize: 18
color: "#bbbbbb"
visible: searchInput.length === 0 ? searchInput.focus ? true : true : false
readOnly: true
enabled: false
}
ListView {
id: searchSuggestListView
z: 3
anchors.top: parent.bottom
interactive: false
anchors.left: parent.left
anchors.right: parent.right
height: model.count * 30
visible: searchInput.focus
model: ListModel {}
delegate: Material_Button {
width: searchSuggestListView.width
height: 30
color: "#787878"
Text {
color: "#343434"
anchors.fill: parent
text: keyword
}
}
}
}
}