mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(app): add Menu/ActionMenuEntry
This commit is contained in:
parent
f68e544a2b
commit
a4cfd66774
5 changed files with 66 additions and 51 deletions
|
|
@ -49,6 +49,7 @@
|
|||
<file>ui/modules/Common/Image/Icon.qml</file>
|
||||
<file>ui/modules/Common/Image/RoundedImage.qml</file>
|
||||
<file>ui/modules/Common/InvertedMouseArea.qml</file>
|
||||
<file>ui/modules/Common/Menu/ActionMenuEntry.qml</file>
|
||||
<file>ui/modules/Common/Menu/ActionMenu.qml</file>
|
||||
<file>ui/modules/Common/Menu/Menu.qml</file>
|
||||
<file>ui/modules/Common/Paned.qml</file>
|
||||
|
|
|
|||
|
|
@ -10,51 +10,8 @@ import Common.Styles 1.0
|
|||
ColumnLayout {
|
||||
id: menu
|
||||
|
||||
signal clicked (int entry)
|
||||
|
||||
spacing: ActionMenuStyle.spacing
|
||||
|
||||
property int entryHeight
|
||||
property int entryWidth
|
||||
property var entries
|
||||
|
||||
Repeater {
|
||||
model: entries
|
||||
|
||||
Rectangle {
|
||||
color: mouseArea.pressed
|
||||
? ActionMenuStyle.entry.color.pressed
|
||||
: (mouseArea.containsMouse
|
||||
? ActionMenuStyle.entry.color.hovered
|
||||
: ActionMenuStyle.entry.color.normal
|
||||
)
|
||||
height: menu.entryHeight
|
||||
width: menu.entryWidth
|
||||
|
||||
Text {
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: ActionMenuStyle.entry.leftMargin
|
||||
right: parent.right
|
||||
rightMargin: ActionMenuStyle.entry.rightMargin
|
||||
}
|
||||
|
||||
color: ActionMenuStyle.entry.text.color
|
||||
elide: Text.ElideRight
|
||||
font.pointSize: ActionMenuStyle.entry.text.fontSize
|
||||
height: parent.height
|
||||
text: modelData
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: menu.clicked(index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
48
tests/ui/modules/Common/Menu/ActionMenuEntry.qml
Normal file
48
tests/ui/modules/Common/Menu/ActionMenuEntry.qml
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import QtQuick 2.7
|
||||
|
||||
import Common.Styles 1.0
|
||||
|
||||
// ===================================================================
|
||||
|
||||
Rectangle {
|
||||
id: entry
|
||||
|
||||
property alias text: text.text
|
||||
|
||||
signal clicked
|
||||
|
||||
color: mouseArea.pressed
|
||||
? ActionMenuStyle.entry.color.pressed
|
||||
: (mouseArea.containsMouse
|
||||
? ActionMenuStyle.entry.color.hovered
|
||||
: ActionMenuStyle.entry.color.normal
|
||||
)
|
||||
height: parent.entryHeight
|
||||
width: parent.entryWidth
|
||||
|
||||
Text {
|
||||
id: text
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
leftMargin: ActionMenuStyle.entry.leftMargin
|
||||
right: parent.right
|
||||
rightMargin: ActionMenuStyle.entry.rightMargin
|
||||
}
|
||||
|
||||
color: ActionMenuStyle.entry.text.color
|
||||
elide: Text.ElideRight
|
||||
font.pointSize: ActionMenuStyle.entry.text.fontSize
|
||||
height: parent.height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: entry.clicked
|
||||
}
|
||||
}
|
||||
|
|
@ -50,6 +50,7 @@ InvertedMouseArea 1.0 InvertedMouseArea.qml
|
|||
|
||||
# Menu
|
||||
ActionMenu 1.0 Menu/ActionMenu.qml
|
||||
ActionMenuEntry 1.0 Menu/ActionMenuEntry.qml
|
||||
Menu 1.0 Menu/Menu.qml
|
||||
|
||||
# Paned
|
||||
|
|
|
|||
|
|
@ -62,15 +62,23 @@ RowLayout {
|
|||
|
||||
entryHeight: 22
|
||||
entryWidth: 120
|
||||
entries: [
|
||||
qsTr('acceptAudioCall'),
|
||||
qsTr('acceptVideoCall'),
|
||||
qsTr('hangup')
|
||||
]
|
||||
|
||||
onClicked: {
|
||||
console.log('entry', entry)
|
||||
menu.hideMenu()
|
||||
ActionMenuEntry {
|
||||
text: qsTr('acceptAudioCall')
|
||||
|
||||
onClicked: menu.hideMenu()
|
||||
}
|
||||
|
||||
ActionMenuEntry {
|
||||
text: qsTr('acceptVideoCall')
|
||||
|
||||
onClicked: menu.hideMenu()
|
||||
}
|
||||
|
||||
ActionMenuEntry {
|
||||
text: qsTr('hangup')
|
||||
|
||||
onClicked: menu.hideMenu()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue