diff --git a/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml b/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml index 11643ae1f1..7803e95bac 100644 --- a/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml +++ b/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml @@ -16,6 +16,7 @@ import Qt.labs.settings 1.0 import "../../styles-uit" import "../../controls-uit" as HifiControls import "../../windows" +import "../" Rectangle { id: root @@ -26,10 +27,26 @@ Rectangle { property var scripts: ScriptDiscoveryService; property var scriptsModel: scripts.scriptsModelFilter property var runningScriptsModel: ListModel { } + property bool developerMenuEnabled: false property bool isHMD: false color: hifi.colors.baseGray + + LetterboxMessage { + id: letterBoxMessage + z: 999 + visible: false + } + + function letterBox(glyph, text, message) { + letterBoxMessage.headerGlyph = glyph; + letterBoxMessage.headerText = text; + letterBoxMessage.text = message; + letterBoxMessage.visible = true; + letterBoxMessage.popupRadius = 0; + } + Connections { target: ScriptDiscoveryService onScriptCountChanged: updateRunningScripts(); @@ -38,6 +55,7 @@ Rectangle { Component.onCompleted: { isHMD = HMD.active; updateRunningScripts(); + developerMenuEnabled = MenuInterface.isMenuEnabled("Developer Menus"); } function updateRunningScripts() { @@ -78,6 +96,14 @@ Rectangle { scripts.stopAllScripts(); } + function canEditScript(script) { + if ((script === "controllerScripts.js") || (script === "defaultScripts.js")) { + return developerMenuEnabled; + } + + return true; + } + Flickable { id: flickable width: tabletRoot.width @@ -125,6 +151,7 @@ Rectangle { expandSelectedRow: true itemDelegate: Item { + property bool canEdit: canEditScript(styleData.value); anchors { left: parent ? parent.left : undefined leftMargin: hifi.dimensions.tablePadding @@ -148,7 +175,7 @@ Rectangle { HiFiGlyphs { id: reloadButton - text: hifi.glyphs.reloadSmall + text: ((canEditScript(styleData.value)) ? hifi.glyphs.reloadSmall : hifi.glyphs.lock) color: reloadButtonArea.pressed ? hifi.colors.white : parent.color anchors { top: parent.top @@ -158,7 +185,17 @@ Rectangle { MouseArea { id: reloadButtonArea anchors { fill: parent; margins: -2 } - onClicked: reloadScript(model.url) + onClicked: { + if (canEdit) { + reloadScript(model.url) + } else { + letterBox(hifi.glyphs.lock, + "Need Developer Mode On", + "In order to edit, delete or reload this script," + + " turn on Developer Mode by going to:" + + " Menu > Settings > Developer Menus"); + } + } } } @@ -166,6 +203,7 @@ Rectangle { id: stopButton text: hifi.glyphs.closeSmall color: stopButtonArea.pressed ? hifi.colors.white : parent.color + visible: canEditScript(styleData.value) anchors { top: parent.top right: parent.right @@ -174,7 +212,11 @@ Rectangle { MouseArea { id: stopButtonArea anchors { fill: parent; margins: -2 } - onClicked: stopScript(model.url) + onClicked: { + if (canEdit) { + stopScript(model.url) + } + } } } diff --git a/interface/resources/qml/styles-uit/HifiConstants.qml b/interface/resources/qml/styles-uit/HifiConstants.qml index 1556a9c0c0..4a26d11128 100644 --- a/interface/resources/qml/styles-uit/HifiConstants.qml +++ b/interface/resources/qml/styles-uit/HifiConstants.qml @@ -337,5 +337,6 @@ Item { readonly property string playback_play: "\ue01d" readonly property string stop_square: "\ue01e" readonly property string avatarTPose: "\ue01f" + readonly property string lock: "\ue006" } } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index c7223be208..1907b0437a 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -98,10 +98,10 @@ Menu::Menu() { // Edit > Running Scripts auto action = addActionToQMenuAndActionHash(editMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J); connect(action, &QAction::triggered, [] { - static const QUrl widgetUrl("hifi/dialogs/RunningScripts.qml"); static const QUrl tabletUrl("../../hifi/dialogs/TabletRunningScripts.qml"); - static const QString name("RunningScripts"); - qApp->showDialog(widgetUrl, tabletUrl, name); + auto tabletScriptingInterface = DependencyManager::get(); + TabletProxy* tablet = tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"); + tablet->pushOntoStack(tabletUrl); }); // Edit > Open and Run Script from File... [advanced] diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index acba15d2ec..c8e2d3bc63 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -38,6 +38,7 @@ #include "scripting/AccountScriptingInterface.h" #include "scripting/HMDScriptingInterface.h" #include "scripting/AssetMappingsScriptingInterface.h" +#include "scripting/MenuScriptingInterface.h" #include #include #include "FileDialogHelper.h" @@ -203,6 +204,7 @@ void Web3DOverlay::loadSourceURL() { _webSurface->getSurfaceContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance()); _webSurface->getSurfaceContext()->setContextProperty("InputConfiguration", DependencyManager::get().data()); _webSurface->getSurfaceContext()->setContextProperty("SoundCache", DependencyManager::get().data()); + _webSurface->getSurfaceContext()->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance()); _webSurface->getSurfaceContext()->setContextProperty("pathToFonts", "../../"); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface.data());