Commit 2fa7c843 authored by Ronan Abhamon's avatar Ronan Abhamon

unstable

parent e25e77f4
...@@ -57,7 +57,7 @@ Item { ...@@ -57,7 +57,7 @@ Item {
function _checkPosition (positionEvent) { function _checkPosition (positionEvent) {
// Propagate event. // Propagate event.
positionEvent.accepted = false positionEvent.accepted = false
console.log('click', positionEvent.x, positionEvent.y)
// Click is outside or not. // Click is outside or not.
if (!Utils.pointIsInItem(this, item, positionEvent)) { if (!Utils.pointIsInItem(this, item, positionEvent)) {
if (_timeout != null) { if (_timeout != null) {
......
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Window 2.2 import QtQuick.Window 2.2
import Utils 1.0 // ===================================================================
Item { Item {
id: wrapper id: wrapper
// Not a private property. Can be used with an id.
default property alias content: content.data
property alias popupX: popup.x property alias popupX: popup.x
property alias popupY: popup.y property alias popupY: popup.y
default property alias _content: content.data
function show () { function show () {
popup.show() popup.show()
} }
...@@ -20,18 +19,23 @@ Item { ...@@ -20,18 +19,23 @@ Item {
popup.hide() popup.hide()
} }
x: 0 // DO NOT TOUCH THIS PROPERTIES.
y: 0
// No visible.
visible: false
// No size, no position.
height: 0 height: 0
width: 0 width: 0
visible: false x: 0
y: 0
Window { Window {
id: popup id: popup
flags: Qt.SplashScreen flags: Qt.SplashScreen
height: wrapper.content[0] != null ? wrapper.content[0].height : 0 height: _content[0] != null ? _content[0].height : 0
width: wrapper.content[0] != null ? wrapper.content[0].width : 0 width: _content[0] != null ? _content[0].width : 0
Item { Item {
id: content id: content
......
...@@ -2,7 +2,7 @@ import QtQuick 2.7 ...@@ -2,7 +2,7 @@ import QtQuick 2.7
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
import Common.Styles 1.0 import Common.Styles 1.0
import Utils 1.0
// =================================================================== // ===================================================================
// A reusable search input which display a entries model in a menu. // A reusable search input which display a entries model in a menu.
// Each entry can be filtered with the search input. // Each entry can be filtered with the search input.
...@@ -30,6 +30,7 @@ Item { ...@@ -30,6 +30,7 @@ Item {
menu.hideMenu() menu.hideMenu()
shadow.visible = false shadow.visible = false
searchField.focus = false searchField.focus = false
desktopPopup.hide()
menuClosed() menuClosed()
} }
...@@ -37,16 +38,11 @@ Item { ...@@ -37,16 +38,11 @@ Item {
function _showMenu () { function _showMenu () {
menu.showMenu() menu.showMenu()
shadow.visible = true shadow.visible = true
desktopPopup.show()
menuOpened() menuOpened()
} }
function getMenuInstance () {
console.log('instance parent', Utils.getTopParent(item))
return menu
}
implicitHeight: searchField.height implicitHeight: searchField.height
Item { Item {
...@@ -73,10 +69,33 @@ Item { ...@@ -73,10 +69,33 @@ Item {
} }
} }
PopupShadow {
id: shadow
anchors.fill: searchField
source: searchField
visible: false
}
DesktopPopup {
id: desktopPopup
property point coords: {
var point = searchBox.mapToItem(null, 0, searchBox.height)
point.x += window.x
point.y += window.y
return point
}
popupX: coords.x
popupY: coords.y
onVisibleChanged: !visible && searchBox._hideMenu()
DropDownDynamicMenu { DropDownDynamicMenu {
id: menu id: menu
//anchors.top: searchField.bottom
launcher: searchField launcher: searchField
width: searchField.width width: searchField.width
...@@ -88,13 +107,6 @@ Item { ...@@ -88,13 +107,6 @@ Item {
anchors.fill: parent anchors.fill: parent
} }
} }
PopupShadow {
id: shadow
anchors.fill: searchField
source: searchField
visible: false
} }
} }
} }
...@@ -148,7 +148,6 @@ function qmlTypeof (object, className) { ...@@ -148,7 +148,6 @@ function qmlTypeof (object, className) {
function pointIsInItem (source, target, point) { function pointIsInItem (source, target, point) {
point = source.mapToItem(target.parent, point.x, point.y) point = source.mapToItem(target.parent, point.x, point.y)
console.log('mapped point', point.x, point.y, target.x, target.y)
return ( return (
point.x >= target.x && point.x >= target.x &&
point.y >= target.y && point.y >= target.y &&
......
...@@ -71,24 +71,6 @@ ApplicationWindow { ...@@ -71,24 +71,6 @@ ApplicationWindow {
onClicked: Utils.openWindow('NewCall', window) onClicked: Utils.openWindow('NewCall', window)
} }
DesktopPopup {
id: desktopPopup
property point coords: {
var point = searchBox.mapToItem(null, 0, searchBox.height)
point.x += window.x
point.y += window.y
return point
}
content: searchBox.getMenuInstance()
popupX: coords.x
popupY: coords.y
onVisibleChanged: !visible && searchBox._hideMenu()
}
// Search. // Search.
SearchBox { SearchBox {
id: searchBox id: searchBox
...@@ -98,15 +80,6 @@ ApplicationWindow { ...@@ -98,15 +80,6 @@ ApplicationWindow {
placeholderText: qsTr('mainSearchBarPlaceholder') placeholderText: qsTr('mainSearchBarPlaceholder')
entryHeight: 50 entryHeight: 50
onMenuClosed: {
console.log('close')
desktopPopup.hide()
}
onMenuOpened: {
desktopPopup.show()
}
model: model1 model: model1
delegate: Contact { delegate: Contact {
......
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