2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtGraphicalEffects 1.15
|
|
|
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-14 11:33:34 +00:00
|
|
|
import "../"
|
2021-10-14 12:14:11 +00:00
|
|
|
import "../panels"
|
2020-05-29 16:27:50 +00:00
|
|
|
|
2020-05-29 18:38:11 +00:00
|
|
|
Popup {
|
2020-06-11 21:23:27 +00:00
|
|
|
property string title
|
2021-01-12 20:51:00 +00:00
|
|
|
property bool noTopMargin: false
|
2021-06-28 11:11:54 +00:00
|
|
|
property bool displayCloseButton: true
|
2020-06-11 21:23:27 +00:00
|
|
|
default property alias content: popupContent.children
|
2020-06-29 22:02:19 +00:00
|
|
|
property alias contentWrapper: popupContent
|
2020-06-11 21:23:27 +00:00
|
|
|
property alias header: headerContent.children
|
2023-06-06 16:45:05 +00:00
|
|
|
property bool destroyOnClose: false
|
2020-05-29 16:27:50 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
id: popup
|
|
|
|
modal: true
|
|
|
|
property alias footer: footerContent.children
|
2020-05-29 16:27:50 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Overlay.modal: Rectangle {
|
2021-02-18 19:07:23 +00:00
|
|
|
color: Qt.rgba(0, 0, 0, 0.4)
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
2021-06-28 11:11:54 +00:00
|
|
|
closePolicy: displayCloseButton? Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
|
|
|
: Popup.NoAutoClose
|
2020-06-11 21:23:27 +00:00
|
|
|
parent: Overlay.overlay
|
2020-09-23 18:01:33 +00:00
|
|
|
x: Math.round(((parent ? parent.width : 0) - width) / 2)
|
|
|
|
y: Math.round(((parent ? parent.height : 0) - height) / 2)
|
2020-06-11 21:23:27 +00:00
|
|
|
width: 480
|
|
|
|
height: 510 // TODO find a way to make this dynamic
|
|
|
|
background: Rectangle {
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.background
|
2020-06-11 21:23:27 +00:00
|
|
|
radius: 8
|
|
|
|
}
|
2021-04-07 13:59:42 +00:00
|
|
|
onClosed: {
|
2023-05-23 12:46:16 +00:00
|
|
|
if (popup.destroyOnClose)
|
|
|
|
popup.destroy();
|
2021-04-07 13:59:42 +00:00
|
|
|
}
|
2020-06-11 21:23:27 +00:00
|
|
|
padding: 0
|
|
|
|
contentItem: Item {
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: headerContent
|
2021-10-18 11:11:11 +00:00
|
|
|
objectName: "headerContent"
|
2020-06-11 21:23:27 +00:00
|
|
|
height: {
|
2021-01-12 20:51:00 +00:00
|
|
|
const count = children.length
|
|
|
|
let h = 0
|
|
|
|
for (let i = 0; i < count; i++) {
|
|
|
|
h += children[i] ? children[i].height : 0
|
|
|
|
}
|
|
|
|
return h
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-09-30 12:33:26 +00:00
|
|
|
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: popup.noTopMargin ? 0 : Theme.padding
|
|
|
|
anchors.bottomMargin: Theme.padding
|
|
|
|
anchors.rightMargin: Theme.padding
|
|
|
|
anchors.leftMargin: Theme.padding
|
2020-06-09 10:01:19 +00:00
|
|
|
|
2020-06-19 18:06:58 +00:00
|
|
|
StyledText {
|
2020-06-11 21:23:27 +00:00
|
|
|
text: title
|
2021-10-18 11:11:11 +00:00
|
|
|
objectName: "titleText"
|
2020-09-30 12:33:26 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.left: parent.left
|
2022-04-04 12:45:27 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 44
|
2020-06-11 21:23:27 +00:00
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 17
|
2021-01-12 20:51:00 +00:00
|
|
|
height: visible ? 24 : 0
|
2022-02-11 19:34:12 +00:00
|
|
|
elide: Text.ElideRight
|
2020-06-11 21:23:27 +00:00
|
|
|
visible: !!title
|
2020-09-30 12:33:26 +00:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
2020-06-09 10:01:19 +00:00
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Rectangle {
|
|
|
|
id: closeButton
|
2022-08-11 19:16:59 +00:00
|
|
|
objectName: "modalCloseButtonRectangle"
|
2020-09-30 12:33:26 +00:00
|
|
|
property bool hovered: false
|
2021-06-28 11:11:54 +00:00
|
|
|
visible: displayCloseButton
|
2020-06-11 21:23:27 +00:00
|
|
|
height: 32
|
|
|
|
width: 32
|
2021-01-12 20:51:00 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 12
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 12
|
2020-06-11 21:23:27 +00:00
|
|
|
radius: 8
|
2024-10-15 19:26:12 +00:00
|
|
|
color: hovered ? Theme.palette.backgroundHover : Theme.palette.transparent
|
2020-05-29 16:27:50 +00:00
|
|
|
|
2020-06-25 13:23:17 +00:00
|
|
|
SVGImage {
|
2020-06-11 21:23:27 +00:00
|
|
|
id: closeModalImg
|
2021-10-18 11:11:11 +00:00
|
|
|
objectName: "closeImage"
|
2021-10-14 14:46:34 +00:00
|
|
|
source: "../img/close.svg"
|
2020-09-30 12:33:26 +00:00
|
|
|
width: 11
|
|
|
|
height: 11
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
2020-07-13 18:45:54 +00:00
|
|
|
ColorOverlay {
|
|
|
|
anchors.fill: closeModalImg
|
|
|
|
source: closeModalImg
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.textColor
|
2020-07-13 18:45:54 +00:00
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
MouseArea {
|
|
|
|
id: closeModalMouseArea
|
2021-10-18 11:11:11 +00:00
|
|
|
objectName: "closeSensor"
|
2020-06-11 21:23:27 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
hoverEnabled: true
|
|
|
|
onExited: {
|
2020-09-30 12:33:26 +00:00
|
|
|
closeButton.hovered = false
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
|
|
|
onEntered: {
|
2020-09-30 12:33:26 +00:00
|
|
|
closeButton.hovered = true
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Separator {
|
|
|
|
id: separator
|
|
|
|
anchors.top: headerContent.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: visible ? Theme.padding : 0
|
2020-12-04 16:01:38 +00:00
|
|
|
visible: title.length > 0
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
2020-05-29 16:27:50 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Item {
|
|
|
|
id: popupContent
|
2021-10-18 11:11:11 +00:00
|
|
|
objectName: "contentParent"
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.top: separator.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.topMargin: Theme.padding
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.bottom: separator2.top
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.bottomMargin: Theme.padding
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.left: parent.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.leftMargin: Theme.padding
|
2020-06-11 21:23:27 +00:00
|
|
|
anchors.right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.rightMargin: Theme.padding
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
2020-05-29 18:38:11 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Separator {
|
|
|
|
id: separator2
|
2021-03-16 12:14:07 +00:00
|
|
|
visible: footerContent.visible && footerContent.height > 0
|
2021-01-13 19:15:52 +00:00
|
|
|
anchors.bottom: footerContent.top
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.bottomMargin: visible ? Theme.padding : 0
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
2020-05-29 18:38:11 +00:00
|
|
|
|
2020-06-11 21:23:27 +00:00
|
|
|
Item {
|
2020-07-15 19:38:03 +00:00
|
|
|
id: footerContent
|
2021-10-18 11:11:11 +00:00
|
|
|
objectName: "footerParent"
|
2021-01-13 19:15:52 +00:00
|
|
|
visible: children.length > 0
|
|
|
|
height: visible ? children[0] && children[0].height : 0
|
2020-07-15 19:38:03 +00:00
|
|
|
width: parent.width
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.bottomMargin: visible ? Theme.padding : 0
|
|
|
|
anchors.rightMargin: visible ? Theme.padding : 0
|
|
|
|
anchors.leftMargin: visible ? Theme.padding : 0
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|
2023-05-23 12:46:16 +00:00
|
|
|
}
|
2020-06-11 21:23:27 +00:00
|
|
|
}
|