Commit e25e77f4 authored by Ronan Abhamon's avatar Ronan Abhamon

unstable

parent 2d739495
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
<file>ui/modules/Common/Menu/Menu.qml</file> <file>ui/modules/Common/Menu/Menu.qml</file>
<file>ui/modules/Common/Paned.qml</file> <file>ui/modules/Common/Paned.qml</file>
<file>ui/modules/Common/Popup/AbstractDropDownMenu.qml</file> <file>ui/modules/Common/Popup/AbstractDropDownMenu.qml</file>
<file>ui/modules/Common/Popup/DesktopPopup.qml</file>
<file>ui/modules/Common/Popup/DropDownDynamicMenu.qml</file> <file>ui/modules/Common/Popup/DropDownDynamicMenu.qml</file>
<file>ui/modules/Common/Popup/DropDownMenu.qml</file> <file>ui/modules/Common/Popup/DropDownMenu.qml</file>
<file>ui/modules/Common/Popup/PopupShadow.qml</file> <file>ui/modules/Common/Popup/PopupShadow.qml</file>
......
...@@ -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) {
......
...@@ -74,6 +74,13 @@ Item { ...@@ -74,6 +74,13 @@ Item {
} }
} }
// Block clicks, wheel... below menu.
MouseArea {
anchors.fill: content
hoverEnabled: true
onWheel: {}
}
// Menu content. // Menu content.
Rectangle { Rectangle {
id: content id: content
...@@ -102,19 +109,17 @@ Item { ...@@ -102,19 +109,17 @@ Item {
// ----------------------------------------------------------------- // -----------------------------------------------------------------
states: [ states: State {
State { name: 'opened'
name: 'opened' when: _isOpen
when: _isOpen
PropertyChanges { PropertyChanges {
focus: true // Necessary to use `Keys.onEscapePressed`. focus: true // Necessary to use `Keys.onEscapePressed`.
opacity: 1 opacity: 1
target: menu target: menu
visible: true visible: true
}
} }
] }
transitions: [ transitions: [
Transition { Transition {
......
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
function show () {
popup.show()
}
function hide () {
popup.hide()
}
x: 0
y: 0
height: 0
width: 0
visible: false
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
Item {
id: content
// Fake parent.
property var $parent: wrapper
}
}
}
...@@ -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.
...@@ -41,6 +41,12 @@ Item { ...@@ -41,6 +41,12 @@ Item {
menuOpened() menuOpened()
} }
function getMenuInstance () {
console.log('instance parent', Utils.getTopParent(item))
return menu
}
implicitHeight: searchField.height implicitHeight: searchField.height
Item { Item {
...@@ -70,7 +76,7 @@ Item { ...@@ -70,7 +76,7 @@ Item {
DropDownDynamicMenu { DropDownDynamicMenu {
id: menu id: menu
anchors.top: searchField.bottom //anchors.top: searchField.bottom
launcher: searchField launcher: searchField
width: searchField.width width: searchField.width
......
...@@ -56,6 +56,7 @@ Menu 1.0 Menu/Menu.qml ...@@ -56,6 +56,7 @@ Menu 1.0 Menu/Menu.qml
Paned 1.0 Paned.qml Paned 1.0 Paned.qml
# Popup # Popup
DesktopPopup 1.0 Popup/DesktopPopup.qml
DropDownDynamicMenu 1.0 Popup/DropDownDynamicMenu.qml DropDownDynamicMenu 1.0 Popup/DropDownDynamicMenu.qml
DropDownMenu 1.0 Popup/DropDownMenu.qml DropDownMenu 1.0 Popup/DropDownMenu.qml
PopupShadow 1.0 Popup/PopupShadow.qml PopupShadow 1.0 Popup/PopupShadow.qml
......
...@@ -108,10 +108,14 @@ function clearTimeout (timer) { ...@@ -108,10 +108,14 @@ function clearTimeout (timer) {
// Returns the top (root) parent of one object. // Returns the top (root) parent of one object.
function getTopParent (object) { function getTopParent (object) {
var parent = object.parent function _getTopParent (object) {
return object.$parent || object.parent
}
var parent = _getTopParent(object)
while (parent.parent != null) { while (_getTopParent(parent) != null) {
parent = parent.parent parent = _getTopParent(parent)
} }
return parent return parent
...@@ -144,6 +148,7 @@ function qmlTypeof (object, className) { ...@@ -144,6 +148,7 @@ 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,20 +71,40 @@ ApplicationWindow { ...@@ -71,20 +71,40 @@ 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
Layout.fillWidth: true Layout.fillWidth: true
maxMenuHeight: 300 // See Hick's law for good choice. maxMenuHeight: 300 // See Hick's law for good choice.
placeholderText: qsTr('mainSearchBarPlaceholder') placeholderText: qsTr('mainSearchBarPlaceholder')
entryHeight: 50 entryHeight: 50
onMenuClosed: content.enabled = true onMenuClosed: {
console.log('close')
desktopPopup.hide()
}
onMenuOpened: { onMenuOpened: {
if (!collapse.isCollapsed()) { desktopPopup.show()
// TODO, open desktop popup.
}
content.enabled = false
} }
model: model1 model: model1
...@@ -120,7 +140,6 @@ ApplicationWindow { ...@@ -120,7 +140,6 @@ ApplicationWindow {
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
id: content
spacing: 0 spacing: 0
// Main menu. // Main menu.
......
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