mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-30 10:29:24 +00:00
97 lines
2.7 KiB
QML
97 lines
2.7 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
|
|
|
|
property color _textColor:
|
|
(button.down
|
|
? menuItemStyle.text.color.pressed
|
|
: (
|
|
button.hovered
|
|
? menuItemStyle.text.color.hovered
|
|
: menuItemStyle.text.color.normal
|
|
))
|
|
|
|
height:visible?undefined:0
|
|
|
|
Component.onCompleted: menu.width = Math.max(menu.width, implicitWidth)
|
|
opacity: enabled ? 1.0 : 0.5
|
|
|
|
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.lineCount > 0 ? rowText.contentHeight/rowText.lineCount + 2 : 0
|
|
overwriteColor: button._textColor
|
|
}
|
|
}
|
|
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._textColor
|
|
|
|
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
|
|
}
|
|
}
|