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 function standardButton(button) {
55 return dialogButtonBox.standardButton(button);
58 default property alias mainContent: mainLayout.data
60 property string iconName:
switch (root.dialogType) {
62 return "data-success";
64 return "data-warning";
68 return "data-information";
70 return "data-warning";
73 x: Math.round((parent.width - width) / 2)
74 y: Math.round((parent.height - height) / 2)
77 parent: applicationWindow().QQC2.Overlay.overlay
79 implicitWidth: Math.min(parent.width -
Kirigami.Units.gridUnit * 2,
Kirigami.Units.gridUnit * 20)
80 implicitHeight: Math.min(Math.max(implicitBackgroundHeight + topInset + bottomInset,
81 contentHeight + topPadding + bottomPadding
82 + (implicitHeaderHeight > 0 ? implicitHeaderHeight + spacing : 0)
83 + (implicitFooterHeight > 0 ? implicitFooterHeight + spacing : 0)), parent.height -
Kirigami.Units.gridUnit * 2,
Kirigami.Units.gridUnit * 30)
85 title:
switch (root.dialogType) {
87 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Success");
89 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Warning");
91 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Error");
93 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Information");
95 return i18ndc(
"kirigami-addons6",
"@title:dialog",
"Warning");
98 padding:
Kirigami.Units.largeSpacing * 2
99 bottomPadding:
Kirigami.Units.largeSpacing
101 property bool _automaticallyClosed:
false
107 function openDialog(): void {
108 if (root.dontShowAgainName.length > 0) {
109 if (root.standardButtons === QQC2.Dialog.Ok) {
110 const show = MessageDialogHelper.shouldBeShownContinue(root.dontShowAgainName);
112 root._automaticallyClosed = true;
116 checkbox.checked = false;
117 root._automaticallyClosed = false;
123 root._automaticallyClosed =
true;
131 checkbox.checked =
false;
132 root._automaticallyClosed =
false;
140 if (root.dontShowAgainName && checkbox.checked && !root._automaticallyClosed) {
141 if (root.standardButtons === QQC2.Dialog.Ok) {
150 if (root.dontShowAgainName && checkbox.checked && !root._automaticallyClosed) {
151 if (root.standardButtons === QQC2.Dialog.Ok) {
160 if (root.dontShowAgainName && checkbox.checked && !root._automaticallyClosed) {
161 if (root.standardButtons === QQC2.Dialog.Ok) {
169 contentItem: GridLayout {
172 columns: !icon.visible || root._mobileLayout ? 1 : 2
178 visible: root.iconName.length > 0
179 source: root.iconName
180 Layout.preferredWidth:
Kirigami.Units.iconSizes.huge
181 Layout.preferredHeight:
Kirigami.Units.iconSizes.huge
182 Layout.alignment: gridLayout.columns === 2 ?
Qt.AlignTop :
Qt.AlignHCenter
188 spacing:
Kirigami.Units.smallSpacing
190 Layout.fillWidth:
true
195 elide: QQC2.Label.ElideRight
196 wrapMode:
Text.WordWrap
197 horizontalAlignment: gridLayout.columns === 2 ?
Qt.AlignLeft :
Qt.AlignHCenter
199 Layout.fillWidth:
true
204 readonly
property bool _mobileLayout: {
205 if (root.width <
Kirigami.Units.gridUnit * 20) {
211 let totalImplicitWidth = checkbox.implicitWidth + gridLayoutFooter.columnSpacing;
212 for (let i = 0; i < repeater.count; i++) {
213 totalImplicitWidth += repeater.itemAt(i).implicitWidth + gridLayoutFooter.columnSpacing
216 return totalImplicitWidth > footer.width;
222 columns: root._mobileLayout ? 1 : 1 + repeater.count + 1
224 rowSpacing:
Kirigami.Units.mediumSpacing
225 columnSpacing:
Kirigami.Units.mediumSpacing
230 visible: dontShowAgainName.length > 0
231 text:
i18ndc(
"kirigami-addons6",
"@label:checkbox",
"Do not show again")
234 Layout.fillWidth: true
239 model: dialogButtonBox.contentModel
245 standardButtons: root.standardButtons
247 onAccepted: root.accepted();
248 onDiscarded: root.discarded();
249 onApplied: root.applied();
250 onHelpRequested: root.helpRequested();
251 onRejected: root.rejected();
257 delegate: QQC2.Button {
260 Layout.fillWidth: root._mobileLayout
261 Layout.leftMargin: root._mobileLayout ?
Kirigami.Units.largeSpacing : 0
262 Layout.rightMargin: root._mobileLayout ?
Kirigami.Units.largeSpacing : 0
263 Layout.bottomMargin: root._mobileLayout ? 0 : 2
273 easing.type: Easing.InOutQuad
274 duration:
Kirigami.Units.longDuration
283 easing.type: Easing.InOutQuad
284 duration:
Kirigami.Units.longDuration
291 background: Components.DialogRoundedBackground {}
294 QQC2.Overlay.modal: Rectangle {
295 color:
Qt.rgba(0, 0, 0, 0.3)
298 Behavior on opacity {
300 duration:
Kirigami.Units.longDuration
301 easing.type: Easing.InOutQuad
A dialog to show a message.
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)