From b1d472c9bac995e237a84c23b2fb4fea56f36bbc Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 29 Aug 2016 12:28:59 -0700 Subject: [PATCH 01/11] workaround for Script.resolvePath() bug --- scripts/defaultScripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index 98825c594d..f3539acb3f 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -44,7 +44,7 @@ if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_I menuName: MENU_CATEGORY, menuItemName: MENU_ITEM, isCheckable: true, - isChecked: false, + isChecked: true, // temporary WORKAROUND for Scripts.resolvePath() bug grouping: "Advanced" }); } From 6272db42dafc2cbc0171f81d21eb80bffb817584 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 29 Aug 2016 13:53:08 -0700 Subject: [PATCH 02/11] restore onNewViewRequested --- interface/resources/qml/controls-uit/WebView.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index faf7f746a2..04c8ef873d 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -61,6 +61,11 @@ WebEngineView { } } + onNewViewRequested:{ + var component = Qt.createComponent("../Browser.qml"); + var newWindow = component.createObject(desktop); + request.openIn(newWindow.webView) + } // This breaks the webchannel used for passing messages. Fixed in Qt 5.6 // See https://bugreports.qt.io/browse/QTBUG-49521 From 11f00ed46cf2d571cf6bc2f3e72f0efb107a8069 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 29 Aug 2016 14:44:48 -0700 Subject: [PATCH 03/11] add a hook so that clients can gain access to the new component, window, and request --- interface/resources/qml/controls-uit/WebView.qml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index 04c8ef873d..8c46aabcae 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -61,10 +61,12 @@ WebEngineView { } } + property var newWindowHook: function (component, newWindow, request) { }; // override if you need to onNewViewRequested:{ - var component = Qt.createComponent("../Browser.qml"); - var newWindow = component.createObject(desktop); - request.openIn(newWindow.webView) + var component = Qt.createComponent("../Browser.qml"); + var newWindow = component.createObject(desktop); + request.openIn(newWindow.webView) + newWindowHook(component, newWindow, request); } // This breaks the webchannel used for passing messages. Fixed in Qt 5.6 From b50d24fb00fd514d46c2e5b932b7e09dc703b348 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 29 Aug 2016 17:11:29 -0700 Subject: [PATCH 04/11] don't use Script.resolvePath() in local functions --- scripts/system/edit.js | 12 +++++++----- scripts/system/mod.js | 7 +++++-- scripts/system/notifications.js | 7 ++++--- scripts/system/snapshot.js | 4 +++- scripts/system/users.js | 14 ++++++++------ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 1a50fb0d8b..d6a5f9e68b 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -164,9 +164,10 @@ function toggleMarketplace() { } } +var TOOLS_PATH = Script.resolvePath("assets/images/tools/"); + var toolBar = (function () { var EDIT_SETTING = "io.highfidelity.isEditting"; // for communication with other scripts - var TOOL_ICON_URL = Script.resolvePath("assets/images/tools/"); var that = {}, toolBar, systemToolbar, @@ -199,7 +200,7 @@ var toolBar = (function () { } function addButton(name, image, handler) { - var imageUrl = TOOL_ICON_URL + image; + var imageUrl = TOOLS_PATH + image; var button = toolBar.addButton({ objectName: name, imageURL: imageUrl, @@ -232,7 +233,7 @@ var toolBar = (function () { systemToolbar = Toolbars.getToolbar(SYSTEM_TOOLBAR); activeButton = systemToolbar.addButton({ objectName: EDIT_TOGGLE_BUTTON, - imageURL: TOOL_ICON_URL + "edit.svg", + imageURL: TOOLS_PATH + "edit.svg", visible: true, alpha: 0.9, buttonState: 1, @@ -1326,13 +1327,14 @@ function pushCommandForSelections(createdEntityData, deletedEntityData) { UndoStack.pushCommand(applyEntityProperties, undoData, applyEntityProperties, redoData); } +var ENTITY_PROPERTIES_URL = Script.resolvePath('html/entityProperties.html'); + var PropertiesTool = function (opts) { var that = {}; - var url = Script.resolvePath('html/entityProperties.html'); var webView = new OverlayWebWindow({ title: 'Entity Properties', - source: url, + source: ENTITY_PROPERTIES_URL, toolWindow: true }); diff --git a/scripts/system/mod.js b/scripts/system/mod.js index e69c2ce2f6..193feebdb2 100644 --- a/scripts/system/mod.js +++ b/scripts/system/mod.js @@ -16,8 +16,11 @@ // grab the toolbar var toolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); +var ASSETS_PATH = Script.resolvePath("assets" +var TOOLS_PATH = Script.resolvePath("assets/images/tools/"); + function buttonImageURL() { - return Script.resolvePath("assets/images/tools/" + (Users.canKick ? 'kick.svg' : 'ignore.svg')); + return TOOLS_PATH + (Users.canKick ? 'kick.svg' : 'ignore.svg')); } // setup the mod button and add it to the toolbar @@ -68,7 +71,7 @@ function buttonClicked(){ button.clicked.connect(buttonClicked); function overlayURL() { - return Script.resolvePath("assets") + "/images/" + (Users.canKick ? "kick-target.svg" : "ignore-target.svg"); + return ASSETS_PATH + "/images/" + (Users.canKick ? "kick-target.svg" : "ignore-target.svg"); } function updateOverlays() { diff --git a/scripts/system/notifications.js b/scripts/system/notifications.js index 673b48961d..f41b0502c8 100644 --- a/scripts/system/notifications.js +++ b/scripts/system/notifications.js @@ -124,7 +124,6 @@ var NotificationType = { var randomSounds = new SoundArray({ localOnly: true }, true); var numberOfSounds = 2; for (var i = 1; i <= numberOfSounds; i++) { - randomSounds.addSound(Script.resolvePath("assets/sounds/notification-general"+ i + ".raw")); } @@ -317,6 +316,8 @@ function notify(notice, button, height, imageProperties, image) { return notificationText; } +var CLOSE_NOTIFICATION_ICON = Script.resolvePath("assets/images/close-small-light.svg"); + // This function creates and sizes the overlays function createNotification(text, notificationType, imageProperties) { var count = (text.match(/\n/g) || []).length, @@ -363,7 +364,7 @@ function createNotification(text, notificationType, imageProperties) { width: 10.0, height: 10.0, subImage: { x: 0, y: 0, width: 10, height: 10 }, - imageURL: Script.resolvePath("assets/images/close-small-light.svg"), + imageURL: CLOSE_NOTIFICATION_ICON, color: { red: 255, green: 255, blue: 255}, visible: true, alpha: backgroundAlpha @@ -534,7 +535,7 @@ function onDomainConnectionRefused(reason) { function onSnapshotTaken(path, notify) { if (notify) { var imageProperties = { - path: Script.resolvePath("file:///" + path), + path: "file:///" + path, aspectRatio: Window.innerWidth / Window.innerHeight } createNotification(wordWrap("Snapshot saved to " + path), NotificationType.SNAPSHOT, imageProperties); diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index c9876af039..5eebadd02f 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -32,9 +32,11 @@ function showFeedWindow() { DialogsManager.showFeed(); } +var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html"); + var outstanding; function confirmShare(data) { - var dialog = new OverlayWebWindow('Snapshot Review', Script.resolvePath("html/SnapshotReview.html"), 800, 320); + var dialog = new OverlayWebWindow('Snapshot Review', SNAPSHOT_REVIEW_URL, 800, 320); function onMessage(message) { // Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following: // 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.) diff --git a/scripts/system/users.js b/scripts/system/users.js index a56656a074..76722bd58d 100644 --- a/scripts/system/users.js +++ b/scripts/system/users.js @@ -13,6 +13,10 @@ (function() { // BEGIN LOCAL_SCOPE +// resolve these paths immediately +var MIN_MAX_BUTTON_SVG = Script.resolvePath("assets/images/tools/min-max-toggle.svg"); +var BASE_URL = Script.resolvePath("assets/images/tools/"); + var PopUpMenu = function (properties) { var value = properties.value, promptOverlay, @@ -25,8 +29,7 @@ var PopUpMenu = function (properties) { MIN_MAX_BUTTON_SVG_WIDTH = 17.1, MIN_MAX_BUTTON_SVG_HEIGHT = 32.5, MIN_MAX_BUTTON_WIDTH = 14, - MIN_MAX_BUTTON_HEIGHT = MIN_MAX_BUTTON_WIDTH, - MIN_MAX_BUTTON_SVG = Script.resolvePath("assets/images/tools/min-max-toggle.svg"); + MIN_MAX_BUTTON_HEIGHT = MIN_MAX_BUTTON_WIDTH; function positionDisplayOptions() { var y, @@ -223,8 +226,7 @@ var PopUpMenu = function (properties) { var usersWindow = (function () { - var baseURL = Script.resolvePath("assets/images/tools/"), - WINDOW_WIDTH = 260, + var WINDOW_WIDTH = 260, WINDOW_MARGIN = 12, WINDOW_BASE_MARGIN = 6, // A little less is needed in order look correct WINDOW_FONT = { @@ -261,7 +263,7 @@ var usersWindow = (function () { WINDOW_BORDER_ALPHA = 0.5, windowBorder, - MIN_MAX_BUTTON_SVG = baseURL + "min-max-toggle.svg", + MIN_MAX_BUTTON_SVG = BASE_URL + "min-max-toggle.svg", MIN_MAX_BUTTON_SVG_WIDTH = 17.1, MIN_MAX_BUTTON_SVG_HEIGHT = 32.5, MIN_MAX_BUTTON_WIDTH = 14, @@ -293,7 +295,7 @@ var usersWindow = (function () { scrollbarBackgroundHeight, scrollbarBarHeight, FRIENDS_BUTTON_SPACER = 6, // Space before add/remove friends button - FRIENDS_BUTTON_SVG = baseURL + "add-remove-friends.svg", + FRIENDS_BUTTON_SVG = BASE_URL + "add-remove-friends.svg", FRIENDS_BUTTON_SVG_WIDTH = 107, FRIENDS_BUTTON_SVG_HEIGHT = 27, FRIENDS_BUTTON_WIDTH = FRIENDS_BUTTON_SVG_WIDTH, From 99acc9045de5c39eaa6cea28ddb16b0d3dd9ade4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 29 Aug 2016 17:15:01 -0700 Subject: [PATCH 05/11] disable defaultScripts.js debugging by default --- scripts/defaultScripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index f3539acb3f..98825c594d 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -44,7 +44,7 @@ if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_I menuName: MENU_CATEGORY, menuItemName: MENU_ITEM, isCheckable: true, - isChecked: true, // temporary WORKAROUND for Scripts.resolvePath() bug + isChecked: false, grouping: "Advanced" }); } From 2d8bb54b937c335e5003a729d766880b67a64a1f Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 29 Aug 2016 17:37:24 -0700 Subject: [PATCH 06/11] fix typo --- scripts/system/mod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/mod.js b/scripts/system/mod.js index 193feebdb2..5ed7159506 100644 --- a/scripts/system/mod.js +++ b/scripts/system/mod.js @@ -16,7 +16,7 @@ // grab the toolbar var toolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); -var ASSETS_PATH = Script.resolvePath("assets" +var ASSETS_PATH = Script.resolvePath("assets"); var TOOLS_PATH = Script.resolvePath("assets/images/tools/"); function buttonImageURL() { From c5b998a2a8e7472ebcbf5dffe3a272308be5eb9a Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 30 Aug 2016 12:18:03 -0700 Subject: [PATCH 07/11] use new hook in marketplace code --- interface/resources/qml/MarketplaceComboBox.qml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml index f7f224485b..66d9b92ea2 100644 --- a/interface/resources/qml/MarketplaceComboBox.qml +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -48,15 +48,12 @@ Rectangle { property var autoCancel: 'var element = $("a.btn.cancel"); element.click();' - onNewViewRequested: { - var component = Qt.createComponent("Browser.qml"); - var newWindow = component.createObject(desktop); - request.openIn(newWindow.webView); + newWindowHook: function (component, newWindow) { if (File.isZippedFbx(desktop.currentUrl)) { + runJavaScript(autoCancel); zipTimer.handler = function() { newWindow.destroy(); - runJavaScript(autoCancel); - } + }; zipTimer.start(); } } From 232ac74b267342dbdb7ab25d6174fe13c25581f2 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 30 Aug 2016 14:06:20 -0700 Subject: [PATCH 08/11] back to master version --- interface/resources/qml/MarketplaceComboBox.qml | 11 +++++++---- interface/resources/qml/controls-uit/WebView.qml | 7 ------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/interface/resources/qml/MarketplaceComboBox.qml b/interface/resources/qml/MarketplaceComboBox.qml index 66d9b92ea2..fec151d755 100644 --- a/interface/resources/qml/MarketplaceComboBox.qml +++ b/interface/resources/qml/MarketplaceComboBox.qml @@ -28,7 +28,7 @@ Rectangle { color: hifi.colors.baseGrayShadow property var currentUrl: "https://metaverse.highfidelity.com/marketplace" - Controls.WebView { + Controls.BaseWebView { id: webview url: currentUrl anchors.top: switchMarketView.bottom @@ -48,12 +48,15 @@ Rectangle { property var autoCancel: 'var element = $("a.btn.cancel"); element.click();' - newWindowHook: function (component, newWindow) { + onNewViewRequested: { + var component = Qt.createComponent("Browser.qml"); + var newWindow = component.createObject(desktop); + request.openIn(newWindow.webView); if (File.isZippedFbx(desktop.currentUrl)) { - runJavaScript(autoCancel); zipTimer.handler = function() { newWindow.destroy(); - }; + runJavaScript(autoCancel); + } zipTimer.start(); } } diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index 8c46aabcae..faf7f746a2 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -61,13 +61,6 @@ WebEngineView { } } - property var newWindowHook: function (component, newWindow, request) { }; // override if you need to - onNewViewRequested:{ - var component = Qt.createComponent("../Browser.qml"); - var newWindow = component.createObject(desktop); - request.openIn(newWindow.webView) - newWindowHook(component, newWindow, request); - } // This breaks the webchannel used for passing messages. Fixed in Qt 5.6 // See https://bugreports.qt.io/browse/QTBUG-49521 From 564769f7d3f1234d64e3e6edc7c577ff2a0a6869 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 30 Aug 2016 14:07:34 -0700 Subject: [PATCH 09/11] move WebView.qml to baseWebView.qml --- .../resources/qml/controls-uit/{WebView.qml => BaseWebView.qml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename interface/resources/qml/controls-uit/{WebView.qml => BaseWebView.qml} (100%) diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/BaseWebView.qml similarity index 100% rename from interface/resources/qml/controls-uit/WebView.qml rename to interface/resources/qml/controls-uit/BaseWebView.qml From 88245075233464e1d860e977a428652ea0aea53f Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Tue, 30 Aug 2016 14:37:08 -0700 Subject: [PATCH 10/11] new smaller WebView.qml --- .../resources/qml/controls-uit/WebView.qml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 interface/resources/qml/controls-uit/WebView.qml diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml new file mode 100644 index 0000000000..2ce007c42a --- /dev/null +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -0,0 +1,20 @@ +// +// WebView.qml +// +// Created by Bradley Austin Davis on 12 Jan 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.5 +import "." + +BaseWebView { + onNewViewRequested: { + var component = Qt.createComponent("../Browser.qml"); + var newWindow = component.createObject(desktop); + request.openIn(newWindow.webView) + } +} From 12e6920a8d9f5226ee2c0364473f858476186e0f Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 31 Aug 2016 08:15:00 -0700 Subject: [PATCH 11/11] fix syntax error --- scripts/system/mod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/mod.js b/scripts/system/mod.js index 5ed7159506..b2c9785539 100644 --- a/scripts/system/mod.js +++ b/scripts/system/mod.js @@ -20,7 +20,7 @@ var ASSETS_PATH = Script.resolvePath("assets"); var TOOLS_PATH = Script.resolvePath("assets/images/tools/"); function buttonImageURL() { - return TOOLS_PATH + (Users.canKick ? 'kick.svg' : 'ignore.svg')); + return TOOLS_PATH + (Users.canKick ? 'kick.svg' : 'ignore.svg'); } // setup the mod button and add it to the toolbar