linphone-desktop/linphone-app/ui/modules/Common/Menus/MenuItem.qml
Julien Wadel 235b5bda7c Fix history titles.
Add an object displayer for javascript variables.
Fix ICS expansion design.
Click on ICS will expand it instead of calling it.
Fix ICS Uri.
2022-06-30 16:43:32 +02:00

103 lines
2.9 KiB
QML

import QtQuick 2.7
import QtQuick.Controls 2.3 as Controls //2.3 for menu property (Qt 5.10)
import QtQuick.Layouts 1.3
import Common 1.0
import Common.Styles 1.0
// =============================================================================
// Using MenuItem.icon doesn't seem to work as of 07/2021
// Workaround : Implement own Icon
Controls.MenuItem {
id: button
property alias iconMenu : iconArea.icon
property alias iconSizeMenu: iconArea.iconSize
property alias iconOverwriteColorMenu: iconArea.overwriteColor
property alias iconLayoutDirection : rowArea.layoutDirection
property var menuItemStyle : MenuItemStyle.normal
onMenuItemStyleChanged: if(!menuItemStyle) menuItemStyle = MenuItemStyle.normal
property alias textWeight : rowText.font.bold
property int offsetTopMargin : 0
property int offsetBottomMargin : 0
height:visible?undefined:0
Component.onCompleted: menu.width = Math.max(menu.width, implicitWidth)
background: Rectangle {
color: button.down
? menuItemStyle.background.color.pressed
: (
button.hovered
? menuItemStyle.background.color.hovered
: menuItemStyle.background.color.normal
)
implicitHeight: button.menuItemStyle.background.height
}
contentItem:RowLayout{
id:rowArea
spacing:10
Item{
Layout.fillHeight: true
Layout.preferredWidth: iconArea.icon?height/rowText.lineCount:0
Layout.leftMargin:(iconLayoutDirection == Qt.LeftToRight ? menuItemStyle.leftMargin : 0)
Layout.rightMargin:(iconLayoutDirection == Qt.LeftToRight ? 0 : menuItemStyle.rightMargin)
Icon{
id: iconArea
visible: icon
anchors.centerIn: parent
iconSize: rowText.contentHeight/rowText.lineCount + 2
overwriteColor: button.enabled
? (button.down
? menuItemStyle.text.color.pressed
: (
button.hovered
? menuItemStyle.text.color.hovered
: menuItemStyle.text.color.normal
))
: menuItemStyle.text.color.disabled
}
}
Text {
id:rowText
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin:(iconLayoutDirection == Qt.LeftToRight ? 0 : menuItemStyle.leftMargin)
Layout.rightMargin:(iconLayoutDirection == Qt.LeftToRight ? menuItemStyle.rightMargin : 0)
color: button.enabled
? (button.down
? menuItemStyle.text.color.pressed
: (
button.hovered
? menuItemStyle.text.color.hovered
: menuItemStyle.text.color.normal
))
: menuItemStyle.text.color.disabled
elide: Text.ElideRight
font {
weight: menuItemStyle.text.weight
pointSize: menuItemStyle.text.pointSize
}
text: button.text
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
}
}
hoverEnabled: true
MouseArea{
anchors.fill:parent
propagateComposedEvents:true
acceptedButtons: Qt.NoButton
cursorShape: parent.hovered
? Qt.PointingHandCursor
: Qt.ArrowCursor
}
}