forked from zccrs/ithome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearch.qml
104 lines (98 loc) · 2.91 KB
/
Search.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
import QtQuick 1.1
import com.nokia.meego 1.1
MyPage{
property bool inputFocus: true
function close()
{
if(online){
if(textfield.text!=""){
Qt.openUrlExternally("https://www.google.com.hk/search?q=www.ithome.com"+textfield.text)
textfield.focus=false
textfield.text=""
textfield.platformCloseSoftwareInputPanel()
}
}else{
showBanner("亲,还没联网呢")
}
}
TextField{
id:textfield
platformStyle: TextFieldStyle{
paddingLeft: searchIcon.width
paddingRight: clearButton.width
}
placeholderText: "请输入搜索内容"
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.margins: 20
Image {
id: searchIcon;
anchors { left: parent.left; verticalCenter: parent.verticalCenter; }
source: "image://theme/icon-m-common-search";
}
Item {
id: clearButton;
anchors { right: parent.right; verticalCenter: parent.verticalCenter; }
height: clearButtonImage.height;
width: clearButtonImage.width;
opacity: textfield.activeFocus ? 1 : 0;
Behavior on opacity {
NumberAnimation { duration: 100; }
}
Image {
id: clearButtonImage;
source: "image://theme/icon-m-input-clear";
}
MouseArea {
id: clearMouseArea;
anchors.fill: parent;
onClicked: {
textfield.focus=false
textfield.text=""
textfield.platformCloseSoftwareInputPanel();
}
}
}
}
ToolButton{
id:button1
text:"返回"
anchors.left: parent.left
anchors.leftMargin: 20
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
onClicked: {
current_page="page"
textfield.focus=false
textfield.platformCloseSoftwareInputPanel()
textfield.text=""
pageStack.pop()
if(loading)
main.busyIndicatorShow()//显示缓冲圈圈
}
}
ToolButton{
text:"搜索"
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
anchors.right: parent.right
anchors.rightMargin: 20
onClicked: {
close()
}
}
Keys.onEnterPressed: {
close()
}
Keys.onPressed: {
if(event.key===16777220)
{
if(textfield.activeFocus){
close()
}else textfield.forceActiveFocus()
}
//console.log(event.key)
}
}
//