Added a timeout to update the content holder parent after interactive window has finished loading

This commit is contained in:
Rebecca Stankus 2019-10-23 16:42:28 -07:00
parent 8e8c157567
commit f8102be74d
6 changed files with 10 additions and 43 deletions

View file

@ -72,7 +72,7 @@ Windows.Window {
function delay(delayTimeMS, delayFunction) { function delay(delayTimeMS, delayFunction) {
timer.interval = delayTimeMS; timer.interval = delayTimeMS;
timer.repeat = true; timer.repeat = false;
timer.triggered.connect(delayFunction); timer.triggered.connect(delayFunction);
timer.start(); timer.start();
} }
@ -108,14 +108,8 @@ Windows.Window {
function updateContentParent() { function updateContentParent() {
if (presentationMode === Desktop.PresentationMode.VIRTUAL) { if (presentationMode === Desktop.PresentationMode.VIRTUAL) {
contentHolder.parent = root; contentHolder.parent = root;
print("INTERACTIVEWINDOWQML CHANGED CONTENT PARENT TO ROOT. CONTENT HOLDER PARENT IS ", contentHolder.parent);
} else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) {
contentHolder.parent = nativeWindow.contentItem; contentHolder.parent = nativeWindow.contentItem;
print("INTERACTIVEWINDOWQML CHANGED CONTENT PARENT TO NATIVE WINDOW CONTENTITEM: ", nativeWindow.contentItem, ". CONTENT HOLDER PARENT IS ", contentHolder.parent);
} else if (!nativeWindow) {
print("INTERACTIVEWINDOWQML COULD NOT CHANGE CONTENT PARENT. NO NATIVE WINDOW.");
} else {
print("INTERACTIVEWINDOWQML COULD OT CHANGE CONTENT PARENT BUT HAVE A NATIVE WINDOW");
} }
} }
@ -129,20 +123,16 @@ Windows.Window {
} else if (presentationMode === Desktop.PresentationMode.NATIVE) { } else if (presentationMode === Desktop.PresentationMode.NATIVE) {
shown = false; shown = false;
if (nativeWindow) { if (nativeWindow) {
print("INTERACTIVEWINDOWQML SET UP PRES MODE FOUND NATIVE WINDOW");
updateInteractiveWindowPositionForMode(); updateInteractiveWindowPositionForMode();
nativeWindow.setVisible(interactiveWindowVisible); nativeWindow.setVisible(interactiveWindowVisible);
} else {
print("INTERACTIVEWINDOWQML SET UP PRES MODE DID NOT FIND NATIVE WINDOW");
} }
} else if (presentationMode === modeNotSet) { } else if (presentationMode === modeNotSet) {
console.error("presentationMode should be set"); console.error("presentationMode should be set.");
} }
} }
Component.onCompleted: { Component.onCompleted: {
print("INTERACTIVEWINDOWQML ONROOTCOMPLETED COMPLETED. ID IS ", this, " . CONTENT HOLDER PARENT IS ", contentHolder.parent);
x = interactiveWindowPosition.x; x = interactiveWindowPosition.x;
y = interactiveWindowPosition.y; y = interactiveWindowPosition.y;
width = interactiveWindowSize.width; width = interactiveWindowSize.width;
@ -157,8 +147,9 @@ Windows.Window {
width: interactiveWindowSize.width width: interactiveWindowSize.width
height: interactiveWindowSize.height height: interactiveWindowSize.height
Component.onCompleted: { Component.onCompleted: {
// calling setupPresentationMode from here does not work because the fn will not find the native window delay(500, function() {
print("INTERACTIVEWINDOWQML NATIVE WINDOW COMPLETED. ID IS ", this, " CONTENT HOLDER PARENT IS ", contentHolder.parent); updateContentParent();
});
} }
Rectangle { Rectangle {
@ -213,11 +204,10 @@ Windows.Window {
closeEvent.accepted = false; closeEvent.accepted = false;
windowClosed(); windowClosed();
}); });
// finally set the initial window mode: // finally set the initial window mode:
setupPresentationMode(); setupPresentationMode();
updateContentParent();
//TODO move this to wherever initialization is actually completed
initialized = true; initialized = true;
} }
@ -342,11 +332,5 @@ Windows.Window {
Item { Item {
id: contentHolder id: contentHolder
anchors.fill: parent anchors.fill: parent
Component.onCompleted: {
print("INTERACTIVEWINDOWQML CONTENTHOLDER COMPLETED. ID IS ", contentHolder, " . CONTENT HOLDER PARENT IS ", contentHolder.parent);
}
onParentChanged: {
print("INTERACTIVEWINDOWQML NATIVE WINDOW PARENT CHANGED. CONTENT HOLDER PARENT IS ", contentHolder.parent);
}
} }
} }

