linphone-desktop/linphone-app/ui/modules/Common/Menus/MenuItem.qml

90 lines
2.4 KiB
QML

import QtQuick 2.7
import QtQuick.Controls 2.2 as Controls
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 iconLayoutDirection : rowArea.layoutDirection
property var menuItemStyle : MenuItemStyle.normal
property alias textWeight : rowText.font.bold
property int offsetTopMargin : 0
property int offsetBottomMargin : 0
height:visible?undefined:0
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:20
Icon{
id: iconArea
visible: icon
width: icon?iconSize:0
Layout.leftMargin:(iconLayoutDirection == Qt.LeftToRight ? menuItemStyle.leftMargin : 0)
Layout.rightMargin:(iconLayoutDirection == Qt.LeftToRight ? 0 : menuItemStyle.rightMargin)
}
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
//leftPadding: menuItemStyle.leftPadding
//rightPadding: menuItemStyle.rightPadding
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
//anchors.top: parent.top
//anchors.bottom : parent.bottom
}
}
hoverEnabled: true
MouseArea{
anchors.fill:parent
propagateComposedEvents:true
acceptedButtons: Qt.NoButton
cursorShape: parent.hovered
? Qt.PointingHandCursor
: Qt.ArrowCursor
}
}