KNewStuff

Dialog.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 dialog which has a NewStuff.Page at the base
10 *
11 * This component is equivalent to the old DownloadDialog, but you should consider
12 * using NewStuff.Page instead for a more modern style of integration into your
13 * application's flow.
14 * @see KNewStuff::DownloadDialog
15 * @since 5.63
16 */
17
18import QtQuick
19import org.kde.kirigami as Kirigami
20import org.kde.newstuff as NewStuff
21
22Window {
23 id: component
24
25 // Keep in sync with the implicit sizes in DialogContent.qml and the default
26 // size in dialog.cpp
27 width: Math.min(Kirigami.Units.gridUnit * 44, Screen.width)
28 height: Math.min(Kirigami.Units.gridUnit * 30, Screen.height)
29
30 /**
31 * The configuration file to use for this button
32 */
33 property alias configFile: newStuffPage.configFile
34
35 /**
36 * Set the text that should appear as the dialog's title. Will be set as
37 * i18nd("knewstuff6", "Download New %1").
38 *
39 * @default The name defined by your knsrc config file
40 * @note For the sake of consistency, you should NOT override the title property, just set this one
41 */
42 property string downloadNewWhat: engine.name
43 title: component.downloadNewWhat.length > 0
44 ? i18ndc("knewstuff6", "The dialog title when we know which type of stuff is being requested", "Download New %1", component.downloadNewWhat)
45 : i18ndc("knewstuff6", "A placeholder title used in the dialog when there is no better title available", "Download New Stuff")
46
47 /**
48 * The engine which handles the content in this dialog
49 */
50 property alias engine: newStuffPage.engine
51
52 /**
53 * The default view mode of the dialog spawned by this button. This should be
54 * set using the NewStuff.Page.ViewMode enum
55 * @see NewStuff.Page.ViewMode
56 */
57 property alias viewMode: newStuffPage.viewMode
58
59 /**
60 * emitted when the Hot New Stuff dialog is about to be shown, usually
61 * as a result of the user having click on the button
62 */
63 signal aboutToShowDialog()
64
65 /**
66 * This forwards the entryEvent from the QtQuick engine
67 * @see Engine::entryEvent
68 * @since 5.82
69 */
70 signal entryEvent(var entry, int event)
71
72 property Connections engineConnections: Connections {
73 target: component.engine
74
75 function onEntryEvent(entry, event) {
76 component.entryEvent(entry, event);
77 }
78 }
79
80 /**
81 * Show the details page for a specific entry.
82 * If you call this function before the engine initialisation has been completed,
83 * the action itself will be postponed until that has happened.
84 * @param providerId The provider ID for the entry you wish to show details for
85 * @param entryId The unique ID for the entry you wish to show details for
86 * @since 5.79
87 */
88 function showEntryDetails(providerId, entryId) {
89 newStuffPage.__showEntryDetails(providerId, entryId);
90 }
91
92 function open() {
93 component.visible = true;
94 }
95
96 onVisibleChanged: {
97 if (visible) {
98 newStuffPage.engine.revalidateCacheEntries();
99 }
100 }
101
102 color: Kirigami.Theme.backgroundColor
103
104 NewStuff.DialogContent {
105 id: newStuffPage
106 anchors.fill: parent
107 downloadNewWhat: component.downloadNewWhat
108 Keys.onEscapePressed: event => component.close()
109 }
110
111 Component {
112 id: uploadPage
113 NewStuff.UploadPage {
114 objectName: "uploadPage"
115 engine: newStuffPage.engine
116 }
117 }
118}
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
const QList< QKeySequence > & open()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:20:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.