Port UserConsentSheet to Kirigami.Dialog

This commit is contained in:
Tobias Fella
2024-04-26 22:51:48 +02:00
parent 7e4361bb5e
commit b1e338579d

View File

@@ -295,6 +295,7 @@ Kirigami.ApplicationWindow {
KeyVerificationDialog {} KeyVerificationDialog {}
} }
Connections { Connections {
target: root.connection target: root.connection
@@ -309,32 +310,39 @@ Kirigami.ApplicationWindow {
}); });
} }
function onUserConsentRequired(url) { function onUserConsentRequired(url) {
let consent = consentSheetComponent.createObject(this); let consent = consentDialogComponent.createObject(this);
consent.url = url; consent.url = url;
consent.open(); consent.open();
} }
} }
Component { Component {
id: consentSheetComponent id: consentDialogComponent
Kirigami.OverlaySheet { Kirigami.Dialog {
id: consentSheet id: consentDialog
property string url: "" property string url: ""
title: i18n("User consent") width: Math.min(Kirigami.Units.gridUnit * 24, root.width)
height: Kirigami.Units.gridUnit * 8
leftPadding: Kirigami.Units.largeSpacing
rightPadding: Kirigami.Units.largeSpacing
QQC2.Label { title: i18nc("@title:dialog", "User Consent")
id: label
contentItem: QQC2.Label {
text: i18n("Your homeserver requires you to agree to its terms and conditions before being able to use it. Please click the button below to read them.") text: i18n("Your homeserver requires you to agree to its terms and conditions before being able to use it. Please click the button below to read them.")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
width: parent.width horizontalAlignment: Qt.AlignHCenter
} verticalAlignment: Qt.AlignVCenter
footer: QQC2.Button {
text: i18n("Open")
onClicked: UrlHelper.openUrl(consentSheet.url)
} }
customFooterActions: [
Kirigami.Action {
text: i18n("Open")
icon.name: "internet-services"
onTriggered: UrlHelper.openUrl(consentDialog.url)
}
]
} }
} }