diff --git a/tests/resources.qrc b/tests/resources.qrc
index 1cf661e59..4fbf73e79 100644
--- a/tests/resources.qrc
+++ b/tests/resources.qrc
@@ -51,6 +51,8 @@
ui/modules/Common/InvertedMouseArea.qml
ui/modules/Common/Menu.qml
ui/modules/Common/Paned.qml
+ ui/modules/Common/Popup/AbstractDropDownMenu.qml
+ ui/modules/Common/Popup/DropDownDynamicMenu.qml
ui/modules/Common/Popup/DropDownMenu.qml
ui/modules/Common/Popup/PopupShadow.qml
ui/modules/Common/qmldir
diff --git a/tests/ui/modules/Common/Popup/AbstractDropDownMenu.qml b/tests/ui/modules/Common/Popup/AbstractDropDownMenu.qml
new file mode 100644
index 000000000..965be712c
--- /dev/null
+++ b/tests/ui/modules/Common/Popup/AbstractDropDownMenu.qml
@@ -0,0 +1,100 @@
+import QtQuick 2.7
+
+import Common 1.0
+import Common.Styles 1.0
+import Utils 1.0
+
+// ===================================================================
+// Low component to display a list/menu in a popup.
+// ===================================================================
+
+Item {
+ // Optionnal parameter, if defined and if a click is detected
+ // on it, menu is not closed.
+ property var launcher
+
+ // Optionnal parameters, set the position of Menu relative
+ // to this item.
+ property var relativeTo
+ property int relativeX: 0
+ property int relativeY: 0
+
+ default property alias _content: content.data
+
+ signal menuClosed
+ signal menuOpened
+
+ // -----------------------------------------------------------------
+
+ function isOpen () {
+ return visible
+ }
+
+ function showMenu () {
+ if (visible) {
+ return
+ }
+
+ if (relativeTo != null) {
+ this.x = relativeTo.mapToItem(null, relativeX, relativeY).x
+ this.y = relativeTo.mapToItem(null, relativeX, relativeY).y
+ }
+
+ visible = true
+ menuOpened()
+ }
+
+ function hideMenu () {
+ if (!visible) {
+ return
+ }
+
+ visible = false
+ menuClosed()
+ }
+
+ function _computeHeight () {
+ console.exception('Virtual method must be implemented.')
+ }
+
+ // -----------------------------------------------------------------
+
+ implicitHeight: _computeHeight()
+ visible: false
+ z: Constants.zPopup
+
+ Keys.onEscapePressed: hideMenu()
+
+ // Set parent menu to root.
+ Component.onCompleted: {
+ if (relativeTo != null) {
+ parent = Utils.getTopParent(this)
+ }
+ }
+
+ // Menu content.
+ Rectangle {
+ id: content
+
+ anchors.fill: parent
+ color: PopupStyle.backgroundColor
+
+ layer {
+ enabled: true
+ effect: PopupShadow {}
+ }
+ }
+
+ // Inverted mouse area to detect click outside menu.
+ InvertedMouseArea {
+ anchors.fill: parent
+ enabled: parent.visible
+
+ onPressed: {
+ if (launcher != null && pointIsInItem(launcher)) {
+ return
+ }
+ hideMenu()
+ }
+ }
+}
diff --git a/tests/ui/modules/Common/Popup/DropDownDynamicMenu.qml b/tests/ui/modules/Common/Popup/DropDownDynamicMenu.qml
new file mode 100644
index 000000000..c3d16f5ba
--- /dev/null
+++ b/tests/ui/modules/Common/Popup/DropDownDynamicMenu.qml
@@ -0,0 +1,12 @@
+AbstractDropDownMenu {
+ property int entryHeight
+ property int maxMenuHeight
+
+ function _computeHeight () {
+ var model = _content[0].model
+ var height = model.count * entryHeight
+ return (maxMenuHeight !== undefined && height > maxMenuHeight)
+ ? maxMenuHeight
+ : height
+ }
+}
diff --git a/tests/ui/modules/Common/Popup/DropDownMenu.qml b/tests/ui/modules/Common/Popup/DropDownMenu.qml
index 4070563ad..7bc57f005 100644
--- a/tests/ui/modules/Common/Popup/DropDownMenu.qml
+++ b/tests/ui/modules/Common/Popup/DropDownMenu.qml
@@ -1,113 +1,5 @@
-import QtQuick 2.7
-
-import Common 1.0
-import Common.Styles 1.0
-import Utils 1.0
-
-// ===================================================================
-// Low component to display a list/menu in a popup.
-// ===================================================================
-
-Rectangle {
- // Attributes used only with a ListView child.
- property int entryHeight
- property int maxMenuHeight
-
- // Optionnal parameter, if defined and if a click is detected
- // on it, menu is not closed.
- property var launcher
-
- // Optionnal parameters, set the position of Menu relative
- // to this item.
- property var relativeTo
- property int relativeX: 0
- property int relativeY: 0
-
- default property alias _content: content.data
-
- signal menuClosed
- signal menuOpened
-
- function isOpen () {
- return visible
- }
-
- function showMenu () {
- if (visible) {
- return
- }
-
- if (relativeTo != null) {
- this.x = relativeTo.mapToItem(null, relativeX, relativeY).x
- this.y = relativeTo.mapToItem(null, relativeX, relativeY).y
- }
-
- visible = true
- menuOpened()
- }
-
- function hideMenu () {
- if (!visible) {
- return
- }
-
- visible = false
- menuClosed()
- }
-
+AbstractDropDownMenu {
function _computeHeight () {
- var model = _content[0].model
- if (model == null || !Utils.qmlTypeof(model, 'QQmlListModel')) {
- return content.height
- }
-
- console.assert(
- entryHeight != null,
- '`entryHeight` must be defined when used with `ListView`.'
- )
-
- var height = model.count * entryHeight
- return (maxMenuHeight !== undefined && height > maxMenuHeight)
- ? maxMenuHeight
- : height
- }
-
- implicitHeight: _computeHeight()
- visible: false
- z: Constants.zPopup
-
- Keys.onEscapePressed: hideMenu()
-
- // Set parent menu to root.
- Component.onCompleted: {
- if (relativeTo != null) {
- parent = Utils.getTopParent(this)
- }
- }
-
- // Menu content.
- Rectangle {
- id: content
-
- anchors.fill: parent
- color: PopupStyle.backgroundColor
-
- layer {
- enabled: true
- effect: PopupShadow {}
- }
- }
-
- // Inverted mouse area to detect click outside menu.
- InvertedMouseArea {
- anchors.fill: parent
- enabled: parent.visible
-
- onPressed: {
- if (launcher != null && pointIsInItem(launcher)) {
- return
- }
- hideMenu()
- }
+ return content.height
}
}
diff --git a/tests/ui/modules/Common/SearchBox.qml b/tests/ui/modules/Common/SearchBox.qml
index e7317a7e2..46af3d2c5 100644
--- a/tests/ui/modules/Common/SearchBox.qml
+++ b/tests/ui/modules/Common/SearchBox.qml
@@ -63,7 +63,7 @@ Item {
}
}
- DropDownMenu {
+ DropDownDynamicMenu {
id: menu
anchors.top: searchField.bottom
diff --git a/tests/ui/modules/Common/qmldir b/tests/ui/modules/Common/qmldir
index 93fd2ba09..1749fe81e 100644
--- a/tests/ui/modules/Common/qmldir
+++ b/tests/ui/modules/Common/qmldir
@@ -55,6 +55,7 @@ Menu 1.0 Menu.qml
Paned 1.0 Paned.qml
# Popup
+DropDownDynamicMenu 1.0 Popup/DropDownDynamicMenu.qml
DropDownMenu 1.0 Popup/DropDownMenu.qml
PopupShadow 1.0 Popup/PopupShadow.qml
diff --git a/tests/ui/modules/Linphone/Call/CallControls.qml b/tests/ui/modules/Linphone/Call/CallControls.qml
index 1e1c8bd63..0ef35568a 100644
--- a/tests/ui/modules/Linphone/Call/CallControls.qml
+++ b/tests/ui/modules/Linphone/Call/CallControls.qml
@@ -52,7 +52,6 @@ RowLayout {
DropDownMenu {
id: menu
- entryHeight: 22
implicitHeight: toto.height
launcher: button
relativeTo: button