View file

@ -133,7 +133,6 @@ void DesktopScriptingInterface::show(const QString& path, const QString& title)
} }
InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) { InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) {
qDebug() << "CREATING WINDOW WITH URL " << sourceUrl << " AND PROPERTIES " << properties;
if (QThread::currentThread() != thread()) { if (QThread::currentThread() != thread()) {
InteractiveWindowPointer interactiveWindow = nullptr; InteractiveWindowPointer interactiveWindow = nullptr;
BLOCKING_INVOKE_METHOD(this, "createWindowOnThread", BLOCKING_INVOKE_METHOD(this, "createWindowOnThread",
@ -141,8 +140,7 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString&
Q_ARG(QString, sourceUrl), Q_ARG(QString, sourceUrl),
Q_ARG(QVariantMap, properties), Q_ARG(QVariantMap, properties),
Q_ARG(QThread*, QThread::currentThread())); Q_ARG(QThread*, QThread::currentThread()));
qDebug() << "RETURNING INTERACTIVE WINDOW " << interactiveWindow; return interactiveWindow;
return interactiveWindow;
} }
@ -163,10 +161,8 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindowOnThread(const Q
// that the source URL is permitted // that the source URL is permitted
const auto& urlValidator = OffscreenQmlSurface::getUrlValidator(); const auto& urlValidator = OffscreenQmlSurface::getUrlValidator();
if (!urlValidator(sourceUrl)) { if (!urlValidator(sourceUrl)) {
qDebug("INTERACTIVE WINDOW SOURCE URL WAS NOT VALID");
return nullptr; return nullptr;
} }
qDebug() << "WINDOW SOURCE URL: " << sourceUrl;
InteractiveWindowPointer window = new InteractiveWindow(sourceUrl, properties, _restricted); InteractiveWindowPointer window = new InteractiveWindow(sourceUrl, properties, _restricted);
window->moveToThread(targetThread); window->moveToThread(targetThread);
return window; return window;

View file

@ -167,7 +167,6 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
&InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection);
if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) {
qDebug() << "CREATING WINDOW THAT IS DOCKED WITH NATIVE PRES MODE";
QVariantMap nativeWindowInfo = properties[DOCKED_PROPERTY].toMap(); QVariantMap nativeWindowInfo = properties[DOCKED_PROPERTY].toMap();
Qt::DockWidgetArea dockArea = Qt::TopDockWidgetArea; Qt::DockWidgetArea dockArea = Qt::TopDockWidgetArea;
QString title; QString title;
@ -196,7 +195,6 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
* @property {InteractiveWindow.DockArea} dockArea - The edge of the Interface window to dock to. * @property {InteractiveWindow.DockArea} dockArea - The edge of the Interface window to dock to.
*/ */
if (nativeWindowInfo.contains(DOCK_AREA_PROPERTY)) { if (nativeWindowInfo.contains(DOCK_AREA_PROPERTY)) {
qDebug() << "CREATING DOCK AREA FOR NATIVE WINDOW " << DOCK_AREA_PROPERTY;
DockArea dockedArea = (DockArea) nativeWindowInfo[DOCK_AREA_PROPERTY].toInt(); DockArea dockedArea = (DockArea) nativeWindowInfo[DOCK_AREA_PROPERTY].toInt();
int tempWidth = 0; int tempWidth = 0;
int tempHeight = 0; int tempHeight = 0;
@ -255,7 +253,6 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
_dockWidget->setObjectName("DockedWidget"); _dockWidget->setObjectName("DockedWidget");
mainWindow->addDockWidget(dockArea, _dockWidget.get()); mainWindow->addDockWidget(dockArea, _dockWidget.get());
} else { } else {
qDebug() << "CREATING OTHER WINDOW (NOT DOCKED WITH NATIVE PRES MODE)";
auto contextInitLambda = [&](QQmlContext* context) { auto contextInitLambda = [&](QQmlContext* context) {
// If the restricted flag is on, the web content will not be able to access local files // If the restricted flag is on, the web content will not be able to access local files
ContextAwareProfile::restrictContext(context, restricted); ContextAwareProfile::restrictContext(context, restricted);
@ -339,7 +336,6 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) { if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) {
sourceURL = QUrl::fromLocalFile(sourceURL.toString()).toString(); sourceURL = QUrl::fromLocalFile(sourceURL.toString()).toString();
} }
qDebug() << "CREATING OTHER WINDOW WITH SOURCE URL: " << sourceUrl;
object->setObjectName("InteractiveWindow"); object->setObjectName("InteractiveWindow");
object->setProperty(SOURCE_PROPERTY, sourceURL); object->setProperty(SOURCE_PROPERTY, sourceURL);
}; };

View file

@ -380,7 +380,6 @@ function onMessageFromEmoteAppBar(message) {
if (message.source !== EMOTE_APP_BAR_MESSAGE_SOURCE) { if (message.source !== EMOTE_APP_BAR_MESSAGE_SOURCE) {
return; return;
} }
print("EMOTE WINDOW MESSAGE");
switch (message.method) { switch (message.method) {
case "positive": case "positive":
if (!message.data.isPressingAndHolding) { if (!message.data.isPressingAndHolding) {
@ -522,11 +521,9 @@ var EMOTE_APP_BAR_WINDOW_FLAGS = 0x00000001 | // Qt::Window
var emoteAppBarWindow = false; var emoteAppBarWindow = false;
function showEmoteAppBar() { function showEmoteAppBar() {
if (emoteAppBarWindow) { if (emoteAppBarWindow) {
print("EMOTE APP BAR WINDOW ALREADY EXISTS. DO NOT SHOW AGAIN.");
return; return;
} }
print("CREATE EMOTE WINDOW");
emoteAppBarWindow = Desktop.createWindow(EMOTE_APP_BAR_QML_PATH, { emoteAppBarWindow = Desktop.createWindow(EMOTE_APP_BAR_QML_PATH, {
title: EMOTE_APP_BAR_WINDOW_TITLE, title: EMOTE_APP_BAR_WINDOW_TITLE,
presentationMode: EMOTE_APP_BAR_PRESENTATION_MODE, presentationMode: EMOTE_APP_BAR_PRESENTATION_MODE,
@ -542,7 +539,6 @@ function showEmoteAppBar() {
overrideFlags: EMOTE_APP_BAR_WINDOW_FLAGS overrideFlags: EMOTE_APP_BAR_WINDOW_FLAGS
}); });
print("EMOTE APP BAR WINDOW CREATED: ", emoteAppBarWindow);
emoteAppBarWindow.fromQml.connect(onMessageFromEmoteAppBar); emoteAppBarWindow.fromQml.connect(onMessageFromEmoteAppBar);
} }
@ -552,7 +548,6 @@ function showEmoteAppBar() {
// We should add that functionality to the Window Scripting Interface, and remove `isWindowMinimized` below. // We should add that functionality to the Window Scripting Interface, and remove `isWindowMinimized` below.
var isWindowMinimized = false; var isWindowMinimized = false;
function maybeChangeEmoteIndicatorVisibility(desiredVisibility) { function maybeChangeEmoteIndicatorVisibility(desiredVisibility) {
print("MAYBE CHANGE EMOTE WINDOW VISIBILITY ", desiredVisibility);
if (isWindowMinimized || HMD.active) { if (isWindowMinimized || HMD.active) {
desiredVisibility = false; desiredVisibility = false;
} }
@ -587,7 +582,6 @@ var emojiCodeMap;
var customEmojiCodeMap; var customEmojiCodeMap;
var _this; var _this;
function setup() { function setup() {
print("STARTING EMOTE SCRIPT");
deleteOldReticles(); deleteOldReticles();
// make a map of just the utf codes to help with accesing // make a map of just the utf codes to help with accesing

View file

@ -39,9 +39,6 @@ Rectangle {
readonly property string emoteIconSource: "images/emote_Icon.svg" readonly property string emoteIconSource: "images/emote_Icon.svg"
property bool allowEmoteDrawerExpansion: Settings.getValue("simplifiedUI/allowEmoteDrawerExpansion", true) property bool allowEmoteDrawerExpansion: Settings.getValue("simplifiedUI/allowEmoteDrawerExpansion", true)
Component.onCompleted: {
print("EMOTE APP BAR ROOT WINDOW HAS COMPLETED LOADING");
}
onRequestedWidthChanged: { onRequestedWidthChanged: {
root.requestNewWidth(root.requestedWidth); root.requestNewWidth(root.requestedWidth);

View file

@ -718,7 +718,7 @@ function restoreLODSettings() {
var nametag = Script.require("./simplifiedNametag/simplifiedNametag.js"); var nametag = Script.require("./simplifiedNametag/simplifiedNametag.js");
var si = Script.require("./simplifiedStatusIndicator/simplifiedStatusIndicator.js"); var si = Script.require("./simplifiedStatusIndicator/simplifiedStatusIndicator.js");
var simplifiedEmote = Script.require("../simplifiedEmote/simplifiedEmote.js?" + Date.now()); var simplifiedEmote = Script.require("../simplifiedEmote/simplifiedEmote.js");
var oldShowAudioTools; var oldShowAudioTools;
var oldShowBubbleTools; var oldShowBubbleTools;
var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false); var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false);