[plasma/plasma-workspace/Plasma/6.7] kcms/cursortheme: CursorTheme/main.qml: Ensure the cursor icons and text fit combobox popup

Akseli Lahtinen <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit c1ce4015b557e3a32c949d110725656eca609582 by Akseli Lahtinen.
Committed on 17/07/2026 at 07:47.
Pushed by akselmo into branch 'Plasma/6.7'.

CursorTheme/main.qml: Ensure the cursor icons and text fit combobox popup

Due to how the cursor sizes are calculated, they're exact
squares, even when the cursor itself looks like a rectangle.

This causes the text being pushed around by the icon bounding
box, even when there is some space.

Remove the unnecessary binding that confuses the popup.
Instead make sure the icon sizes match their actual size.

This patch also fixes some warnings with Unqualified
accesses.

BUG: 521187
(cherry picked from commit 9ff6f9577f0f00919ed9624667e4629e39cb65c3)

M  +2    -0    kcms/cursortheme/kcmcursortheme.cpp
M  +6    -13   kcms/cursortheme/ui/main.qml

https://invent.kde.org/plasma/plasma-workspace/-/commit/c1ce4015b557e3a32c949d110725656eca609582

diff --git a/kcms/cursortheme/kcmcursortheme.cpp b/kcms/cursortheme/kcmcursortheme.cpp
index 1936c2306c..b78dec6305 100644
--- a/kcms/cursortheme/kcmcursortheme.cpp
+++ b/kcms/cursortheme/kcmcursortheme.cpp
@@ -206,9 +206,11 @@ void CursorThemeConfig::updateSizeComboBox()
 
             // insert the items
             m_pixmap = theme->createIcon(0);
+            m_pixmap = m_pixmap.copy(QRegion(m_pixmap.createHeuristicMask(true)).boundingRect());
 
             for (int i : sizes) {
                 m_pixmap = theme->createIcon(i);
+                m_pixmap = m_pixmap.copy(QRegion(m_pixmap.createHeuristicMask(true)).boundingRect());
                 auto *item = new QStandardItem(QIcon(m_pixmap), QString::number(i));
                 item->setData(i);
                 m_sizesModel->appendRow(item);
diff --git a/kcms/cursortheme/ui/main.qml b/kcms/cursortheme/ui/main.qml
index 5e0e4bbc98..44c67e8a0b 100644
--- a/kcms/cursortheme/ui/main.qml
+++ b/kcms/cursortheme/ui/main.qml
@@ -101,9 +101,6 @@ KCM.GridViewKCM {
             displayComponent: QtControls.ComboBox {
                 id: sizeCombo
 
-                property int maxContentWidth: implicitContentWidth
-                popup.width: Math.max(availableWidth, maxContentWidth)
-
                 model: kcm.sizesModel
                 textRole: "display"
                 displayText: i18n("Size: %1", currentText)
@@ -123,18 +120,20 @@ KCM.GridViewKCM {
                 delegate: QtControls.ItemDelegate {
                     id: sizeComboDelegate
 
+                    required property var model
+                    required property var index
                     readonly property int size: parseInt(model.display)
 
-                    width: parent.width
+                    width: ListView.view?.width
                     highlighted: ListView.isCurrentItem
 
                     contentItem: RowLayout {
                         Kirigami.Icon {
-                            source: model.decoration
+                            source: sizeComboDelegate.model.decoration
                             smooth: true
                             // On wayland the cursor size is logical pixels, and on X11 it's physical pixels.
                             property real devicePixelRatio: KWindowSystem.isPlatformWayland ? 1 : Screen.devicePixelRatio
-                            property size iconSize: kcm.iconSizeFromIndex(index)
+                            property size iconSize: kcm.iconSizeFromIndex(sizeComboDelegate.index)
                             Layout.preferredWidth: iconSize.width / devicePixelRatio
                             Layout.preferredHeight: iconSize.height / devicePixelRatio
                             visible: valid && sizeComboDelegate.size > 0
@@ -144,17 +143,11 @@ KCM.GridViewKCM {
                         QtControls.Label {
                             Layout.alignment: Qt.AlignRight
                             color: sizeComboDelegate.highlighted ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
-                            text: i18n("Size: %1", model[sizeCombo.textRole])
+                            text: i18n("Size: %1", sizeComboDelegate.size)
                             textFormat: Text.PlainText
                             elide: Text.ElideRight
                         }
                     }
-                    Binding {
-                        target: sizeCombo
-                        property: "maxContentWidth"
-                        value: implicitWidth
-                        when: index == sizeCombo.count - 1
-                    }
                 }
             }
         },
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.