makeObject(): accept a component as first argument

This commit is contained in:
miruka 2019-12-15 05:26:36 -04:00
parent 09d94e7390
commit 59260e108a

View File

@ -1,5 +1,11 @@
function makeObject(url, parent=null, properties={}, callback=null) { function makeObject(urlComponent, parent=null, properties={}, callback=null) {
let comp = Qt.createComponent(url, Component.Asynchronous) let comp = urlComponent
if (! Qt.isQtObject(urlComponent)) {
// It's an url or path string to a component
comp = Qt.createComponent(urlComponent, Component.Asynchronous)
}
let ready = false let ready = false
comp.statusChanged.connect(status => { comp.statusChanged.connect(status => {
@ -32,9 +38,9 @@ function makeObject(url, parent=null, properties={}, callback=null) {
} }
function makePopup(url, parent=null, properties={}, callback=null, function makePopup(urlComponent, parent=null, properties={}, callback=null,
autoDestruct=true) { autoDestruct=true) {
makeObject(url, parent, properties, (popup) => { makeObject(urlComponent, parent, properties, (popup) => {
popup.open() popup.open()
if (autoDestruct) popup.closed.connect(() => { popup.destroy() }) if (autoDestruct) popup.closed.connect(() => { popup.destroy() })
if (callback) callback(popup) if (callback) callback(popup)