panel: Fix quicksetting delegate width not getting enforced on label

This commit is contained in:
Devin Lin 2021-10-16 12:46:36 -04:00 committed by Devin Lin
parent 1eb7965fca
commit e168b2bdb6
2 changed files with 9 additions and 5 deletions

View file

@ -27,12 +27,15 @@ ColumnLayout {
required property var toggleFunction
property alias labelOpacity: label.opacity
required property real boundingWidth
property color disabledButtonColor: PlasmaCore.Theme.backgroundColor
property color disabledPressedButtonColor: Qt.darker(disabledButtonColor, 1.1)
property color enabledButtonColor: Kirigami.ColorUtils.adjustColor(PlasmaCore.ColorScope.highlightColor, {"alpha": 0.4*255})
property color enabledPressedButtonColor: Kirigami.ColorUtils.adjustColor(PlasmaCore.ColorScope.highlightColor, {"alpha": 0.6*255});
Rectangle {
id: iconButton
Layout.preferredWidth: PlasmaCore.Units.iconSizes.large + PlasmaCore.Units.smallSpacing
Layout.minimumHeight: width
Layout.alignment: Qt.AlignHCenter
@ -95,7 +98,7 @@ ColumnLayout {
PlasmaComponents.Label {
id: label
Layout.maximumWidth: parent.width
Layout.maximumWidth: delegateRoot.boundingWidth - arrow.width - PlasmaCore.Units.smallSpacing * 2
Layout.alignment: Qt.AlignHCenter
text: delegateRoot.text
@ -106,6 +109,7 @@ ColumnLayout {
verticalAlignment: Text.AlignVCenter
PlasmaCore.SvgItem {
id: arrow
anchors {
left: parent.right
verticalCenter: parent.verticalCenter

View file

@ -140,10 +140,10 @@ Item {
delegate: Delegate {
id: delegateItem
required property var modelData
width: root.expandedRatio < 0.4
? Math.max(implicitWidth + PlasmaCore.Units.smallSpacing * 2, flow.width / (flow.columns + 1))
: Math.max(implicitWidth + PlasmaCore.Units.smallSpacing * 2,
(flow.width / (flow.columns + 1)) * (1 - root.expandedRatio) + (flow.width / flow.columns) * root.expandedRatio)
width: Math.max(implicitWidth + PlasmaCore.Units.smallSpacing * 2, boundingWidth)
boundingWidth: root.expandedRatio < 0.4
? flow.width / (flow.columns + 1)
: (flow.width / (flow.columns + 1)) * (1 - root.expandedRatio) + (flow.width / flow.columns) * root.expandedRatio
labelOpacity: y > 0 ? 1 : root.expandedRatio
opacity: y <= 0 ? 1 : root.expandedRatio