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

View file

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