disable reload default scripts by default

This commit is contained in:
Dante Ruiz 2017-07-20 21:15:00 +01:00
parent 87d9dfd243
commit 3c862c34b2
4 changed files with 51 additions and 6 deletions

View file

@ -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)
}
}
}
}

View file

@ -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"
}
}

View file

@ -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<TabletScriptingInterface>();
TabletProxy* tablet = tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system");
tablet->pushOntoStack(tabletUrl);
});
// Edit > Open and Run Script from File... [advanced]

View file

@ -38,6 +38,7 @@
#include "scripting/AccountScriptingInterface.h"
#include "scripting/HMDScriptingInterface.h"
#include "scripting/AssetMappingsScriptingInterface.h"
#include "scripting/MenuScriptingInterface.h"
#include <Preferences.h>
#include <ScriptEngines.h>
#include "FileDialogHelper.h"
@ -203,6 +204,7 @@ void Web3DOverlay::loadSourceURL() {
_webSurface->getSurfaceContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance());
_webSurface->getSurfaceContext()->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
_webSurface->getSurfaceContext()->setContextProperty("SoundCache", DependencyManager::get<SoundCache>().data());
_webSurface->getSurfaceContext()->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
_webSurface->getSurfaceContext()->setContextProperty("pathToFonts", "../../");
tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface.data());