Kirigami-addons

FormCardDialog.qml
1// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4import QtQuick
5import QtQuick.Controls as QQC2
6import QtQuick.Layouts
7
8import org.kde.kirigami as Kirigami
9import org.kde.kirigamiaddons.components as Components
10import org.kde.kirigamiaddons.formcard as FormCard
11
12/**
13 * A dialog designed to use FormCard delegates as it's content.
14 *
15 * \code{.qml}
16 * import org.kde.kirigamiaddons.formcard as FormCard
17 * import QtQuick.Controls
18 *
19 * FormCard.FormCardDialog {
20 * title: "Add Thingy"
21 *
22 * standardButtons: Dialog.Ok | Dialog.Cancel
23 * FormCard.FormTextFieldDelegate {
24 * label: i18nc("@label:textbox Notebook name", "Name:")
25 * }
26 *
27 * FormCard.FormDelegateSeparator {}
28 *
29 * FormCard.FormButtonDelegate {
30 * text: i18nc("@action:button", "Color")
31 * icon.name: "color-picker"
32 * }
33 *
34 * FormCard.FormDelegateSeparator {}
35 *
36 * FormCard.FormButtonDelegate {
37 * text: i18nc("@action:button", "Icon")
38 * icon.name: "preferences-desktop-emoticons"
39 * }
40 * }
41 * \endcode{}
42 *
43 * \image html formcarddialog.png
44 *
45 * \since 1.1.0
46 */
47QQC2.Dialog {
48 id: root
49
50 default property alias content: columnLayout.data
51
52 x: Math.round((parent.width - width) / 2)
53 y: Math.round((parent.height - height) / 2)
54 z: Kirigami.OverlayZStacking.z
55
56 background: Components.DialogRoundedBackground {}
57
58 parent: applicationWindow().QQC2.Overlay.overlay
59
60 implicitWidth: Math.min(parent.width - Kirigami.Units.gridUnit * 2, Kirigami.Units.gridUnit * 15)
61
62 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
63 contentHeight + topPadding + bottomPadding
64 + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
65 + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0))
66
67 modal: true
68 focus: true
69
70 padding: 0
71
72 header: Kirigami.Heading {
73 text: root.title
74 elide: QQC2.Label.ElideRight
75 leftPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
76 rightPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
77 topPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
78 bottomPadding: 0
79 }
80
81 contentItem: ColumnLayout {
82 id: columnLayout
83
84 spacing: 0
85 property int _internal_formcard_margins: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
86 }
87
88 footer: QQC2.DialogButtonBox {
89 leftPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
90 rightPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
91 bottomPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
92 topPadding: Kirigami.Units.smallSpacing
93 spacing: Kirigami.Units.mediumSpacing
94
95 standardButtons: root.standardButtons
96 }
97}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:54:39 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.