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

unstable

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