File: Services.qml

package info (click to toggle)
kaccounts-providers 4%3A20.12.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 868 kB
  • sloc: cpp: 676; makefile: 3; sh: 3
file content (87 lines) | stat: -rw-r--r-- 2,711 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 *  SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
 *  SPDX-FileCopyrightText: 2019 Rituka Patwal <ritukapatwal21@gmail.com>
 *  SPDX-FileCopyrightText: 2015 Martin Klapetek <mklapetek@kde.org>
 *
 *  SPDX-License-Identifier: LGPL-2.0-or-later
 */

import QtQuick 2.2
import org.kde.kirigami 2.5 as Kirigami
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.5

Kirigami.ScrollablePage {
    id: root
    title: i18n("Services")

    property var disabledServices: []

    ListView {
        model: helper.availableServices

        clip: true

        // Cheap copy of Kirigami.BasicListItem with CheckBox instead of Icon
        delegate: Kirigami.AbstractListItem {
            id: listItem
            highlighted: false
            onClicked: serviceCheck.toggle()

            RowLayout {
                CheckBox {
                    id: serviceCheck
                    Layout.alignment: Qt.AlignVCenter
                    checked: true
                    onCheckedChanged: {
                        if (serviceCheck.checked) {
                            const idx = root.disabledServices.indexOf(modelData.id);
                            if (idx > -1) {
                                root.disabledServices.splice(idx, 1);
                            }
                        } else {
                            root.disabledServices.push(modelData.id);
                        }
                    }
                }

                ColumnLayout {
                    spacing: 0
                    Layout.fillWidth: true
                    Layout.alignment: Qt.AlignVCenter

                    Label {
                        Layout.fillWidth: true
                        text: modelData.name
                        color: listItem.pressed ? listItem.activeTextColor : listItem.textColor
                        elide: Text.ElideRight
                    }

                    Label {
                        Layout.fillWidth: true
                        text: modelData.description
                        color: listItem.pressed ? listItem.activeTextColor : listItem.textColor
                        elide: Text.ElideRight
                        font: Kirigami.Theme.smallFont
                        opacity: 0.7
                        visible: text.length > 0
                    }
                }
            }
        }
    }

    footer: ToolBar {
         RowLayout {
            anchors.fill: parent

            Button {
                text: i18n("Finish")
                Layout.alignment: Qt.AlignRight
                onClicked: {
                    helper.finish(root.disabledServices)
                }
            }
         }
    }
}