mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 07:03:44 +02:00
Add directory & avatar browsing preferences
This commit is contained in:
parent
c7186590ea
commit
27fdb523cb
9 changed files with 159 additions and 29 deletions
|
@ -18,13 +18,13 @@ FocusScope {
|
||||||
// The VR version of the primary menu
|
// The VR version of the primary menu
|
||||||
property var rootMenu: Menu { objectName: "rootMenu" }
|
property var rootMenu: Menu { objectName: "rootMenu" }
|
||||||
|
|
||||||
|
Component { id: messageDialogBuilder; MessageDialog { } }
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
readonly property int zBasisNormal: 0
|
readonly property int zBasisNormal: 0
|
||||||
readonly property int zBasisAlwaysOnTop: 4096
|
readonly property int zBasisAlwaysOnTop: 4096
|
||||||
readonly property int zBasisModal: 8192
|
readonly property int zBasisModal: 8192
|
||||||
readonly property var messageDialogBuilder: Component { MessageDialog { } }
|
|
||||||
readonly property var nativeMessageDialogBuilder: Component { OriginalDialogs.MessageDialog { } }
|
|
||||||
|
|
||||||
function findChild(item, name) {
|
function findChild(item, name) {
|
||||||
for (var i = 0; i < item.children.length; ++i) {
|
for (var i = 0; i < item.children.length; ++i) {
|
||||||
|
@ -165,9 +165,7 @@ FocusScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
function messageBox(properties) {
|
function messageBox(properties) {
|
||||||
// Debugging: native message dialog for comparison
|
return messageDialogBuilder.createObject(desktop, properties);
|
||||||
// d.nativeMessageDialogBuilder.createObject(desktop, properties);
|
|
||||||
return d.messageDialogBuilder.createObject(desktop, properties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function popupMenu(point) {
|
function popupMenu(point) {
|
||||||
|
@ -216,7 +214,7 @@ FocusScope {
|
||||||
console.log("Focus item is " + offscreenWindow.activeFocusItem);
|
console.log("Focus item is " + offscreenWindow.activeFocusItem);
|
||||||
var focusedItem = offscreenWindow.activeFocusItem ;
|
var focusedItem = offscreenWindow.activeFocusItem ;
|
||||||
if (DebugQML && focusedItem) {
|
if (DebugQML && focusedItem) {
|
||||||
var rect = desktop.mapToItem(null, focusedItem.x, focusedItem.y, focusedItem.width, focusedItem.height);
|
var rect = desktop.mapFromItem(focusedItem, 0, 0, focusedItem.width, focusedItem.height);
|
||||||
focusDebugger.visible = true
|
focusDebugger.visible = true
|
||||||
focusDebugger.x = rect.x;
|
focusDebugger.x = rect.x;
|
||||||
focusDebugger.y = rect.y;
|
focusDebugger.y = rect.y;
|
||||||
|
|
|
@ -25,6 +25,14 @@ Window {
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restoreAll() {
|
||||||
|
for (var i = 0; i < sections.length; ++i) {
|
||||||
|
var section = sections[i];
|
||||||
|
section.restoreAll();
|
||||||
|
}
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
clip: true
|
||||||
|
@ -70,7 +78,12 @@ Window {
|
||||||
Row {
|
Row {
|
||||||
id: dialogButtons
|
id: dialogButtons
|
||||||
anchors { bottom: parent.bottom; right: parent.right; margins: 8 }
|
anchors { bottom: parent.bottom; right: parent.right; margins: 8 }
|
||||||
Button { text: "Cancel"; onClicked: root.destroy(); }
|
|
||||||
|
Button {
|
||||||
|
text: "Cancel";
|
||||||
|
onClicked: root.restoreAll();
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Save all changes"
|
text: "Save all changes"
|
||||||
onClicked: root.saveAll();
|
onClicked: root.saveAll();
|
||||||
|
|
|
@ -1,33 +1,80 @@
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtQuick.Controls 1.4 as Original
|
import QtQuick.Controls 1.4
|
||||||
|
|
||||||
import "."
|
import "."
|
||||||
|
import "../../../dialogs"
|
||||||
|
|
||||||
Preference {
|
Preference {
|
||||||
id: root
|
id: root
|
||||||
property alias spinner: spinner
|
property alias buttonText: button.text
|
||||||
height: spinner.height
|
property alias text: dataTextField.text
|
||||||
|
property alias placeholderText: dataTextField.placeholderText
|
||||||
|
property real spacing: 8
|
||||||
|
property var browser;
|
||||||
|
height: labelText.height + Math.max(dataTextField.height, button.height) + spacing
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
spinner.value = preference.value;
|
dataTextField.text = preference.value;
|
||||||
|
console.log("MyAvatar modelName " + MyAvatar.getFullAvatarModelName())
|
||||||
|
console.log("Application : " + ApplicationInterface)
|
||||||
|
ApplicationInterface.fullAvatarURLChanged.connect(processNewAvatar);
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onDestruction: {
|
||||||
|
ApplicationInterface.fullAvatarURLChanged.disconnect(processNewAvatar);
|
||||||
|
}
|
||||||
|
|
||||||
|
function processNewAvatar(url, modelName) {
|
||||||
|
if (browser) {
|
||||||
|
browser.destroy();
|
||||||
|
browser = null
|
||||||
|
}
|
||||||
|
|
||||||
|
dataTextField.text = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
preference.value = spinner.value;
|
preference.value = dataTextField.text;
|
||||||
|
preference.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restores the original avatar URL
|
||||||
|
function restore() {
|
||||||
preference.save();
|
preference.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
text: root.label
|
id: labelText
|
||||||
anchors.verticalCenter: spinner.verticalCenter
|
text: root.label
|
||||||
}
|
}
|
||||||
|
|
||||||
Original.SpinBox {
|
TextField {
|
||||||
id: spinner
|
id: dataTextField
|
||||||
decimals: preference.decimals
|
placeholderText: root.placeholderText
|
||||||
minimumValue: preference.min
|
text: preference.value
|
||||||
maximumValue: preference.max
|
anchors {
|
||||||
width: 100
|
top: labelText.bottom
|
||||||
anchors { right: parent.right }
|
left: parent.left
|
||||||
|
right: button.left
|
||||||
|
topMargin: root.spacing
|
||||||
|
rightMargin: root.spacing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: avatarBrowserBuilder;
|
||||||
|
AvatarBrowser { }
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: button
|
||||||
|
anchors { right: parent.right; verticalCenter: dataTextField.verticalCenter }
|
||||||
|
text: "Browse"
|
||||||
|
onClicked: {
|
||||||
|
root.browser = avatarBrowserBuilder.createObject(desktop);
|
||||||
|
root.browser.windowDestroyed.connect(function(){
|
||||||
|
root.browser = null;
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import QtQuick 2.3
|
||||||
|
import QtQuick.Controls 1.2
|
||||||
|
import QtWebEngine 1.1
|
||||||
|
|
||||||
|
import "../../../windows" as Windows
|
||||||
|
import "../../../controls" as Controls
|
||||||
|
import "../../../styles"
|
||||||
|
|
||||||
|
Windows.Window {
|
||||||
|
id: root
|
||||||
|
HifiConstants { id: hifi }
|
||||||
|
width: 900; height: 700
|
||||||
|
resizable: true
|
||||||
|
anchors.centerIn: parent
|
||||||
|
modality: Qt.ApplicationModal
|
||||||
|
frame: Windows.ModalFrame {}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Controls.WebView {
|
||||||
|
id: webview
|
||||||
|
anchors { top: parent.top; left: parent.left; right: parent.right; bottom: closeButton.top; margins: 8 }
|
||||||
|
url: "https://metaverse.highfidelity.com/marketplace?category=avatars"
|
||||||
|
focus: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: closeButton
|
||||||
|
anchors { bottom: parent.bottom; right: parent.right; margins: 8 }
|
||||||
|
text: "Close"
|
||||||
|
onClicked: root.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ import QtQuick 2.5
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
|
|
||||||
import "."
|
import "."
|
||||||
|
import "../../../dialogs"
|
||||||
|
|
||||||
Preference {
|
Preference {
|
||||||
id: root
|
id: root
|
||||||
|
@ -38,12 +39,22 @@ Preference {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: fileBrowserBuilder;
|
||||||
|
FileDialog { selectDirectory: true }
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: button
|
id: button
|
||||||
anchors {
|
anchors { right: parent.right; verticalCenter: dataTextField.verticalCenter }
|
||||||
right: parent.right;
|
|
||||||
verticalCenter: dataTextField.verticalCenter
|
|
||||||
}
|
|
||||||
text: "Browse"
|
text: "Browse"
|
||||||
|
onClicked: {
|
||||||
|
var browser = fileBrowserBuilder.createObject(desktop, { selectDirectory: true, folder: fileDialogHelper.pathToUrl(preference.value) });
|
||||||
|
browser.selectedFile.connect(function(fileUrl){
|
||||||
|
console.log(fileUrl);
|
||||||
|
dataTextField.text = fileDialogHelper.urlToPath(fileUrl);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,7 @@ Item {
|
||||||
anchors { left: parent.left; right: parent.right }
|
anchors { left: parent.left; right: parent.right }
|
||||||
property var preference;
|
property var preference;
|
||||||
property string label: preference ? preference.name : "";
|
property string label: preference ? preference.name : "";
|
||||||
Component.onCompleted: preference.load();
|
Component.onCompleted: if (preference) { preference.load(); }
|
||||||
|
|
||||||
|
function restore() { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,13 @@ Preference {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restoreAll() {
|
||||||
|
for (var i = 0; i < d.preferences.length; ++i) {
|
||||||
|
var preference = d.preferences[i];
|
||||||
|
preference.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
children: [ toggle, header, contentContainer ]
|
children: [ toggle, header, contentContainer ]
|
||||||
height: expanded ? header.height + contentContainer.height + root.spacing * 3
|
height: expanded ? header.height + contentContainer.height + root.spacing * 3
|
||||||
|
@ -68,6 +75,7 @@ Preference {
|
||||||
property var spinnerBuilder: Component { SpinBox { } }
|
property var spinnerBuilder: Component { SpinBox { } }
|
||||||
property var checkboxBuilder: Component { CheckBox { } }
|
property var checkboxBuilder: Component { CheckBox { } }
|
||||||
property var sliderBuilder: Component { Slider { } }
|
property var sliderBuilder: Component { Slider { } }
|
||||||
|
property var avatarBuilder: Component { Avatar { } }
|
||||||
property var preferences: []
|
property var preferences: []
|
||||||
|
|
||||||
function buildPreferences() {
|
function buildPreferences() {
|
||||||
|
@ -104,6 +112,9 @@ Preference {
|
||||||
builder = checkboxBuilder;
|
builder = checkboxBuilder;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Preference.Avatar:
|
||||||
|
builder = avatarBuilder;
|
||||||
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (builder) {
|
if (builder) {
|
||||||
|
|
|
@ -58,8 +58,8 @@ void setupPreferences() {
|
||||||
|
|
||||||
{
|
{
|
||||||
auto getter = [=]()->QString { return myAvatar->getFullAvatarURLFromPreferences().toString(); };
|
auto getter = [=]()->QString { return myAvatar->getFullAvatarURLFromPreferences().toString(); };
|
||||||
auto setter = [=](const QString& value) { /* FIXME */ };
|
auto setter = [=](const QString& value) { myAvatar->useFullAvatarURL(value, ""); };
|
||||||
auto preference = new BrowsePreference(AVATAR_BASICS, "Appearance: ", getter, setter);
|
auto preference = new AvatarPreference(AVATAR_BASICS, "Appearance: ", getter, setter);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ public:
|
||||||
Spinner,
|
Spinner,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Button,
|
Button,
|
||||||
|
// Special casing for an unusual preference
|
||||||
|
Avatar
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Preference(QObject* parent = nullptr) : QObject(parent) {}
|
explicit Preference(QObject* parent = nullptr) : QObject(parent) {}
|
||||||
|
@ -237,6 +239,17 @@ protected:
|
||||||
QString _browseLabel { "Browse" };
|
QString _browseLabel { "Browse" };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AvatarPreference : public BrowsePreference {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
AvatarPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||||
|
: BrowsePreference(category, name, getter, setter) {
|
||||||
|
_browseLabel = "Change";
|
||||||
|
}
|
||||||
|
Type getType() { return Avatar; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class CheckPreference : public BoolPreference {
|
class CheckPreference : public BoolPreference {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue