Warning, /plasma/plasma-workspace/lookandfeel/sddm-theme/SessionButton.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2016 David Edmundson <davidedmundson@kde.org>
0003     SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 import QtQuick 2.15
0009 
0010 import org.kde.plasma.core 2.0 as PlasmaCore
0011 import org.kde.plasma.components 3.0 as PlasmaComponents
0012 
0013 PlasmaComponents.ToolButton {
0014     id: root
0015 
0016     property int currentIndex: -1
0017 
0018     text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Desktop Session: %1", instantiator.objectAt(currentIndex).text || "")
0019     visible: menu.count > 1
0020 
0021     Component.onCompleted: {
0022         currentIndex = sessionModel.lastIndex
0023     }
0024     checkable: true
0025     checked: menu.opened
0026     onToggled: {
0027         if (checked) {
0028             menu.popup(root, 0, 0)
0029         } else {
0030             menu.dismiss()
0031         }
0032     }
0033 
0034     signal sessionChanged()
0035 
0036     PlasmaComponents.Menu {
0037         PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.NormalColorGroup
0038         PlasmaCore.ColorScope.inherit: false
0039 
0040         id: menu
0041         Instantiator {
0042             id: instantiator
0043             model: sessionModel
0044             onObjectAdded: menu.insertItem(index, object)
0045             onObjectRemoved: menu.removeItem(object)
0046             delegate: PlasmaComponents.MenuItem {
0047                 text: model.name
0048                 onTriggered: {
0049                     root.currentIndex = model.index
0050                     sessionChanged()
0051                 }
0052             }
0053         }
0054     }
0055 }