From f9bea8cc5f7581823b515ad67f8ad74a1705b1c8 Mon Sep 17 00:00:00 2001 From: consti10 Date: Thu, 14 Sep 2023 17:46:57 +0200 Subject: [PATCH] delete unused, add some type of keyboard / joystick navigation --- qml/qml.qrc | 2 +- qml/ui/HUDOverlayGrid.qml | 33 +++++++++++++++---- qml/ui/configpopup/ConfigPopup.qml | 2 ++ qml/ui/widgets/BaseWidget.qml | 4 +++ ...seWidgetForm.ui.qml => BaseWidgetForm.qml} | 0 5 files changed, 34 insertions(+), 7 deletions(-) rename qml/ui/widgets/{BaseWidgetForm.ui.qml => BaseWidgetForm.qml} (100%) diff --git a/qml/qml.qrc b/qml/qml.qrc index daf8bb449..b642f5161 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -48,7 +48,7 @@ ui/widgets/FlightTimeWidget.qml ui/HUDOverlayGrid.qml ui/widgets/BaseWidget.qml - ui/widgets/BaseWidgetForm.ui.qml + ui/widgets/BaseWidgetForm.qml ui/widgets/FpvWidget.qml ui/widgets/HeadingWidget.qml ui/widgets/SpeedWidget.qml diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index 48ee96009..dde19de35 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -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){ @@ -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){ @@ -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){ @@ -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() @@ -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() } } diff --git a/qml/ui/configpopup/ConfigPopup.qml b/qml/ui/configpopup/ConfigPopup.qml index c844e40c0..a015176b7 100644 --- a/qml/ui/configpopup/ConfigPopup.qml +++ b/qml/ui/configpopup/ConfigPopup.qml @@ -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 } } diff --git a/qml/ui/widgets/BaseWidget.qml b/qml/ui/widgets/BaseWidget.qml index 0e144a0a6..24f52cbad 100644 --- a/qml/ui/widgets/BaseWidget.qml +++ b/qml/ui/widgets/BaseWidget.qml @@ -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() diff --git a/qml/ui/widgets/BaseWidgetForm.ui.qml b/qml/ui/widgets/BaseWidgetForm.qml similarity index 100% rename from qml/ui/widgets/BaseWidgetForm.ui.qml rename to qml/ui/widgets/BaseWidgetForm.qml