From 83a61555924f42176e7feb09d5cfb1d743b5785c Mon Sep 17 00:00:00 2001 From: Rebecca Stankus Date: Tue, 22 Oct 2019 12:33:47 -0700 Subject: [PATCH 1/4] Added tons of logging to debug interactive window --- interface/resources/qml/InteractiveWindow.qml | 44 +++++++++++++++++++ .../scripting/DesktopScriptingInterface.cpp | 6 ++- interface/src/ui/InteractiveWindow.cpp | 4 ++ .../simplifiedEmote/simplifiedEmote.js | 8 +++- .../ui/qml/SimplifiedEmoteIndicator.qml | 5 ++- scripts/simplifiedUI/ui/simplifiedUI.js | 2 +- 6 files changed, 65 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/InteractiveWindow.qml b/interface/resources/qml/InteractiveWindow.qml index b27668f70c..0cf7760886 100644 --- a/interface/resources/qml/InteractiveWindow.qml +++ b/interface/resources/qml/InteractiveWindow.qml @@ -53,6 +53,7 @@ Windows.Window { property var initialized: false; onSourceChanged: { + print("INTERACTIVEWINDOWQML SOURCE CHANGED"); if (dynamicContent) { dynamicContent.destroy(); dynamicContent = null; @@ -67,15 +68,20 @@ Windows.Window { } function updateInteractiveWindowPositionForMode() { + print("INTERACTIVEWINDOWQML UPDATING WINDOW POSITION FOR MODE: PRESENTATION MODE IS ", presentationMode); if (presentationMode === Desktop.PresentationMode.VIRTUAL) { + print("INTERACTIVEWINDOWQML PRESENTATION MODE IS VIRTUAL"); x = interactiveWindowPosition.x; y = interactiveWindowPosition.y; } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { + print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE"); if (interactiveWindowPosition.x === 0 && interactiveWindowPosition.y === 0) { + print("INTERACTIVEWINDOWQML NATIVE WINDOW IS AT x:0 AND y:0. CALCULATING NEW POSITION."); // default position for native window in center of main application window nativeWindow.x = Math.floor(Window.x + (Window.innerWidth / 2) - (interactiveWindowSize.width / 2)); nativeWindow.y = Math.floor(Window.y + (Window.innerHeight / 2) - (interactiveWindowSize.height / 2)); } else { + print("INTERACTIVEWINDOWQML NATIVE WINDOW IS NOT AT x:0 AND y:0. MOVING TO POSITION OF INTERACTIVE WINDOW"); nativeWindow.x = interactiveWindowPosition.x; nativeWindow.y = interactiveWindowPosition.y; } @@ -83,36 +89,46 @@ Windows.Window { } function updateInteractiveWindowSizeForMode() { + print("INTERACTIVEWINDOWQML UPDATING SIZE FOR MODE. SETTING ROOT AND CONTENT HOLDER WIDTH AND HEIGHT TO MATCH INTERACTIVE WINDOW."); root.width = interactiveWindowSize.width; root.height = interactiveWindowSize.height; contentHolder.width = interactiveWindowSize.width; contentHolder.height = interactiveWindowSize.height; if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { + print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE SO ALSO SETTING NATIVE WINDOW WIDTH AND HEIGHT TO MATCH INTERACTIVE WINDOW."); nativeWindow.width = interactiveWindowSize.width; nativeWindow.height = interactiveWindowSize.height; } } function updateContentParent() { + print("INTERACTIVEWINDOWQML UPDATE CONTENT PARENT"); if (presentationMode === Desktop.PresentationMode.VIRTUAL) { + print("INTERACTIVEWINDOWQML PRESENTATION MODE IS VIRTUAL"); contentHolder.parent = root; } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { + print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE"); contentHolder.parent = nativeWindow.contentItem; } } function setupPresentationMode() { + print("INTERACTIVEWINDOWQML SET UP PRESENTATION MODE"); if (presentationMode === Desktop.PresentationMode.VIRTUAL) { + print("INTERACTIVEWINDOWQML PRESENTATION MODE IS VIRTUAL. UPDATING CONTENT PARENT, UPDATING INTERACTIVE WINDOW POSITION FOR MODE, AND SETTING VIRTUAL WINDOW VISIBILITY TO MATCH INTERACTIVE WINDOW VISIBILITY."); if (nativeWindow) { + print("INTERACTIVEWINDOWQML SETTING NATIVE WINDOW TO NOT VISIBLE"); nativeWindow.setVisible(false); } updateContentParent(); updateInteractiveWindowPositionForMode(); shown = interactiveWindowVisible; } else if (presentationMode === Desktop.PresentationMode.NATIVE) { + print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE"); shown = false; if (nativeWindow) { + print("INTERACTIVEWINDOWQML NATIVE EXISTS. UPDATING CONTENT PARENT, UPDATING INTERACTIVE WINDOW POSITION FOR MODE, AND SETTING NATIVE WINDOW VISIBILITY TO MATCH INTERACTIVE WINDOW VISIBILITY."); updateContentParent(); updateInteractiveWindowPositionForMode(); nativeWindow.setVisible(interactiveWindowVisible); @@ -123,6 +139,7 @@ Windows.Window { } Component.onCompleted: { + print("INTERACTIVEWINDOWQML ONROOTCOMPLETED FIX FOR OSX PARENT LOSS!!!!! CONNECTING SIGNALS TO UPDATE CONTENT PARENT WHEN PARENT HEIGHT OR WIDTH CHANGES. SETTING X,Y,WIDTH, AND HEIGHT TO MATCH INTERACTIVE WINDOW. CREATING NATIVE WINDOW. NATIVE WINDOW IS ALWAYS ON TOP FOR NON-WINDOWS."); // Fix for parent loss on OSX: parent.heightChanged.connect(updateContentParent); parent.widthChanged.connect(updateContentParent); @@ -140,10 +157,26 @@ Windows.Window { id: root; width: interactiveWindowSize.width height: interactiveWindowSize.height + Component.onCompleted: { + print("INTERACTIVEWINDOWQML NATIVE WINDOW COMPLETED"); + } Rectangle { color: hifi.colors.baseGray anchors.fill: parent + + MouseArea { + id: helpButtonMouseArea + anchors.fill: parent + hoverEnabled: true + onEntered: { + Tablet.playSound(TabletEnums.ButtonHover); + } + onClicked: { + nativeWindow.x = 0; + nativeWindow.y = 0; + } + } } }', root, 'InteractiveWindow.qml->nativeWindow'); nativeWindow.title = root.title; @@ -167,27 +200,35 @@ Windows.Window { nativeWindow.xChanged.connect(function() { if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { + print("NATIVE WINDOW X CHANGED SIGNAL. THE WINDOW WAS NATIVE AND VISIBLE"); interactiveWindowPosition = Qt.point(nativeWindow.x, interactiveWindowPosition.y); } }); + nativeWindow.yChanged.connect(function() { + if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { + print("NATIVE WINDOW Y CHANGED SIGNAL. THE WINDOW WAS NATIVE AND VISIBLE"); interactiveWindowPosition = Qt.point(interactiveWindowPosition.x, nativeWindow.y); } }); nativeWindow.widthChanged.connect(function() { if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { + print("NATIVE WINDOW WIDTH CHANGED SIGNAL. THE WINDOW WAS NATIVE AND VISIBLE"); interactiveWindowSize = Qt.size(nativeWindow.width, interactiveWindowSize.height); } }); + nativeWindow.heightChanged.connect(function() { if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { + print("NATIVE WINDOW HEIGHT CHANGED SIGNAL. THE WINDOW WAS NATIVE AND VISIBLE"); interactiveWindowSize = Qt.size(interactiveWindowSize.width, nativeWindow.height); } }); nativeWindow.closing.connect(function(closeEvent) { + print("NATIVE WINDOW CLOSING SIGNAL."); closeEvent.accepted = false; windowClosed(); }); @@ -289,7 +330,10 @@ Windows.Window { onYChanged: { if (presentationMode === Desktop.PresentationMode.VIRTUAL) { + print("VIRTUAL WINDOW Y CHANGE"); interactiveWindowPosition = Qt.point(interactiveWindowPosition.x, y); + } else { + print("NATIVE WINDOW Y CHANGE"); } } diff --git a/interface/src/scripting/DesktopScriptingInterface.cpp b/interface/src/scripting/DesktopScriptingInterface.cpp index ae4af48cd6..aa4329ef33 100644 --- a/interface/src/scripting/DesktopScriptingInterface.cpp +++ b/interface/src/scripting/DesktopScriptingInterface.cpp @@ -133,6 +133,7 @@ void DesktopScriptingInterface::show(const QString& path, const QString& title) } InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) { + qDebug() << "CREATING WINDOW WITH URL " << sourceUrl << " AND PROPERTIES " << properties; if (QThread::currentThread() != thread()) { InteractiveWindowPointer interactiveWindow = nullptr; BLOCKING_INVOKE_METHOD(this, "createWindowOnThread", @@ -140,7 +141,8 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& Q_ARG(QString, sourceUrl), Q_ARG(QVariantMap, properties), Q_ARG(QThread*, QThread::currentThread())); - return interactiveWindow; + qDebug() << "RETURNING INTERACTIVE WINDOW " << interactiveWindow; + return interactiveWindow; } @@ -161,8 +163,10 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindowOnThread(const Q // that the source URL is permitted const auto& urlValidator = OffscreenQmlSurface::getUrlValidator(); if (!urlValidator(sourceUrl)) { + qDebug("INTERACTIVE WINDOW SOURCE URL WAS NOT VALID"); return nullptr; } + qDebug() << "WINDOW SOURCE URL: " << sourceUrl; InteractiveWindowPointer window = new InteractiveWindow(sourceUrl, properties, _restricted); window->moveToThread(targetThread); return window; diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index 6cc26e2409..cb6a02d2cf 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -167,6 +167,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { + qDebug() << "CREATING WINDOW THAT IS DOCKED WITH NATIVE PRES MODE"; QVariantMap nativeWindowInfo = properties[DOCKED_PROPERTY].toMap(); Qt::DockWidgetArea dockArea = Qt::TopDockWidgetArea; QString title; @@ -195,6 +196,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap * @property {InteractiveWindow.DockArea} dockArea - The edge of the Interface window to dock to. */ if (nativeWindowInfo.contains(DOCK_AREA_PROPERTY)) { + qDebug() << "CREATING DOCK AREA FOR NATIVE WINDOW " << DOCK_AREA_PROPERTY; DockArea dockedArea = (DockArea) nativeWindowInfo[DOCK_AREA_PROPERTY].toInt(); int tempWidth = 0; int tempHeight = 0; @@ -253,6 +255,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap _dockWidget->setObjectName("DockedWidget"); mainWindow->addDockWidget(dockArea, _dockWidget.get()); } else { + qDebug() << "CREATING OTHER WINDOW (NOT DOCKED WITH NATIVE PRES MODE)"; auto contextInitLambda = [&](QQmlContext* context) { // If the restricted flag is on, the web content will not be able to access local files ContextAwareProfile::restrictContext(context, restricted); @@ -336,6 +339,7 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) { sourceURL = QUrl::fromLocalFile(sourceURL.toString()).toString(); } + qDebug() << "CREATING OTHER WINDOW WITH SOURCE URL: " << sourceUrl; object->setObjectName("InteractiveWindow"); object->setProperty(SOURCE_PROPERTY, sourceURL); }; diff --git a/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js b/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js index d7d6279e10..caab3c1e46 100644 --- a/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js +++ b/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js @@ -380,6 +380,7 @@ function onMessageFromEmoteAppBar(message) { if (message.source !== EMOTE_APP_BAR_MESSAGE_SOURCE) { return; } + print("EMOTE WINDOW MESSAGE"); switch (message.method) { case "positive": if (!message.data.isPressingAndHolding) { @@ -521,9 +522,11 @@ var EMOTE_APP_BAR_WINDOW_FLAGS = 0x00000001 | // Qt::Window var emoteAppBarWindow = false; function showEmoteAppBar() { if (emoteAppBarWindow) { + print("EMOTE APP BAR WINDOW ALREADY EXISTS. DO NOT SHOW AGAIN."); return; } + print("CREATE EMOTE WINDOW"); emoteAppBarWindow = Desktop.createWindow(EMOTE_APP_BAR_QML_PATH, { title: EMOTE_APP_BAR_WINDOW_TITLE, presentationMode: EMOTE_APP_BAR_PRESENTATION_MODE, @@ -539,6 +542,7 @@ function showEmoteAppBar() { overrideFlags: EMOTE_APP_BAR_WINDOW_FLAGS }); + print("EMOTE APP BAR WINDOW CREATED: ", emoteAppBarWindow); emoteAppBarWindow.fromQml.connect(onMessageFromEmoteAppBar); } @@ -548,6 +552,7 @@ function showEmoteAppBar() { // We should add that functionality to the Window Scripting Interface, and remove `isWindowMinimized` below. var isWindowMinimized = false; function maybeChangeEmoteIndicatorVisibility(desiredVisibility) { + print("MAYBE CHANGE EMOTE WINDOW VISIBILITY ", desiredVisibility); if (isWindowMinimized || HMD.active) { desiredVisibility = false; } @@ -582,6 +587,7 @@ var emojiCodeMap; var customEmojiCodeMap; var _this; function setup() { + print("STARTING EMOTE SCRIPT"); deleteOldReticles(); // make a map of just the utf codes to help with accesing @@ -798,4 +804,4 @@ function toggleEmojiApp() { var emote = setup(); -module.exports = emote; \ No newline at end of file +module.exports = emote; diff --git a/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml b/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml index bbd1d4d735..eb6f105fac 100644 --- a/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml +++ b/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml @@ -1,4 +1,4 @@ -// +// // SimplifiedEmoteIndicator.qml // // Created by Milad Nazeri on 2019-08-05 @@ -39,6 +39,9 @@ Rectangle { readonly property string emoteIconSource: "images/emote_Icon.svg" property bool allowEmoteDrawerExpansion: Settings.getValue("simplifiedUI/allowEmoteDrawerExpansion", true) + Component.onCompleted: { + print("EMOTE APP BAR ROOT WINDOW HAS COMPLETED LOADING"); + } onRequestedWidthChanged: { root.requestNewWidth(root.requestedWidth); diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 2ce6a3e073..4939f9e426 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -718,7 +718,7 @@ function restoreLODSettings() { var nametag = Script.require("./simplifiedNametag/simplifiedNametag.js"); var si = Script.require("./simplifiedStatusIndicator/simplifiedStatusIndicator.js"); -var simplifiedEmote = Script.require("../simplifiedEmote/simplifiedEmote.js"); +var simplifiedEmote = Script.require("../simplifiedEmote/simplifiedEmote.js?" + Date.now()); var oldShowAudioTools; var oldShowBubbleTools; var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false); From 8e8c157567b3d09406d790a36d9a6998523b2598 Mon Sep 17 00:00:00 2001 From: Rebecca Stankus Date: Wed, 23 Oct 2019 16:03:46 -0700 Subject: [PATCH 2/4] Debugging stuff --- interface/resources/qml/InteractiveWindow.qml | 91 ++++++++----------- 1 file changed, 36 insertions(+), 55 deletions(-) diff --git a/interface/resources/qml/InteractiveWindow.qml b/interface/resources/qml/InteractiveWindow.qml index 0cf7760886..1f9f48d55e 100644 --- a/interface/resources/qml/InteractiveWindow.qml +++ b/interface/resources/qml/InteractiveWindow.qml @@ -53,7 +53,6 @@ Windows.Window { property var initialized: false; onSourceChanged: { - print("INTERACTIVEWINDOWQML SOURCE CHANGED"); if (dynamicContent) { dynamicContent.destroy(); dynamicContent = null; @@ -66,22 +65,28 @@ Windows.Window { } }); } + + Timer { + id: timer + } + + function delay(delayTimeMS, delayFunction) { + timer.interval = delayTimeMS; + timer.repeat = true; + timer.triggered.connect(delayFunction); + timer.start(); + } function updateInteractiveWindowPositionForMode() { - print("INTERACTIVEWINDOWQML UPDATING WINDOW POSITION FOR MODE: PRESENTATION MODE IS ", presentationMode); if (presentationMode === Desktop.PresentationMode.VIRTUAL) { - print("INTERACTIVEWINDOWQML PRESENTATION MODE IS VIRTUAL"); x = interactiveWindowPosition.x; y = interactiveWindowPosition.y; } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { - print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE"); if (interactiveWindowPosition.x === 0 && interactiveWindowPosition.y === 0) { - print("INTERACTIVEWINDOWQML NATIVE WINDOW IS AT x:0 AND y:0. CALCULATING NEW POSITION."); // default position for native window in center of main application window nativeWindow.x = Math.floor(Window.x + (Window.innerWidth / 2) - (interactiveWindowSize.width / 2)); nativeWindow.y = Math.floor(Window.y + (Window.innerHeight / 2) - (interactiveWindowSize.height / 2)); } else { - print("INTERACTIVEWINDOWQML NATIVE WINDOW IS NOT AT x:0 AND y:0. MOVING TO POSITION OF INTERACTIVE WINDOW"); nativeWindow.x = interactiveWindowPosition.x; nativeWindow.y = interactiveWindowPosition.y; } @@ -89,60 +94,54 @@ Windows.Window { } function updateInteractiveWindowSizeForMode() { - print("INTERACTIVEWINDOWQML UPDATING SIZE FOR MODE. SETTING ROOT AND CONTENT HOLDER WIDTH AND HEIGHT TO MATCH INTERACTIVE WINDOW."); root.width = interactiveWindowSize.width; root.height = interactiveWindowSize.height; contentHolder.width = interactiveWindowSize.width; contentHolder.height = interactiveWindowSize.height; if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { - print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE SO ALSO SETTING NATIVE WINDOW WIDTH AND HEIGHT TO MATCH INTERACTIVE WINDOW."); nativeWindow.width = interactiveWindowSize.width; nativeWindow.height = interactiveWindowSize.height; } } function updateContentParent() { - print("INTERACTIVEWINDOWQML UPDATE CONTENT PARENT"); if (presentationMode === Desktop.PresentationMode.VIRTUAL) { - print("INTERACTIVEWINDOWQML PRESENTATION MODE IS VIRTUAL"); contentHolder.parent = root; + print("INTERACTIVEWINDOWQML CHANGED CONTENT PARENT TO ROOT. CONTENT HOLDER PARENT IS ", contentHolder.parent); } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { - print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE"); 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"); } } function setupPresentationMode() { - print("INTERACTIVEWINDOWQML SET UP PRESENTATION MODE"); if (presentationMode === Desktop.PresentationMode.VIRTUAL) { - print("INTERACTIVEWINDOWQML PRESENTATION MODE IS VIRTUAL. UPDATING CONTENT PARENT, UPDATING INTERACTIVE WINDOW POSITION FOR MODE, AND SETTING VIRTUAL WINDOW VISIBILITY TO MATCH INTERACTIVE WINDOW VISIBILITY."); if (nativeWindow) { - print("INTERACTIVEWINDOWQML SETTING NATIVE WINDOW TO NOT VISIBLE"); nativeWindow.setVisible(false); } - updateContentParent(); updateInteractiveWindowPositionForMode(); shown = interactiveWindowVisible; } else if (presentationMode === Desktop.PresentationMode.NATIVE) { - print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE"); shown = false; if (nativeWindow) { - print("INTERACTIVEWINDOWQML NATIVE EXISTS. UPDATING CONTENT PARENT, UPDATING INTERACTIVE WINDOW POSITION FOR MODE, AND SETTING NATIVE WINDOW VISIBILITY TO MATCH INTERACTIVE WINDOW VISIBILITY."); - updateContentParent(); + print("INTERACTIVEWINDOWQML SET UP PRES MODE FOUND NATIVE WINDOW"); updateInteractiveWindowPositionForMode(); nativeWindow.setVisible(interactiveWindowVisible); + } else { + print("INTERACTIVEWINDOWQML SET UP PRES MODE DID NOT FIND NATIVE WINDOW"); } } else if (presentationMode === modeNotSet) { - console.error("presentationMode should be set."); + console.error("presentationMode should be set"); } } Component.onCompleted: { - print("INTERACTIVEWINDOWQML ONROOTCOMPLETED FIX FOR OSX PARENT LOSS!!!!! CONNECTING SIGNALS TO UPDATE CONTENT PARENT WHEN PARENT HEIGHT OR WIDTH CHANGES. SETTING X,Y,WIDTH, AND HEIGHT TO MATCH INTERACTIVE WINDOW. CREATING NATIVE WINDOW. NATIVE WINDOW IS ALWAYS ON TOP FOR NON-WINDOWS."); - // Fix for parent loss on OSX: - parent.heightChanged.connect(updateContentParent); - parent.widthChanged.connect(updateContentParent); + print("INTERACTIVEWINDOWQML ONROOTCOMPLETED COMPLETED. ID IS ", this, " . CONTENT HOLDER PARENT IS ", contentHolder.parent); x = interactiveWindowPosition.x; y = interactiveWindowPosition.y; @@ -158,25 +157,13 @@ Windows.Window { width: interactiveWindowSize.width height: interactiveWindowSize.height Component.onCompleted: { - print("INTERACTIVEWINDOWQML NATIVE WINDOW COMPLETED"); + // calling setupPresentationMode from here does not work because the fn will not find the native window + print("INTERACTIVEWINDOWQML NATIVE WINDOW COMPLETED. ID IS ", this, " CONTENT HOLDER PARENT IS ", contentHolder.parent); } Rectangle { color: hifi.colors.baseGray anchors.fill: parent - - MouseArea { - id: helpButtonMouseArea - anchors.fill: parent - hoverEnabled: true - onEntered: { - Tablet.playSound(TabletEnums.ButtonHover); - } - onClicked: { - nativeWindow.x = 0; - nativeWindow.y = 0; - } - } } }', root, 'InteractiveWindow.qml->nativeWindow'); nativeWindow.title = root.title; @@ -200,50 +187,40 @@ Windows.Window { nativeWindow.xChanged.connect(function() { if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { - print("NATIVE WINDOW X CHANGED SIGNAL. THE WINDOW WAS NATIVE AND VISIBLE"); interactiveWindowPosition = Qt.point(nativeWindow.x, interactiveWindowPosition.y); } }); nativeWindow.yChanged.connect(function() { - if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { - print("NATIVE WINDOW Y CHANGED SIGNAL. THE WINDOW WAS NATIVE AND VISIBLE"); interactiveWindowPosition = Qt.point(interactiveWindowPosition.x, nativeWindow.y); } }); nativeWindow.widthChanged.connect(function() { if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { - print("NATIVE WINDOW WIDTH CHANGED SIGNAL. THE WINDOW WAS NATIVE AND VISIBLE"); interactiveWindowSize = Qt.size(nativeWindow.width, interactiveWindowSize.height); } }); nativeWindow.heightChanged.connect(function() { if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { - print("NATIVE WINDOW HEIGHT CHANGED SIGNAL. THE WINDOW WAS NATIVE AND VISIBLE"); interactiveWindowSize = Qt.size(interactiveWindowSize.width, nativeWindow.height); } }); nativeWindow.closing.connect(function(closeEvent) { - print("NATIVE WINDOW CLOSING SIGNAL."); closeEvent.accepted = false; windowClosed(); }); - + // finally set the initial window mode: setupPresentationMode(); - + updateContentParent(); +//TODO move this to wherever initialization is actually completed initialized = true; } - Component.onDestruction: { - parent.heightChanged.disconnect(updateContentParent); - parent.widthChanged.disconnect(updateContentParent); - } - // Handle message traffic from the script that launched us to the loaded QML function fromScript(message) { if (root.dynamicContent && root.dynamicContent.fromScript) { @@ -273,8 +250,8 @@ Windows.Window { interactiveWindowSize.width = newWidth; updateInteractiveWindowSizeForMode(); } - function onRequestNewHeight(newWidth) { - interactiveWindowSize.width = newWidth; + function onRequestNewHeight(newHeight) { + interactiveWindowSize.height = newHeight; updateInteractiveWindowSizeForMode(); } @@ -330,10 +307,7 @@ Windows.Window { onYChanged: { if (presentationMode === Desktop.PresentationMode.VIRTUAL) { - print("VIRTUAL WINDOW Y CHANGE"); interactiveWindowPosition = Qt.point(interactiveWindowPosition.x, y); - } else { - print("NATIVE WINDOW Y CHANGE"); } } @@ -352,6 +326,7 @@ Windows.Window { onPresentationModeChanged: { if (initialized) { setupPresentationMode(); + updateContentParent(); } } @@ -367,5 +342,11 @@ Windows.Window { Item { id: contentHolder 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); + } } } From f8102be74d64adde93ad138cfedb7fd56dfbb263 Mon Sep 17 00:00:00 2001 From: Rebecca Stankus Date: Wed, 23 Oct 2019 16:42:28 -0700 Subject: [PATCH 3/4] Added a timeout to update the content holder parent after interactive window has finished loading --- interface/resources/qml/InteractiveWindow.qml | 32 +++++-------------- .../scripting/DesktopScriptingInterface.cpp | 6 +--- interface/src/ui/InteractiveWindow.cpp | 4 --- .../simplifiedEmote/simplifiedEmote.js | 6 ---- .../ui/qml/SimplifiedEmoteIndicator.qml | 3 -- scripts/simplifiedUI/ui/simplifiedUI.js | 2 +- 6 files changed, 10 insertions(+), 43 deletions(-) diff --git a/interface/resources/qml/InteractiveWindow.qml b/interface/resources/qml/InteractiveWindow.qml index 1f9f48d55e..3741db74c1 100644 --- a/interface/resources/qml/InteractiveWindow.qml +++ b/interface/resources/qml/InteractiveWindow.qml @@ -72,7 +72,7 @@ Windows.Window { function delay(delayTimeMS, delayFunction) { timer.interval = delayTimeMS; - timer.repeat = true; + timer.repeat = false; timer.triggered.connect(delayFunction); timer.start(); } @@ -108,14 +108,8 @@ Windows.Window { function updateContentParent() { if (presentationMode === Desktop.PresentationMode.VIRTUAL) { contentHolder.parent = root; - print("INTERACTIVEWINDOWQML CHANGED CONTENT PARENT TO ROOT. CONTENT HOLDER PARENT IS ", contentHolder.parent); } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { 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) { shown = false; if (nativeWindow) { - print("INTERACTIVEWINDOWQML SET UP PRES MODE FOUND NATIVE WINDOW"); updateInteractiveWindowPositionForMode(); nativeWindow.setVisible(interactiveWindowVisible); - } else { - print("INTERACTIVEWINDOWQML SET UP PRES MODE DID NOT FIND NATIVE WINDOW"); } } else if (presentationMode === modeNotSet) { - console.error("presentationMode should be set"); + console.error("presentationMode should be set."); } } Component.onCompleted: { - print("INTERACTIVEWINDOWQML ONROOTCOMPLETED COMPLETED. ID IS ", this, " . CONTENT HOLDER PARENT IS ", contentHolder.parent); - + x = interactiveWindowPosition.x; y = interactiveWindowPosition.y; width = interactiveWindowSize.width; @@ -157,8 +147,9 @@ Windows.Window { width: interactiveWindowSize.width height: interactiveWindowSize.height Component.onCompleted: { - // calling setupPresentationMode from here does not work because the fn will not find the native window - print("INTERACTIVEWINDOWQML NATIVE WINDOW COMPLETED. ID IS ", this, " CONTENT HOLDER PARENT IS ", contentHolder.parent); + delay(500, function() { + updateContentParent(); + }); } Rectangle { @@ -213,11 +204,10 @@ Windows.Window { closeEvent.accepted = false; windowClosed(); }); - + // finally set the initial window mode: setupPresentationMode(); - updateContentParent(); -//TODO move this to wherever initialization is actually completed + initialized = true; } @@ -342,11 +332,5 @@ Windows.Window { Item { id: contentHolder 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); - } } } diff --git a/interface/src/scripting/DesktopScriptingInterface.cpp b/interface/src/scripting/DesktopScriptingInterface.cpp index aa4329ef33..ae4af48cd6 100644 --- a/interface/src/scripting/DesktopScriptingInterface.cpp +++ b/interface/src/scripting/DesktopScriptingInterface.cpp @@ -133,7 +133,6 @@ void DesktopScriptingInterface::show(const QString& path, const QString& title) } InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) { - qDebug() << "CREATING WINDOW WITH URL " << sourceUrl << " AND PROPERTIES " << properties; if (QThread::currentThread() != thread()) { InteractiveWindowPointer interactiveWindow = nullptr; BLOCKING_INVOKE_METHOD(this, "createWindowOnThread", @@ -141,8 +140,7 @@ InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& Q_ARG(QString, sourceUrl), Q_ARG(QVariantMap, properties), 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 const auto& urlValidator = OffscreenQmlSurface::getUrlValidator(); if (!urlValidator(sourceUrl)) { - qDebug("INTERACTIVE WINDOW SOURCE URL WAS NOT VALID"); return nullptr; } - qDebug() << "WINDOW SOURCE URL: " << sourceUrl; InteractiveWindowPointer window = new InteractiveWindow(sourceUrl, properties, _restricted); window->moveToThread(targetThread); return window; diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index cb6a02d2cf..6cc26e2409 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -167,7 +167,6 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap &InteractiveWindowProxy::emitScriptEvent, Qt::QueuedConnection); if (properties.contains(DOCKED_PROPERTY) && presentationMode == InteractiveWindowPresentationMode::Native) { - qDebug() << "CREATING WINDOW THAT IS DOCKED WITH NATIVE PRES MODE"; QVariantMap nativeWindowInfo = properties[DOCKED_PROPERTY].toMap(); Qt::DockWidgetArea dockArea = Qt::TopDockWidgetArea; 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. */ if (nativeWindowInfo.contains(DOCK_AREA_PROPERTY)) { - qDebug() << "CREATING DOCK AREA FOR NATIVE WINDOW " << DOCK_AREA_PROPERTY; DockArea dockedArea = (DockArea) nativeWindowInfo[DOCK_AREA_PROPERTY].toInt(); int tempWidth = 0; int tempHeight = 0; @@ -255,7 +253,6 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap _dockWidget->setObjectName("DockedWidget"); mainWindow->addDockWidget(dockArea, _dockWidget.get()); } else { - qDebug() << "CREATING OTHER WINDOW (NOT DOCKED WITH NATIVE PRES MODE)"; auto contextInitLambda = [&](QQmlContext* context) { // If the restricted flag is on, the web content will not be able to access local files ContextAwareProfile::restrictContext(context, restricted); @@ -339,7 +336,6 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) { sourceURL = QUrl::fromLocalFile(sourceURL.toString()).toString(); } - qDebug() << "CREATING OTHER WINDOW WITH SOURCE URL: " << sourceUrl; object->setObjectName("InteractiveWindow"); object->setProperty(SOURCE_PROPERTY, sourceURL); }; diff --git a/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js b/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js index caab3c1e46..e0ef9aaf5d 100644 --- a/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js +++ b/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js @@ -380,7 +380,6 @@ function onMessageFromEmoteAppBar(message) { if (message.source !== EMOTE_APP_BAR_MESSAGE_SOURCE) { return; } - print("EMOTE WINDOW MESSAGE"); switch (message.method) { case "positive": if (!message.data.isPressingAndHolding) { @@ -522,11 +521,9 @@ var EMOTE_APP_BAR_WINDOW_FLAGS = 0x00000001 | // Qt::Window var emoteAppBarWindow = false; function showEmoteAppBar() { if (emoteAppBarWindow) { - print("EMOTE APP BAR WINDOW ALREADY EXISTS. DO NOT SHOW AGAIN."); return; } - print("CREATE EMOTE WINDOW"); emoteAppBarWindow = Desktop.createWindow(EMOTE_APP_BAR_QML_PATH, { title: EMOTE_APP_BAR_WINDOW_TITLE, presentationMode: EMOTE_APP_BAR_PRESENTATION_MODE, @@ -542,7 +539,6 @@ function showEmoteAppBar() { overrideFlags: EMOTE_APP_BAR_WINDOW_FLAGS }); - print("EMOTE APP BAR WINDOW CREATED: ", emoteAppBarWindow); emoteAppBarWindow.fromQml.connect(onMessageFromEmoteAppBar); } @@ -552,7 +548,6 @@ function showEmoteAppBar() { // We should add that functionality to the Window Scripting Interface, and remove `isWindowMinimized` below. var isWindowMinimized = false; function maybeChangeEmoteIndicatorVisibility(desiredVisibility) { - print("MAYBE CHANGE EMOTE WINDOW VISIBILITY ", desiredVisibility); if (isWindowMinimized || HMD.active) { desiredVisibility = false; } @@ -587,7 +582,6 @@ var emojiCodeMap; var customEmojiCodeMap; var _this; function setup() { - print("STARTING EMOTE SCRIPT"); deleteOldReticles(); // make a map of just the utf codes to help with accesing diff --git a/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml b/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml index eb6f105fac..674966c228 100644 --- a/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml +++ b/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml @@ -39,9 +39,6 @@ Rectangle { readonly property string emoteIconSource: "images/emote_Icon.svg" property bool allowEmoteDrawerExpansion: Settings.getValue("simplifiedUI/allowEmoteDrawerExpansion", true) - Component.onCompleted: { - print("EMOTE APP BAR ROOT WINDOW HAS COMPLETED LOADING"); - } onRequestedWidthChanged: { root.requestNewWidth(root.requestedWidth); diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 4939f9e426..2ce6a3e073 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -718,7 +718,7 @@ function restoreLODSettings() { var nametag = Script.require("./simplifiedNametag/simplifiedNametag.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 oldShowBubbleTools; var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false); From 9a8fda2705c6b3fab2a2adcaefbfdcd7ac542366 Mon Sep 17 00:00:00 2001 From: Rebecca Stankus Date: Thu, 24 Oct 2019 10:24:18 -0700 Subject: [PATCH 4/4] Feedback changes --- interface/resources/qml/InteractiveWindow.qml | 18 ++++++++---------- .../simplifiedEmote/simplifiedEmote.js | 2 +- .../ui/qml/SimplifiedEmoteIndicator.qml | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/interface/resources/qml/InteractiveWindow.qml b/interface/resources/qml/InteractiveWindow.qml index 3741db74c1..3a4ec8838c 100644 --- a/interface/resources/qml/InteractiveWindow.qml +++ b/interface/resources/qml/InteractiveWindow.qml @@ -68,13 +68,11 @@ Windows.Window { Timer { id: timer - } - - function delay(delayTimeMS, delayFunction) { - timer.interval = delayTimeMS; - timer.repeat = false; - timer.triggered.connect(delayFunction); - timer.start(); + interval: 500; + repeat: false; + onTriggered: { + updateContentParent(); + } } function updateInteractiveWindowPositionForMode() { @@ -146,10 +144,10 @@ Windows.Window { id: root; width: interactiveWindowSize.width height: interactiveWindowSize.height + // fix for missing content on OSX initial startup with a non-maximized interface window. It seems that in this case, we cannot update + // the content parent during creation of the Window root. This added delay will update the parent after the root has finished loading. Component.onCompleted: { - delay(500, function() { - updateContentParent(); - }); + timer.start(); } Rectangle { diff --git a/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js b/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js index e0ef9aaf5d..d7d6279e10 100644 --- a/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js +++ b/scripts/simplifiedUI/simplifiedEmote/simplifiedEmote.js @@ -798,4 +798,4 @@ function toggleEmojiApp() { var emote = setup(); -module.exports = emote; +module.exports = emote; \ No newline at end of file diff --git a/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml b/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml index 674966c228..bbd1d4d735 100644 --- a/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml +++ b/scripts/simplifiedUI/simplifiedEmote/ui/qml/SimplifiedEmoteIndicator.qml @@ -1,4 +1,4 @@ -// +// // SimplifiedEmoteIndicator.qml // // Created by Milad Nazeri on 2019-08-05