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

KDE's Doxygen guidelines are available online.