Add legacy modals helpers

This commit is contained in:
B.Melnik 2021-10-15 14:31:29 +03:00
parent 1b78c20a0d
commit fe60d1ff5c
No known key found for this signature in database
GPG Key ID: 4A9B2E42E3BD4727
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,75 @@
import QtQuick 2.14
import "../status-desktop/ui/shared" as Shared
QtObject {
id: root
property Shared.ModalPopup target: null
property var header
property var contentItem
property var footer
property Helpers __helpers: Helpers {}
Component {
id: headerComp
QtObject {
property Shared.StyledText title: null
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
}
Component {
id: cbComponent
QtObject {
property Rectangle background: null
property Shared.SVGImage icon: null
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"))
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")
root.footer = __helpers.getObjectByObjectName(target.contetItem, "footerParent")
}
}
}

View File

@ -9,6 +9,7 @@ DEFINES += PROJECT_PATH=\"$${PWD}\"
DISTFILES += \
base/ChatsModelData.qml \
base/Helpers.qml \
base/LegacyModalsHelpers.qml \
base/ModalHelpers.qml \
base/ProfileModelData.qml \
base/WindowTestCase.qml \