Changeset View
Changeset View
Standalone View
Standalone View
discover/qml/SourcesPage.qml
1 | import QtQuick 2.4 | 1 | import QtQuick 2.4 | ||
---|---|---|---|---|---|
2 | import QtQuick.Controls 2.1 | 2 | import QtQuick.Controls 2.1 | ||
3 | import QtQuick.Layouts 1.1 | 3 | import QtQuick.Layouts 1.1 | ||
4 | import org.kde.discover 2.0 | 4 | import org.kde.discover 2.0 | ||
5 | import org.kde.discover.app 1.0 | 5 | import org.kde.discover.app 1.0 | ||
6 | import org.kde.kirigami 2.2 as Kirigami | 6 | import org.kde.kirigami 2.10 as Kirigami | ||
7 | import "navigation.js" as Navigation | 7 | import "navigation.js" as Navigation | ||
8 | 8 | | |||
9 | DiscoverPage { | 9 | DiscoverPage { | ||
10 | id: page | 10 | id: page | ||
11 | clip: true | 11 | clip: true | ||
12 | title: i18n("Sources") | 12 | title: i18n("Sources") | ||
13 | property string search: "" | 13 | property string search: "" | ||
14 | 14 | | |||
15 | background: Rectangle { | 15 | background: Rectangle { | ||
16 | color: Kirigami.Theme.backgroundColor | 16 | color: Kirigami.Theme.backgroundColor | ||
17 | Kirigami.Theme.colorSet: Kirigami.Theme.Window | 17 | Kirigami.Theme.colorSet: Kirigami.Theme.Window | ||
18 | Kirigami.Theme.inherit: false | 18 | Kirigami.Theme.inherit: false | ||
19 | } | 19 | } | ||
20 | 20 | | |||
21 | mainItem: ListView { | 21 | mainItem: ListView { | ||
22 | id: sourcesView | 22 | id: sourcesView | ||
23 | model: QSortFilterProxyModel { | 23 | model: QSortFilterProxyModel { | ||
24 | filterRegExp: new RegExp(page.search, 'i') | 24 | filterRegExp: new RegExp(page.search, 'i') | ||
25 | dynamicSortFilter: false //We don't want to sort, as sorting can have some semantics on some backends | 25 | dynamicSortFilter: false //We don't want to sort, as sorting can have some semantics on some backends | ||
26 | sourceModel: SourcesModel | 26 | sourceModel: SourcesModel | ||
27 | } | 27 | } | ||
28 | currentIndex: -1 | 28 | currentIndex: -1 | ||
29 | 29 | | |||
30 | section.property: "sourceName" | 30 | section.property: "sourceName" | ||
31 | section.delegate: Kirigami.AbstractListItem { | 31 | section.delegate: Kirigami.ListSectionHeader { | ||
32 | id: backendItem | 32 | id: backendItem | ||
33 | hoverEnabled: false | 33 | | ||
34 | supportsMouseEvents: false | | |||
35 | readonly property QtObject backend: SourcesModel.sourcesBackendByName(section) | 34 | readonly property QtObject backend: SourcesModel.sourcesBackendByName(section) | ||
36 | readonly property QtObject resourcesBackend: backend.resourcesBackend | 35 | readonly property QtObject resourcesBackend: backend.resourcesBackend | ||
37 | readonly property bool isDefault: ResourcesModel.currentApplicationBackend === resourcesBackend | 36 | readonly property bool isDefault: ResourcesModel.currentApplicationBackend === resourcesBackend | ||
38 | 37 | | |||
38 | width: sourcesView.width | ||||
39 | label: backendItem.isDefault ? i18n("%1 (Default)", resourcesBackend.displayName) : resourcesBackend.displayName | ||||
40 | | ||||
41 | customItems: [ | ||||
39 | RowLayout { | 42 | RowLayout { | ||
40 | id: sourceTitleLayout | 43 | id: sourceTitleLayout | ||
41 | Layout.fillHeight: true | | |||
42 | Connections { | 44 | Connections { | ||
43 | target: backendItem.backend | 45 | target: backendItem.backend | ||
44 | onPassiveMessage: window.showPassiveNotification(message) | 46 | onPassiveMessage: window.showPassiveNotification(message) | ||
45 | onProceedRequest: { | 47 | onProceedRequest: { | ||
46 | var dialog = sourceProceedDialog.createObject(window, {sourcesBackend: backendItem.backend, title: title, description: description}) | 48 | var dialog = sourceProceedDialog.createObject(window, {sourcesBackend: backendItem.backend, title: title, description: description}) | ||
47 | dialog.open() | 49 | dialog.open() | ||
48 | } | 50 | } | ||
49 | } | 51 | } | ||
50 | 52 | | |||
51 | Kirigami.Heading { | | |||
52 | Layout.fillWidth: true | | |||
53 | Layout.leftMargin: Kirigami.Units.smallSpacing | | |||
54 | Layout.alignment: Qt.AlignVCenter | | |||
55 | text: backendItem.isDefault ? i18n("%1 (Default)", resourcesBackend.displayName) : resourcesBackend.displayName | | |||
56 | level: 3 | | |||
57 | } | | |||
58 | | ||||
59 | Instantiator { | 53 | Instantiator { | ||
60 | id: backendActionsInst | 54 | id: backendActionsInst | ||
61 | model: ActionsModel { | 55 | model: ActionsModel { | ||
62 | actions: backendItem.backend ? backendItem.backend.actions : undefined | 56 | actions: backendItem.backend ? backendItem.backend.actions : undefined | ||
63 | } | 57 | } | ||
64 | delegate: Button { | 58 | delegate: Button { | ||
65 | parent: sourceTitleLayout | 59 | parent: sourceTitleLayout | ||
66 | Layout.column: 1 | 60 | Layout.column: 1 | ||
Show All 33 Lines | 93 | Button { | |||
100 | visible: resourcesBackend && resourcesBackend.hasApplications | 94 | visible: resourcesBackend && resourcesBackend.hasApplications | ||
101 | 95 | | |||
102 | enabled: !backendItem.isDefault | 96 | enabled: !backendItem.isDefault | ||
103 | text: i18n("Make default") | 97 | text: i18n("Make default") | ||
104 | icon.name: "favorite" | 98 | icon.name: "favorite" | ||
105 | onClicked: ResourcesModel.currentApplicationBackend = backendItem.backend.resourcesBackend | 99 | onClicked: ResourcesModel.currentApplicationBackend = backendItem.backend.resourcesBackend | ||
106 | } | 100 | } | ||
107 | } | 101 | } | ||
102 | ] | ||||
108 | } | 103 | } | ||
109 | 104 | | |||
110 | Component { | 105 | Component { | ||
111 | id: sourceProceedDialog | 106 | id: sourceProceedDialog | ||
112 | Kirigami.OverlaySheet { | 107 | Kirigami.OverlaySheet { | ||
113 | id: sheet | 108 | id: sheet | ||
114 | showCloseButton: false | 109 | showCloseButton: false | ||
115 | property QtObject sourcesBackend | 110 | property QtObject sourcesBackend | ||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |