blob: ad387b51d40be113a3c556572972f94a872b8ace (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
SPDX-FileCopyrightText: 2016 David Edmundson <davidedmundson@kde.org>
SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.15
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kirigami 2.20 as Kirigami
PlasmaComponents.ToolButton {
id: root
property int currentIndex: -1
text: i18nd("plasma-desktop-sddm-theme", "Desktop Session: %1", instantiator.objectAt(currentIndex).text || "")
visible: menu.count > 1
Component.onCompleted: {
currentIndex = sessionModel.lastIndex
}
checkable: true
checked: menu.opened
onToggled: {
if (checked) {
menu.popup(root, 0, 0)
} else {
menu.dismiss()
}
}
signal sessionChanged()
PlasmaComponents.Menu {
Kirigami.Theme.colorSet: Kirigami.Theme.Window
Kirigami.Theme.inherit: false
id: menu
Instantiator {
id: instantiator
model: sessionModel
onObjectAdded: (index, object) => menu.insertItem(index, object)
onObjectRemoved: (index, object) => menu.removeItem(object)
delegate: PlasmaComponents.MenuItem {
text: model.name
onTriggered: {
root.currentIndex = model.index
sessionChanged()
}
}
}
}
}
|