import QtQuick 2.15 import QtQuick.Controls 2.15 Window { id: hangpromptbox visibility: Window.FullScreen; flags: Qt.Dialog | Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint modality: Qt.ApplicationModal color: "transparent" property var _message : string(""); property var _urlIcon : string(""); property var _cancelCallback; property var _cancelUserargs; Rectangle { anchors.centerIn : parent width: 360 height: 360 color: "#980e57ea" radius: 16 Image { anchors.top: parent.top anchors.topMargin: 32 anchors.horizontalCenter: parent.horizontalCenter width: 200 height: 200 opacity: 0.5 source: _urlIcon } Text { anchors.bottom: parent.bottom anchors.bottomMargin: 64 anchors.horizontalCenter: parent.horizontalCenter text: _message color: "#ffffff" font.pixelSize: 32 font.bold: true } Text { anchors.bottom: parent.bottom anchors.bottomMargin: 16 anchors.horizontalCenter: parent.horizontalCenter text: qsTr("取消") color: "#ffffff" font.pixelSize: 24 font.underline: true font.bold: false MouseArea { anchors.fill: parent onClicked: { if (typeof _cancelCallback === "function") { // 如果存在用户参数 if (_cancelUserargs !== null) { _cancelCallback(_cancelUserargs); } else { _cancelCallback(); } } hide(); } } } } // 设置取消按钮回调函数 function setCancelCallBack(callback, userargs) { _cancelCallback = callback; _cancelUserargs = userargs; } // 隐藏并且执行回调 function hideExecuteCallback() { if (typeof _cancelCallback === "function") { // 如果存在用户参数 if (_cancelUserargs !== null) { _cancelCallback(_cancelUserargs); } else { _cancelCallback(); } _cancelCallback = null; } visible = false; } // 消息 function message(message) { _message = message } // 图标 function urlIcon(urlIcon) { _urlIcon = urlIcon; } // 显示 function show() { visible = true; } // 隐藏 function hide() { _cancelCallback = null; visible = false; } }