From e168b2bdb675019d49f34118bd599bfeb5936a02 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Sat, 16 Oct 2021 12:46:36 -0400 Subject: [PATCH] panel: Fix quicksetting delegate width not getting enforced on label --- .../panel/package/contents/ui/quicksettings/Delegate.qml | 6 +++++- .../contents/ui/quicksettings/QuickSettingsPanel.qml | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/containments/panel/package/contents/ui/quicksettings/Delegate.qml b/containments/panel/package/contents/ui/quicksettings/Delegate.qml index 80176ae6..debe6dee 100644 --- a/containments/panel/package/contents/ui/quicksettings/Delegate.qml +++ b/containments/panel/package/contents/ui/quicksettings/Delegate.qml @@ -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 diff --git a/containments/panel/package/contents/ui/quicksettings/QuickSettingsPanel.qml b/containments/panel/package/contents/ui/quicksettings/QuickSettingsPanel.qml index 5eaafc5d..53e204e9 100644 --- a/containments/panel/package/contents/ui/quicksettings/QuickSettingsPanel.qml +++ b/containments/panel/package/contents/ui/quicksettings/QuickSettingsPanel.qml @@ -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