From 857451a06736ad4f0c5ef9f1bd1f61f4552abac2 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Wed, 11 Feb 2026 17:15:04 +0800 Subject: [PATCH] fix(notification): improve combobox width calculation and styling - Replace fixed width with dynamic calculation based on text content using TextMetrics - Add custom DciIcon indicator for dropdown arrow with proper theming - Adjust padding values for better visual alignment - Constrain max width to 200px to prevent excessive expansion log: improve combobox width calculation and styling bug: PMS-350643 --- panels/notification/plugin/NotifyAction.qml | 28 +++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/panels/notification/plugin/NotifyAction.qml b/panels/notification/plugin/NotifyAction.qml index a39175420..a9e359702 100644 --- a/panels/notification/plugin/NotifyAction.qml +++ b/panels/notification/plugin/NotifyAction.qml @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -141,12 +141,35 @@ Control { Layout.maximumWidth: 200 Layout.alignment: Qt.AlignHCenter sourceComponent: ComboBox { + id: comboBox + padding: 0 + rightPadding: 4 property var expandActions: actions.slice(1) textRole: "text" implicitHeight: 30 - implicitWidth: 160 model: expandActions activeFocusOnTab: false + + TextMetrics { + id: textMetrics + font: comboBox.font + text: comboBox.displayText + } + + implicitWidth: Math.min(200, textMetrics.width + comboBox.padding + comboBox.rightPadding + 28) + + indicator: DciIcon { + x: comboBox.width - width - comboBox.rightPadding + y: comboBox.topPadding + (comboBox.availableHeight - height) / 2 + sourceSize.width: DS.Style.comboBox.iconSize + sourceSize.height: DS.Style.comboBox.iconSize + palette: DTK.makeIconPalette(comboBox.palette) + name: "arrow_ordinary_down" + mode: comboBox.D.ColorSelector.controlState + theme: comboBox.D.ColorSelector.controlTheme + fallbackToQIcon: false + } + Keys.onBacktabPressed: function(event) { // Go back to first action button if (firstActionBtn.enabled) { @@ -164,6 +187,7 @@ Control { } delegate: NotifyActionButton { required property int index + padding: 0 width: parent.width actionData: expandActions[index] activeFocusOnTab: false