Warning, /frameworks/knewstuff/src/qtquick/qml/Dialog.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 /**
0008  * @brief A dialog which has a NewStuff.Page at the base
0009  *
0010  * This component is equivalent to the old DownloadDialog, but you should consider
0011  * using NewStuff.Page instead for a more modern style of integration into your
0012  * application's flow.
0013  * @see KNewStuff::DownloadDialog
0014  * @since 5.63
0015  */
0016 
0017 import QtQuick 2.11
0018 import QtQuick.Window 2.15
0019 import QtQuick.Controls 2.5 as QtControls
0020 import QtQuick.Layouts 1.13 as QtLayouts
0021 
0022 import org.kde.kirigami 2.7 as Kirigami
0023 import org.kde.newstuff 1.85 as NewStuff
0024 
0025 Window {
0026     id: component
0027     width: Math.min(Kirigami.Units.gridUnit * 44, Screen.width)
0028     height: Math.min(Kirigami.Units.gridUnit * 30, Screen.height)
0029 
0030     /**
0031      * The configuration file to use for this button
0032      */
0033     property alias configFile: newStuffPage.configFile
0034 
0035     /**
0036      * Set the text that should appear as the dialog's title. Will be set as
0037      * i18nd("knewstuff5", "Download New %1").
0038      *
0039      * @default The name defined by your knsrc config file
0040      * @note For the sake of consistency, you should NOT override the title property, just set this one
0041      */
0042     property string downloadNewWhat: engine.name
0043     title: component.downloadNewWhat.length > 0 ? i18ndc("knewstuff5", "The dialog title when we know which type of stuff is being requested", "Download New %1", component.downloadNewWhat) : i18ndc("knewstuff5", "A placeholder title used in the dialog when there is no better title available", "Download New Stuff")
0044 
0045     /**
0046      * The engine which handles the content in this dialog
0047      */
0048     property alias engine: newStuffPage.engine
0049 
0050     /**
0051      * The default view mode of the dialog spawned by this button. This should be
0052      * set using the NewStuff.Page.ViewMode enum
0053      * @see NewStuff.Page.ViewMode
0054      */
0055     property alias viewMode: newStuffPage.viewMode
0056 
0057     /**
0058      * emitted when the Hot New Stuff dialog is about to be shown, usually
0059      * as a result of the user having click on the button
0060      */
0061     signal aboutToShowDialog();
0062 
0063     /**
0064      * This forwards the entryEvent from the QtQuick engine
0065      * @see Engine::entryEvent
0066      * @since 5.82
0067      */
0068     signal entryEvent(QtObject entry, int event);
0069     property Connections engineConnections: Connections {
0070         target: engine
0071         function onEntryEvent(entry, event) {
0072             entryEvent(entry, event);
0073         }
0074     }
0075 
0076     /**
0077      * Contains the entries which have been changed.
0078      * @note This is cleared when the dialog is shown, so the changed entries are those
0079      * changed since the dialog was opened most recently (rather than the lifetime
0080      * of the instance of the Dialog component)
0081      * @deprecated Since 5.82, use entryEvent of component.engine instead
0082      */
0083     property alias changedEntries: component.engine.changedEntries
0084 
0085     /**
0086      * Show the details page for a specific entry.
0087      * If you call this function before the engine initialisation has been completed,
0088      * the action itself will be postponed until that has happened.
0089      * @param providerId The provider ID for the entry you wish to show details for
0090      * @param entryId The unique ID for the entry you wish to show details for
0091      * @since 5.79
0092      */
0093     function showEntryDetails(providerId, entryId) {
0094         newStuffPage.showEntryDetails(providerId, entryId);
0095     }
0096 
0097     function open() {
0098         component.visible = true;
0099     }
0100 
0101     onVisibleChanged: {
0102         if (visible === true) {
0103             newStuffPage.engine.engine.revalidateCacheEntries();
0104             newStuffPage.engine.resetChangedEntries();
0105         }
0106     }
0107 
0108     color: Kirigami.Theme.backgroundColor
0109 
0110     NewStuff.DialogContent {
0111         anchors.fill: parent
0112         id: newStuffPage
0113         downloadNewWhat: component.downloadNewWhat
0114         Keys.onEscapePressed: component.close()
0115     }
0116 
0117     Component {
0118         id: uploadPage
0119         NewStuff.UploadPage {
0120             objectName: "uploadPage"
0121             engine: newStuffPage.engine
0122         }
0123     }
0124 }