KNewStuff

UploadPage.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
8/**
9 * @brief A Kirigami.Page component used for showing how to upload KNS entries to a service
10 *
11 * This page shows a short guide for uploading new content to the service provided by a KNewStuff
12 * provider. This attempts to use the information available through the provider itself, and
13 * shows a link to the service's web page, and email in case it is not the KDE Store.
14 *
15 * While there are not currently any services which support direct OCS API based uploading of
16 * new content, we still need a way to guide people to how to do this, hence this component's
17 * simplistic nature.
18 *
19 * This component is functionally equivalent to the old UploadDialog
20 * @see KNewStuff::UploadDialog
21 * @since 5.85
22 */
23
24import QtQuick
25import QtQuick.Controls as QQC2
26import QtQuick.Layouts
27import org.kde.kirigami as Kirigami
28import org.kde.newstuff as NewStuff
29
30import "private" as Private
31
32Kirigami.ScrollablePage {
33 id: component
34
35 /**
36 * The NewStuffQuick Engine instance used to display content for this item.
37 * You can either pass in one that has already been set up (such as from a
38 * NewStuff.Page or NewStuff.Dialog), or you can construct a new one yourself,
39 * simply by doing something like this (which will use the wallpapers configuration):
40 \code
41 NewStuff.UploadPage {
42 engine: NewStuff.Engine {
43 configFile: "wallpapers.knsrc"
44 }
45 }
46 \endcode
47 */
48 required property QtObject engine
49
50 title: i18nc("@knewstuff6", "Upload New Stuff: %1", component.engine.name)
51
53 parent: component.QQC2.Overlay.overlay
54 }
55
56 Private.ErrorDisplayer {
57 engine: component.engine
58 active: component.isCurrentPage
59 }
60
61 ColumnLayout {
62 Layout.fillWidth: true
63 spacing: Kirigami.Units.smallSpacing
64
65 Item {
66 Layout.fillWidth: true
67 Layout.preferredHeight: implicitHeight
68
69 Behavior on Layout.preferredHeight {
71 duration: Kirigami.Units.longDuration
72 easing.type: Easing.InOutQuad
73 }
74 }
75
76 implicitHeight: uploaderBusy.running
77 ? uploaderBusy.height + uploaderBusyInfo.height + Kirigami.Units.largeSpacing * 4
78 : 0
79
80 visible: uploaderBusy.running
81 opacity: uploaderBusy.running ? 1 : 0
82
83 Behavior on opacity {
85 duration: Kirigami.Units.longDuration
86 easing.type: Easing.InOutQuad
87 }
88 }
89
90 QQC2.BusyIndicator {
91 id: uploaderBusy
92
93 anchors {
94 horizontalCenter: parent.horizontalCenter
95 bottom: parent.verticalCenter
96 bottomMargin: Kirigami.Units.largeSpacing
97 }
98 running: component.engine.isLoading && component.engine.isValid
99 }
100
101 QQC2.Label {
102 id: uploaderBusyInfo
103
104 anchors {
105 top: parent.verticalCenter
106 left: parent.left
107 right: parent.right
108 margins: Kirigami.Units.largeSpacing
109 }
110 horizontalAlignment: Text.AlignHCenter
111 text: i18ndc("knewstuff6", "A text shown beside a busy indicator suggesting that data is being fetched", "Updating information…")
112 }
113 }
114
115 Repeater {
116 model: NewStuff.ProvidersModel {
117 engine: component.engine
118 }
119
120 Kirigami.Card {
121 enabled: !uploaderBusy.running
122
123 banner {
124 title: {
125 if (model.name === "api.kde-look.org") {
126 return i18ndc("knewstuff6", "The name of the KDE Store", "KDE Store");
127 } else if (model.name !== "") {
128 return model.name;
129 } else if (component.engine.name !== "") {
130 return component.engine.name;
131 } else {
132 return i18ndc("knewstuff6", "An unnamed provider", "Your Provider");
133 }
134 }
135 titleIcon: model.icon.toString() === "" ? "get-hot-new-stuff" : model.icon
136 }
137
138 actions: [
139 Kirigami.Action {
140 visible: model.website !== ""
141 text: i18ndc("knewstuff6", "Text for an action which causes the specified website to be opened using the user's system default browser", "Open Website: %1", model.website)
142 onTriggered: source => {
143 Qt.openUrlExternally(model.website);
144 }
145 },
146
147 Kirigami.Action {
148 visible: model.contactEmail !== "" && model.name !== "api.kde-look.org"
149 text: i18ndc("knewstuff6", "Text for an action which will attempt to send an email using the user's system default email client", "Send Email To: %1", model.contactEmail)
150 onTriggered: source => {
151 Qt.openUrlExternally("mailto:" + model.contactEmail);
152 }
153 }
154 ]
155
156 contentItem: QQC2.Label {
157 wrapMode: Text.Wrap
158 text: model.name === "api.kde-look.org"
159 ? i18ndc("knewstuff6", "A description of how to upload content to a generic provider", "To upload new entries, or to add content to an existing entry on the KDE Store, please open the website and log in. Once you have done this, you will be able to find the My Products entry in the menu which pops up when you click your user icon. Click on this entry to go to the product management system, where you can work on your products.")
160 : i18ndc("knewstuff6", "A description of how to upload content to the KDE Store specifically", "To upload new entries, or to add content to an existing entry, please open the provider's website and follow the instructions there. You will likely need to create a user and log in to a product management system, where you will need to follow the instructions for how to add. Alternatively, you might be required to contact the managers of the site directly to get new content added.")
161 }
162 }
163 }
164 }
165}
A component used to forward questions from KNewStuff's engine to the UI.
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:54:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.