Warning, /frameworks/knewstuff/src/qtquick/qml/EntryDetails.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003     SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 /**
0009  * @brief A Kirigami.Page component used for displaying the details for a single entry
0010  *
0011  * This component is equivalent to the details view in the old DownloadDialog
0012  * @see KNewStuff::DownloadDialog
0013  * @since 5.63
0014  */
0015 
0016 import QtQuick
0017 import QtQuick.Controls as QQC2
0018 import QtQuick.Layouts
0019 
0020 import org.kde.kirigami 2 as Kirigami
0021 import org.kde.kcmutils as KCM
0022 import org.kde.newstuff as NewStuff
0023 
0024 import "private" as Private
0025 
0026 KCM.SimpleKCM {
0027     id: component
0028 
0029     property QtObject newStuffModel
0030     property var entry
0031 
0032     property string name
0033     property var author
0034     property alias shortSummary: shortSummaryItem.text
0035     property alias summary: summaryItem.text
0036     property alias previews: screenshotsItem.screenshotsModel
0037     property string homepage
0038     property string donationLink
0039     property int status
0040     property int commentsCount
0041     property int rating
0042     property int downloadCount
0043     property var downloadLinks
0044     property string providerId
0045     property int entryType
0046 
0047     Component.onCompleted: {
0048         updateContents();
0049         newStuffModel.engine.updateEntryContents(component.entry);
0050     }
0051 
0052     Connections {
0053         target: newStuffModel
0054         function onEntryChanged(changedEntry) {
0055             if (entry === changedEntry) {
0056                 updateContents();
0057             }
0058         }
0059     }
0060 
0061     function updateContents() {
0062         component.providerId = entry.providerId;
0063         component.status = entry.status;
0064 
0065         component.author = entry.author;
0066         component.name = entry.name;
0067         component.shortSummary = entry.shortSummary;
0068         component.summary = entry.summary;
0069         component.homepage = entry.homepage;
0070         component.donationLink = entry.donationLink;
0071         component.status = entry.status;
0072         component.commentsCount = entry.numberOfComments;
0073         component.rating = entry.rating;
0074         component.downloadCount = entry.downloadCount;
0075 
0076         const modelIndex = newStuffModel.index(newStuffModel.indexOfEntry(entry), 0);
0077         component.previews = newStuffModel.data(modelIndex, NewStuff.ItemsModel.PreviewsRole);
0078         component.downloadLinks = newStuffModel.data(modelIndex, NewStuff.ItemsModel.DownloadLinksRole);
0079 
0080     }
0081 
0082     NewStuff.DownloadItemsSheet {
0083         id: downloadItemsSheet
0084 
0085         onItemPicked: {
0086             const entryName = newStuffModel.data(newStuffModel.index(entryId, 0), NewStuff.ItemsModel.NameRole);
0087             applicationWindow().showPassiveNotification(i18ndc("knewstuff6", "A passive notification shown when installation of an item is initiated", "Installing %1 from %2", downloadName, entryName), 1500);
0088             newStuffModel.engine.install(component.entry, downloadItemId);
0089         }
0090     }
0091 
0092     Private.ErrorDisplayer {
0093         engine: component.newStuffModel.engine
0094         active: component.isCurrentPage
0095     }
0096 
0097     NewStuff.Author {
0098         id: entryAuthor
0099         engine: component.newStuffModel.engine
0100         providerId: component.providerId
0101         username: author.name
0102     }
0103 
0104     title: i18ndc("knewstuff6", "Combined title for the entry details page made of the name of the entry, and the author's name", "%1 by %2", component.name, entryAuthor.name)
0105 
0106     actions: [
0107         Kirigami.Action {
0108             text: component.downloadLinks.length == 1 ? i18ndc("knewstuff6", "Request installation of this item, available when there is exactly one downloadable item", "Install") : i18ndc("knewstuff6", "Show installation options, where there is more than one downloadable item", "Install…")
0109             icon.name: "install"
0110             onTriggered: {
0111                 if (component.downloadLinks.length == 1) {
0112                     newStuffModel.engine.install(component.entry, NewStuff.ItemsModel.FirstLinkId);
0113                 } else {
0114                     downloadItemsSheet.downloadLinks = component.downloadLinks;
0115                     downloadItemsSheet.entry = component.index;
0116                     downloadItemsSheet.open();
0117                 }
0118             }
0119             enabled: component.status == NewStuff.Entry.Downloadable || component.status == NewStuff.Entry.Deleted
0120             visible: enabled
0121         },
0122         Kirigami.Action {
0123             text: i18ndc("knewstuff6", "Request updating of this item", "Update")
0124             icon.name: "update-none"
0125             onTriggered: newStuffModel.update(component.entry, NewStuff.ItemsModel.AutoDetectLinkId)
0126             enabled: component.status == NewStuff.Entry.Updateable
0127             visible: enabled
0128         },
0129         Kirigami.Action {
0130             text: i18ndc("knewstuff6", "Request uninstallation of this item", "Uninstall")
0131             icon.name: "edit-delete"
0132             onTriggered: newStuffModel.engine.uninstall(component.entry)
0133             enabled: component.status == NewStuff.Entry.Installed || component.status == NewStuff.Entry.Updateable
0134             visible: enabled
0135         }
0136     ]
0137 
0138     ColumnLayout {
0139         spacing: Kirigami.Units.smallSpacing
0140 
0141         Kirigami.AbstractCard {
0142             id: statusCard
0143 
0144             readonly property string message: {
0145                 switch (component.status) {
0146                 case NewStuff.Entry.Downloadable:
0147                 case NewStuff.Entry.Installed:
0148                 case NewStuff.Entry.Updateable:
0149                 case NewStuff.Entry.Deleted:
0150                     return "";
0151                 case NewStuff.Entry.Installing:
0152                     return i18ndc("knewstuff6", "Status message to be shown when the entry is in the process of being installed OR uninstalled", "Currently working on the item %1 by %2. Please wait…", component.name, entryAuthor.name);
0153                 case NewStuff.Entry.Updating:
0154                     return i18ndc("knewstuff6", "Status message to be shown when the entry is in the process of being updated", "Currently updating the item %1 by %2. Please wait…", component.name, entryAuthor.name);
0155                 default:
0156                     return i18ndc("knewstuff6", "Status message which should only be shown when the entry has been given some unknown or invalid status.", "This item is currently in an invalid or unknown state. <a href=\"https://bugs.kde.org/enter_bug.cgi?product=frameworks-knewstuff\">Please report this to the KDE Community in a bug report</a>.");
0157                 }
0158             }
0159 
0160             visible: opacity > 0
0161             opacity: message.length > 0 ? 1 : 0
0162 
0163             Behavior on opacity {
0164                 NumberAnimation {
0165                     duration: Kirigami.Units.longDuration
0166                 }
0167             }
0168 
0169             Layout.fillWidth: true
0170             Layout.margins: Kirigami.Units.largeSpacing
0171 
0172             contentItem: RowLayout {
0173                 Layout.fillWidth: true
0174                 spacing: Kirigami.Units.smallSpacing
0175 
0176                 QQC2.Label {
0177                     Layout.fillWidth: true
0178                     text: statusCard.message
0179                     wrapMode: Text.Wrap
0180                     onLinkActivated: Qt.openUrlExternally(link);
0181                 }
0182 
0183                 QQC2.BusyIndicator {
0184                     running: statusCard.opacity > 0
0185                 }
0186             }
0187         }
0188 
0189         Item {
0190             Layout.fillWidth: true
0191             height: Kirigami.Units.gridUnit * 3
0192         }
0193 
0194         Private.EntryScreenshots {
0195             id: screenshotsItem
0196             Layout.fillWidth: true
0197         }
0198 
0199         Kirigami.Heading {
0200             id: shortSummaryItem
0201             wrapMode: Text.Wrap
0202             Layout.fillWidth: true
0203         }
0204 
0205         Kirigami.FormLayout {
0206             Layout.fillWidth: true
0207 
0208             Kirigami.LinkButton {
0209                 Kirigami.FormData.label: i18nd("knewstuff6", "Comments and Reviews:")
0210                 enabled: component.commentsCount > 0
0211                 text: i18ndc("knewstuff6", "A link which, when clicked, opens a new sub page with comments (comments with or without ratings) for this entry", "%1 Reviews and Comments", component.commentsCount)
0212                 onClicked: pageStack.push(commentsPage)
0213             }
0214 
0215             Private.Rating {
0216                 id: ratingsItem
0217                 Kirigami.FormData.label: i18nd("knewstuff6", "Rating:")
0218                 rating: component.rating
0219             }
0220 
0221             Kirigami.UrlButton {
0222                 Kirigami.FormData.label: i18nd("knewstuff6", "Homepage:")
0223                 text: i18ndc("knewstuff6", "A link which, when clicked, opens the website associated with the entry (this could be either one specific to the project, the author's homepage, or any other website they have chosen for the purpose)", "Open the homepage for %1", component.name)
0224                 url: component.homepage
0225                 visible: component.homepage
0226             }
0227 
0228             Kirigami.UrlButton {
0229                 Kirigami.FormData.label: i18nd("knewstuff6", "How To Donate:")
0230                 text: i18ndc("knewstuff6", "A link which, when clicked, opens a website with information on donation in support of the entry", "Find out how to donate to this project")
0231                 url: component.donationLink
0232                 visible: component.donationLink
0233             }
0234         }
0235 
0236         Kirigami.SelectableLabel {
0237             id: summaryItem
0238 
0239             Layout.fillWidth: true
0240             Layout.margins: Kirigami.Units.largeSpacing
0241 
0242             textFormat: Text.RichText
0243         }
0244 
0245         Component {
0246             id: commentsPage
0247 
0248             Private.EntryCommentsPage {
0249                 itemsModel: component.newStuffModel
0250                 entry: component.entry
0251                 entryName: component.name
0252                 entryAuthorId: component.author.name
0253                 entryProviderId: component.providerId
0254             }
0255         }
0256     }
0257 }