Skip to content

Commit

Permalink
delete unused, add some type of keyboard / joystick navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Sep 14, 2023
1 parent 5a458a6 commit f9bea8c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<file>ui/widgets/FlightTimeWidget.qml</file>
<file>ui/HUDOverlayGrid.qml</file>
<file>ui/widgets/BaseWidget.qml</file>
<file>ui/widgets/BaseWidgetForm.ui.qml</file>
<file>ui/widgets/BaseWidgetForm.qml</file>
<file>ui/widgets/FpvWidget.qml</file>
<file>ui/widgets/HeadingWidget.qml</file>
<file>ui/widgets/SpeedWidget.qml</file>
Expand Down
33 changes: 27 additions & 6 deletions qml/ui/HUDOverlayGrid.qml
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ Item {
// Now the user can move around
return;
}
close_popup_all_items();
if(m_highlight_index==0){
stop_keyboard_navigation()
return;
}
goto_previous_visible_item();
highlight_specific_item(m_highlight_index);
/*m_highlight_index--;
if(m_highlight_index<0)m_highlight_index=0;
highlight_specific_item(m_highlight_index);*/
}
function dummy_joystick_right(){
if(!m_keyboard_navigation_active){
Expand All @@ -101,13 +99,22 @@ Item {
// Now the user can move around
return;
}
/*m_highlight_index++;
if(m_highlight_index>m_MAX_ITEM_INDEX)m_highlight_index=0;
highlight_specific_item(m_highlight_index);*/
close_popup_all_items()
goto_next_visible_item();
highlight_specific_item(m_highlight_index);
}
function dummy_joystick_up(){
if(m_keyboard_navigation_active){
stop_keyboard_navigation();
}
}
function dummy_joystick_down(){
if(m_keyboard_navigation_active){
stop_keyboard_navigation();
}
}

// Goes to the next item in order, but skipping invisible widgets
function goto_next_visible_item(){
m_highlight_index++;
if(m_highlight_index>m_MAX_ITEM_INDEX){
Expand All @@ -119,6 +126,7 @@ Item {
}
goto_next_visible_item()
}
// Goes to the previous item in order, but skipping invisible widgets
function goto_previous_visible_item(){
m_highlight_index--;
if(m_highlight_index<0){
Expand Down Expand Up @@ -162,6 +170,11 @@ Item {
dirty_get_item_by_index(i).m_special_highlight=false;
}
}
function close_popup_all_items(){
for(let i = 1; i <= m_MAX_ITEM_INDEX; i++){
dirty_get_item_by_index(i).dirty_close_action_popup()
}
}

function highlight_specific_item(index_to_highlight){
unhighlight_all_items()
Expand Down Expand Up @@ -193,6 +206,14 @@ Item {
//console.log("right was pressed")
event.accepted=true;
dummy_joystick_right();
}else if(event.key == Qt.Key_Up){
//console.log("up was pressed")
event.accepted=true;
dummy_joystick_up()
}else if(event.key == Qt.Key_Down){
//console.log("down was pressed")
event.accepted=true;
dummy_joystick_down()
}
}

Expand Down
2 changes: 2 additions & 0 deletions qml/ui/configpopup/ConfigPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ Rectangle {
mainStackLayout.currentIndex=tmp_index;
}else if(event.key == Qt.Key_Left){
close_all()
}else if(event.key == Qt.Key_Right){
//mainStackLayout.childAt(mainStackLayout.currentIndex).focus=true
}
}

Expand Down
4 changes: 4 additions & 0 deletions qml/ui/widgets/BaseWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ BaseWidgetForm {
function dirty_open_action_popup(){
widgetAction.open()
}
function dirty_close_action_popup(){
widgetAction.close()
}

function dirty_open_close_action_popup(){
if(widgetAction.opened){
widgetAction.close()
Expand Down
File renamed without changes.

0 comments on commit f9bea8c

Please sign in to comment.