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 0007 import QtQuick.Controls as QQC2 0008 import org.kde.kirigami 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 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 * @see Dialog 0021 * @see MenuDialog 0022 * 0023 * Example usage: 0024 * 0025 * @code{.qml} 0026 * Kirigami.PromptDialog { 0027 * title: "Reset settings?" 0028 * subtitle: "The stored settings for the application will be deleted, with the defaults restored." 0029 * standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel 0030 * 0031 * onAccepted: console.log("Accepted") 0032 * onRejected: console.log("Rejected") 0033 * } 0034 * @endcode 0035 * 0036 * Text field prompt dialog: 0037 * 0038 * @code{.qml} 0039 * Kirigami.PromptDialog { 0040 * id: textPromptDialog 0041 * title: "New Folder" 0042 * 0043 * standardButtons: Kirigami.Dialog.NoButton 0044 * customFooterActions: [ 0045 * Kirigami.Action { 0046 * text: qsTr("Create Folder") 0047 * icon.name: "dialog-ok" 0048 * onTriggered: { 0049 * showPassiveNotification("Created"); 0050 * textPromptDialog.close(); 0051 * } 0052 * }, 0053 * Kirigami.Action { 0054 * text: qsTr("Cancel") 0055 * icon.name: "dialog-cancel" 0056 * onTriggered: { 0057 * textPromptDialog.close(); 0058 * } 0059 * } 0060 * ] 0061 * 0062 * QQC2.TextField { 0063 * placeholderText: qsTr("Folder name...") 0064 * } 0065 * } 0066 * @endcode 0067 * 0068 * @inherit Dialog 0069 */ 0070 Kirigami.Dialog { 0071 default property alias mainItem: control.contentItem 0072 0073 /** 0074 * The text to use in the dialog's contents. 0075 */ 0076 property string subtitle 0077 0078 /** 0079 * The padding around the content, within the scroll area. 0080 * 0081 * Default is `Kirigami.Units.largeSpacing`. 0082 */ 0083 property real contentPadding: Kirigami.Units.largeSpacing 0084 0085 /** 0086 * The top padding of the content, within the scroll area. 0087 */ 0088 property real contentTopPadding: contentPadding 0089 0090 /** 0091 * The bottom padding of the content, within the scroll area. 0092 */ 0093 property real contentBottomPadding: contentPadding 0094 0095 /** 0096 * The left padding of the content, within the scroll area. 0097 */ 0098 property real contentLeftPadding: contentPadding 0099 0100 /** 0101 * The right padding of the content, within the scroll area. 0102 */ 0103 property real contentRightPadding: contentPadding 0104 0105 padding: 0 // we want content padding, not padding of the scrollview 0106 preferredWidth: Kirigami.Units.gridUnit * 18 0107 0108 QQC2.Control { 0109 id: control 0110 topPadding: contentTopPadding 0111 bottomPadding: contentBottomPadding 0112 leftPadding: contentLeftPadding 0113 rightPadding: contentRightPadding 0114 0115 contentItem: Kirigami.SelectableLabel { 0116 text: subtitle 0117 wrapMode: QQC2.Label.Wrap 0118 } 0119 } 0120 }