overte-HifiExperiments/interface/resources/qml/dialogs/preferences/BrowsablePreference.qml
2016-09-12 21:39:52 -07:00

115 lines
3.4 KiB
QML

//
// BrowsablePreference.qml
//
// Created by Bradley Austin Davis on 18 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 "../../dialogs"
import "../../controls-uit"
import "../../controls" as Controls
Preference {
id: root
property alias text: dataTextField.text
property alias placeholderText: dataTextField.placeholderText
height: control.height + hifi.dimensions.controlInterlineHeight + (keyboardRaised ? 200 : 0)
property bool keyboardRaised: false
property bool punctuationMode: false
Component.onCompleted: {
dataTextField.text = preference.value;
}
function save() {
preference.value = dataTextField.text;
preference.save();
}
Item {
id: control
anchors {
left: parent.left
right: parent.right
bottom: keyboard1.top
}
height: Math.max(dataTextField.controlHeight, button.height)
TextField {
id: dataTextField
anchors {
left: parent.left
right: button.left
rightMargin: hifi.dimensions.contentSpacing.x
bottom: parent.bottom
}
label: root.label
placeholderText: root.placeholderText
colorScheme: hifi.colorSchemes.dark
}
Component {
id: fileBrowserBuilder;
FileDialog { selectDirectory: true }
}
Button {
id: button
text: preference.browseLabel
anchors {
right: parent.right
verticalCenter: dataTextField.verticalCenter
}
onClicked: {
var browser = fileBrowserBuilder.createObject(desktop, {
selectDirectory: true,
dir: fileDialogHelper.pathToUrl(preference.value)
});
browser.selectedFile.connect(function(fileUrl){
console.log(fileUrl);
dataTextField.text = fileDialogHelper.urlToPath(fileUrl);
});
}
}
}
// virtual keyboard, letters
Controls.Keyboard {
id: keyboard1
// y: parent.keyboardRaised ? parent.height : 0
height: parent.keyboardRaised ? 200 : 0
visible: parent.keyboardRaised && !parent.punctuationMode
enabled: parent.keyboardRaised && !parent.punctuationMode
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
// anchors.bottomMargin: 2 * hifi.dimensions.contentSpacing.y
}
Controls.KeyboardPunctuation {
id: keyboard2
// y: parent.keyboardRaised ? parent.height : 0
height: parent.keyboardRaised ? 200 : 0
visible: parent.keyboardRaised && parent.punctuationMode
enabled: parent.keyboardRaised && parent.punctuationMode
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
// anchors.bottomMargin: 2 * hifi.dimensions.contentSpacing.y
}
}