6import QtQuick.Controls as QQC2
7import QtQuick.Templates as T
9import org.kde.kirigami as Kirigami
10import org.kde.kirigamiaddons.components as Components
11import org.kde.kirigamiaddons.formcard as FormCard
12import org.kde.kirigamiaddons.delegates as Delegates
39 property int dialogType: Components.MessageDialog.Success
52 property string dontShowAgainName: ''
54 default property alias mainContent: mainLayout.data
56 property string iconName: ''
58 x: Math.round((parent.width - width) / 2)
59 y: Math.round((parent.height - height) / 2)
60 z: Kirigami.OverlayZStacking.z
62 parent: applicationWindow().QQC2.Overlay.overlay
64 width: Math.min(parent.width - Kirigami.Units.gridUnit * 2, Kirigami.Units.gridUnit * 20)
65 height: Math.min(implicitHeight, parent.height - Kirigami.Units.gridUnit * 2, Kirigami.Units.gridUnit * 30)
67 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
68 contentWidth + leftPadding + rightPadding,
71 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
72 contentHeight + topPadding + bottomPadding
73 + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
74 + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0))
76 title: switch (root.dialogType) {
77 case MessageDialog.Success:
78 return i18nc("@title:dialog",
"Success");
80 return i18nc(
"@title:dialog",
"Warning");
82 return i18nc(
"@title:dialog",
"Error");
84 return i18nc(
"@title:dialog",
"Information");
86 return i18nc(
"@title:dialog",
"Warning");
89 padding:
Kirigami.Units.largeSpacing * 2
90 bottomPadding:
Kirigami.Units.largeSpacing
92 property bool _automaticallyClosed:
false
98 function openDialog(): void {
99 if (root.dontShowAgainName) {
100 if (root.standardButtons === QQC2.Dialog.Ok) {
103 root._automaticallyClosed =
true;
106 checkbox.checked =
false;
107 root._automaticallyClosed =
false;
113 root._automaticallyClosed =
true;
122 checkbox.checked =
false;
123 root._automaticallyClosed =
false;
131 if (root.dontShowAgainName && checkbox.checked && !root._automaticallyClosed) {
132 if (root.standardButtons === QQC2.Dialog.Ok) {
141 if (root.dontShowAgainName && checkbox.checked && !root._automaticallyClosed) {
142 if (root.standardButtons === QQC2.Dialog.Ok) {
150 contentItem: GridLayout {
153 columns: root.width >
Kirigami.Units.gridUnit * 18 ? 2 : 1
154 rowSpacing:
Kirigami.Units.largeSpacing
158 if (root.iconName.length > 0) {
161 switch (root.dialogType) {
163 return "data-success";
165 return "data-warning";
169 return "data-information";
171 return "data-warning";
174 Layout.preferredWidth:
Kirigami.Units.iconSizes.huge
175 Layout.preferredHeight:
Kirigami.Units.iconSizes.huge
176 Layout.alignment: gridLayout.columns === 2 ?
Qt.AlignTop :
Qt.AlignHCenter
182 spacing:
Kirigami.Units.smallSpacing
184 Layout.fillWidth:
true
189 elide: QQC2.Label.ElideRight
190 wrapMode:
Text.WordWrap
191 Layout.fillWidth:
true
197 spacing:
Kirigami.Units.largeSpacing
202 visible: dontShowAgainName.length > 0
204 text:
i18nc(
"@label:checkbox",
"Do not show again")
207 Layout.fillWidth: true
210 QQC2.DialogButtonBox {
211 leftPadding:
Kirigami.Units.largeSpacing * 2
212 rightPadding:
Kirigami.Units.largeSpacing * 2
213 bottomPadding:
Kirigami.Units.largeSpacing * 2
214 topPadding:
Kirigami.Units.largeSpacing * 2
216 standardButtons: root.standardButtons
218 onAccepted: root.accepted();
219 onDiscarded: root.discarded();
220 onApplied: root.applied();
221 onHelpRequested: root.helpRequested();
222 onRejected: root.rejected();
224 Layout.fillWidth:
true
233 easing.type: Easing.InOutQuad
234 duration:
Kirigami.Units.longDuration
243 easing.type: Easing.InOutQuad
244 duration:
Kirigami.Units.longDuration
251 background: Components.DialogRoundedBackground {}
254 QQC2.Overlay.modal: Rectangle {
255 color:
Qt.rgba(0, 0, 0, 0.3)
258 Behavior on opacity {
260 duration:
Kirigami.Units.longDuration
261 easing.type: Easing.InOutQuad
A dialog to show a message.
QString i18nc(const char *context, const char *text, const TYPE &arg...)