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. 14
      components/dialogs/DesktopSystemDialog.qml
  2. 34
      components/dialogs/examples/test.qml

@ -47,6 +47,11 @@ Kirigami.AbstractApplicationWindow {
* This property holds the QQC2 DialogButtonBox used in the footer of the dialog.
*/
readonly property alias dialogButtonBox: footerButtonBox
/**
* Controls whether the accept button is enabled
*/
property bool acceptable: true
width: column.implicitWidth
height: column.implicitHeight + footer.implicitHeight
@ -132,7 +137,14 @@ Kirigami.AbstractApplicationWindow {
spacing: Kirigami.Units.smallSpacing
onAccepted: root.accept()
onRejected: root.reject()
Binding {
target: footerButtonBox.standardButton(DialogButtonBox.Ok)
property: "enabled"
when: footerButtonBox.standardButton(DialogButtonBox.Ok)
value: root.acceptable
}
Repeater {
model: root.actions

@ -56,9 +56,9 @@ Kirigami.AbstractApplicationWindow {
title: "Authentication Required"
subtitle: "Authentication is needed to run `/usr/bin/ls` as the super user."
iconName: "im-user-online"
Kirigami.PasswordField {}
actions: [
Kirigami.Action {
text: "Details"
@ -77,6 +77,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 {
id: desktopCSDPolkit
@ -293,6 +313,16 @@ Kirigami.AbstractApplicationWindow {
}
}
}
Button {
text: "XDG dialog (Desktop)"
onClicked: {
if (checkbox.checked) {
xdgDialog.showFullScreen()
} else {
xdgDialog.show()
}
}
}
Button {
text: "Polkit dialog (Mobile)"
onClicked: {

Loading…
Cancel
Save