[plasma/plasma-login-manager] src/frontend/greeter/qml: frontend/greeter: Improve session button appearance and behavior

Oliver Beard <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit b868bb44f6b536522c1372f4f045d8b98842a3ce by Oliver Beard.
Committed on 22/07/2026 at 09:12.
Pushed by olib into branch 'master'.

frontend/greeter: Improve session button appearance and behavior

Use `PC3.ComboBox`, with flat styling, and a custom content item so the label elides rather than clips.

M  +1    -3    src/frontend/greeter/qml/Login.qml
M  +22   -43   src/frontend/greeter/qml/SessionButton.qml

https://invent.kde.org/plasma/plasma-login-manager/-/commit/b868bb44f6b536522c1372f4f045d8b98842a3ce

diff --git a/src/frontend/greeter/qml/Login.qml b/src/frontend/greeter/qml/Login.qml
index a6499e5f..e222c884 100644
--- a/src/frontend/greeter/qml/Login.qml
+++ b/src/frontend/greeter/qml/Login.qml
@@ -95,7 +95,6 @@ SessionManagementScreen {
     }
 
     RowLayout {
-        id: passwordRow
         Layout.fillWidth: true
 
         PlasmaExtras.PasswordField {
@@ -157,8 +156,7 @@ SessionManagementScreen {
     }
 
     SessionButton {
-        id: sessionButton
-        Layout.maximumWidth: passwordRow.width
+        Layout.fillWidth: true
     }
 
     // Synchronise state
diff --git a/src/frontend/greeter/qml/SessionButton.qml b/src/frontend/greeter/qml/SessionButton.qml
index b99c4ea9..95043ae8 100644
--- a/src/frontend/greeter/qml/SessionButton.qml
+++ b/src/frontend/greeter/qml/SessionButton.qml
@@ -1,61 +1,41 @@
 /*
-    SPDX-FileCopyrightText: 2016 David Edmundson <[email protected]>
-    SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <[email protected]>
+    SPDX-FileCopyrightText: 2026 Oliver Beard <[email protected]>
 
     SPDX-License-Identifier: LGPL-2.0-or-later
 */
 
-import QtQuick 2.15
+import QtQuick
+import QtQuick.Controls as QQC2
 
-import org.kde.plasma.components 3.0 as PlasmaComponents
-import org.kde.kirigami 2.20 as Kirigami
+import org.kde.plasma.components as PlasmaComponents
+import org.kde.kirigami as Kirigami
 
 import org.kde.plasma.login as PlasmaLogin
 
-PlasmaComponents.ToolButton {
+PlasmaComponents.ComboBox {
     id: root
 
-    property int currentIndex: PlasmaLogin.GreeterState.sessionIndex
+    model: PlasmaLogin.SessionModel
+    textRole: "display"
 
-    // Count is used as instantiator may not have made items yet
-    text: i18nd("plasma_login", "Desktop Session: %1", instantiator.count > currentIndex ? instantiator.objectAt(currentIndex).text : "")
-    visible: menu.count > 1
+    visible: count > 1
+    flat: true
+    displayText: i18nd("plasma_login", "Desktop Session: %1", currentText)
 
-    checkable: true
-    checked: menu.opened
-    onToggled: {
-        if (checked) {
-            menu.popup(root, 0, 0)
-        } else {
-            menu.dismiss()
-        }
-    }
+    contentItem: QQC2.Label {
+        font: root.font
+        horizontalAlignment: Text.AlignLeft
+        verticalAlignment: Text.AlignVCenter
+        elide: Text.ElideRight
 
-    signal sessionChanged()
-
-    PlasmaComponents.Menu {
-        Kirigami.Theme.colorSet: Kirigami.Theme.Window
-        Kirigami.Theme.inherit: false
+        text: root.displayText
+    }
 
-        id: menu
-        Instantiator {
-            id: instantiator
-            model: PlasmaLogin.SessionModel
-            onObjectAdded: (index, object) => menu.insertItem(index, object)
-            onObjectRemoved: (index, object) => menu.removeItem(object)
-            delegate: PlasmaComponents.MenuItem {
-                PlasmaComponents.ToolTip.text: model.comment
-                PlasmaComponents.ToolTip.visible: hovered
-                PlasmaComponents.ToolTip.delay: Kirigami.Units.toolTipDelay
+    PlasmaComponents.ToolTip.text: currentText
+    PlasmaComponents.ToolTip.visible: hovered && contentItem.truncated && !popup.visible
+    PlasmaComponents.ToolTip.delay: Kirigami.Units.toolTipDelay
 
-                text: model.display
-                onTriggered: {
-                    root.currentIndex = model.index
-                    sessionChanged()
-                }
-            }
-        }
-    }
+    currentIndex: PlasmaLogin.GreeterState.sessionIndex
 
     Connections {
         target: PlasmaLogin.GreeterState
@@ -63,7 +43,6 @@ PlasmaComponents.ToolButton {
         function onSessionIndexChanged() {
             if (root.currentIndex != PlasmaLogin.GreeterState.sessionIndex) {
                 root.currentIndex = PlasmaLogin.GreeterState.sessionIndex;
-                menu.currentIndex = root.currentIndex;
             }
         }
     }
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.