DependenciesButton.qml 1.81 KB
Newer Older
1
/*
2
 *   SPDX-FileCopyrightText: 2018 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
3
 *
4
 *   SPDX-License-Identifier: LGPL-2.0-or-later
5
6
 */

7
import QtQuick 2.8
8
import QtQuick.Controls 2.1
9
import org.kde.kirigami 2.14 as Kirigami
10

11
Kirigami.LinkButton {
12
13
14
    text: i18n("Show Dependencies...")

    onClicked: overlay.open()
15
    visible: view.model.count > 0
16
17
18
19
20
21

    Connections {
        target: resource
        onDependenciesFound: {
            view.model.clear()
            for (var v in dependencies) {
22
                view.model.append(dependencies[v])
23
24
25
26
            }
        }
    }

27
    Kirigami.OverlaySheet {
28
29
        id: overlay

30
31
        parent: applicationWindow().overlay

32
        header: Kirigami.Heading { text: i18n("Dependencies for package: %1", resource.packageName) }
33

34
35
        ListView {
            id: view
36
            implicitWidth: Kirigami.Units.gridUnit * 25
37
            clip: true
38
            model: ListModel {}
39
40
            // FIXME: Workaround for https://bugs.kde.org/show_bug.cgi?id=435546
            headerPositioning: ListView.OverlayHeader
41
42
43
44

            section.property: "packageInfo"
            section.delegate: Kirigami.ListSectionHeader {
                width: view.width
45
                // FIXME: Workaround for https://bugs.kde.org/show_bug.cgi?id=435546
46
47
48
                height: Kirigami.Units.fontMetrics.xHeight * 4
                label: section
            }
49
            delegate: Kirigami.BasicListItem {
50
                width: view.width
51
52
                text: model.packageName
                subtitle: model.packageDescription
53
54
55
56
                // No need to offer a hover/selection effect since these list
                // items are non-interactive and non-selectable
                activeBackgroundColor: "transparent"
                activeTextColor: Kirigami.Theme.textColor
57
58
59
60
            }
        }
    }
}