Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Unified UI ] Settings #1125

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
822 changes: 0 additions & 822 deletions interface/resources/qml/hifi/dialogs/graphics/GraphicsSettings.qml

This file was deleted.

70 changes: 0 additions & 70 deletions scripts/system/graphicsSettings.js

This file was deleted.

Binary file added scripts/system/settings/img/back_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions scripts/system/settings/img/back_arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scripts/system/settings/img/icon_black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scripts/system/settings/img/icon_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions scripts/system/settings/qml_widgets/HeaderElement.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
height: 60
width: parent.width
id: root
z: 1 // FIXME: Layout issue? Shouldn't need to adjust the z-index but I do.

Rectangle {
anchors.fill: parent;
color: "black"
}

Image {
source: "../img/back_arrow.png"
anchors.verticalCenter: parent.verticalCenter
height: 40
width: 40
x: current_page == "Settings" ? -40 : 10

Behavior on x {
NumberAnimation {
duration: 200
easing.type: Easing.InOutCubic
}
}

MouseArea {
anchors.fill: parent
onClicked: {
current_page = "Settings";
}
}
}

Text {
text: current_page
color: "white"
font.pointSize: 18
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
horizontalAlignment: Text.AlignHCenter
}
}
24 changes: 24 additions & 0 deletions scripts/system/settings/qml_widgets/SettingCenterContainer.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.3

ScrollView {
width: parent.width
height:parent.height
y: header.height
id: root

ColumnLayout {
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
spacing: 0
}

// For each child of index not of 0, append as child of index of 0.
// Append children of the custom element to the ColumnLayout.
Component.onCompleted: {
for (var i = 1; i < root.contentChildren.length; i++) {
root.contentChildren[i].parent = root.contentChildren[0]
}
}
}
28 changes: 28 additions & 0 deletions scripts/system/settings/qml_widgets/SettingSubviewListElement.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import QtQuick 2.15

Item {
width: parent.width
height: 60

Rectangle {
width: parent.width
height: parent.height
color: index % 2 === 0 ? Qt.rgba(0,0,0,0) : Qt.rgba(0.15,0.15,0.15,1)
anchors.fill: parent
}

Text {
text: page_name
color: "white"
font.pointSize: 16
anchors.verticalCenter: parent.verticalCenter
x: 10
}

MouseArea {
anchors.fill: parent
onClicked: {
current_page = page_name;
}
}
}
80 changes: 80 additions & 0 deletions scripts/system/settings/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//
// settings.js
//
// App to configure Overte
//
// Created by Armored Dragon, 2024.
// Copyright 2024 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html

/* global Script Tablet */

// TODO: Bind Target frame Rate to Graphics Preset
// TODO: Fullscreen display?

(() => {
"use strict";
var tablet;
var appButton;
var active = false;
const url = Script.resolvePath("./settings.qml")

tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
appButton = tablet.addButton({
icon: Script.resolvePath("./img/icon_white.png"),
activeIcon: Script.resolvePath("./img/icon_black.png"),
text: "SETTINGS",
isActive: active,
});

// When script ends, remove itself from tablet
Script.scriptEnding.connect(function () {
console.log("Shutting Down");
tablet.removeButton(appButton);
});

// Overlay button toggle
appButton.clicked.connect(toolbarButtonClicked);
tablet.fromQml.connect(fromQML);
tablet.screenChanged.connect(onTabletScreenChanged);

function toolbarButtonClicked() {
if (active) tablet.gotoHomeScreen();
else tablet.loadQMLSource(url);

active = !active;
appButton.editProperties({
isActive: active,
});
}

function onTabletScreenChanged(type, new_url){
if (url == new_url) active = true;
else active = false;

appButton.editProperties({
isActive: active,
});
}

// Communication
function fromQML(event) {
console.log(`New QML event:\n${JSON.stringify(event)}`);

switch (event.type) {
case "initialized":
getActivePolls();
break;
}
}
/**
* Emit a packet to the HTML front end. Easy communication!
* @param {Object} packet - The Object packet to emit to the HTML
* @param {("show_message"|"clear_messages"|"notification"|"initial_settings")} packet.type - The type of packet it is
*/
// function _emitEvent(packet = { type: "" }) {
// tablet.sendToQml(packet);
// }
})();
Loading
Loading