DEV-122: Add a developer menu in Settings

This commit is contained in:
Zach Fox 2019-06-11 12:53:43 -07:00
parent 973e93aa2f
commit 7bdd3084e9
2 changed files with 134 additions and 0 deletions

View file

@ -14,16 +14,41 @@ import stylesUit 1.0 as HifiStylesUit
import "./audio" as AudioSettings
import "./general" as GeneralSettings
import "./vr" as VrSettings
import "./dev" as DevSettings
Rectangle {
property string activeTabView: "generalTabView"
id: root
color: simplifiedUI.colors.darkBackground
anchors.fill: parent
property bool developerModeEnabled: Settings.getValue("simplifiedUI/developerModeEnabled", false)
SimplifiedConstants.SimplifiedConstants {
id: simplifiedUI
}
focus: true
Keys.onPressed: {
if ((event.key == Qt.Key_D) && (event.modifiers & Qt.ControlModifier && event.modifiers & Qt.AltModifier && event.modifiers & Qt.ShiftModifier)) {
var currentSetting = Settings.getValue("simplifiedUI/developerModeEnabled", false);
var newSetting = !currentSetting;
Settings.setValue("simplifiedUI/developerModeEnabled", newSetting);
root.developerModeEnabled = newSetting;
if (newSetting) {
console.log("Developer mode ON. You are now a developer!");
} else {
console.log("Developer mode OFF.");
if (root.activeTabView === "devTabView") {
tabListView.currentIndex = 2;
root.activeTabView = "vrTabView";
}
}
}
}
Component.onCompleted: {
root.forceActiveFocus();
}
Rectangle {
@ -49,6 +74,10 @@ Rectangle {
tabTitle: "VR"
tabViewName: "vrTabView"
}
ListElement {
tabTitle: "Dev"
tabViewName: "devTabView"
}
}
@ -70,6 +99,8 @@ Rectangle {
highlight: highlightBar
interactive: contentItem.width > width
delegate: Item {
visible: model.tabTitle !== "Dev" || (model.tabTitle === "Dev" && root.developerModeEnabled)
width: tabTitleText.paintedWidth + 64
height: parent.height
@ -125,6 +156,12 @@ Rectangle {
visible: activeTabView === "vrTabView"
anchors.fill: parent
}
DevSettings.Dev {
id: devTabViewContainer
visible: activeTabView === "devTabView"
anchors.fill: parent
}
}
Image {

View file

@ -0,0 +1,97 @@
//
// Dev.qml
//
// Created by Zach Fox on 2019-06-11
// Copyright 2019 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.10
import QtQuick.Controls 2.3
import "../../simplifiedConstants" as SimplifiedConstants
import "../../simplifiedControls" as SimplifiedControls
import stylesUit 1.0 as HifiStylesUit
import QtQuick.Layouts 1.3
Flickable {
id: root
contentWidth: parent.width
contentHeight: devColumnLayout.height
topMargin: 24
bottomMargin: 24
clip: true
onVisibleChanged: {
if (visible) {
root.contentX = 0;
root.contentY = -root.topMargin;
}
}
SimplifiedConstants.SimplifiedConstants {
id: simplifiedUI
}
ColumnLayout {
id: devColumnLayout
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
spacing: simplifiedUI.margins.settings.spacingBetweenSettings
ColumnLayout {
id: uiControlsContainer
Layout.preferredWidth: parent.width
spacing: 0
HifiStylesUit.GraphikRegular {
id: uiControlsTitle
text: "User Interface"
Layout.maximumWidth: parent.width
height: paintedHeight
size: 22
color: simplifiedUI.colors.text.white
}
HifiStylesUit.GraphikRegular {
id: uiControlsSubtitle
text: "You'll have to restart Interface after changing either of these settings. If you don't get any Toolbar apps back after restarting, run defaultScripts.js manually."
Layout.maximumWidth: parent.width
height: paintedHeight
size: 16
color: simplifiedUI.colors.text.white
wrapMode: Text.Wrap
}
ColumnLayout {
id: uiControlsSwitchGroup
Layout.topMargin: simplifiedUI.margins.settings.settingsGroupTopMargin
SimplifiedControls.Switch {
id: keepMenusSwitch
width: parent.width
height: 18
labelTextOn: "Keep Old Menus (File, Edit, etc)"
checked: Settings.getValue("simplifiedUI/keepMenus", false);
onClicked: {
Settings.setValue("simplifiedUI/keepMenus", !Settings.getValue("simplifiedUI/keepMenus", false));
}
}
SimplifiedControls.Switch {
id: keepOldUIAndScriptsSwitch
width: parent.width
height: 18
labelTextOn: "Keep Old UI and Scripts"
checked: Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false);
onClicked: {
Settings.setValue("simplifiedUI/keepExistingUIAndScripts", !Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false));
}
}
}
}
}
}