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.kcmutils as KCM
28import org.kde.kirigami 2 as Kirigami
29import org.kde.newstuff as NewStuff
30
31import "private" as Private
32
33Kirigami.ScrollablePage {
34 id: component
35
36 /**
37 * The NewStuffQuick Engine instance used to display content for this item.
38 * You can either pass in one that has already been set up (such as from a
39 * NewStuff.Page or NewStuff.Dialog), or you can construct a new one yourself,
40 * simply by doing something like this (which will use the wallpapers configuration):
41 \code
42 NewStuff.UploadPage {
43 engine: NewStuff.Engine {
44 configFile: "wallpapers.knsrc"
45 }
46 }
47 \endcode
48 */
49 required property QtObject engine
50
51 title: i18nc("@knewstuff6", "Upload New Stuff: %1", component.engine.name)
52
54
55 Private.ErrorDisplayer {
56 engine: component.engine
57 active: component.isCurrentPage
58 }
59
60 ColumnLayout {
61 Layout.fillWidth: true
62 spacing: Kirigami.Units.smallSpacing
63
64 Item {
65 Layout.fillWidth: true
66 Layout.preferredHeight: implicitHeight
67
68 Behavior on Layout.preferredHeight {
70 duration: Kirigami.Units.longDuration
71 easing.type: Easing.InOutQuad
72 }
73 }
74
75 implicitHeight: uploaderBusy.running
76 ? uploaderBusy.height + uploaderBusyInfo.height + Kirigami.Units.largeSpacing * 4
77 : 0
78
79 visible: uploaderBusy.running
80 opacity: uploaderBusy.running ? 1 : 0
81
82 Behavior on opacity {
84 duration: Kirigami.Units.longDuration
85 easing.type: Easing.InOutQuad
86 }
87 }
88
89 QQC2.BusyIndicator {
90 id: uploaderBusy
91
92 anchors {
93 horizontalCenter: parent.horizontalCenter
94 bottom: parent.verticalCenter
95 bottomMargin: Kirigami.Units.largeSpacing
96 }
97 running: component.engine.isLoading && component.engine.isValid
98 }
99
100 QQC2.Label {
101 id: uploaderBusyInfo
102
103 anchors {
104 top: parent.verticalCenter
105 left: parent.left
106 right: parent.right
107 margins: Kirigami.Units.largeSpacing
108 }
109 horizontalAlignment: Text.AlignHCenter
110 text: i18ndc("knewstuff6", "A text shown beside a busy indicator suggesting that data is being fetched", "Updating information…")
111 }
112 }
113
114 Repeater {
115 model: NewStuff.ProvidersModel {
116 engine: component.engine.engine
117 }
118
119 Kirigami.Card {
120 enabled: !uploaderBusy.running
121
122 banner {
123 title: {
124 if (model.name === "api.kde-look.org") {
125 return i18ndc("knewstuff6", "The name of the KDE Store", "KDE Store");
126 } else if (model.name !== "") {
127 return model.name;
128 } else if (component.engine.name !== "") {
129 return component.engine.name;
130 } else {
131 return i18ndc("knewstuff6", "An unnamed provider", "Your Provider");
132 }
133 }
134 titleIcon: model.icon == "" ? "get-hot-new-stuff" : model.icon
135 }
136
137 actions: [
138 Kirigami.Action {
139 visible: model.website != ""
140 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)
141 onTriggered: Qt.openUrlExternally(model.website)
142 },
143
145 visible: model.contactEmail != "" && model.name != "api.kde-look.org"
146 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)
147 onTriggered: Qt.openUrlExternally("mailto:" + model.contactEmail)
148 }
149 ]
150
151 contentItem: QQC2.Label {
152 wrapMode: Text.Wrap
153 text: model.name === "api.kde-look.org"
154 ? 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 .")
155 : 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.")
156 }
157 }
158 }
159 }
160}
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 Tue Mar 26 2024 11:21:35 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.