From 83a61555924f42176e7feb09d5cfb1d743b5785c Mon Sep 17 00:00:00 2001 From: Rebecca Stankus Date: Tue, 22 Oct 2019 12:33:47 -0700 Subject: [PATCH] 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);