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: switch (root.dialogType) {
57 case MessageDialog.Success:
58 return "data-success";
60 return "data-warning";
64 return "data-information";
66 return "data-warning";
69 x: Math.round((parent.width - width) / 2)
70 y: Math.round((parent.height - height) / 2)
73 parent: applicationWindow().QQC2.Overlay.overlay
75 implicitWidth: Math.min(parent.width -
Kirigami.Units.gridUnit * 2,
Kirigami.Units.gridUnit * 20)
76 implicitHeight: Math.min(Math.max(implicitBackgroundHeight + topInset + bottomInset,
77 contentHeight + topPadding + bottomPadding
78 + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
79 + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0)), parent.height -
Kirigami.Units.gridUnit * 2,
Kirigami.Units.gridUnit * 30)
81 title:
switch (root.dialogType) {
83 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Success");
85 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Warning");
87 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Error");
89 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Information");
91 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Warning");
94 padding:
Kirigami.Units.largeSpacing * 2
95 bottomPadding:
Kirigami.Units.largeSpacing
97 property bool _automaticallyClosed:
false
103 function openDialog(): void {
104 if (root.dontShowAgainName.length > 0) {
105 if (root.standardButtons === QQC2.Dialog.Ok) {
106 const show = MessageDialogHelper.shouldBeShownContinue(root.dontShowAgainName);
108 root._automaticallyClosed = true;
112 checkbox.checked = false;
113 root._automaticallyClosed = false;
119 root._automaticallyClosed =
true;
127 checkbox.checked =
false;
128 root._automaticallyClosed =
false;
136 if (root.dontShowAgainName && checkbox.checked && !root._automaticallyClosed) {
137 if (root.standardButtons === QQC2.Dialog.Ok) {
146 if (root.dontShowAgainName && checkbox.checked && !root._automaticallyClosed) {
147 if (root.standardButtons === QQC2.Dialog.Ok) {
156 if (root.dontShowAgainName && checkbox.checked && !root._automaticallyClosed) {
157 if (root.standardButtons === QQC2.Dialog.Ok) {
165 contentItem: GridLayout {
168 columns: icon.visible && root.width >
Kirigami.Units.gridUnit * 18 ? 2 : 1
169 rowSpacing:
Kirigami.Units.largeSpacing
174 visible: root.iconName.length > 0
175 source: root.iconName
176 Layout.preferredWidth:
Kirigami.Units.iconSizes.huge
177 Layout.preferredHeight:
Kirigami.Units.iconSizes.huge
178 Layout.alignment: gridLayout.columns === 2 ?
Qt.AlignTop :
Qt.AlignHCenter
184 spacing:
Kirigami.Units.smallSpacing
186 Layout.fillWidth:
true
191 elide: QQC2.Label.ElideRight
192 wrapMode:
Text.WordWrap
193 Layout.fillWidth:
true
199 spacing:
Kirigami.Units.largeSpacing
204 visible: dontShowAgainName.length > 0
206 text:
i18ndc(
"kirigami-addons6",
"@label:checkbox",
"Do not show again")
209 Layout.fillWidth: true
212 QQC2.DialogButtonBox {
218 standardButtons: root.standardButtons
220 onAccepted: root.accepted();
221 onDiscarded: root.discarded();
222 onApplied: root.applied();
223 onHelpRequested: root.helpRequested();
224 onRejected: root.rejected();
226 Layout.fillWidth:
true
235 easing.type: Easing.InOutQuad
236 duration:
Kirigami.Units.longDuration
245 easing.type: Easing.InOutQuad
246 duration:
Kirigami.Units.longDuration
253 background: Components.DialogRoundedBackground {}
256 QQC2.Overlay.modal: Rectangle {
257 color:
Qt.rgba(0, 0, 0, 0.3)
260 Behavior on opacity {
262 duration:
Kirigami.Units.longDuration
263 easing.type: Easing.InOutQuad
A dialog to show a message.
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)