Commit a1f33b42 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(SearchBox): change text input style

parent b7a48f73
...@@ -9,7 +9,7 @@ import Common.Styles 1.0 ...@@ -9,7 +9,7 @@ import Common.Styles 1.0
// =================================================================== // ===================================================================
Item { Item {
id: item id: searchBox
property alias delegate: list.delegate property alias delegate: list.delegate
property alias entryHeight: menu.entryHeight property alias entryHeight: menu.entryHeight
...@@ -26,23 +26,26 @@ Item { ...@@ -26,23 +26,26 @@ Item {
signal menuClosed signal menuClosed
signal menuOpened signal menuOpened
// -----------------------------------------------------------------
function hideMenu () { function hideMenu () {
menu.hideMenu() if (!_isOpen) {
shadow.visible = false return
searchField.focus = false }
desktopPopup.hide()
menuClosed() _isOpen = false
} }
function showMenu () { function showMenu () {
menu.showMenu() if (_isOpen) {
shadow.visible = true return
desktopPopup.show() }
menuOpened() _isOpen = true
} }
// -----------------------------------------------------------------
implicitHeight: searchField.height implicitHeight: searchField.height
Item { Item {
...@@ -61,6 +64,11 @@ Item { ...@@ -61,6 +64,11 @@ Item {
onActiveFocusChanged: activeFocus && searchBox.showMenu() onActiveFocusChanged: activeFocus && searchBox.showMenu()
onTextChanged: { onTextChanged: {
console.assert(
model.setFilterFixedString != null,
'`model.setFilterFixedString` must be defined.'
)
model.setFilterFixedString(text) model.setFilterFixedString(text)
if (model.invalidate) { if (model.invalidate) {
...@@ -69,17 +77,11 @@ Item { ...@@ -69,17 +77,11 @@ Item {
} }
} }
PopupShadow { // Wrap the search box menu in a window.
id: shadow
anchors.fill: searchField
source: searchField
visible: false
}
DesktopPopup { DesktopPopup {
id: desktopPopup id: desktopPopup
// The menu is always below the search field.
property point coords: { property point coords: {
var point = searchBox.mapToItem(null, 0, searchBox.height) var point = searchBox.mapToItem(null, 0, searchBox.height)
point.x += window.x point.x += window.x
...@@ -109,4 +111,42 @@ Item { ...@@ -109,4 +111,42 @@ Item {
} }
} }
} }
// -----------------------------------------------------------------
states: State {
name: 'opened'
when: _isOpen
}
transitions: [
Transition {
from: ''
to: 'opened'
ScriptAction {
script: {
menu.showMenu()
desktopPopup.show()
menuOpened()
}
}
},
Transition {
from: 'opened'
to: ''
ScriptAction {
script: {
menu.hideMenu()
searchField.focus = false
desktopPopup.hide()
menuClosed()
}
}
}
]
} }
...@@ -15,9 +15,9 @@ QtObject { ...@@ -15,9 +15,9 @@ QtObject {
property QtObject shadow: QtObject { property QtObject shadow: QtObject {
property color color: Colors.f property color color: Colors.f
property int horizontalOffset: 2 property int horizontalOffset: 4
property int radius: 8 property int radius: 8
property int samples: 15 property int samples: 15
property int verticalOffset: 2 property int verticalOffset: 4
} }
} }
...@@ -9,7 +9,14 @@ QtObject { ...@@ -9,7 +9,14 @@ QtObject {
property color shadowColor: Colors.f property color shadowColor: Colors.f
property Rectangle searchFieldBackground: Rectangle { property Rectangle searchFieldBackground: Rectangle {
implicitHeight: 30 implicitHeight: 40
border {
color: '#CBCBCB'
width: 1
}
radius: 4
} }
property QtObject text: QtObject { property QtObject text: QtObject {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment