Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/qml/NewStuffDialog.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2019 Dan Leinir Turthra Jensen <admin@leinir.dk> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | * later version accepted by the membership of KDE e.V. (or its | ||||
9 | * successor approved by the membership of KDE e.V.), which shall | ||||
10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | * | ||||
12 | * This library is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | * Lesser General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU Lesser General Public | ||||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | * | ||||
20 | */ | ||||
21 | | ||||
22 | /** | ||||
23 | * @brief A dialog which has a NewStuffPage at the base | ||||
24 | * | ||||
25 | * This component is equivalent to the old DownloadDialog, but you should consider | ||||
26 | * using NewStuffPage instead for a more modern style of integration into your | ||||
27 | * application's flow. | ||||
28 | * @see KNewStuff::DownloadDialog | ||||
29 | */ | ||||
30 | | ||||
31 | import QtQuick 2.7 | ||||
32 | import QtQuick.Controls 2.5 as QtControls | ||||
33 | import QtQuick.Dialogs 1.3 as QtDialogs | ||||
34 | import QtQuick.Layouts 1.12 as QtLayouts | ||||
35 | | ||||
36 | QtDialogs.Dialog { | ||||
37 | id: component | ||||
38 | | ||||
39 | /** | ||||
40 | * The configuration file to use for this button | ||||
41 | */ | ||||
42 | property alias configFile: newStuffPage.configFile | ||||
43 | | ||||
44 | /** | ||||
45 | * Set the text that should appear on the button. Will be set as | ||||
46 | * i18n("Download New %1"). The string is also used to give the dialog spawned | ||||
47 | * by clicking the button its title (the same as the button's text). | ||||
48 | * | ||||
49 | * @note For the sake of consistency, you should NOT override the text propety, just set this one | ||||
50 | */ | ||||
51 | property string downloadNewWhat: i18n("Stuff") | ||||
52 | title: i18n("Download New %1").arg(component.downloadNewWhat) | ||||
53 | | ||||
54 | /** | ||||
55 | * The engine which handles the content in this dialog | ||||
56 | */ | ||||
57 | property alias engine: newStuffPage.engine | ||||
58 | | ||||
59 | /** | ||||
60 | * The default view mode of the dialog spawned by this button. This should be | ||||
61 | * set using the NewStuffPage.ViewMode enum | ||||
62 | * @see NewStuffPage.ViewMode | ||||
63 | */ | ||||
64 | property alias viewMode: newStuffPage.viewMode | ||||
65 | | ||||
66 | /** | ||||
67 | * emitted when the Hot New Stuff dialog is about to be shown, usually | ||||
68 | * as a result of the user having click on the button | ||||
69 | */ | ||||
70 | signal aboutToShowDialog(); | ||||
71 | | ||||
72 | /** | ||||
73 | * emitted when the dialog has been closed | ||||
74 | */ | ||||
75 | signal dialogFinished(var changedEntries); | ||||
76 | | ||||
77 | | ||||
78 | contentItem: QtLayouts.ColumnLayout { | ||||
79 | NewStuffDialogContent { | ||||
80 | id: newStuffPage | ||||
81 | QtLayouts.Layout.fillWidth: true | ||||
82 | QtLayouts.Layout.fillHeight: true | ||||
83 | downloadNewWhat: component.downloadNewWhat | ||||
84 | } | ||||
85 | QtControls.DialogButtonBox { | ||||
86 | QtLayouts.Layout.fillWidth: true | ||||
87 | standardButtons: QtControls.DialogButtonBox.Close | ||||
88 | onClicked: { | ||||
89 | newStuffPage.engine.resetChangedEntries(); | ||||
90 | component.close(); | ||||
91 | component.dialogFinished(newStuffPage.engine.changedEntries); | ||||
92 | } | ||||
93 | } | ||||
94 | } | ||||
95 | } |