diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f6b961fd5..000000000 Binary files a/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 4b7e1f3d3..000000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew deleted file mode 100755 index cccdd3d51..000000000 --- a/android/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat deleted file mode 100644 index f9553162f..000000000 --- a/android/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/qml/qml.qrc b/qml/qml.qrc index 757cfab5f..979ce22a2 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -307,5 +307,9 @@ ui/sidebar/InfoElement2.qml ui/elements/ErrorMessageBox.qml ui/elements/ColorDialoque.qml + ui/sidebar/ChoiceSelector.qml + ui/sidebar/BaseJoyEditElement2.qml + ui/sidebar/MavlinkChoiceElement2.qml + ui/sidebar/MappedMavlinkChoices.qml diff --git a/qml/ui/HUDOverlayGrid.qml b/qml/ui/HUDOverlayGrid.qml index 32f585462..5107d9945 100644 --- a/qml/ui/HUDOverlayGrid.qml +++ b/qml/ui/HUDOverlayGrid.qml @@ -278,6 +278,12 @@ Item { width: parent.width height: parent.height visible: !quickPanel.visible + MouseArea{ + anchors.fill: parent + onClicked: { + sidebar.notify_sidebar_user_clicked_outside(); + } + } // By default on top row // -------------------------------------------------------------------------- diff --git a/qml/ui/sidebar/BaseJoyEditElement2.qml b/qml/ui/sidebar/BaseJoyEditElement2.qml new file mode 100644 index 000000000..d1e7a8662 --- /dev/null +++ b/qml/ui/sidebar/BaseJoyEditElement2.qml @@ -0,0 +1,98 @@ +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls.Material 2.12 + +import Qt.labs.settings 1.0 + +import OpenHD 1.0 + +import "../../ui" as Ui +import "../elements" + +// +// Base for an UI element that has the following properties: +// left / right: Increment / Decrement (model) value (If increment / decrement is available) +// top / bottom : Go to next / previous element +// MIDDLE: Show the current value +// +// It looks like this: +// |--------------------| +// | TITLE VALUE * | -> Selector (can be opened) +// |--------------------| +// +// Joystick navigatable (focus) but also supports touch. +Item{ + id: base_joy_edit_element + width: 320 + height: 70 + + property string m_title: "FILL ME" + + property bool m_is_selected: false + + property string m_displayed_value: "VALUE T" + + property bool m_is_enabled: true + + // Allows the parent to override the text color + // Right now only used by the change frequency element + property bool override_show_red_text: false + + // Emitted if the the element is clicked (for non-joystick usage) + signal base_joy_edit_element_clicked(); + + function takeover_control(){ + focus=true; + } + + Rectangle{ + width: parent.width + height:parent.height + border.color: "white" + border.width: base_joy_edit_element.focus ? 3 : 0; + color: "#333c4c" + opacity: base_joy_edit_element.focus ? 1.0 : 0.3; + } + + + Text { + id: title_str + text: qsTr(m_title) + width: parent.width/2 + height: parent.height + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 18 + anchors.top: parent.top + color: "white" + } + + Text{ + id:value_string + width: parent.width/2 + height: parent.height + text: m_displayed_value + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignHCenter + font.pixelSize: 15 + color: override_show_red_text? "red" : "white" + anchors.right: parent.right + } + + + Rectangle{ + width: parent.width + height: parent.height + color: "gray" + opacity: 0.7 + visible: !m_is_enabled + } + + MouseArea{ + anchors.fill: parent + onClicked: { + base_joy_edit_element_clicked() + } + } +} diff --git a/qml/ui/sidebar/ChoiceSelector.qml b/qml/ui/sidebar/ChoiceSelector.qml new file mode 100644 index 000000000..d99acca03 --- /dev/null +++ b/qml/ui/sidebar/ChoiceSelector.qml @@ -0,0 +1,195 @@ +import QtQuick 2.12 + +Rectangle{ + id: choiceSelector + width: 200 + height: secondaryUiHeight - (secondaryUiHeight/8) + //color: "green" + color: "transparent" + visible: false + + // Index of the element that is selected when the selector is opened (current value) + property int m_initial_index: -1 + // Changed as the user navigates around + property int m_current_user_selected_index: -1; + // We are only 'clickable' if no joystick usage + property bool m_allow_clickable: false + + property var m_parent + + function open_choices(x_model,current_value,parent){ + // First, find the current selection inside the model + availableChociesModel.clear(); + var current_value_index=0 + var current_value_found_in_model=false; + for(var i=0;i { + console.log("ChoiceSelector key was pressed:"+event); + if(event.key == Qt.Key_Left){ + // Either close immediately or go back to the initial choice (don't save) + if(m_current_user_selected_index==m_initial_index){ + close_choices(); + }else{ + m_current_user_selected_index=m_initial_index; + } + event.accepted=true; + }else if(event.key == Qt.Key_Right){ + // Save and close or do nothing + if(m_current_user_selected_index==m_initial_index){ + // Do nothing + }else{ + close_choices(); + } + event.accepted=true; + }else if(event.key==Qt.Key_Up){ + if(m_current_user_selected_index>0){ + m_current_user_selected_index--; + }else{ + // Out of bounds + } + event.accepted=true; + }else if(event.key==Qt.Key_Down){ + if(m_current_user_selected_index+1 { + console.log("BaseJoyElement"+m_title+" key was pressed:"+event); + if(event.key == Qt.Key_Left){ + sidebar.regain_control_on_sidebar_stack(); + event.accepted=true; + }else if(event.key == Qt.Key_Right){ + open_choices_menu(false); + event.accepted=true; + }else if(event.key==Qt.Key_Up){ + choiceSelector.discard_and_close(); + goto_previous() + event.accepted=true; + }else if(event.key==Qt.Key_Down){ + choiceSelector.discard_and_close(); + goto_next(); + event.accepted=true; + }else if(event.key==Qt.Key_Enter || event.key==Qt.Key_Return){ + open_choices_menu(false); + event.accepted=true; + } + } + + onBase_joy_edit_element_clicked: { + if(choiceSelector.visible){ + choiceSelector.close_choices(); + }else{ + open_choices_menu(true); + } + } + + function open_choices_menu(clickable){ + if(!m_param_exists){ + _qopenhd.show_toast("N/A"); + return; + } + if(m_settings_model.ui_is_busy){ + _qopenhd.show_toast("Busy, please try again later"); + return; + } + const m_elements_model=mappedMavlinkChoices.get_model(m_param_id); + if(override_takes_string_param){ + choiceSelector.open_choices(m_elements_model,m_actual_value_string,mavlinkChoiceElement2) + }else{ + choiceSelector.open_choices(m_elements_model,m_actual_value_int,mavlinkChoiceElement2) + } + choiceSelector.set_clickable(clickable) + } + + onVisibleChanged: { + if(visible){ + populate(); + } + } + + property int m_update_count: m_settings_model.update_count + onM_update_countChanged: { + if(visible){ + if(m_settings_model.last_updated_param_id===m_param_id){ + populate(); + } + } + } + property bool m_has_params_fetched: m_settings_model.has_params_fetched + onM_has_params_fetchedChanged: { + if(visible){ + populate(); + } + } + + // Avoid binding loop + property string populate_display_text:"I SHOULD NEVER APPEAR" + + function populate(){ + // Don't mind those 3 + if(m_param_id==mPARAM_ID_CHANNEL_WIDTH || m_param_id==mPARAM_ID_FREQUENCY || m_param_id==mPARAM_ID_RATE){ + return; + } + // First, check if the system is alive + if(!m_settings_model.system_is_alive()){ + // Do not enable the elements, system is not alive + m_param_exists=false; + populate_display_text="N/A"; + return; + } + if(!m_settings_model.has_params_fetched){ + m_param_exists=false; + populate_display_text="N/A"; + return; + } + if(override_takes_string_param){ + m_param_exists=m_settings_model.param_string_exists(m_param_id) + }else{ + m_param_exists=m_settings_model.param_int_exists(m_param_id) + } + if(!m_param_exists){ + console.log("Param "+m_param_id+" does not exist"); + populate_display_text="NOT\nAVAILABLE"; + return; + } + if(override_takes_string_param){ + var actual_value_string=m_settings_model.get_cached_string(m_param_id); + update_display_text(actual_value_string); + }else{ + var actual_value_int=m_settings_model.get_cached_int(m_param_id); + update_display_text(actual_value_int); + } + m_param_exists=true; + } + + + function update_display_text(value){ + if(override_takes_string_param){ + m_actual_value_string=value + }else{ + m_actual_value_int=value; + } + const m_elements_model=mappedMavlinkChoices.get_model(m_param_id); + var model_index=-1; + for(var i=0;i