mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-20 04:58:09 +00:00
feat(ui): remove DropDownMenu component, create a Popup component instead
This commit is contained in:
parent
f6f32adf97
commit
72d33df1d5
5 changed files with 86 additions and 18 deletions
|
|
@ -231,7 +231,7 @@
|
|||
<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/DropDownMenu.qml</file>
|
||||
<file>ui/modules/Common/Popup/Popup.qml</file>
|
||||
<file>ui/modules/Common/Popup/PopupShadow.qml</file>
|
||||
<file>ui/modules/Common/qmldir</file>
|
||||
<file>ui/modules/Common/Styles/Animations/BusyIndicatorStyle.qml</file>
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
import Utils 1.0
|
||||
|
||||
// =============================================================================
|
||||
// Menu which supports menu like `ActionMenu` or `Menu`.
|
||||
// =============================================================================
|
||||
|
||||
AbstractDropDownMenu {
|
||||
function _computeHeight () {
|
||||
return _content[0].height
|
||||
}
|
||||
}
|
||||
80
linphone-desktop/ui/modules/Common/Popup/Popup.qml
Normal file
80
linphone-desktop/ui/modules/Common/Popup/Popup.qml
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.1 as Controls
|
||||
|
||||
import Utils 1.0
|
||||
|
||||
// =============================================================================
|
||||
|
||||
Item {
|
||||
// Optionnal parameters, set the position of popup relative to this item.
|
||||
property var relativeTo
|
||||
property int relativeX: 0
|
||||
property int relativeY: 0
|
||||
|
||||
default property alias _content: popup.contentItem
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
visible: false
|
||||
|
||||
function show () {
|
||||
if (popup.visible) {
|
||||
return
|
||||
}
|
||||
|
||||
if (relativeTo) {
|
||||
var parent = Utils.getTopParent(this)
|
||||
|
||||
popup.x = Qt.binding(function () {
|
||||
return relativeTo ? relativeTo.mapToItem(null, relativeX, relativeY).x : 0
|
||||
})
|
||||
popup.y = Qt.binding(function () {
|
||||
return relativeTo ? relativeTo.mapToItem(null, relativeX, relativeY).y : 0
|
||||
})
|
||||
} else {
|
||||
popup.x = Qt.binding(function () {
|
||||
return x
|
||||
})
|
||||
popup.y = Qt.binding(function () {
|
||||
return y
|
||||
})
|
||||
}
|
||||
|
||||
popup.open()
|
||||
}
|
||||
|
||||
function hide () {
|
||||
if (!popup.visible) {
|
||||
return
|
||||
}
|
||||
|
||||
popup.x = 0
|
||||
popup.y = 0
|
||||
|
||||
popup.close()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Controls.Popup {
|
||||
id: popup
|
||||
|
||||
background: Rectangle {
|
||||
height: popup.height
|
||||
width: popup.width
|
||||
|
||||
layer {
|
||||
enabled: true
|
||||
effect: PopupShadow {}
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: Column {
|
||||
id: internalData
|
||||
}
|
||||
|
||||
padding: 0
|
||||
|
||||
Component.onCompleted: parent = Utils.getTopParent(this)
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ Paned 1.0 Misc/Paned.qml
|
|||
AbstractDropDownMenu 1.0 Popup/AbstractDropDownMenu.qml
|
||||
DesktopPopup 1.0 Popup/DesktopPopup.qml
|
||||
DropDownDynamicMenu 1.0 Popup/DropDownDynamicMenu.qml
|
||||
DropDownMenu 1.0 Popup/DropDownMenu.qml
|
||||
Popup 1.0 Popup/Popup.qml
|
||||
PopupShadow 1.0 Popup/PopupShadow.qml
|
||||
|
||||
TooltipArea 1.0 Tooltip/TooltipArea.qml
|
||||
|
|
|
|||
|
|
@ -59,13 +59,12 @@ ListView {
|
|||
: 'burger_menu'
|
||||
iconSize: CallsStyle.entry.iconMenuSize
|
||||
|
||||
onClicked: menu.showMenu()
|
||||
onClicked: popup.show()
|
||||
|
||||
DropDownMenu {
|
||||
id: menu
|
||||
Popup {
|
||||
id: popup
|
||||
|
||||
implicitWidth: actionMenu.width
|
||||
launcher: button
|
||||
relativeTo: callControls
|
||||
relativeX: callControls.width
|
||||
|
||||
|
|
@ -82,7 +81,7 @@ ListView {
|
|||
entryName: modelData.name
|
||||
|
||||
onClicked: {
|
||||
menu.hideMenu()
|
||||
popup.hide()
|
||||
params.actions[index].handler()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue