From 92ecd9853bab0bd0c4199ce5a38c5827c7a71f46 Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 11:33:07 +0100 Subject: [PATCH] finalize: Everything is usable up to minimum resolution (480p 16:9) --- app/main.cpp | 16 ++++-- app/telemetry/settings/frequencyhelper.cpp | 14 ++++- app/telemetry/settings/frequencyhelper.h | 4 +- app/util/qrenderstats.cpp | 8 +-- app/util/qrenderstats.h | 7 ++- qml/main.qml | 7 +++ .../dev/AppDeveloperStatsPanel.qml | 45 ++++++++------- .../MavlinkOpenHDWBParamPanel.qml | 57 +++++++++++-------- .../openhd_settings/PopupAnalyzeChannels.qml | 2 +- .../openhd_settings/PopupTxPowerEditor.qml | 26 +++------ qml/ui/configpopup/status/PanelStatus.qml | 14 +---- .../status/StatusCardBodyOpenHD.qml | 2 +- .../configpopup/status/StatusCardsColumn.qml | 12 ++-- qml/ui/elements/AppSettings.qml | 2 + qml/ui/elements/BaseHeaderItem.qml | 5 ++ 15 files changed, 122 insertions(+), 99 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 8062b3f3c..bfec3a8b9 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -186,6 +186,15 @@ static void android_check_permissions(){ #endif } +static void write_screen_resolutions(QApplication& app){ + const auto actual_size=QGuiApplication::primaryScreen()->size(); + QRenderStats::instance().set_screen_width_height(actual_size.width(),actual_size.height()); + // This includes dpi adjustment + QScreen* screen=app.primaryScreen(); + if(screen){ + QRenderStats::instance().set_display_width_height(screen->size().width(),screen->size().height()); + } +} int main(int argc, char *argv[]) { @@ -238,12 +247,7 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); // Customize cursor if needed QOpenHD::instance().customize_cursor_from_settings(); - { - QScreen* screen=app.primaryScreen(); - if(screen){ - QRenderStats::instance().set_display_width_height(screen->size().width(),screen->size().height()); - } - } + write_screen_resolutions(app); QOpenHDVideoHelper::reset_qopenhd_switch_primary_secondary(); #if defined(__ios__) diff --git a/app/telemetry/settings/frequencyhelper.cpp b/app/telemetry/settings/frequencyhelper.cpp index 22928cb97..543a798dc 100644 --- a/app/telemetry/settings/frequencyhelper.cpp +++ b/app/telemetry/settings/frequencyhelper.cpp @@ -12,10 +12,10 @@ FrequencyHelper &FrequencyHelper::instance() return instance; } -QList FrequencyHelper::get_frequencies(bool openhd_bands_only) +QList FrequencyHelper::get_frequencies(int filter) { QList ret; - if(openhd_bands_only){ + if(filter==0){ auto tmp=openhd::get_openhd_channels_1_to_5(); for(auto& channel:tmp){ ret.push_back(channel.frequency); @@ -24,7 +24,15 @@ QList FrequencyHelper::get_frequencies(bool openhd_bands_only) const auto frequency_items=openhd::get_all_channels_2G_5G(); for(auto& item:frequency_items){ if(item.is_legal_at_least_one_country){ - ret.push_back(item.frequency); + if(filter==1){ + if(item.frequency<3000){ + ret.push_back(item.frequency); + } + }else{ + if(item.frequency>3000){ + ret.push_back(item.frequency); + } + } } } } diff --git a/app/telemetry/settings/frequencyhelper.h b/app/telemetry/settings/frequencyhelper.h index 20d8fc5a2..ce30d5f28 100644 --- a/app/telemetry/settings/frequencyhelper.h +++ b/app/telemetry/settings/frequencyhelper.h @@ -14,8 +14,8 @@ class FrequencyHelper : public QObject public: explicit FrequencyHelper(QObject *parent = nullptr); static FrequencyHelper &instance(); - - Q_INVOKABLE QList get_frequencies(bool openhd_bands_only); + // Filter: 0 - OpenHD 1-5 only, 1= all 2.4G freq, 2 = all 5.8G freq + Q_INVOKABLE QList get_frequencies(int filter); Q_INVOKABLE QList get_frequencies_all_40Mhz(); Q_INVOKABLE bool get_frequency_radar(int frequency_mhz); diff --git a/app/util/qrenderstats.cpp b/app/util/qrenderstats.cpp index 05813d729..5b96cea1c 100644 --- a/app/util/qrenderstats.cpp +++ b/app/util/qrenderstats.cpp @@ -33,18 +33,18 @@ void QRenderStats::registerOnWindow(QQuickWindow *window) connect(window, &QQuickWindow::afterRenderPassRecording, this, &QRenderStats::m_QQuickWindow_afterRenderPassRecording, Qt::DirectConnection); } -void QRenderStats::set_display_width_height(int width, int height) +void QRenderStats::set_screen_width_height(int width, int height) { std::stringstream ss; ss<0){ var index=find_index(comboBoxFreq.model,_wbLinkSettingsHelper.curr_channel_mhz); if(index>=0){ @@ -148,6 +134,7 @@ Rectangle{ //ScrollBar.vertical.policy: ScrollBar.AlwaysOn ScrollBar.vertical.interactive: true visible: (!popup_analyze_channels.visible && !popup_enable_stbc_ldpc.visible && !popup_change_tx_power.visible && !popup_scan_channels.visible) + clip: true ColumnLayout{ width: main_scroll_view.width @@ -167,8 +154,7 @@ Rectangle{ Layout.alignment: Qt.AlignCenter Layout.preferredWidth: elementComboBoxWidth id: comboBoxFreq - //model: supported_frequencies_model - //model: frequencies_model_openhd_channels_only + model: frequencies_model textRole: "title" implicitWidth: elementComboBoxWidth currentIndex: 0 @@ -220,7 +206,7 @@ Rectangle{ } enabled: _ohdSystemGround.is_alive && _ohdSystemGround.wb_gnd_operating_mode==0; } - Switch{ + /*Switch{ Layout.alignment: Qt.AlignCenter text: "SIMPLIFY" checked: true @@ -230,6 +216,29 @@ Rectangle{ function_rebuild_ui(); } } + }*/ + TabBar{ + id: filter_tab_bar + Layout.preferredWidth: 200 + currentIndex: settings.qopenhd_frequency_filter_selection + onCurrentIndexChanged: { + if(currentIndex!=settings.qopenhd_frequency_filter_selection){ + settings.qopenhd_frequency_filter_selection=currentIndex; + function_rebuild_ui(); + if(currentIndex==1 || currentIndex==2){ + _qopenhd.show_toast("Please watch out for wifi pollution"); + } + } + } + TabButton{ + text: "1-5" + } + TabButton{ + text: "2.4G" + } + TabButton{ + text: "5.8G" + } } Item{ // FILLER Layout.fillWidth: true diff --git a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml index 223fa488f..ce1887729 100644 --- a/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml +++ b/qml/ui/configpopup/openhd_settings/PopupAnalyzeChannels.qml @@ -29,7 +29,7 @@ Rectangle{ property bool m_normalize_data: false; property int m_chart_view_minimum_width: 1280; - property int m_chart_view_minimum_width2: 640; + property int m_chart_view_minimum_width2: 1280; property bool m_chart_enlarged: false; diff --git a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml index 4a23d3ac3..763f0256e 100644 --- a/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml +++ b/qml/ui/configpopup/openhd_settings/PopupTxPowerEditor.qml @@ -29,6 +29,8 @@ Rectangle{ property bool m_is_air: false property int m_user_selected_card_manufacturer: -1; + property int left_text_minimum_width: 100 + property int left_text_preferred_width: 100 function open(){ if(_fcMavlinkSystem.is_alive && _fcMavlinkSystem.armed){ @@ -234,9 +236,6 @@ Rectangle{ //Layout.preferredWidth: 600 Item{ - Layout.row: 0 - Layout.column: 0 - Layout.columnSpan: 4 Layout.fillWidth: true Layout.preferredHeight: 80 Text{ // TITLE @@ -259,8 +258,8 @@ Rectangle{ RowLayout{ Layout.fillWidth: true Text{ - Layout.minimumWidth: 100 - Layout.preferredWidth: 250 + Layout.minimumWidth: left_text_minimum_width + Layout.preferredWidth: left_text_preferred_width text: "RF CHIP:\n" +get_card_chipset_str() horizontalAlignment: Qt.AlignHCenter font.pixelSize: 14 @@ -279,16 +278,14 @@ Rectangle{ } // FILLER Item{ - Layout.row: 1 - Layout.column: 3 Layout.fillWidth: true } } RowLayout{ Layout.fillWidth: true Text{ - Layout.minimumWidth: 100 - Layout.preferredWidth: 250 + Layout.minimumWidth: left_text_minimum_width + Layout.preferredWidth: left_text_preferred_width text: "DISARMED:\n"+get_current_tx_power_int(1)+" "+get_tx_power_unit(); horizontalAlignment: Qt.AlignHCenter font.pixelSize: 14 @@ -329,11 +326,8 @@ Rectangle{ _messageBoxInstance.set_text_and_show("TX Power applied when FC is disarmed"); } } - // FILLER Item{ - Layout.row: 2 - Layout.column: 4 Layout.fillWidth: true } } @@ -341,8 +335,8 @@ Rectangle{ RowLayout{ Layout.fillWidth: true Text{ - Layout.minimumWidth: 100 - Layout.preferredWidth: 250 + Layout.minimumWidth: left_text_minimum_width + Layout.preferredWidth: left_text_preferred_width text: { var power_int=get_current_tx_power_int(2); if(power_int==0) return "ARMED:\nDISABLED"; @@ -361,8 +355,6 @@ Rectangle{ font.pixelSize: 14 } Button{ - Layout.row: 3 - Layout.column: 2 text: "SAVE" enabled: m_user_selected_card_manufacturer>=0; onClicked: { @@ -382,8 +374,6 @@ Rectangle{ font.pixelSize: 14 } ButtonIconInfo{ - Layout.row: 3 - Layout.column: 3 onClicked: { _messageBoxInstance.set_text_and_show("TX Power applied when FC is armed. By default, set to 0 (DISABLE) which means the same tx power (tx power disarmed) is applied regardless"+ "if armed or not."); diff --git a/qml/ui/configpopup/status/PanelStatus.qml b/qml/ui/configpopup/status/PanelStatus.qml index 79b8aa87b..b0cbca935 100644 --- a/qml/ui/configpopup/status/PanelStatus.qml +++ b/qml/ui/configpopup/status/PanelStatus.qml @@ -40,14 +40,6 @@ Rectangle { } ScrollView { - /*id:mavlinkExtraWBParamPanel - width: parent.width - height: parent.height - contentHeight: mainItem.height - contentWidth: mainItem.width - clip: true - //ScrollBar.vertical.policy: ScrollBar.AlwaysOn - ScrollBar.vertical.interactive: true*/ width: parent.width anchors.top: selectItemInStackLayoutBar.bottom anchors.left: parent.left @@ -68,21 +60,19 @@ Rectangle { id: statuscardscolumn width: parent.width height: 350 - anchors.leftMargin: 4 anchors.topMargin: 4 - + anchors.rightMargin: 4 anchors.left: parent.left + anchors.right: parent.right // anchors.top: qopenhdversioncard.bottom } - PingUtilColumn { id:actionsButtonMenu width: parent.width height: 80 anchors.top: statuscardscolumn.bottom - } } } diff --git a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml index 9e05c3f79..8e42b7365 100644 --- a/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml +++ b/qml/ui/configpopup/status/StatusCardBodyOpenHD.qml @@ -11,7 +11,7 @@ import OpenHD 1.0 import "../../../ui" as Ui import "../../elements" -ColumnLayout { +Column { //Layout.fillWidth: true //Layout.fillHeight: true // from https://doc.qt.io/qt-6/qml-qtquick-layouts-rowlayout.html diff --git a/qml/ui/configpopup/status/StatusCardsColumn.qml b/qml/ui/configpopup/status/StatusCardsColumn.qml index 1de4f7c6d..9768c5c75 100644 --- a/qml/ui/configpopup/status/StatusCardsColumn.qml +++ b/qml/ui/configpopup/status/StatusCardsColumn.qml @@ -14,12 +14,14 @@ import "../../elements" // The 3 status cards (OpenHD AIR & GND, FC) // next to each other Row{ - width: parent.width - height: parent.height + id: status_cards_row + property int m_spacing_px: 3 + + property int m_card_width: (parent.width-4*m_spacing_px)/3; + property int m_card_height: status_cards_row.height + + spacing: m_spacing_px - property int m_card_width: parent.width/3-3; - property int m_card_height: 350 - padding: 3 Card { width: m_card_width height:m_card_height diff --git a/qml/ui/elements/AppSettings.qml b/qml/ui/elements/AppSettings.qml index 52daf95fb..f40ca06ce 100644 --- a/qml/ui/elements/AppSettings.qml +++ b/qml/ui/elements/AppSettings.qml @@ -407,4 +407,6 @@ Settings { property int qopenhd_mavlink_connection_mode: 0; property string qopenhd_mavlink_connection_manual_tcp_ip: "192.168.178.36" + + property int qopenhd_frequency_filter_selection: 0; } diff --git a/qml/ui/elements/BaseHeaderItem.qml b/qml/ui/elements/BaseHeaderItem.qml index 15867b6f6..a8c3eee66 100644 --- a/qml/ui/elements/BaseHeaderItem.qml +++ b/qml/ui/elements/BaseHeaderItem.qml @@ -7,6 +7,11 @@ Item { property string m_text: "FILL ME" + Rectangle{ + anchors.fill: parent + color: "#8cbfd7f3" + } + Rectangle{ width: parent.width height: 2