Improve HMenu/HMenuItem style

This commit is contained in:
miruka
2019-08-21 16:23:22 -04:00
parent ed96409645
commit 437324bd64
6 changed files with 103 additions and 5 deletions

View File

@@ -2,4 +2,28 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
Menu {
id: menu
padding: theme.controls.menu.borderWidth
implicitWidth: {
let result = 0
let leftPadding = 0
let rightPadding = 0
for (let i = 0; i < count; ++i) {
let item = itemAt(i)
result = Math.max(item.contentItem.implicitWidth, result)
leftPadding = Math.max(item.leftPadding, leftPadding)
rightPadding = Math.max(item.rightPadding, rightPadding)
}
return Math.min(
result + leftPadding + rightPadding, theme.minimumSupportedWidth
)
}
background: HRectangle {
color: "transparent"
border.color: theme.controls.menu.border
border.width: theme.controls.menu.borderWidth
}
}

View File

@@ -4,10 +4,10 @@ import QtQuick.Controls 2.12
MenuItem {
id: menuItem
spacing: theme.spacing
leftPadding: spacing / 1.5
rightPadding: spacing / 1.5
topPadding: spacing / 2
bottomPadding: spacing / 2
leftPadding: spacing
rightPadding: spacing
topPadding: spacing / 1.5
bottomPadding: spacing / 1.5
readonly property alias iconItem: contentItem.icon
@@ -23,5 +23,6 @@ MenuItem {
id: contentItem
button: menuItem
buttonTheme: theme.controls.menuItem
label.horizontalAlignment: Label.AlignLeft
}
}