Warning, /plasma/discover/discover/qml/BrowsingPage.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 * SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 pragma ComponentBehavior: Bound 0009 0010 import QtQuick 0011 import QtQuick.Controls as QQC2 0012 import QtQuick.Layouts 0013 import org.kde.kirigami as Kirigami 0014 import org.kde.discover as Discover 0015 import org.kde.discover.app as DiscoverApp 0016 0017 DiscoverPage { 0018 id: page 0019 0020 title: i18nc("@title:window the name of a top-level 'home' page", "Home") 0021 objectName: "featured" 0022 0023 actions: window.wideScreen ? [ searchAction ] : [] 0024 0025 header: Item { 0026 height: !message.active ? 0 : message.height + message.anchors.margins 0027 0028 DiscoverInlineMessage { 0029 id: message 0030 0031 anchors { 0032 top: parent.top 0033 left: parent.left 0034 right: parent.right 0035 margins: Kirigami.Units.smallSpacing 0036 } 0037 0038 inlineMessage: Discover.ResourcesModel.inlineMessage 0039 } 0040 } 0041 0042 readonly property bool isHome: true 0043 0044 Kirigami.Theme.colorSet: Kirigami.Theme.Window 0045 Kirigami.Theme.inherit: false 0046 0047 DiscoverApp.FeaturedModel { 0048 id: featuredModel 0049 } 0050 0051 Kirigami.LoadingPlaceholder { 0052 visible: featuredModel.isFetching 0053 anchors.centerIn: parent 0054 } 0055 0056 Loader { 0057 active: featuredModel.count === 0 && !featuredModel.isFetching 0058 anchors.centerIn: parent 0059 width: parent.width - (Kirigami.Units.largeSpacing * 4) 0060 sourceComponent: Kirigami.PlaceholderMessage { 0061 readonly property Discover.InlineMessage helpfulError: featuredModel.currentApplicationBackend.explainDysfunction() 0062 0063 icon.name: helpfulError.iconName 0064 text: i18n("Unable to load applications") 0065 explanation: helpfulError.message 0066 0067 Repeater { 0068 model: helpfulError.actions 0069 delegate: QQC2.Button { 0070 id: delegate 0071 0072 required property Discover.DiscoverAction modelData 0073 0074 Layout.alignment: Qt.AlignHCenter 0075 0076 action: ConvertDiscoverAction { 0077 action: delegate.modelData 0078 } 0079 } 0080 } 0081 } 0082 } 0083 0084 signal clearSearch() 0085 0086 Kirigami.CardsLayout { 0087 id: apps 0088 0089 maximumColumns: 4 0090 rowSpacing: Kirigami.Units.gridUnit 0091 columnSpacing: Kirigami.Units.gridUnit 0092 maximumColumnWidth: Kirigami.Units.gridUnit * 6 0093 0094 Kirigami.Heading { 0095 // Need to undo some the row spacing of the parent layout which looks bad here 0096 Layout.bottomMargin: -(apps.rowSpacing / 2) 0097 Layout.columnSpan: apps.columns 0098 Layout.fillWidth: true 0099 text: i18nc("@title:group", "Most Popular") 0100 wrapMode: Text.Wrap 0101 visible: popRep.count > 0 && !featuredModel.isFetching 0102 } 0103 0104 Repeater { 0105 id: popRep 0106 model: DiscoverApp.PaginateModel { 0107 pageSize: apps.maximumColumns * 2 0108 sourceModel: DiscoverApp.OdrsAppsModel { 0109 // filter: FOSS 0110 } 0111 } 0112 delegate: GridApplicationDelegate { visible: !featuredModel.isFetching } 0113 } 0114 0115 Kirigami.Heading { 0116 Layout.topMargin: Kirigami.Units.gridUnit 0117 // Need to undo some the row spacing of the parent layout which looks bad here 0118 Layout.bottomMargin: -(apps.rowSpacing / 2) 0119 Layout.columnSpan: apps.columns 0120 Layout.fillWidth: true 0121 text: i18nc("@title:group", "Newly Published & Recently Updated") 0122 wrapMode: Text.Wrap 0123 visible: recentlyUpdatedRepeater.count > 0 && !featuredModel.isFetching 0124 } 0125 0126 Repeater { 0127 id: recentlyUpdatedRepeater 0128 model: recentlyUpdatedModelInstantiator.object 0129 delegate: GridApplicationDelegate { visible: !featuredModel.isFetching } 0130 } 0131 0132 Instantiator { 0133 id: recentlyUpdatedModelInstantiator 0134 0135 active: { 0136 // TODO: Add packagekit-backend of rolling distros 0137 return [ 0138 "flatpak-backend", 0139 "snap-backend", 0140 ].includes(Discover.ResourcesModel.currentApplicationBackend.name); 0141 } 0142 0143 DiscoverApp.PaginateModel { 0144 pageSize: apps.maximumColumns * 2 0145 sourceModel: Discover.ResourcesProxyModel { 0146 filteredCategoryName: "All Applications" 0147 backendFilter: Discover.ResourcesModel.currentApplicationBackend 0148 sortRole: Discover.ResourcesProxyModel.ReleaseDateRole 0149 sortOrder: Qt.DescendingOrder 0150 } 0151 } 0152 } 0153 0154 Kirigami.Heading { 0155 Layout.topMargin: Kirigami.Units.gridUnit 0156 // Need to undo some the row spacing of the parent layout which looks bad here 0157 Layout.bottomMargin: -(apps.rowSpacing / 2) 0158 Layout.columnSpan: apps.columns 0159 Layout.fillWidth: true 0160 text: i18nc("@title:group", "Editor's Choice") 0161 wrapMode: Text.Wrap 0162 visible: featuredRep.count > 0 && !featuredModel.isFetching 0163 } 0164 0165 Repeater { 0166 id: featuredRep 0167 model: featuredModel 0168 delegate: GridApplicationDelegate { visible: !featuredModel.isFetching } 0169 } 0170 0171 Kirigami.Heading { 0172 Layout.topMargin: Kirigami.Units.gridUnit 0173 // Need to undo some the row spacing of the parent layout which looks bad here 0174 Layout.bottomMargin: -(apps.rowSpacing / 2) 0175 Layout.columnSpan: apps.columns 0176 Layout.fillWidth: true 0177 text: i18nc("@title:group", "Highest-Rated Games") 0178 wrapMode: Text.Wrap 0179 visible: gamesRep.count > 0 && !featuredModel.isFetching 0180 } 0181 0182 Repeater { 0183 id: gamesRep 0184 model: DiscoverApp.PaginateModel { 0185 pageSize: apps.maximumColumns 0186 sourceModel: Discover.ResourcesProxyModel { 0187 filteredCategoryName: "Games" 0188 backendFilter: Discover.ResourcesModel.currentApplicationBackend 0189 sortRole: Discover.ResourcesProxyModel.SortableRatingRole 0190 sortOrder: Qt.DescendingOrder 0191 } 0192 } 0193 delegate: GridApplicationDelegate { visible: !featuredModel.isFetching } 0194 } 0195 0196 QQC2.Button { 0197 text: i18nc("@action:button", "See More") 0198 icon.name: "go-next-view" 0199 Layout.columnSpan: apps.columns 0200 onClicked: Navigation.openCategory(Discover.CategoryModel.findCategoryByName("Games")) 0201 visible: gamesRep.count > 0 && !featuredModel.isFetching 0202 } 0203 0204 Kirigami.Heading { 0205 Layout.topMargin: Kirigami.Units.gridUnit 0206 Layout.columnSpan: apps.columns 0207 Layout.fillWidth: true 0208 text: i18nc("@title:group", "Highest-Rated Developer Tools") 0209 wrapMode: Text.Wrap 0210 visible: devRep.count > 0 && !featuredModel.isFetching 0211 } 0212 0213 Repeater { 0214 id: devRep 0215 model: DiscoverApp.PaginateModel { 0216 pageSize: apps.maximumColumns 0217 sourceModel: Discover.ResourcesProxyModel { 0218 filteredCategoryName: "Developer Tools" 0219 backendFilter: Discover.ResourcesModel.currentApplicationBackend 0220 sortRole: Discover.ResourcesProxyModel.SortableRatingRole 0221 sortOrder: Qt.DescendingOrder 0222 } 0223 } 0224 delegate: GridApplicationDelegate { visible: !featuredModel.isFetching } 0225 } 0226 0227 QQC2.Button { 0228 text: i18nc("@action:button", "See More") 0229 icon.name: "go-next-view" 0230 Layout.columnSpan: apps.columns 0231 onClicked: Navigation.openCategory(Discover.CategoryModel.findCategoryByName("Developer Tools")) 0232 visible: devRep.count > 0 && !featuredModel.isFetching 0233 } 0234 } 0235 }