desktop-ui-tests/base/LegacyModalsHelpers.qml

78 lines
2.4 KiB
QML
Raw Permalink Normal View History

2021-10-15 11:31:29 +00:00
import QtQuick 2.14
import "../status-desktop/ui/shared/popups" as SharedPopups
import "../status-desktop/ui/shared/panels" as SharedPanels
2021-10-15 11:31:29 +00:00
QtObject {
id: root
property SharedPopups.ModalPopup target: null
2021-10-15 11:31:29 +00:00
property var header
property var contentItem
property var footer
property Helpers __helpers: Helpers {}
property var headerComp: Component {
2021-10-15 11:31:29 +00:00
QtObject {
property SharedPanels.StyledText title: null
2021-10-15 11:31:29 +00:00
property var closeButton: null
}
}
function findInContent(objectName) {
if (root.contentItem) {
return __helpers.getObjectByObjectName(root.contentItem, objectName)
}
return null
}
function findInFooter(objectName) {
if (root.footer) {
return __helpers.getObjectByObjectName(root.footer, objectName)
}
return null
}
property var cbComponent: Component {
2021-10-15 11:31:29 +00:00
QtObject {
property Rectangle background: null
property SharedPanels.SVGImage icon: null
2021-10-15 11:31:29 +00:00
property MouseArea sensor: null
function click() {
if (sensor) {
sensor.clicked()
}
}
}
}
onTargetChanged: {
if (target) {
var hdr = __helpers.getObjectByObjectName(target.contentItem, "headerContent")
var headerNew = headerComp.createObject()
headerNew.title = __helpers.getObjectByObjectName(hdr, "titleText")
var clbtn = __helpers.getObjectByObjectName(__helpers.getObjectByObjectName(target.contentItem, "closeButtonRectangle"))
2021-10-25 13:37:51 +00:00
2021-10-15 11:31:29 +00:00
var icon = __helpers.getObjectByObjectName(clbtn, "closeImage")
var sensor = __helpers.getObjectByObjectName(clbtn, "closeSensor")
headerNew.closeButton = cbComponent.createObject(null, {
background: clbtn,
icon: icon,
sensor: sensor
})
root.header = headerNew
root.contentItem = __helpers.getObjectByObjectName(target.contentItem, "contentParent")
2021-10-25 13:37:51 +00:00
2021-10-15 11:31:29 +00:00
root.footer = __helpers.getObjectByObjectName(target.contetItem, "footerParent")
}
}
}