Upgrade confirmation popup to be used as lambda from QML
This commit is contained in:
parent
42a00cc236
commit
5381f59bf4
1 changed files with 14 additions and 3 deletions
|
|
@ -18,12 +18,14 @@ ApplicationWindow {
|
||||||
Dialog {
|
Dialog {
|
||||||
property var requestDialog
|
property var requestDialog
|
||||||
property int index
|
property int index
|
||||||
|
property var callback: requestDialog?.result
|
||||||
signal closePopup(int index)
|
signal closePopup(int index)
|
||||||
onClosed: closePopup(index)
|
onClosed: closePopup(index)
|
||||||
text: requestDialog.message
|
text: requestDialog.message
|
||||||
details: requestDialog.details
|
details: requestDialog.details
|
||||||
onAccepted: requestDialog.result(1)
|
// For C++, requestDialog need to be call directly
|
||||||
onRejected: requestDialog.result(0)
|
onAccepted: requestDialog ? requestDialog.result(1) : callback(1)
|
||||||
|
onRejected: requestDialog ? requestDialog.result(0) : callback(0)
|
||||||
width: 278 * DefaultStyle.dp
|
width: 278 * DefaultStyle.dp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +58,16 @@ ApplicationWindow {
|
||||||
popup.open()
|
popup.open()
|
||||||
popup.closePopup.connect(removeFromPopupLayout)
|
popup.closePopup.connect(removeFromPopupLayout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showConfirmationLambdaPopup(title,details,callback){
|
||||||
|
console.log("Showing confirmation popup")
|
||||||
|
var popup = confirmPopupComp.createObject(popupLayout, {"text": title, "details":details,"callback":callback})
|
||||||
|
popup.index = popupLayout.popupList.length
|
||||||
|
popupLayout.popupList.push(popup)
|
||||||
|
popup.open()
|
||||||
|
popup.closePopup.connect(removeFromPopupLayout)
|
||||||
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: popupLayout
|
id: popupLayout
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue