KNewStuff

DownloadItemsSheet.qml
1/*
2 SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk>
3 SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8import QtQuick
9import QtQuick.Controls as QQC2
10import QtQuick.Layouts
11import org.kde.kirigami as Kirigami
12import org.kde.kirigami.delegates as KirigamiDelegates
13import org.kde.newstuff as NewStuff
14
15/**
16 * @brief An overlay sheet for showing a list of download options for one entry
17 *
18 * This is used by the NewStuff.Page component
19 * @since 5.63
20 */
21Kirigami.Dialog {
22 id: component
23
24 property var entry
25
26 // Ensure the dialog does not get too small
27 height: Math.max(Math.round(root.height - (root.height / 4)), Kirigami.Units.gridUnit * 20)
28 width: Math.max(Math.round(root.width - (root.width / 4)), Kirigami.Units.gridUnit * 25)
29
30 property alias downloadLinks: itemsView.model
31
32 signal itemPicked(var entry, int downloadItemId, string downloadName)
33
34 showCloseButton: false
35 title: i18nd("knewstuff6", "Pick Your Installation Option")
36
37 ListView {
38 id: itemsView
39
40 clip: true
41
42 headerPositioning: ListView.InlineHeader
43 header: QQC2.Label {
44 width: ListView.view.width - ListView.view.leftMargin - ListView.view.rightMargin
45 padding: Kirigami.Units.largeSpacing
46
47 text: i18nd("knewstuff6", "Please select the option you wish to install from the list of downloadable items below. If it is unclear which you should chose out of the available options, please contact the author of this item and ask that they clarify this through the naming of the items.")
48 wrapMode: Text.Wrap
49 }
50
51 delegate: QQC2.ItemDelegate {
52 id: delegate
53
54 width: itemsView.width
55
56 icon.name: modelData.icon
57 text: modelData.name
58
59 Kirigami.Theme.useAlternateBackgroundColor: true
60
61 // Don't need a highlight, hover, or pressed effects
62 highlighted: false
63 hoverEnabled: false
64 down: false
65
66 contentItem: RowLayout {
67 spacing: Kirigami.Units.smallSpacing
68
69 // TODO: switch to just IconTitle once it exists, since we don't need
70 // the subtitle here and are only using a Kirigami delegate for the visual
71 // consistency it offers
72 Kirigami.IconTitleSubtitle {
73 Layout.fillWidth: true
74 icon.name: delegate.icon.name
75 title: delegate.text
76 selected: delegate.highlighted
77 wrapMode: Text.WrapAnywhere
78 }
79 QQC2.Label {
80 text: modelData.formattedSize
81 color: delegate.highlighted
82 ? Kirigami.Theme.highlightedTextColor
83 : Kirigami.Theme.textColor
84 }
85 QQC2.ToolButton {
86 id: installButton
87
88 text: i18nd("knewstuff6", "Install")
89 icon.name: "install-symbolic"
90
91 onClicked: {
92 component.close();
93 component.itemPicked(component.entry, modelData.id, modelData.name);
94 }
95 }
96 }
97 }
98 }
99}
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.