Implement a DesktopSystemDialog.acceptable property

Specifies if the accept button is enabled and otherwise should control
if we can accept the dialog.
wilder-5.24
Aleix Pol 4 years ago committed by Devin Lin
parent 4cfa7ae744
commit ca21953b05
  1. 12
      components/dialogs/DesktopSystemDialog.qml
  2. 30
      components/dialogs/examples/test.qml

@ -48,6 +48,11 @@ Kirigami.AbstractApplicationWindow {
*/ */
readonly property alias dialogButtonBox: footerButtonBox readonly property alias dialogButtonBox: footerButtonBox
/**
* Controls whether the accept button is enabled
*/
property bool acceptable: true
width: column.implicitWidth width: column.implicitWidth
height: column.implicitHeight + footer.implicitHeight height: column.implicitHeight + footer.implicitHeight
minimumHeight: column.Layout.minimumHeight + footer.implicitHeight minimumHeight: column.Layout.minimumHeight + footer.implicitHeight
@ -133,6 +138,13 @@ Kirigami.AbstractApplicationWindow {
onAccepted: root.accept() onAccepted: root.accept()
onRejected: root.reject() onRejected: root.reject()
Binding {
target: footerButtonBox.standardButton(DialogButtonBox.Ok)
property: "enabled"
when: footerButtonBox.standardButton(DialogButtonBox.Ok)
value: root.acceptable
}
Repeater { Repeater {
model: root.actions model: root.actions

@ -78,6 +78,26 @@ Kirigami.AbstractApplicationWindow {
] ]
} }
DesktopSystemDialog {
id: xdgDialog
title: "Wallet access"
subtitle: "Share your wallet with 'Somebody'."
iconName: "kwallet"
acceptable: false
dialogButtonBox.standardButtons: DialogButtonBox.Ok | DialogButtonBox.Ok
Component.onCompleted: {
dialogButtonBox.standardButton(DialogButtonBox.Ok).text = "Share"
}
actions: [
Kirigami.Action {
text: "Something Happens"
iconName: "documentinfo"
onTriggered: xdgDialog.acceptable = true
}
]
}
DesktopCSDSystemDialog { DesktopCSDSystemDialog {
id: desktopCSDPolkit id: desktopCSDPolkit
title: "Authentication Required" title: "Authentication Required"
@ -293,6 +313,16 @@ Kirigami.AbstractApplicationWindow {
} }
} }
} }
Button {
text: "XDG dialog (Desktop)"
onClicked: {
if (checkbox.checked) {
xdgDialog.showFullScreen()
} else {
xdgDialog.show()
}
}
}
Button { Button {
text: "Polkit dialog (Mobile)" text: "Polkit dialog (Mobile)"
onClicked: { onClicked: {

Loading…
Cancel
Save