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