wasm: Add qtloader compatibility API
Implement the main features of the pre Qt 6.6 loader as adaption layer on top of the new loader. Task-id: QTBUG-115049 Change-Id: Iabe860d3fb0488fd003876508787da3688e0c87b Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com> (cherry picked from commit 20d17b1a3b0e3a17a0ed1214cc21d84d79d3c829) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5bc7d8b2e8
commit
2b62922e2e
@ -219,3 +219,57 @@ async function qtLoad(config)
|
|||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compatibility API. This API is deprecated,
|
||||||
|
// and will be removed in a future version of Qt.
|
||||||
|
function QtLoader(qtConfig) {
|
||||||
|
|
||||||
|
const warning = 'Warning: The QtLoader API is deprecated and will be removed in ' +
|
||||||
|
'a future version of Qt. Please port to the new qtLoad() API.';
|
||||||
|
console.warn(warning);
|
||||||
|
|
||||||
|
let emscriptenConfig = qtConfig.moduleConfig || {}
|
||||||
|
qtConfig.moduleConfig = undefined;
|
||||||
|
const showLoader = qtConfig.showLoader;
|
||||||
|
qtConfig.showLoader = undefined;
|
||||||
|
const showError = qtConfig.showError;
|
||||||
|
qtConfig.showError = undefined;
|
||||||
|
const showExit = qtConfig.showExit;
|
||||||
|
qtConfig.showExit = undefined;
|
||||||
|
const showCanvas = qtConfig.showCanvas;
|
||||||
|
qtConfig.showCanvas = undefined;
|
||||||
|
if (qtConfig.canvasElements) {
|
||||||
|
qtConfig.containerElements = qtConfig.canvasElements
|
||||||
|
qtConfig.canvasElements = undefined;
|
||||||
|
} else {
|
||||||
|
qtConfig.containerElements = qtConfig.containerElements;
|
||||||
|
qtConfig.containerElements = undefined;
|
||||||
|
}
|
||||||
|
emscriptenConfig.qt = qtConfig;
|
||||||
|
|
||||||
|
let qtloader = {
|
||||||
|
exitCode: undefined,
|
||||||
|
exitText: "",
|
||||||
|
loadEmscriptenModule: _name => {
|
||||||
|
try {
|
||||||
|
qtLoad(emscriptenConfig);
|
||||||
|
} catch (e) {
|
||||||
|
showError?.(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qtConfig.onLoaded = () => {
|
||||||
|
showCanvas?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
qtConfig.onExit = exit => {
|
||||||
|
qtloader.exitCode = exit.code
|
||||||
|
qtloader.exitText = exit.text;
|
||||||
|
showExit?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
showLoader?.("Loading");
|
||||||
|
|
||||||
|
return qtloader;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user