basic prefreneces done

This commit is contained in:
Dante Ruiz 2017-02-11 00:51:01 +00:00
parent 46cfa7cf13
commit 888d4ff706
6 changed files with 186 additions and 194 deletions

View file

@ -12,12 +12,33 @@
import QtQuick 2.5
import "tabletWindows"
import "../../dialogs"
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0
StackView {
id: profileRoot
initialItem: root
objectName: "stack"
property var eventBridge;
signal sendToScript(var message);
function pushSource(path) {
editRoot.push(Qt.reslovedUrl(path));
}
function popSource() {
}
TabletPreferencesDialog {
id: root
objectName: "GeneralPreferencesDialog"
width: parent.width
height: parent.height
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Sixense Controllers", "Perception Neuron", "Kinect"]
}
TabletPreferencesDialog {
id: root
objectName: "GeneralPreferencesDialog"
width: parent.width
height: parent.height
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Sixense Controllers", "Perception Neuron", "Kinect"]
}

View file

@ -13,72 +13,166 @@ import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0
import "."
import "./preferences"
import "../../../styles-uit"
import "../../../controls-uit" as HifiControls
Item {
id: root
id: dialog
width: 480
height: 600
height: 720
HifiConstants { id: hifi }
property var sections: []
property var showCategories: []
function saveAll() {
for (var i = 0; i < sections.length; ++i) {
var section = sections[i];
section.saveAll();
}
}
function restoreAll() {
for (var i = 0; i < sections.length; ++i) {
var section = sections[i];
section.restoreAll();
}
}
Rectangle {
id: main
height: parent.height - 40
anchors {
top: parent.top
bottom: footer.top
left: parent.left
right: parent.right
}
gradient: Gradient {
GradientStop {
position: 0
color: "#2b2b2b"
}
GradientStop {
position: 1
color: "#0f212e"
}
}
Flickable {
id: scrollView
width: parent.width
height: parent.height
contentWidth: parent.width
contentHeight: getSectionsHeight();
Column {
width: 480
Component {
id: sectionBuilder
Section {}
}
Component.onCompleted: {
var categories = Preferences.categories;
var i;
// build a map of valid categories.
var categoryMap = {};
for (i = 0; i < categories.length; i++) {
categoryMap[categories[i]] = true;
}
// create a section for each valid category in showCategories
// NOTE: the sort order of items in the showCategories array is the same order in the dialog.
for (i = 0; i < showCategories.length; i++) {
if (categoryMap[showCategories[i]]) {
sections.push(sectionBuilder.createObject(prefControls, {name: showCategories[i]}));
}
}
if (sections.length) {
// Default sections to expanded/collapsed as appropriate for dialog.
if (sections.length === 1) {
sections[0].collapsable = false
sections[0].expanded = true
} else {
for (i = 0; i < sections.length; i++) {
sections[i].collapsable = false;
sections[i].expanded = true;
}
}
sections[0].isFirst = true;
sections[sections.length - 1].isLast = true;
}
scrollView.contentHeight = scrollView.getSectionsHeight();
}
Column {
id: prefControls
width: 480
}
}
function getSectionsHeight() {
var totalHeight = 0;
for (var i = 0; i < sections.length; i++) {
totalHeight += sections[i].height
}
console.log(totalHeight);
return totalHeight;
}
}
}
ListView {
Rectangle {
id: footer
height: 40
Component {
id: sectionBuilder
Section {}
anchors {
top: main.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
}
Component.onCompleted: {
var categories = Preferences.categories;
var i;
// build a map of valid categories.
var categoryMap = {};
for (i = 0; i < categories.length; i++) {
categoryMap[categories[i]] = true;
gradient: Gradient {
GradientStop {
position: 0
color: "#2b2b2b"
}
// create a section for each valid category in showCategories
// NOTE: the sort order of items in the showCategories array is the same order in the dialog.
for (i = 0; i < showCategories.length; i++) {
if (categoryMap[showCategories[i]]) {
sections.push(sectionBuilder.createObject(prefControls, {name: showCategories[i]}));
}
}
if (sections.length) {
// Default sections to expanded/collapsed as appropriate for dialog.
if (sections.length === 1) {
sections[0].collapsable = false
sections[0].expanded = true
} else {
for (i = 0; i < sections.length; i++) {
sections[i].collapsable = true;
sections[i].expanded = true;
}
}
sections[0].isFirst = true;
sections[sections.length - 1].isLast = true;
GradientStop {
position: 1
color: "#0f212e"
}
}
Column {
id: prefControls
width: 320
Row {
anchors {
top: parent,top
right: parent.right
rightMargin: hifi.dimensions.contentMargin.x
}
spacing: hifi.dimensions.contentSpacing.x
HifiControls.Button {
text: "Save changes"
color: hifi.buttons.blue
onClicked: root.saveAll()
}
HifiControls.Button {
text: "Cancel"
color: hifi.buttons.white
onClicked: root.restoreAll()
}
}
}

View file

@ -16,157 +16,32 @@ import QtGraphicalEffects 1.0
import "."
import "../../../styles-uit"
import "../../../controls-uit" as HiFiControls
FocusScope{
Item {
id: window
HifiConstants { id: hifi }
childern [ plane ]
children: [ pane ]
property var footer: Item {}
readonly var footerContentHeight: 40
property var pane: Item {
property bool isScrolling: true//scrollView.height < scrollView.contentItem.height
property int contentWidth: scrollView.width - (isScrolling ? 10 : 0)
property int scrollHeight: scrollView.height
anchors.fill: parent
anchors.rightMargin: 11
Rectangle {
id: contentBackground
anchors.fill: parent
color: hifi.colors.baseGray
visible: true
}
LinearGradient {
visible: true
anchors.top: contentBackground.bottom
anchors.left: contentBackground.left
width: contentBackground.width - 1
height: 4
start: Qt.point(0, 0)
end: Qt.point(0, 4)
gradient: Gradient {
GradientStop { position: 0.0; color: hifi.colors.darkGray }
GradientStop { position: 1.0; color: hifi.colors.darkGray0 }
}
cached: true
}
ScrollView {
id: scrollView
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
verticalScrollBarPolicy: Qt.ScrollBarAsNeeded
anchors.fill: parent
anchors.rightMargin: parent.isScrolling ? 1 : 0
anchors.bottomMargin: footerPane.height
style: ScrollViewStyle {
padding.right: -7 // Move to right away from content.
handle: Item {
implicitWidth: 8
Rectangle {
radius: 4
color: hifi.colors.white30
anchors {
fill: parent
leftMargin: 2 // Finesse size and position.
topMargin: 1
bottomMargin: 1
}
}
}
scrollBarBackground: Item {
implicitWidth: 10
Rectangle {
color: hifi.colors.darkGray30
radius: 4
anchors {
fill: parent
topMargin: -1 // Finesse size
bottomMargin: -2
}
}
}
incrementControl: Item {
visible: false
}
decrementControl: Item {
visible: false
}
}
}
function scrollBy(delta) {
scrollView.flickableItem.contentY += delta;
}
Rectangle {
// Optional non-scrolling footer.
id: footerPane
property alias keyboardOverride: window.keyboardOverride
property alias keyboardRaised: window.keyboardRaised
property alias punctuationMode: window.punctuationMode
anchors {
left: parent.left
bottom: parent.bottom
}
width: parent.contentWidth
height: footerContentHeight + (keyboard.enabled && keyboard.raised ? keyboard.height : 0)
color: hifi.colors.baseGray
visible: footer.height > 0 || keyboard.enabled && keyboard.raised
Item {
// Horizontal rule.
anchors {
top: parent.top
left: parent.left
right: parent.right
}
visible: footer.height > 0
Rectangle {
width: parent.width
height: 1
y: 1 // Stop displaying content just above horizontal rule/=.
color: hifi.colors.baseGrayShadow
}
Rectangle {
width: parent.width
height: 1
y: 2
color: hifi.colors.baseGrayHighlight
}
}
Item {
anchors {
left: parent.left
right: parent.right
top: parent.top
topMargin: hifi.dimensions.contentSpacing.y + 3
}
children: [ footer ]
}
HiFiControls.Keyboard {
id: keyboard
enabled: !keyboardOverride
raised: keyboardEnabled && keyboardRaised
numeric: punctuationMode
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
}
width: 480
//gradient: Gradient {
//GradientStop {
//position: 0
//color: "#2b2b2b"
//}
//GradientStop {
//position: 1
//color: "#0f212e"
//}
//}
}
}
}

View file

@ -19,7 +19,7 @@ import "."
Preference {
id: root
property bool collapsable: true
property bool collapsable: false
property bool expanded: false
property bool isFirst: false
property bool isLast: false

View file

@ -65,7 +65,7 @@ Preference {
verticalCenter: dataTextField.verticalCenter
}
onClicked: {
var browser = fileBrowserBuilder.createObject(desktop, {
var browser = fileBrowserBuilder.createObject({
selectDirectory: true,
dir: fileDialogHelper.pathToUrl(preference.value)
});

View file

@ -38,6 +38,7 @@
#include "scripting/AccountScriptingInterface.h"
#include "scripting/HMDScriptingInterface.h"
#include <Preferences.h>
#include "FileDialogHelper.h"
static const float DPI = 30.47f;
static const float INCHES_TO_METERS = 1.0f / 39.3701f;
@ -168,6 +169,7 @@ void Web3DOverlay::loadSourceURL() {
_webSurface->getRootContext()->setContextProperty("AddressManager", DependencyManager::get<AddressManager>().data());
_webSurface->getRootContext()->setContextProperty("Account", AccountScriptingInterface::getInstance());
_webSurface->getRootContext()->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
_webSurface->getRootContext()->setContextProperty("fileDialogHelper", new FileDialogHelper());
tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data());
// Override min fps for tablet UI, for silky smooth scrolling