Kirigami2

PromptDialog.qml
1 /*
2  SPDX-FileCopyrightText: 2021 Devin Lin <[email protected]>
3  SPDX-License-Identifier: GPL-2.0-or-later
4 */
5 
6 import QtQuick 2.15
7 import QtQuick.Controls 2.15 as QQC2
8 import org.kde.kirigami 2.20 as Kirigami
9 
10 /**
11  * A simple dialog to quickly prompt a user with information,
12  * and possibly perform an action.
13  *
14  * Provides content padding (instead of padding outside of the scroll
15  * area). Also has a default preferredWidth, as well as the `subtitle` property.
16  *
17  * <b>Note:</b> If a `mainItem` is specified, it will replace
18  * the subtitle label, and so the respective property will have no effect.
19  *
20  * @see Dialog
21  * @see MenuDialog
22  *
23  * Example usage:
24  *
25  * @code{.qml}
26  * Kirigami.PromptDialog {
27  * title: "Reset settings?"
28  * subtitle: "The stored settings for the application will be deleted, with the defaults restored."
29  * standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
30  *
31  * onAccepted: console.log("Accepted")
32  * onRejected: console.log("Rejected")
33  * }
34  * @endcode
35  *
36  * Text field prompt dialog:
37  *
38  * @code{.qml}
39  * Kirigami.PromptDialog {
40  * id: textPromptDialog
41  * title: "New Folder"
42  *
43  * standardButtons: Kirigami.Dialog.NoButton
44  * customFooterActions: [
45  * Kirigami.Action {
46  * text: qsTr("Create Folder")
47  * iconName: "dialog-ok"
48  * onTriggered: {
49  * showPassiveNotification("Created");
50  * textPromptDialog.close();
51  * }
52  * },
53  * Kirigami.Action {
54  * text: qsTr("Cancel")
55  * iconName: "dialog-cancel"
56  * onTriggered: {
57  * textPromptDialog.close();
58  * }
59  * }
60  * ]
61  *
62  * QQC2.TextField {
63  * placeholderText: qsTr("Folder name...")
64  * }
65  * }
66  * @endcode
67  *
68  * @inherit Dialog
69  */
70 Kirigami.Dialog {
71  default property alias mainItem: control.contentItem
72 
73  /**
74  * The text to use in the dialog's contents.
75  */
76  property string subtitle
77 
78  /**
79  * The padding around the content, within the scroll area.
80  *
81  * Default is `Kirigami.Units.largeSpacing`.
82  */
83  property real contentPadding: Kirigami.Units.largeSpacing
84 
85  /**
86  * The top padding of the content, within the scroll area.
87  */
88  property real contentTopPadding: contentPadding
89 
90  /**
91  * The bottom padding of the content, within the scroll area.
92  */
93  property real contentBottomPadding: contentPadding
94 
95  /**
96  * The left padding of the content, within the scroll area.
97  */
98  property real contentLeftPadding: contentPadding
99 
100  /**
101  * The right padding of the content, within the scroll area.
102  */
103  property real contentRightPadding: contentPadding
104 
105  padding: 0 // we want content padding, not padding of the scrollview
106  preferredWidth: Kirigami.Units.gridUnit * 18
107 
108  QQC2.Control {
109  id: control
110  topPadding: contentTopPadding
111  bottomPadding: contentBottomPadding
112  leftPadding: contentLeftPadding
113  rightPadding: contentRightPadding
114 
115  contentItem: Kirigami.SelectableLabel {
116  text: subtitle
117  wrapMode: QQC2.Label.Wrap
118  }
119  }
120 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 04:11:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.