feat: message dialogs
This commit is contained in:
parent
0e874d8745
commit
913a7e5b5d
|
@ -25,6 +25,9 @@ Rectangle {
|
|||
property Component browserDialogComponent: BrowserDialog {
|
||||
onClosing: destroy()
|
||||
}
|
||||
|
||||
property Component jsDialogComponent: JSDialogWindow {}
|
||||
|
||||
property bool currentTabConnected: false
|
||||
|
||||
ListModel {
|
||||
|
@ -491,6 +494,12 @@ Rectangle {
|
|||
sslDialog.enqueue(error);
|
||||
}
|
||||
|
||||
onJavaScriptDialogRequested: function(request) {
|
||||
request.accepted = true;
|
||||
var dialog = jsDialogComponent.createObject(browserWindow, {"request": request});
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
onNewViewRequested: function(request) {
|
||||
if (!request.userInitiated) {
|
||||
print("Warning: Blocked a popup window.");
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
import QtWebEngine 1.10
|
||||
import "../../../shared"
|
||||
import "../../../imports"
|
||||
|
||||
ModalPopup {
|
||||
id: root
|
||||
property QtObject request
|
||||
|
||||
onClosed: {
|
||||
request.dialogReject();
|
||||
root.destroy();
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
switch (request.type) {
|
||||
case JavaScriptDialogRequest.DialogTypeAlert:
|
||||
cancelButton.visible = false;
|
||||
title.text = qsTr("Alert");
|
||||
message.text = request.message;
|
||||
prompt.text = "";
|
||||
prompt.visible = false;
|
||||
break;
|
||||
case JavaScriptDialogRequest.DialogTypeConfirm:
|
||||
title.text = qsTr("Confirm");
|
||||
message.text = request.message;
|
||||
prompt.text = "";
|
||||
prompt.visible = false;
|
||||
break;
|
||||
case JavaScriptDialogRequest.DialogTypePrompt:
|
||||
title.text = qsTr("Prompt");
|
||||
message.text = request.message;
|
||||
prompt.text = request.defaultText;
|
||||
prompt.visible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: rectangle
|
||||
height: 30
|
||||
anchors.rightMargin: 0
|
||||
anchors.leftMargin: 0
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
|
||||
Text {
|
||||
id: title
|
||||
x: 54
|
||||
y: 5
|
||||
color: "#ffffff"
|
||||
text: qsTr("Title")
|
||||
font.pointSize: 12
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ScrollView {
|
||||
width: parent.width
|
||||
height: 100
|
||||
TextArea {
|
||||
id: message
|
||||
wrapMode: TextEdit.Wrap
|
||||
readOnly: true
|
||||
text: ""
|
||||
}
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: prompt
|
||||
width: 300
|
||||
height: 22
|
||||
Layout.fillWidth: true
|
||||
font.pointSize: 12
|
||||
}
|
||||
|
||||
Button {
|
||||
id: okButton
|
||||
width: 90
|
||||
height: 30
|
||||
text: qsTr("OK")
|
||||
onClicked: {
|
||||
request.dialogAccept(prompt.text);
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: cancelButton
|
||||
width: 90
|
||||
height: 30
|
||||
anchors.top: okButton.bottom
|
||||
text: qsTr("Cancel")
|
||||
onClicked: {
|
||||
request.dialogReject();
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue