AddonsView.qml 1.95 KB
Newer Older
1
import QtQuick 2.1
2
import QtQuick.Controls 2.14
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
3
import QtQuick.Layouts 1.1
4
import org.kde.discover 2.0
5
import "navigation.js" as Navigation
6
import org.kde.kirigami 2.14 as Kirigami
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
7

8
Kirigami.OverlaySheet {
9
    id: addonsView
10
11
    parent: applicationWindow().overlay

12
13
    property alias application: addonsModel.application
    property bool isInstalling: false
14
    readonly property alias addonsCount: listview.count
15
    readonly property bool containsAddons: listview.count > 0 || isExtended
16
    readonly property bool isExtended: ResourcesModel.isExtended(application.appstreamId)
17

18
    title: i18n("Addons for %1", application.name)
19

20
    ListView {
21
22
23
24
        id: listview

        implicitWidth: Kirigami.Units.gridUnit * 25

25
        visible: addonsView.containsAddons
26
        enabled: !addonsView.isInstalling
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
27

28
        model: ApplicationAddonsModel { id: addonsModel }
29

30
31
        delegate: Kirigami.CheckableListItem {
            id: listItem
32

33
34
35
36
37
38
39
            enabled: !addonsView.isInstalling

            icon: undefined
            label: model.display
            subtitle: model.toolTip

            checked: model.checked
40

41
            onCheckedChanged: addonsModel.changeState(packageName, listItem.checked)
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
42
        }
43
    }
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
44

45
    footer: RowLayout {
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
46

47
        readonly property bool active: addonsModel.hasChanges && !addonsView.isInstalling
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
48

49
        Button {
50
            text: i18n("More…")
51
            visible: application.appstreamId.length>0 && addonsView.isExtended
52
            onClicked: Navigation.openExtends(application.appstreamId, application.name)
53
        }
54

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
        Item { Layout.fillWidth: true }

        Button {
            icon.name: "dialog-ok"
            text: i18n("Apply Changes")
            onClicked: addonsModel.applyChanges()

            enabled: parent.active
        }
        Button {
            icon.name: "document-revert"
            text: i18n("Reset")
            onClicked: addonsModel.discardChanges()

            enabled: parent.active
70
71
        }
    }
Jonathan Thomas's avatar
Jonathan Thomas committed
72
}