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     SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 /**
0009  * @brief A dialog which has a NewStuff.Page at the base
0010  *
0011  * This component is equivalent to the old DownloadDialog, but you should consider
0012  * using NewStuff.Page instead for a more modern style of integration into your
0013  * application's flow.
0014  * @see KNewStuff::DownloadDialog
0015  * @since 5.63
0016  */
0017 
0018 import QtQuick
0019 import QtQuick.Window
0020 import org.kde.kirigami 2 as Kirigami
0021 import org.kde.newstuff as NewStuff
0022 
0023 Window {
0024     id: component
0025 
0026     width: Math.min(Kirigami.Units.gridUnit * 44, Screen.width)
0027     height: Math.min(Kirigami.Units.gridUnit * 30, Screen.height)
0028 
0029     /**
0030      * The configuration file to use for this button
0031      */
0032     property alias configFile: newStuffPage.configFile
0033 
0034     /**
0035      * Set the text that should appear as the dialog's title. Will be set as
0036      * i18nd("knewstuff6", "Download New %1").
0037      *
0038      * @default The name defined by your knsrc config file
0039      * @note For the sake of consistency, you should NOT override the title property, just set this one
0040      */
0041     property string downloadNewWhat: engine.name
0042     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")
0043 
0044     /**
0045      * The engine which handles the content in this dialog
0046      */
0047     property alias engine: newStuffPage.engine
0048 
0049     /**
0050      * The default view mode of the dialog spawned by this button. This should be
0051      * set using the NewStuff.Page.ViewMode enum
0052      * @see NewStuff.Page.ViewMode
0053      */
0054     property alias viewMode: newStuffPage.viewMode
0055 
0056     /**
0057      * emitted when the Hot New Stuff dialog is about to be shown, usually
0058      * as a result of the user having click on the button
0059      */
0060     signal aboutToShowDialog()
0061 
0062     /**
0063      * This forwards the entryEvent from the QtQuick engine
0064      * @see Engine::entryEvent
0065      * @since 5.82
0066      */
0067     signal entryEvent(var entry, int event)
0068 
0069     property Connections engineConnections: Connections {
0070         target: component.engine
0071 
0072         function onEntryEvent(entry, event) {
0073             component.entryEvent(entry, event);
0074         }
0075     }
0076 
0077     /**
0078      * Show the details page for a specific entry.
0079      * If you call this function before the engine initialisation has been completed,
0080      * the action itself will be postponed until that has happened.
0081      * @param providerId The provider ID for the entry you wish to show details for
0082      * @param entryId The unique ID for the entry you wish to show details for
0083      * @since 5.79
0084      */
0085     function showEntryDetails(providerId, entryId) {
0086         newStuffPage.__showEntryDetails(providerId, entryId);
0087     }
0088 
0089     function open() {
0090         component.visible = true;
0091     }
0092 
0093     onVisibleChanged: {
0094         if (visible) {
0095             newStuffPage.engine.revalidateCacheEntries();
0096         }
0097     }
0098 
0099     color: Kirigami.Theme.backgroundColor
0100 
0101     NewStuff.DialogContent {
0102         id: newStuffPage
0103         anchors.fill: parent
0104         downloadNewWhat: component.downloadNewWhat
0105         Keys.onEscapePressed: component.close()
0106     }
0107 
0108     Component {
0109         id: uploadPage
0110         NewStuff.UploadPage {
0111             objectName: "uploadPage"
0112             engine: newStuffPage.engine
0113         }
0114     }
0115 }