Skip to content

Commit

Permalink
improve dev-menu (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelscholle authored Dec 30, 2024
1 parent a1da3cb commit 283d578
Showing 1 changed file with 113 additions and 43 deletions.
156 changes: 113 additions & 43 deletions qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml
Original file line number Diff line number Diff line change
@@ -1,62 +1,53 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12


import Qt.labs.settings 1.0

import OpenHD 1.0

import "../../../ui" as Ui
import "../../elements"

// Dirty here i place stuff that can be usefully during development
// Main container
Rectangle {
id: elementAppDeveloperStats
width: parent.width
height: parent.height

property int rowHeight: 64
property int text_minHeight: 20

color: "#eaeaea"

function yes_or_no_as_string(yes){
if(yes) return "Y"
return "N"
function yes_or_no_as_string(yes) {
if (yes) return "Y";
return "N";
}

function get_features_string(){
var ret = ""
ret += "AVCODEC:" + yes_or_no_as_string(QOPENHD_ENABLE_VIDEO_VIA_AVCODEC) + ", "
ret += "MMAL:" + yes_or_no_as_string(QOPENHD_HAVE_MMAL) + ", "
ret += "GSTREAMER_QMLGLSINK:" + yes_or_no_as_string(QOPENHD_ENABLE_GSTREAMER_QMLGLSINK) + ", "
function get_features_string() {
var ret = "";
ret += "AVCODEC:" + yes_or_no_as_string(QOPENHD_ENABLE_VIDEO_VIA_AVCODEC) + ", ";
ret += "MMAL:" + yes_or_no_as_string(QOPENHD_HAVE_MMAL) + ", ";
ret += "GSTREAMER_QMLGLSINK:" + yes_or_no_as_string(QOPENHD_ENABLE_GSTREAMER_QMLGLSINK) + ", ";
return ret;
}

// TabBar for consistent style
TabBar {
// This screen doesn't tab, but we use the tab bar element for a consistent style
id: selectItemInStackLayoutBar
width: parent.width
TabButton {
text: qsTr("Developer Menu")
}
}
ScrollView{

// Main layout with scrollable content
ScrollView {
anchors.left: parent.left
anchors.right: parent.right
anchors.top: selectItemInStackLayoutBar.bottom
anchors.bottom: parent.bottom
anchors.margins: 5
contentHeight: main_column_layout.height
contentWidth: main_column_layout.width
//ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ScrollBar.vertical.interactive: true
anchors.margins: 10

Column {
id: main_column_layout
width: parent.width
spacing: 6
Text{

Text {
height: 23
text: qsTr("QOpenHD version: " + _qopenhd.version_string + " for " + Qt.platform.os)
}
Expand All @@ -66,53 +57,59 @@ Rectangle {
}
Text {
height: 23
text: qsTr("Resolution: " +" Screen "+ _qrenderstats.screen_width_height_str+" ADJ:"+_qrenderstats.display_width_height_str + " Window: "+ _qrenderstats.window_width+"x"+_qrenderstats.window_height)
text: qsTr("Resolution: " + " Screen " + _qrenderstats.screen_width_height_str + " ADJ:" + _qrenderstats.display_width_height_str + " Window: " + _qrenderstats.window_width + "x" + _qrenderstats.window_height)
}
Text {
height: 23
text: qsTr("Art Horizon mavlink update rate:" + _fcMavlinkSystem.curr_update_rate_mavlink_message_attitude + " Hz")
}
Text {
height: 23
text: qsTr("Tele in" + _mavlinkTelemetry.telemetry_pps_in + " pps")
text: qsTr("Tele in " + _mavlinkTelemetry.telemetry_pps_in + " pps")
}

// Buttons for actions
GridLayout {
columns: 4
id: buttonGrid
columns: 3
rowSpacing: 10
columnSpacing: 10

Button {
width: 400
text: "Restart local OHD service"
onClicked: {
_qopenhd.restart_local_oenhd_service()
_qopenhd.restart_local_oenhd_service();
}
}
Button {
id: local_ip_button
text: "Show local IP"
onClicked: {
var text = _qopenhd.show_local_ip()
local_ip_button.text = text
var text = _qopenhd.show_local_ip();
local_ip_button.text = text;
}
}
Button {
id: write_local_log
text: "Write GND log to SD"
onClicked: {
var text = _qopenhd.write_local_log()
write_local_log.text = text
var text = _qopenhd.write_local_log();
write_local_log.text = text;
}
}
Button {
id: write_air_log
text: "Write AIR log to SD"
onClicked: {
var text = "Not implemented yet"
write_air_log.text = text
var text = "Not implemented yet";
write_air_log.text = text;
}
}
Button {
text: "Set Tele rates"
onClicked: {
_mavlinkTelemetry.re_apply_rates()
_mavlinkTelemetry.re_apply_rates();
}
}
Button {
Expand Down Expand Up @@ -144,30 +141,103 @@ Rectangle {
}
}
Button {
id:sdbut
text: "Self Distruct"
id: sdbut
text: "Self Destruct"
onClicked: {
sdbut.text="just kidding";
sdbut.text = "just kidding";
}
}
Button {
font.capitalization: Font.MixedCase
text: qsTr("Restart QOpenHD")
onPressed: {
qopenhdservicedialoque.open_dialoque(0)
qopenhdservicedialoque.open_dialoque(0);
}
}
Button {
font.capitalization: Font.MixedCase
text: qsTr("Cancel QOpenHD")
onPressed: {
qopenhdservicedialoque.open_dialoque(1)
qopenhdservicedialoque.open_dialoque(1);
}
}
}

// Terminal-like Scrollable Text Display
Rectangle {
id: terminalContainer
visible: false
width: parent.width
height: 200
color: "black" // Background color

ScrollView {
id: terminalScrollView
anchors.fill: parent
ScrollBar.vertical.interactive: true
ScrollBar.vertical.policy: ScrollBar.AlwaysOn

TextArea {
id: terminalTextArea
readOnly: true
wrapMode: TextArea.WrapAtWordBoundaryOrAnywhere
text: ""
font.pixelSize: 14
color: "white" // Text color
background: Rectangle { color: "black" }
}
}
}

Row {
spacing: 10

Button {
text: "Show Air Info"
onClicked: {
showSystemInfo(_ohdSystemAir, "Air");
terminalContainer.visible = true;
}
}
Button {
text: "Show Ground Info"
onClicked: {
showSystemInfo(_ohdSystemGround, "Ground");
terminalContainer.visible = true;
}
}
Button {
text: "Show Mavlink Info"
onClicked: {
showSystemInfo(_fcMavlinkSystem, "Mavlink");
terminalContainer.visible = true;
}
}
Button {
text: "\uf2ed"
onClicked: {
terminalTextArea.text = " \n";
}
}
}
}
}
QOpenHDServiceDialoque{

function showSystemInfo(systemObject, title) {
if (systemObject) {
terminalTextArea.text += title + " System Information:\n\n";
for (var key in systemObject) {
if (systemObject.hasOwnProperty(key) && typeof systemObject[key] !== "function") {
terminalTextArea.text += key + ": " + systemObject[key] + "\n";
}
}
} else {
terminalTextArea.text += title + " System Information unavailable.\n";
}
}


QOpenHDServiceDialoque {
id: qopenhdservicedialoque
}
}

0 comments on commit 283d578

Please sign in to comment.