feat(MainWindow): close search menu if focus window is lost

This commit is contained in:
Ronan Abhamon 2016-10-27 11:38:22 +02:00
parent 4a0337379b
commit 5be1c604c6
2 changed files with 10 additions and 7 deletions

View file

@ -26,7 +26,7 @@ Item {
signal menuClosed
signal menuOpened
function _hideMenu () {
function hideMenu () {
menu.hideMenu()
shadow.visible = false
searchField.focus = false
@ -35,7 +35,7 @@ Item {
menuClosed()
}
function _showMenu () {
function showMenu () {
menu.showMenu()
shadow.visible = true
desktopPopup.show()
@ -57,9 +57,9 @@ Item {
font.pointSize: SearchBoxStyle.text.fontSize
width: parent.width
Keys.onEscapePressed: _hideMenu()
Keys.onEscapePressed: searchBox.hideMenu()
onActiveFocusChanged: activeFocus && _showMenu()
onActiveFocusChanged: activeFocus && searchBox.showMenu()
onTextChanged: {
model.setFilterFixedString(text)
@ -91,7 +91,7 @@ Item {
popupX: coords.x
popupY: coords.y
onVisibleChanged: !visible && searchBox._hideMenu()
onVisibleChanged: !visible && searchBox.hideMenu()
DropDownDynamicMenu {
id: menu
@ -99,7 +99,7 @@ Item {
launcher: searchField
width: searchField.width
onMenuClosed: _hideMenu()
onMenuClosed: searchBox.hideMenu()
ScrollableListView {
id: list

View file

@ -111,6 +111,9 @@ ApplicationWindow {
}
}
onActiveFocusItemChanged: activeFocusItem == null &&
searchBox.hideMenu()
RowLayout {
anchors.fill: parent
spacing: 0
@ -193,12 +196,12 @@ ApplicationWindow {
}
}
}
// Logo.
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 80
color: '#EAEAEA'
//a: qsTr("ooo")
}
}