17import QtQuick.Controls as QQC2
20import org.kde.kcmutils as KCMUtils
21import org.kde.kirigami as Kirigami
22import org.kde.newstuff as NewStuff
23import org.kde.coreaddons as KCoreAddons
25import "private" as Private
26import "private/entrygriddelegates" as EntryGridDelegates
37 property alias configFile: newStuffEngine.configFile
39 readonly
property alias engine: newStuffEngine
48 property alias showUploadAction: uploadAction.visible
58 function showEntryDetails(providerId, entryId) {
59 _showEntryDetailsThrottle.enabled =
true;
60 _showEntryDetailsThrottle.entry = newStuffEngine. __createEntry(providerId, entryId);
61 if (newStuffEngine.busyState === NewStuff.Engine.Initializing) {
62 _showEntryDetailsThrottle.queryWhenInitialized =
true;
64 _showEntryDetailsThrottle.requestDetails();
70 id: _showEntryDetailsThrottle
71 target: newStuffModel.engine
75 property bool queryWhenInitialized:
false
77 function requestDetails() {
78 newStuffEngine.updateEntryContents(entry);
79 queryWhenInitialized =
false;
82 function onBusyStateChanged() {
83 if (queryWhenInitialized && newStuffEngine.busyState !== NewStuff.Engine.Initializing) {
85 queryWhenInitialized =
false;
89 function onSignalEntryEvent(changedEntry, event) {
90 if (event === NewStuff.Engine.DetailsLoadedEvent && changedEntry === entry) {
92 pageStack.push(detailsPage, {
94 providerId: changedEntry.providerId,
102 id: _restoreSearchState
107 function onCurrentIndexChanged() {
108 if (pageStack.currentIndex === 0) {
109 newStuffEngine.restoreSearch();
110 _restoreSearchState.enabled =
false;
115 property string uninstallLabel:
i18ndc(
"knewstuff6",
"Request uninstallation of this item",
"Uninstall")
116 property
string useLabel: engine.useLabel
118 property
int viewMode:
Page.ViewMode.Tiles
128 Component.onCompleted: {
129 view.currentIndex = -1;
132 title: newStuffEngine.name
134 headerPaddingEnabled:
false
136 readonly
property bool riskyContent: newStuffEngine.contentWarningType === NewStuff.Engine.Executables
137 visible: !loadingOverlay.visible
139 position:
Kirigami.InlineMessage.Position.Header
141 ?
xi18ndc(
"knewstuff6",
"@info displayed as InlineMessage",
"Use caution when accessing user-created content shown here, as it may contain executable code that hasn't been tested by KDE or %1 for safety, stability, or quality.",
KCoreAddons.KOSRelease.name)
142 :
i18ndc(
"knewstuff6",
"@info displayed as InlineMessage",
"User-created content shown here hasn't been tested by KDE or %1 for functionality or quality.",
KCoreAddons.
KOSRelease.
name)
150 parent: root.QQC2.Overlay.overlay
153 Private.ErrorDisplayer {
154 engine: newStuffEngine
155 active: root.isCurrentPage
158 QQC2.ActionGroup { id: viewFilterActionGroup }
159 QQC2.ActionGroup { id: viewSortingActionGroup }
163 visible: newStuffEngine.needsLazyLoadSpinner
164 displayComponent: QQC2.BusyIndicator {
172 if (newStuffEngine.filter === 0) {
173 return i18ndc(
"knewstuff6",
"@action:button opening menu similar to combobox, filter list",
"All");
174 }
else if (newStuffEngine.filter === 1) {
175 return i18ndc(
"knewstuff6",
"@action:button opening menu similar to combobox, filter list",
"Installed");
176 }
else if (newStuffEngine.filter === 2) {
177 return i18ndc(
"knewstuff6",
"@action:button opening menu similar to combobox, filter list",
"Updateable");
183 icon.name:
"view-filter"
186 icon.name:
"package-available"
187 text:
i18ndc(
"knewstuff6",
"@option:radio similar to combobox item, List option which will set the filter to show everything",
"All")
189 checked: newStuffEngine.filter === 0
190 onTriggered: source => {
191 newStuffEngine.filter = 0;
193 QQC2.ActionGroup.group: viewFilterActionGroup
197 icon.name:
"package-installed-updated"
198 text:
i18ndc(
"knewstuff6",
"@option:radio similar to combobox item, List option which will set the filter so only installed items are shown",
"Installed")
200 checked: newStuffEngine.filter === 1
201 onTriggered: source => {
202 newStuffEngine.filter = 1;
204 QQC2.ActionGroup.group: viewFilterActionGroup
208 icon.name:
"package-installed-outdated"
209 text:
i18ndc(
"knewstuff6",
"@option:radio similar to combobox item, List option which will set the filter so only installed items with updates available are shown",
"Updateable")
211 checked: newStuffEngine.filter === 2
212 onTriggered: source => {
213 newStuffEngine.filter = 2;
215 QQC2.ActionGroup.group: viewFilterActionGroup
221 if (newStuffEngine.sortOrder === 0) {
222 return i18ndc(
"knewstuff6",
"@action:button opening menu similar to combobox, filter list",
"Sort: Release date");
223 }
else if (newStuffEngine.sortOrder === 1) {
224 return i18ndc(
"knewstuff6",
"@action:button opening menu similar to combobox, filter list",
"Sort: Name");
225 }
else if (newStuffEngine.sortOrder === 2) {
226 return i18ndc(
"knewstuff6",
"@action:button opening menu similar to combobox, filter list",
"Sort: Rating");
227 }
else if (newStuffEngine.sortOrder === 3) {
228 return i18ndc(
"knewstuff6",
"@action:button opening menu similar to combobox, filter list",
"Sort: Downloads");
233 icon.name:
"view-sort"
236 icon.name:
"sort-name"
237 text:
i18ndc(
"knewstuff6",
"@option:radio in menu, List option which will set the sort order to be alphabetical based on the name",
"Name")
239 checked: newStuffEngine.sortOrder === 1
240 onTriggered: source => {
241 newStuffEngine.sortOrder = 1;
243 QQC2.ActionGroup.group: viewSortingActionGroup
248 text:
i18ndc(
"knewstuff6",
"@option:radio in menu, List option which will set the sort order to based on user ratings",
"Rating")
250 checked: newStuffEngine.sortOrder === 2
251 onTriggered: source => {
252 newStuffEngine.sortOrder = 2;
254 QQC2.ActionGroup.group: viewSortingActionGroup
258 icon.name:
"download"
259 text:
i18ndc(
"knewstuff6",
"@option:radio similar to combobox item, List option which will set the sort order to based on number of downloads",
"Downloads")
261 checked: newStuffEngine.sortOrder === 3
262 onTriggered: source => {
263 newStuffEngine.sortOrder = 3;
265 QQC2.ActionGroup.group: viewSortingActionGroup
269 icon.name:
"change-date-symbolic"
270 text:
i18ndc(
"knewstuff6",
"@option:radio similar to combobox item, List option which will set the sort order to based on when items were most recently updated",
"Release date")
272 checked: newStuffEngine.sortOrder === 0
273 onTriggered: source => {
274 newStuffEngine.sortOrder = 0;
276 QQC2.ActionGroup.group: viewSortingActionGroup
283 text:
i18nd(
"knewstuff6",
"Upload…")
284 tooltip:
i18nd(
"knewstuff6",
"Learn how to add your own hot new stuff to this list")
285 icon.name:
"upload-media"
286 visible: newStuffEngine.uploadEnabled
288 onTriggered: source => {
289 pageStack.push(uploadPage);
294 text:
i18nd(
"knewstuff6",
"Go to…")
296 id: searchModelActions
297 visible: children.length > 0
301 text:
i18nd(
"knewstuff6",
"Search…")
302 icon.name:
"system-search"
303 displayHint:
Kirigami.DisplayHint.KeepVisible
308 enabled: engine.isValid
309 focusSequence:
"Ctrl+F"
310 placeholderText:
i18nd(
"knewstuff6",
"Search…")
311 text: newStuffEngine.searchTerm
314 newStuffEngine.searchTerm = searchField.text;
317 Component.onCompleted: {
318 if (!
Kirigami.InputMethod.willShowOnActive) {
327 id: searchPresetInstatiator
329 model: newStuffEngine.searchPresetModel
332 required
property int index
334 text: model.displayName
335 icon.name: model.iconName
337 onTriggered: source => {
338 const curIndex = newStuffEngine.searchPresetModel.index(index, 0);
339 newStuffEngine.searchPresetModel.loadSearch(curIndex);
343 onObjectAdded: (index, object) => {
344 searchModelActions.children.push(
object);
349 target: newStuffEngine.searchPresetModel
351 function onModelReset() {
352 searchModelActions.children = [];
357 spacing:
Kirigami.Units.smallSpacing
359 visible: visibleChildren.length > 0
360 height: visible ? implicitHeight : 0
363 visible: categoriesCombo.count > 2
364 text:
i18nd(
"knewstuff6",
"Category:")
370 Layout.fillWidth:
true
373 model: newStuffEngine.categories
374 textRole:
"displayName"
376 onCurrentIndexChanged: {
377 newStuffEngine.categoriesFilter = model.data(model.index(currentIndex, 0), NewStuff.CategoriesModel.NameRole);
382 Layout.alignment:
Qt.AlignRight
384 text:
i18nd(
"knewstuff6",
"Contribute Your Own…")
385 icon.name:
"upload-media"
386 visible: newStuffEngine.uploadEnabled && !uploadAction.visible
389 pageStack.push(uploadPage);
394 view.model: NewStuff.ItemsModel {
397 engine: newStuffEngine
400 NewStuff.DownloadItemsSheet {
401 id: downloadItemsSheet
403 parent: root.QQC2.Overlay.overlay
405 onItemPicked: (entry, downloadItemId) => {
406 newStuffModel.engine.installLinkId(entry, downloadItemId);
410 view.implicitCellWidth:
switch (root.viewMode) {
411 case Page.ViewMode.Preview:
412 return Kirigami.Units.gridUnit * 25;
414 case Page.ViewMode.Tiles:
415 case Page.ViewMode.Icons:
417 return Kirigami.Units.gridUnit * 30;
420 view.implicitCellHeight:
switch (root.viewMode) {
421 case Page.ViewMode.Preview:
422 return Kirigami.Units.gridUnit * 25;
424 case Page.ViewMode.Tiles:
425 case Page.ViewMode.Icons:
427 return Math.round(view.implicitCellWidth / 3);
430 view.delegate:
switch (root.viewMode) {
431 case Page.ViewMode.Preview:
432 return bigPreviewDelegate;
434 case Page.ViewMode.Tiles:
435 case Page.ViewMode.Icons:
441 id: bigPreviewDelegate
443 EntryGridDelegates.BigPreviewDelegate { }
449 EntryGridDelegates.TileDelegate {
450 useLabel: root.useLabel
451 uninstallLabel: root.uninstallLabel
458 NewStuff.EntryDetails { }
464 NewStuff.UploadPage {
465 engine: newStuffEngine
474 opacity: newStuffEngine.isLoading && !newStuffEngine.needsLazyLoadSpinner ? 1 : 0
475 Behavior on opacity {
477 duration:
Kirigami.Units.longDuration
485 color:
Kirigami.Theme.backgroundColor
489 anchors.centerIn: parent
490 text: newStuffEngine.busyMessage
KNSCore::EngineBase for interfacing with QML.
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 i18nd(const char *domain, const char *text, const TYPE &arg...)
QString xi18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
Type type(const QSqlDatabase &db)
QString name(StandardAction id)