Added tons of logging to debug interactive window

This commit is contained in:
Rebecca Stankus 2019-10-22 12:33:47 -07:00
parent edb181bd16
commit 83a6155592
6 changed files with 65 additions and 4 deletions

View file

@ -53,6 +53,7 @@ Windows.Window {
property var initialized: false; property var initialized: false;
onSourceChanged: { onSourceChanged: {
print("INTERACTIVEWINDOWQML SOURCE CHANGED");
if (dynamicContent) { if (dynamicContent) {
dynamicContent.destroy(); dynamicContent.destroy();
dynamicContent = null; dynamicContent = null;
@ -67,15 +68,20 @@ Windows.Window {
} }
function updateInteractiveWindowPositionForMode() { function updateInteractiveWindowPositionForMode() {
print("INTERACTIVEWINDOWQML UPDATING WINDOW POSITION FOR MODE: PRESENTATION MODE IS ", presentationMode);
if (presentationMode === Desktop.PresentationMode.VIRTUAL) { if (presentationMode === Desktop.PresentationMode.VIRTUAL) {
print("INTERACTIVEWINDOWQML PRESENTATION MODE IS VIRTUAL");
x = interactiveWindowPosition.x; x = interactiveWindowPosition.x;
y = interactiveWindowPosition.y; y = interactiveWindowPosition.y;
} else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) {
print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE");
if (interactiveWindowPosition.x === 0 && interactiveWindowPosition.y === 0) { 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 // default position for native window in center of main application window
nativeWindow.x = Math.floor(Window.x + (Window.innerWidth / 2) - (interactiveWindowSize.width / 2)); nativeWindow.x = Math.floor(Window.x + (Window.innerWidth / 2) - (interactiveWindowSize.width / 2));
nativeWindow.y = Math.floor(Window.y + (Window.innerHeight / 2) - (interactiveWindowSize.height / 2)); nativeWindow.y = Math.floor(Window.y + (Window.innerHeight / 2) - (interactiveWindowSize.height / 2));
} else { } else {
print("INTERACTIVEWINDOWQML NATIVE WINDOW IS NOT AT x:0 AND y:0. MOVING TO POSITION OF INTERACTIVE WINDOW");
nativeWindow.x = interactiveWindowPosition.x; nativeWindow.x = interactiveWindowPosition.x;
nativeWindow.y = interactiveWindowPosition.y; nativeWindow.y = interactiveWindowPosition.y;
} }
@ -83,36 +89,46 @@ Windows.Window {
} }
function updateInteractiveWindowSizeForMode() { 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.width = interactiveWindowSize.width;
root.height = interactiveWindowSize.height; root.height = interactiveWindowSize.height;
contentHolder.width = interactiveWindowSize.width; contentHolder.width = interactiveWindowSize.width;
contentHolder.height = interactiveWindowSize.height; contentHolder.height = interactiveWindowSize.height;
if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { 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.width = interactiveWindowSize.width;
nativeWindow.height = interactiveWindowSize.height; nativeWindow.height = interactiveWindowSize.height;
} }
} }
function updateContentParent() { function updateContentParent() {
print("INTERACTIVEWINDOWQML UPDATE CONTENT PARENT");
if (presentationMode === Desktop.PresentationMode.VIRTUAL) { if (presentationMode === Desktop.PresentationMode.VIRTUAL) {
print("INTERACTIVEWINDOWQML PRESENTATION MODE IS VIRTUAL");
contentHolder.parent = root; contentHolder.parent = root;
} else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) { } else if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow) {
print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE");
contentHolder.parent = nativeWindow.contentItem; contentHolder.parent = nativeWindow.contentItem;
} }
} }
function setupPresentationMode() { function setupPresentationMode() {
print("INTERACTIVEWINDOWQML SET UP PRESENTATION MODE");
if (presentationMode === Desktop.PresentationMode.VIRTUAL) { 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) { if (nativeWindow) {
print("INTERACTIVEWINDOWQML SETTING NATIVE WINDOW TO NOT VISIBLE");
nativeWindow.setVisible(false); nativeWindow.setVisible(false);
} }
updateContentParent(); updateContentParent();
updateInteractiveWindowPositionForMode(); updateInteractiveWindowPositionForMode();
shown = interactiveWindowVisible; shown = interactiveWindowVisible;
} else if (presentationMode === Desktop.PresentationMode.NATIVE) { } else if (presentationMode === Desktop.PresentationMode.NATIVE) {
print("INTERACTIVEWINDOWQML PRESENTATION MODE IS NATIVE");
shown = false; shown = false;
if (nativeWindow) { 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(); updateContentParent();
updateInteractiveWindowPositionForMode(); updateInteractiveWindowPositionForMode();
nativeWindow.setVisible(interactiveWindowVisible); nativeWindow.setVisible(interactiveWindowVisible);
@ -123,6 +139,7 @@ Windows.Window {
} }
Component.onCompleted: { 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: // Fix for parent loss on OSX:
parent.heightChanged.connect(updateContentParent); parent.heightChanged.connect(updateContentParent);
parent.widthChanged.connect(updateContentParent); parent.widthChanged.connect(updateContentParent);
@ -140,10 +157,26 @@ Windows.Window {
id: root; id: root;
width: interactiveWindowSize.width width: interactiveWindowSize.width
height: interactiveWindowSize.height height: interactiveWindowSize.height
Component.onCompleted: {
print("INTERACTIVEWINDOWQML NATIVE WINDOW COMPLETED");
}
Rectangle { Rectangle {
color: hifi.colors.baseGray color: hifi.colors.baseGray
anchors.fill: parent 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'); }', root, 'InteractiveWindow.qml->nativeWindow');
nativeWindow.title = root.title; nativeWindow.title = root.title;
@ -167,27 +200,35 @@ Windows.Window {
nativeWindow.xChanged.connect(function() { nativeWindow.xChanged.connect(function() {
if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { 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); interactiveWindowPosition = Qt.point(nativeWindow.x, interactiveWindowPosition.y);
} }
}); });
nativeWindow.yChanged.connect(function() { nativeWindow.yChanged.connect(function() {
if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { 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); interactiveWindowPosition = Qt.point(interactiveWindowPosition.x, nativeWindow.y);
} }
}); });
nativeWindow.widthChanged.connect(function() { nativeWindow.widthChanged.connect(function() {
if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { 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); interactiveWindowSize = Qt.size(nativeWindow.width, interactiveWindowSize.height);
} }
}); });
nativeWindow.heightChanged.connect(function() { nativeWindow.heightChanged.connect(function() {
if (presentationMode === Desktop.PresentationMode.NATIVE && nativeWindow.visible) { 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); interactiveWindowSize = Qt.size(interactiveWindowSize.width, nativeWindow.height);
} }
}); });
nativeWindow.closing.connect(function(closeEvent) { nativeWindow.closing.connect(function(closeEvent) {
print("NATIVE WINDOW CLOSING SIGNAL.");
closeEvent.accepted = false; closeEvent.accepted = false;
windowClosed(); windowClosed();
}); });
@ -289,7 +330,10 @@ Windows.Window {
onYChanged: { onYChanged: {
if (presentationMode === Desktop.PresentationMode.VIRTUAL) { if (presentationMode === Desktop.PresentationMode.VIRTUAL) {
print("VIRTUAL WINDOW Y CHANGE");
interactiveWindowPosition = Qt.point(interactiveWindowPosition.x, y); interactiveWindowPosition = Qt.point(interactiveWindowPosition.x, y);
} else {
print("NATIVE WINDOW Y CHANGE");
} }
} }

View file

@ -133,6 +133,7 @@ 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",
@ -140,6 +141,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;
} }
@ -161,8 +163,10 @@ 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,6 +167,7 @@ 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;
@ -195,6 +196,7 @@ 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;
@ -253,6 +255,7 @@ 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);
@ -336,6 +339,7 @@ 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,6 +380,7 @@ 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) {
@ -521,9 +522,11 @@ 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,
@ -539,6 +542,7 @@ 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);
} }
@ -548,6 +552,7 @@ 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;
} }
@ -582,6 +587,7 @@ 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

@ -1,4 +1,4 @@
// //
// SimplifiedEmoteIndicator.qml // SimplifiedEmoteIndicator.qml
// //
// Created by Milad Nazeri on 2019-08-05 // Created by Milad Nazeri on 2019-08-05
@ -39,6 +39,9 @@ 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"); var simplifiedEmote = Script.require("../simplifiedEmote/simplifiedEmote.js?" + Date.now());
var oldShowAudioTools; var oldShowAudioTools;
var oldShowBubbleTools; var oldShowBubbleTools;
var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false); var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false);