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 import QtQuick 2.15
0009 import QtQuick.Controls 2.4
0010 import QtQuick.Layouts 1.1
0011 import QtQml.Models 2.15
0012 import org.kde.discover 2.0
0013 import org.kde.discover.app 1.0
0014 import "navigation.js" as Navigation
0015 import org.kde.kirigami 2.19 as Kirigami
0016 
0017 DiscoverPage
0018 {
0019     id: page
0020     title: i18n("Discover")
0021     objectName: "featured"
0022 
0023     actions.main: window.wideScreen ? searchAction : null
0024 
0025     header: Item {
0026         height: 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: ResourcesModel.inlineMessage
0039         }
0040     }
0041 
0042     readonly property bool isHome: true
0043 
0044     function searchFor(text) {
0045         if (text.length === 0)
0046             return;
0047         Navigation.openCategory(null, "")
0048     }
0049 
0050     Kirigami.LoadingPlaceholder {
0051         visible: featuredModel.isFetching
0052         anchors.centerIn: parent
0053     }
0054 
0055     Loader {
0056         active: featuredModel.count === 0 && !featuredModel.isFetching
0057         anchors.centerIn: parent
0058         width: parent.width - (Kirigami.Units.largeSpacing * 4)
0059         sourceComponent: Kirigami.PlaceholderMessage {
0060             readonly property var helpfulError: featuredModel.currentApplicationBackend.explainDysfunction()
0061             icon.name: helpfulError.iconName
0062             text: i18n("Unable to load applications")
0063             explanation: helpfulError.message
0064 
0065             Repeater {
0066                 model: helpfulError.actions
0067                 delegate: Button {
0068                     Layout.alignment: Qt.AlignHCenter
0069                     action: ConvertDiscoverAction {
0070                         action: modelData
0071                     }
0072                 }
0073             }
0074         }
0075     }
0076 
0077     signal clearSearch()
0078 
0079     readonly property bool compact: page.width < 550 || !applicationWindow().wideScreen
0080 
0081     footer: ColumnLayout {
0082         spacing: 0
0083 
0084         Kirigami.Separator {
0085             Layout.fillWidth: true
0086             visible: Kirigami.Settings.isMobile && inlineMessage.visible
0087         }
0088     }
0089 
0090     Kirigami.CardsLayout {
0091         id: apps
0092         maximumColumns: 4
0093         rowSpacing: Kirigami.Units.largeSpacing
0094         columnSpacing: Kirigami.Units.largeSpacing
0095 
0096         maximumColumnWidth: Kirigami.Units.gridUnit * 6
0097         Layout.preferredWidth: Math.max(maximumColumnWidth, Math.min((width / columns) - columnSpacing))
0098 
0099         Kirigami.Heading {
0100             Layout.columnSpan: apps.columns
0101             text: i18nc("@title:group", "Most Popular")
0102             visible: popRep.count > 0 && !featuredModel.isFetching
0103         }
0104 
0105         Repeater {
0106             id: popRep
0107             model: PaginateModel {
0108                 pageSize: apps.maximumColumns * 2
0109                 sourceModel: OdrsAppsModel {
0110                     // filter: FOSS
0111                 }
0112             }
0113             delegate: GridApplicationDelegate { visible: !featuredModel.isFetching }
0114         }
0115 
0116         Kirigami.Heading {
0117             Layout.topMargin: Kirigami.Units.largeSpacing * 5
0118             Layout.columnSpan: apps.columns
0119             text: i18nc("@title:group", "Editor's Choice")
0120             visible: !featuredModel.isFetching
0121         }
0122 
0123         Repeater {
0124             model: FeaturedModel {
0125                 id: featuredModel
0126             }
0127             delegate: GridApplicationDelegate { visible: !featuredModel.isFetching }
0128         }
0129 
0130         Kirigami.Heading {
0131             Layout.topMargin: Kirigami.Units.largeSpacing * 5
0132             Layout.columnSpan: apps.columns
0133             text: i18nc("@title:group", "Highest-Rated Games")
0134             visible: gamesRep.count > 0 && !featuredModel.isFetching
0135         }
0136 
0137         Repeater {
0138             id: gamesRep
0139             model: PaginateModel {
0140                 pageSize: apps.maximumColumns
0141                 sourceModel: ResourcesProxyModel {
0142                     filteredCategoryName: "Games"
0143                     backendFilter: ResourcesModel.currentApplicationBackend
0144                     sortRole: ResourcesProxyModel.SortableRatingRole
0145                     sortOrder: Qt.DescendingOrder
0146                 }
0147             }
0148             delegate: GridApplicationDelegate { visible: !featuredModel.isFetching }
0149         }
0150 
0151         Button {
0152             text: i18nc("@action:button", "See More")
0153             icon.name: "go-next-view"
0154             Layout.columnSpan: apps.columns
0155             onClicked: Navigation.openCategory(CategoryModel.findCategoryByName("Games"))
0156             visible: gamesRep.count > 0 && !featuredModel.isFetching
0157         }
0158 
0159         Kirigami.Heading {
0160             Layout.topMargin: Kirigami.Units.largeSpacing * 5
0161             Layout.columnSpan: apps.columns
0162             text: i18nc("@title:group", "Highest-Rated Developer Tools")
0163             visible: devRep.count > 0 && !featuredModel.isFetching
0164         }
0165 
0166         Repeater {
0167             id: devRep
0168             model: PaginateModel {
0169                 pageSize: apps.maximumColumns
0170                 sourceModel: ResourcesProxyModel {
0171                     filteredCategoryName: "Developer Tools"
0172                     backendFilter: ResourcesModel.currentApplicationBackend
0173                     sortRole: ResourcesProxyModel.SortableRatingRole
0174                     sortOrder: Qt.DescendingOrder
0175                 }
0176             }
0177             delegate: GridApplicationDelegate { visible: !featuredModel.isFetching }
0178         }
0179 
0180         Button {
0181             text: i18nc("@action:button", "See More")
0182             icon.name: "go-next-view"
0183             Layout.columnSpan: apps.columns
0184             onClicked: Navigation.openCategory(CategoryModel.findCategoryByName("Developer Tools"))
0185             visible: devRep.count > 0 && !featuredModel.isFetching
0186         }
0187     }
0188 }