diff --git a/tests/ui/modules/Common/InvertedMouseArea.qml b/tests/ui/modules/Common/InvertedMouseArea.qml index e52370458..1cf714521 100644 --- a/tests/ui/modules/Common/InvertedMouseArea.qml +++ b/tests/ui/modules/Common/InvertedMouseArea.qml @@ -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) { diff --git a/tests/ui/modules/Common/Popup/DesktopPopup.qml b/tests/ui/modules/Common/Popup/DesktopPopup.qml index 73ced88ab..2596416a5 100644 --- a/tests/ui/modules/Common/Popup/DesktopPopup.qml +++ b/tests/ui/modules/Common/Popup/DesktopPopup.qml @@ -1,17 +1,16 @@ 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 diff --git a/tests/ui/modules/Common/SearchBox.qml b/tests/ui/modules/Common/SearchBox.qml index 3a98b6d04..cadede542 100644 --- a/tests/ui/modules/Common/SearchBox.qml +++ b/tests/ui/modules/Common/SearchBox.qml @@ -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,22 +69,6 @@ Item { } } - DropDownDynamicMenu { - id: menu - - //anchors.top: searchField.bottom - launcher: searchField - width: searchField.width - - onMenuClosed: _hideMenu() - - ScrollableListView { - id: list - - anchors.fill: parent - } - } - PopupShadow { id: shadow @@ -96,5 +76,37 @@ Item { 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 { + id: menu + + launcher: searchField + width: searchField.width + + onMenuClosed: _hideMenu() + + ScrollableListView { + id: list + + anchors.fill: parent + } + } + } } } diff --git a/tests/ui/scripts/Utils/utils.js b/tests/ui/scripts/Utils/utils.js index bf1d99e1d..2d517e265 100644 --- a/tests/ui/scripts/Utils/utils.js +++ b/tests/ui/scripts/Utils/utils.js @@ -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 && diff --git a/tests/ui/views/MainWindow/MainWindow.qml b/tests/ui/views/MainWindow/MainWindow.qml index 7ef8ddd5d..1f2922296 100644 --- a/tests/ui/views/MainWindow/MainWindow.qml +++ b/tests/ui/views/MainWindow/MainWindow.qml @@ -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 {