From 07fa49d3b10205215786e2b24c2d11923db358be Mon Sep 17 00:00:00 2001 From: consti10 Date: Tue, 14 Nov 2023 16:02:05 +0100 Subject: [PATCH] wb link rate widget - use combobox instead of buttons --- app/main.cpp | 2 +- qml/qml.qrc | 1 + .../AppScreenSettingsView.qml | 8 +- qml/ui/elements/SmallHeaderInfoRow.qml | 27 ++ qml/ui/widgets/VideoBitrateWidgetGeneric.qml | 2 +- qml/ui/widgets/WBLinkRateControlWidget.qml | 332 ++++++------------ 6 files changed, 146 insertions(+), 226 deletions(-) create mode 100644 qml/ui/elements/SmallHeaderInfoRow.qml diff --git a/app/main.cpp b/app/main.cpp index 690d7a88e..9aded53b7 100755 --- a/app/main.cpp +++ b/app/main.cpp @@ -192,7 +192,7 @@ int main(int argc, char *argv[]) { QCoreApplication::setOrganizationDomain("openhd"); QCoreApplication::setApplicationName("QOpenHD"); {// Original screen resoluton before setting anything - QApplication a(argc, argv); + //QApplication a(argc, argv); const auto screen=QGuiApplication::primaryScreen(); if(screen){ const auto actual_size=screen->size(); diff --git a/qml/qml.qrc b/qml/qml.qrc index 6a259d6c2..366439aba 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -266,5 +266,6 @@ ui/elements/ButtonIconInfo2.qml ui/elements/CardBasic.qml ui/elements/ButtonIconConnect.qml + ui/elements/SmallHeaderInfoRow.qml diff --git a/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml b/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml index 60915821b..f7446c79c 100755 --- a/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml +++ b/qml/ui/configpopup/qopenhd_settings/AppScreenSettingsView.qml @@ -51,18 +51,18 @@ ScrollView { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter from : 0.3 - to : 2.0 + to : 2.5 // Important: Looks as without .1 steps, we can get rendering artfacts stepSize: .1 anchors.rightMargin: Qt.inputMethod.visible ? 78 : 18 value: settings.global_scale - // @disable-check M223 onValueChanged: { - // @disable-check M222 + if(settings.global_scale != value){ + _restartqopenhdmessagebox.show(); + } settings.global_scale = value - //_messageBoxInstance.set_text_and_show("Please restart QOpenHD !") } } } diff --git a/qml/ui/elements/SmallHeaderInfoRow.qml b/qml/ui/elements/SmallHeaderInfoRow.qml new file mode 100644 index 000000000..0bda70f74 --- /dev/null +++ b/qml/ui/elements/SmallHeaderInfoRow.qml @@ -0,0 +1,27 @@ +import QtQuick 2.12 + +Item { + width: parent.width + height: 40 + + property string m_text: "FILL ME" + property string m_info_text: "FILL ME" + + Text{ + anchors.fill: parent + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignLeft + text: m_text + font.pixelSize: 18 + font.bold: true + color: "white" + } + ButtonIconInfo{ + anchors.right: parent.right + width: parent.height + height: parent.height + onClicked: { + _messageBoxInstance.set_text_and_show(m_info_text) + } + } +} diff --git a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml index d9cec249a..d82eefc8d 100644 --- a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml +++ b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml @@ -196,7 +196,7 @@ BaseWidget { Layout.preferredWidth: 200 Layout.minimumWidth: 200 height: 50 - currentIndex: 0 + currentIndex: -1 displayText: { if(!_ohdSystemAir.is_alive)return "Res@fps N/A"; return m_curr_video_format; diff --git a/qml/ui/widgets/WBLinkRateControlWidget.qml b/qml/ui/widgets/WBLinkRateControlWidget.qml index 8c785068b..4c98404ec 100644 --- a/qml/ui/widgets/WBLinkRateControlWidget.qml +++ b/qml/ui/widgets/WBLinkRateControlWidget.qml @@ -48,6 +48,24 @@ BaseWidget { //property bool m_is_armed: true property bool m_is_armed: _fcMavlinkSystem.armed + property int m_row_height: 50 + + + ListModel{ + id: mcs_model + ListElement {title: "MCS0 "; value: 0} + ListElement {title: "MCS1 "; value: 1} + ListElement {title: "MCS2 (DEFAULT)"; value: 2} + ListElement {title: "MCS3 (EXPERIMENTAL)"; value: 3} + ListElement {title: "MCS4 (EXPERIMENTAL)"; value: 4} + } + ListModel{ + id: stability_model + ListElement {title: "30%:2 POLLUTED"; value_fec: 30; value_keyframe: 2} + ListElement {title: "30%:3 CITY"; value_fec: 30; value_keyframe: 3} + ListElement {title: "20%:5 DEFAULT"; value_fec: 20; value_keyframe: 5} + //ListElement {title: "10%:5 DESERT"; value_fec: 10; value_keyframe: 5} + } function get_text_channel(){ if(!settings.wb_link_rate_control_widget_show_frequency){ @@ -142,6 +160,34 @@ BaseWidget { } _wbLinkSettingsHelper.change_param_air_channel_width_async(channel_width_mhz,true); } + function get_rate_for_mcs(mcs,is_40mhz){ + if(is_40mhz){ + if(mcs==0) return 7.4; + if(mcs==1) return 15.3; + if(mcs==2) return 22.6; + if(mcs==3) return 25; + if(mcs==4) return 30; + } + if(mcs==0) return 4.7; + if(mcs==1) return 9.8; + if(mcs==2) return 13; + if(mcs==3) return 16.2; + if(mcs==4) return 20; + return -1; + } + function get_mcs_combobox_text(mcs){ + for(var i = 0; i < mcs_model.count; ++i) { + if (mcs_model.get(i).value==mcs) return mcs_model.get(i).title + } + return "MCS "+m_curr_mcs_index; + } + + function get_fec_keyframe_combobox_text(fec,keyframe){ + for(var i = 0; i < stability_model.count; ++i) { + if (stability_model.get(i).value_fec==fec && stability_model.get(i).value_keyframe==keyframe) return stability_model.get(i).title + } + return "FEC:"+fec+"% : KEY:"+keyframe+" ?"; + } property string m_DESCRIPTION_CHANNEL_WIDTH: " A higher bandwidth / 40Mhz channel width increases the bitrate significantly, but also increases interference and reduces the maximum range."+ @@ -264,237 +310,83 @@ Make the video more stable (less microfreezes) on the cost of less image quality width: parent.width height: parent.height - ColumnLayout { - width: m_widget_action_w -32 - height: m_widget_action_h-32 - spacing: 20 + Column { + width: m_widget_action_w-32 + //height: m_widget_action_h + //spacing: 20 - Rectangle{ + SmallHeaderInfoRow{ + m_text: "Range vs Bitrate" + m_info_text: m_DESCRIPTION_CHANNEL_WIDTH + } + Row{ width: parent.width - height: 50 - Layout.fillWidth: true - //color: "#13142e" - //border.width: 5 - //radius: 10 - //color: "green" - color: "black" - ColumnLayout{ - width: parent.width - height: parent.height - spacing: 1 - Rectangle { - height: 32 - width: parent.width - id: itemDescriptionRangeQuality - //color: "green" - color: "black" - Text { - id: simpleDescriptionRangeQuality - text: "Trade range/image quality" - color: "white" - font.bold: true - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - } - Button{ - height: 32 - width: 32 - text: "\uf05a" - anchors.left: simpleDescriptionRangeQuality.right - anchors.top: simpleDescriptionRangeQuality.top - Material.background:Material.LightBlue - anchors.leftMargin: 5 - onClicked: { - _messageBoxInstance.set_text_and_show(m_DESCRIPTION_CHANNEL_WIDTH) - } - } + height: m_row_height + spacing: 20 + enabled: _ohdSystemAir.is_alive; + Button{ + text: "20Mhz" + onClicked: { + set_channel_width_async(20) } - Item{ - width: parent.width - height: 20 - GridLayout{ - width: parent.width - height: parent.height - rows: 2 - columns: 2 - Button{ - text: "20Mhz" - onClicked: { - set_channel_width_async(20) - } - highlighted: m_curr_channel_width==20 - } - Button{ - text: "40Mhz" - onClicked: { - set_channel_width_async(40) - } - highlighted: m_curr_channel_width==40 - } - } + highlighted: m_curr_channel_width==20 + } + Button{ + text: "40Mhz" + onClicked: { + set_channel_width_async(40) } + highlighted: m_curr_channel_width==40 } } - - Rectangle{ - id: areaMCS + SmallHeaderInfoRow{ + m_text: "Range vs Bitrate" + m_info_text: m_DESCRIPTION_MCS + } + ComboBox{ width: parent.width - height: parent.height /3; - //color: "red" - color: "black" - ColumnLayout{ - width: parent.width - height: parent.height - spacing: 1 - Item { - height: 32 - width: parent.width - id: itemDescriptionMCS - Text { - id: simpleDescription - text: "Trade range/image quality" - color: "white" - font.bold: true - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - } - Button{ - height: 32 - width: 32 - text: "\uf05a" - anchors.left: simpleDescription.right - anchors.top: simpleDescription.top - Material.background:Material.LightBlue - anchors.leftMargin: 5 - onClicked: { - _messageBoxInstance.set_text_and_show(m_DESCRIPTION_MCS) - } - } - } - - Rectangle{ - width: parent.width - height: 100; - id: itemMcsChoices - //color: "green" - color: "black" - GridLayout{ - width: parent.width - height: parent.height - rows: 3 - columns: 2 - Button{ - text: "MCS0" - onClicked: { - set_air_only_mcs(0) - } - highlighted: m_curr_mcs_index==0 - } - Button{ - text: "MCS1" - onClicked: { - set_air_only_mcs(1) - } - highlighted: m_curr_mcs_index==1 - } - Button{ - text: "MCS2\n(DEFAULT)" - onClicked: { - set_air_only_mcs(2) - } - highlighted: m_curr_mcs_index==2 - } - Button{ - text: "MCS3" - onClicked: { - set_air_only_mcs(3) - } - highlighted: m_curr_mcs_index==3 - } - } - } + height: m_row_height + id: mcs_cb + model: mcs_model + textRole: "title" + currentIndex: -1 + displayText: { + if(!_ohdSystemAir.is_alive)return "AIR NOT ALIVE"; + return get_mcs_combobox_text(m_curr_mcs_index); + //return "MCS "+m_curr_mcs_index+" / "+get_rate_for_mcs(m_curr_mcs_index,m_curr_channel_width==40)+" MBit/s" } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const mcs=model.get(currentIndex).value + set_air_only_mcs(mcs) + } + enabled: _ohdSystemAir.is_alive; + } + SmallHeaderInfoRow{ + m_text: "Stability vs Bitrate" + m_info_text:m_DESCRIPTION_STABILITY } - Rectangle{ - id: areaKeyframe + ComboBox{ width: parent.width - height: parent.height /3; - //color: "green" - color: "black" - ColumnLayout{ - width: parent.width - height: parent.height - spacing: 5 - Item { - height: 32 - width: parent.width - id: itemDescriptionKeyframe - //anchors.top: itemMcsChoices.bottom - Text { - id: simpleDescriptionKeyframe - text: "Trade Quality/Stability" - color: "white" - font.bold: true - font.pixelSize: detailPanelFontPixels - anchors.left: parent.left - } - Button{ - height: 32 - width: 32 - text: "\uf05a" - anchors.left: simpleDescriptionKeyframe.right - anchors.top: simpleDescriptionKeyframe.top - Material.background:Material.LightBlue - anchors.leftMargin: 5 - onClicked: { - _messageBoxInstance.set_text_and_show(m_DESCRIPTION_STABILITY) - } - } - } - Item{ - width: parent.width - height: parent.height -32; - //color: "green" - GridLayout{ - width: parent.width - height: parent.height - rows: 2 - columns: 2 - Button{ - text: "POLLUTED" - onClicked: { - set_keyframe_interval(2) - set_fec_percentage(30) - } - highlighted: m_curr_keyframe_i == 2 && m_curr_fec_perc==30 - } - Button{ - text: "CITY" - onClicked: { - set_keyframe_interval(3) - set_fec_percentage(20) - } - highlighted: m_curr_keyframe_i == 3 && m_curr_fec_perc==20 - } - Button{ - text: "DEFAULT" - onClicked: { - set_keyframe_interval(5) - set_fec_percentage(20) - } - highlighted: m_curr_keyframe_i == 5 && m_curr_fec_perc==20 - } - Button{ - text: "DESERT" - onClicked: { - set_keyframe_interval(5) - set_fec_percentage(10) - } - highlighted: m_curr_keyframe_i == 5 && m_curr_fec_perc==10 - } - } - } + height: m_row_height + id: pollution_cb + model: stability_model + textRole: "title" + currentIndex: -1 + displayText: { + if(!_ohdSystemAir.is_alive)return "AIR NOT ALIVE"; + return get_fec_keyframe_combobox_text(m_curr_fec_perc,m_curr_keyframe_i) + } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const fec=model.get(currentIndex).value_fec + const key=model.get(currentIndex).value_keyframe + set_fec_percentage(fec) + set_keyframe_interval(key) } + enabled: _ohdSystemAir.is_alive; } } }