Warning, /frameworks/kirigami/src/controls/PromptDialog.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2021 Devin Lin <espidev@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 import QtQuick 2.15
0007 import QtQuick.Controls 2.15 as QQC2
0008 import org.kde.kirigami 2.20 as Kirigami
0009 
0010 /**
0011  * A simple dialog to quickly prompt a user with information,
0012  * and possibly perform an action.
0013  *
0014  * Provides content padding (instead of padding outside of the scroll
0015  * area). Also has a default Dialog::preferredWidth, as well as the ::subtitle property.
0016  *
0017  * <b>Note:</b> If a ::mainItem is specified, it will replace
0018  * the ::subtitle label, and so the respective property will have no effect.
0019  *
0020  * Example usage:
0021  * @code{.qml}
0022  * Kirigami.PromptDialog {
0023  *     title: "Reset settings?"
0024  *     subtitle: "The stored settings for the application will be deleted, with the defaults restored."
0025  *     standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
0026  *
0027  *     onAccepted: console.log("Accepted")
0028  *     onRejected: console.log("Rejected")
0029  * }
0030  * @endcode
0031  *
0032  * Text field prompt dialog:
0033  * @code{.qml}
0034  * Kirigami.PromptDialog {
0035  *     id: textPromptDialog
0036  *     title: "New Folder"
0037  *
0038  *     standardButtons: Kirigami.Dialog.NoButton
0039  *     customFooterActions: [
0040  *         Kirigami.Action {
0041  *             text: qsTr("Create Folder")
0042  *             iconName: "dialog-ok"
0043  *             onTriggered: {
0044  *                 showPassiveNotification("Created");
0045  *                 textPromptDialog.close();
0046  *             }
0047  *         },
0048  *         Kirigami.Action {
0049  *             text: qsTr("Cancel")
0050  *             iconName: "dialog-cancel"
0051  *             onTriggered: {
0052  *                 textPromptDialog.close();
0053  *             }
0054  *         }
0055  *     ]
0056  *
0057  *     QQC2.TextField {
0058  *         placeholderText: qsTr("Folder name...")
0059  *     }
0060  * }
0061  * @endcode
0062  * @see kirigami::Dialog
0063  * @see kirigami::MenuDialog
0064  * @see <a href="https://develop.kde.org/hig/components/navigation/dialog">Human Interface Guidelines on Dialogs</a>
0065  * @see <a href="https://develop.kde.org/hig/components/assistance/message">Human Interface Guidelines on Modal Message Dialogs</a>
0066  * @inherit kirigami::Dialog
0067  */
0068 Kirigami.Dialog {
0069     default property alias mainItem: control.contentItem
0070 
0071     /**
0072      * The text to use in the dialog's contents.
0073      */
0074     property string subtitle
0075 
0076     /**
0077      * The padding around the content, within the scroll area.
0078      *
0079      * Default is `Kirigami.Units.largeSpacing`.
0080      */
0081     property real contentPadding: Kirigami.Units.largeSpacing
0082 
0083     /**
0084      * The top padding of the content, within the scroll area.
0085      */
0086     property real contentTopPadding: contentPadding
0087 
0088     /**
0089      * The bottom padding of the content, within the scroll area.
0090      */
0091     property real contentBottomPadding: contentPadding
0092 
0093     /**
0094      * The left padding of the content, within the scroll area.
0095      */
0096     property real contentLeftPadding: contentPadding
0097 
0098     /**
0099      * The right padding of the content, within the scroll area.
0100      */
0101     property real contentRightPadding: contentPadding
0102 
0103     padding: 0 // we want content padding, not padding of the scrollview
0104     preferredWidth: Kirigami.Units.gridUnit * 18
0105 
0106     QQC2.Control {
0107         id: control
0108         topPadding: contentTopPadding
0109         bottomPadding: contentBottomPadding
0110         leftPadding: contentLeftPadding
0111         rightPadding: contentRightPadding
0112 
0113         contentItem: Kirigami.SelectableLabel {
0114             text: subtitle
0115             wrapMode: QQC2.Label.Wrap
0116         }
0117     }
0118 }