Skip to content

Commit

Permalink
add joystick navigation to sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Feb 12, 2024
1 parent 1e40764 commit 28f2e85
Show file tree
Hide file tree
Showing 12 changed files with 314 additions and 198 deletions.
1 change: 1 addition & 0 deletions qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,6 @@
<file>ui/sidebar/Panel4Recording.qml</file>
<file>ui/sidebar/Panel6Misc.qml</file>
<file>ui/sidebar/Panel7Status.qml</file>
<file>ui/sidebar/SidebarStackButton.qml</file>
</qresource>
</RCC>
2 changes: 1 addition & 1 deletion qml/ui/HUDOverlayGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Item {
if(event.key==Qt.Key_Left || event.key == Qt.Key_Right || event.key == Qt.Key_Up || event.key == Qt.Key_Down){
// If the user presses any navigation key, we open up the sidebar and hand over the inputs to it
if(!sidebar.m_extra_is_visible){
sidebar.open_and_take_control();
sidebar.open_and_take_control(true);
event.accepted=true;
}
}
Expand Down
14 changes: 13 additions & 1 deletion qml/ui/sidebar/BaseJoyEditElement.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Item{
// Emitted if the button right is clicked
signal choice_right();

// Emitted if the button up is clicked (navigate to previous eelement)
signal goto_previous();
signal goto_next();

Keys.onPressed: (event)=> {
console.log("BaseJoyElement"+m_title+" key was pressed:"+event);
if(event.key == Qt.Key_Left){
Expand All @@ -58,13 +62,21 @@ Item{
}else{
_qopenhd.show_toast("NOT AVAILABLE");
}
}else if(event.key==Qt.Key_Up){
goto_previous()
}else if(event.key==Qt.Key_Down){
goto_next();
}
}

function takeover_control(){
focus=true;
}

Rectangle{
width: parent.width
height:parent.height
border.color: "black"
border.color: "white"
border.width: base_joy_edit_element.focus ? 3 : 0;
color: "#333c4c"
opacity: base_joy_edit_element.focus ? 1.0 : 0.3;
Expand Down
98 changes: 22 additions & 76 deletions qml/ui/sidebar/Panel1Link.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,98 +3,44 @@ import QtQuick 2.0
SideBarBasePanel{
override_title: "Link"


function takeover_control(){
edit_frequency_element.takeover_control();
}

Column {
anchors.top: parent.top
anchors.topMargin: secondaryUiHeight/8
spacing: 5

EditFrequencyElement{
id: edit_frequency_element
onGoto_previous: {
sidebar.regain_control_on_sidebar_stack()
}
onGoto_next: {
edit_channel_width_element.takeover_control()
}
}

EditChannelWidthElement{
id: edit_channel_width_element
onGoto_previous: {
edit_frequency_element.takeover_control();
}
onGoto_next: {
edit_rate_element.takeover_control()
}
}

EditRateElement{
id: edit_rate_element
}

/*Text{
text: "Range -> Quality" + " (MCS" + _ohdSystemAir.curr_mcs_index + ")"
font.pixelSize: 14
font.family: "AvantGarde-Medium"
color: "#ffffff"
smooth: true
onGoto_previous: {
edit_channel_width_element.takeover_control()
}
Slider {
id: valueSlider
from: 0
to: 3
stepSize: 1
//snapMode: Slider.SnapToStep
value: 0 // Initial value
Material.accent: Material.Grey
onValueChanged: {
// Handle the slider value change here
console.log("MCS Slider:", value)
}
onGoto_next: {
sidebar.regain_control_on_sidebar_stack()
}
Text{
text: "Frequency" + " (" + _ohdSystemGround.curr_channel_mhz + ")"
font.pixelSize: 14
font.family: "AvantGarde-Medium"
color: "#ffffff"
smooth: true
}
ComboBox {
width: 200
model: [ "2312", "2332", "2352", "2372", "2392", "2412", "2432", "2452", "2472", "2492", "2512", "2532", "2572", "2592", "2612", "2632", "2652", "2672", "2692", "2712", "5180", "5200", "5220", "5240", "5260", "5280", "5300", "5320", "5500", "5520", "5540", "5560", "5580", "5600", "5620", "5640", "5660", "5680", "5700", "5745", "5765", "5785", "5805", "5825", "5845", "5865", "5885" ]
}
Text{
text: "TX Power Air" + " (" + "TODO" + ")"
font.pixelSize: 14
font.family: "AvantGarde-Medium"
color: "#ffffff"
smooth: true
}
Slider {
id: txPowerAirSlider
from: 22
to: 58
stepSize: 4
//snapMode: Slider.SnapToStep
value: 22 // Initial value
Material.accent: Material.Grey
onValueChanged: {
// Handle the slider value change here
console.log("TX Power Air Slider:", value)
}
}
Text{
text: "Bandwith"
font.pixelSize: 14
font.family: "AvantGarde-Medium"
color: "#ffffff"
smooth: true
}
TabBar {
id: control
Material.accent: "#fff"
Material.foreground: "white"
background: Rectangle {
implicitWidth: 100
implicitHeight: 40
color: secondaryUiColor
}
TabButton {
text: qsTr("20MHZ")
}
TabButton {
text: qsTr("40MHZ")
}
}*/

}
}

}
10 changes: 10 additions & 0 deletions qml/ui/sidebar/Panel2Video.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,23 @@ import "../elements"
SideBarBasePanel{
override_title: "Video"

function takeover_control(){
edit_resolution_element.takeover_control();
}

Column {
anchors.top: parent.top
anchors.topMargin: secondaryUiHeight/8
spacing: 5

EditResolutionElement{
id: edit_resolution_element
onGoto_previous: {
sidebar.regain_control_on_sidebar_stack()
}
onGoto_next: {
sidebar.regain_control_on_sidebar_stack()
}
}

/*ComboBox {
Expand Down
34 changes: 33 additions & 1 deletion qml/ui/sidebar/Panel3Camera.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,63 @@ import OpenHD 1.0
import "../elements"

SideBarBasePanel{
id: cameraUI
override_title: "Camera"

function takeover_control(){
brightness.takeover_control();
}

Column {
anchors.top: parent.top
anchors.topMargin: secondaryUiHeight/8
spacing: 5
MavlinkIntChoiceElement{
id: brightness
m_title: "BRIGHTNESS"
m_param_id: "BRIGHTNESS"
m_settings_model: _airCameraSettingsModel
onGoto_previous: {
sidebar.regain_control_on_sidebar_stack()
}
onGoto_next: {
saturation.takeover_control();
}
}
MavlinkIntChoiceElement{
id: saturation
m_title: "SATURATION"
m_param_id: "SATURATION"
m_settings_model: _airCameraSettingsModel
onGoto_previous: {
brightness.takeover_control();
}
onGoto_next: {
contrast.takeover_control();
}
}
MavlinkIntChoiceElement{
id: contrast
m_title: "CONTRAST"
m_param_id: "CONTRAST"
m_settings_model: _airCameraSettingsModel
onGoto_previous: {
saturation.takeover_control();
}
onGoto_next: {
sharpness.takeover_control();
}
}
MavlinkIntChoiceElement{
id: sharpness
m_title: "SHARPNESS"
m_param_id: "SHARPNESS"
m_settings_model: _airCameraSettingsModel
onGoto_previous: {
contrast.takeover_control();
}
onGoto_next: {
sidebar.regain_control_on_sidebar_stack()
}
}
}
}
12 changes: 11 additions & 1 deletion qml/ui/sidebar/Panel4Recording.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,28 @@ import OpenHD 1.0
import "../elements"

SideBarBasePanel{
id: recordingUI
override_title: "Air recording"

function takeover_control(){
recording_mode.takeover_control();
}

Column {
anchors.top: parent.top
anchors.topMargin: secondaryUiHeight/8
spacing: 5

MavlinkIntChoiceElement{
id: recording_mode
m_title: "RECORDING MODE"
m_param_id: "AIR_RECORDING_E"
m_settings_model: _airCameraSettingsModel
onGoto_previous: {
sidebar.regain_control_on_sidebar_stack()
}
onGoto_next: {
// Do nothing
}
}
Text{
text: {
Expand Down
12 changes: 11 additions & 1 deletion qml/ui/sidebar/Panel5RC.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import OpenHD 1.0
import "../elements"

SideBarBasePanel{
id: displayUI
override_title: "OpenHD RC"

function takeover_control(){
joy_rc_enable.takeover_control();
}

property int m_control_yaw : settings.control_widget_use_fc_channels ? _rcchannelsmodelfc.control_yaw : _rcchannelsmodelground.control_yaw
property int m_control_roll: settings.control_widget_use_fc_channels ? _rcchannelsmodelfc.control_roll : _rcchannelsmodelground.control_roll
property int m_control_pitch: settings.control_widget_use_fc_channels ? _rcchannelsmodelfc.control_pitch : _rcchannelsmodelground.control_pitch
Expand All @@ -27,9 +30,16 @@ SideBarBasePanel{


MavlinkIntChoiceElement{
id: joy_rc_enable
m_title: "JOY RC"
m_param_id: "ENABLE_JOY_RC";
m_settings_model: _ohdSystemGroundSettings
onGoto_previous: {
sidebar.regain_control_on_sidebar_stack()
}
onGoto_next: {
sidebar.regain_control_on_sidebar_stack()
}
}

Text{
Expand Down
19 changes: 18 additions & 1 deletion qml/ui/sidebar/Panel6Misc.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,39 @@ import OpenHD 1.0
import "../elements"

SideBarBasePanel{
id: displayUI
override_title: "Misc"

function takeover_control(){
air_wifi_hs.takeover_control();
}

Column {
anchors.top: parent.top
anchors.topMargin: secondaryUiHeight/8
spacing: 5
MavlinkIntChoiceElement{
id: air_wifi_hs
m_title: "AIR WIFI HS"
m_param_id: "WIFI_HOTSPOT_E"
m_settings_model: _ohdSystemAirSettingsModel
onGoto_previous: {
sidebar.regain_control_on_sidebar_stack()
}
onGoto_next: {
gnd_wifi_hs.takeover_control();
}
}
MavlinkIntChoiceElement{
id: gnd_wifi_hs
m_title: "GND WIFI HS"
m_param_id: "WIFI_HOTSPOT_E"
m_settings_model: _ohdSystemGroundSettings
onGoto_previous: {
air_wifi_hs.takeover_control();
}
onGoto_next: {
sidebar.regain_control_on_sidebar_stack()
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion qml/ui/sidebar/Panel7Status.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import OpenHD 1.0
import "../elements"

SideBarBasePanel{
id: miscUI
override_title: "Status / Advanced"

Column {
Expand Down
Loading

0 comments on commit 28f2e85

Please sign in to comment.