Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.5.2 beta #605

Merged
merged 16 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,23 @@ static void android_check_permissions(){
#endif
}


int main(int argc, char *argv[]) {

QCoreApplication::setOrganizationName("OpenHD");
QCoreApplication::setOrganizationDomain("openhd");
QCoreApplication::setApplicationName("QOpenHD");
{// Original screen resoluton before setting anything
//QApplication a(argc, argv);
const auto screen=QGuiApplication::primaryScreen();
if(screen){
const auto actual_size=screen->size();
QRenderStats::instance().set_screen_width_height(actual_size.width(),actual_size.height());
}
// a is deleted again
}

QSettings settings;
qDebug()<<"Storing settings at ["<<settings.fileName()<<"]";

const int screen_custom_font_dpi = settings.value("screen_custom_font_dpi").toInt();
if (screen_custom_font_dpi) {
Expand All @@ -204,22 +213,11 @@ int main(int argc, char *argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
}
//QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);

// From https://stackoverflow.com/questions/63473541/how-to-dynamically-toggle-vsync-in-a-qt-application-at-runtime
// Get rid of VSYNC if possible. Might / might not work. On my ubuntu nvidia & intel laptop, this at least seems to
// result in tripple buffering with unlimited fps, a bit "better" regarding latency than default.
if(settings.value("dev_set_swap_interval_zero",false).toBool()){
qDebug()<<"Request swap interval of 0";
QSurfaceFormat format=QSurfaceFormat::defaultFormat();
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);
}

//QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
const double global_scale = settings.value("global_scale", 1.0).toDouble();
const std::string global_scale_s = std::to_string(global_scale);
QByteArray scaleAsQByteArray(global_scale_s.c_str(), global_scale_s.length());
qputenv("QT_SCALE_FACTOR", scaleAsQByteArray);
qDebug()<<"Storing settings at ["<<settings.fileName()<<"]";

// https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph-renderer.html
//qputenv("QSG_VISUALIZE", "overdraw");
Expand All @@ -234,10 +232,20 @@ int main(int argc, char *argv[]) {
//QLoggingCategory::setFilterRules("qt.qpa.eglfs.*=true");
//QLoggingCategory::setFilterRules("qt.qpa.egl*=true");

// From https://stackoverflow.com/questions/63473541/how-to-dynamically-toggle-vsync-in-a-qt-application-at-runtime
// Get rid of VSYNC if possible. Might / might not work. On my ubuntu nvidia & intel laptop, this at least seems to
// result in tripple buffering with unlimited fps, a bit "better" regarding latency than default.
if(settings.value("dev_set_swap_interval_zero",false).toBool()){
qDebug()<<"Request swap interval of 0";
QSurfaceFormat format=QSurfaceFormat::defaultFormat();
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);
}

QApplication app(argc, argv);
// Customize cursor if needed
QOpenHD::instance().customize_cursor_from_settings();
{
{ // This includes dpi adjustment
QScreen* screen=app.primaryScreen();
if(screen){
QRenderStats::instance().set_display_width_height(screen->size().width(),screen->size().height());
Expand Down
4 changes: 3 additions & 1 deletion app/osd/horizonladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ HorizonLadder::HorizonLadder(QQuickItem *parent): QQuickPaintedItem(parent) {
setRenderTarget(RenderTarget::FramebufferObject);

//m_font.setPixelSize(14);
m_font.setPointSize(14);
m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE);
m_fontAwesome.setPointSize(DEFAULT_FONT_PIXEL_SIZE);
}

void HorizonLadder::paint(QPainter* painter) {
Expand Down Expand Up @@ -500,5 +501,6 @@ void HorizonLadder::set_custom_font_scale(double custom_font_scale)
{
m_custom_font_scale=custom_font_scale;
m_font.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale);
m_fontAwesome.setPointSize(DEFAULT_FONT_PIXEL_SIZE*m_custom_font_scale);
update();
}
2 changes: 1 addition & 1 deletion app/osd/horizonladder.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public slots:

QFont m_font;

QFont m_fontAwesome = QFont("Font Awesome 5 Free", 15, QFont::Bold, false);
QFont m_fontAwesome = QFont("Font Awesome 5 Free", 11, QFont::Bold, false);
double m_custom_font_scale=1.0;
};
#endif //QOPENHD_HORIZON_LADDER
10 changes: 10 additions & 0 deletions app/telemetry/settings/documentedparam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,16 @@ static std::map<std::string, void *> get_whitelisted_params()
ret["CONFIG_BOOT_AIR"]=nullptr;
ret[openhd::WB_MAX_FEC_BLOCK_SIZE_FOR_PLATFORM]=nullptr;
ret[openhd::WB_DEV_AIR_SET_HIGH_RETRANSMIT_COUNT]=nullptr;
// TX POWER Whitelisted, since they should be changed from the quick wizzard
ret[openhd::WB_TX_POWER_MILLI_WATT]=nullptr;
ret[openhd::WB_TX_POWER_MILLI_WATT_ARMED]=nullptr;
ret[openhd::WB_RTL8812AU_TX_PWR_IDX_OVERRIDE]=nullptr;
ret[openhd::WB_RTL8812AU_TX_PWR_IDX_ARMED]=nullptr;
// STBC / LDPC - Whitelisted, since they should be changed from the quick wizzard
ret[openhd::WB_ENABLE_LDPC]=nullptr;
ret[openhd::WB_ENABLE_STBC]=nullptr;
// Whitelisted since normally it should not be changed / has no effect anyways
ret[openhd::WB_ENABLE_SHORT_GUARD]=nullptr;
//ret[""]=nullptr;
return ret;
}
Expand Down
14 changes: 11 additions & 3 deletions app/telemetry/settings/frequencyhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ FrequencyHelper &FrequencyHelper::instance()
return instance;
}

QList<int> FrequencyHelper::get_frequencies(bool openhd_bands_only)
QList<int> FrequencyHelper::get_frequencies(int filter)
{
QList<int> 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);
Expand All @@ -24,7 +24,15 @@ QList<int> 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);
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/telemetry/settings/frequencyhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class FrequencyHelper : public QObject
public:
explicit FrequencyHelper(QObject *parent = nullptr);
static FrequencyHelper &instance();

Q_INVOKABLE QList<int> 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<int> get_frequencies(int filter);
Q_INVOKABLE QList<int> get_frequencies_all_40Mhz();

Q_INVOKABLE bool get_frequency_radar(int frequency_mhz);
Expand Down
7 changes: 5 additions & 2 deletions app/util/qopenhd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ bool QOpenHD::overwrite_settings_from_backup_file()

bool QOpenHD::reset_settings()
{
#ifdef __linux__
/*#ifdef __linux__
QSettings settings;
std::string file_name = settings.fileName().toStdString();
int result = remove(file_name.c_str());
Expand All @@ -213,7 +213,10 @@ bool QOpenHD::reset_settings()
qDebug() << "Error: Failed to delete file" << QString::fromStdString(file_name);
return false;
#endif
return false;
return false;*/
QSettings settings;
settings.clear();
return true;
}


Expand Down
8 changes: 4 additions & 4 deletions app/util/qrenderstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<<width<<"x"<<height;
set_display_width_height_str(ss.str().c_str());
set_screen_width_height_str(ss.str().c_str());
}

void QRenderStats::set_window_width_height(int width, int height)
void QRenderStats::set_display_width_height(int width, int height)
{
std::stringstream ss;
ss<<width<<"x"<<height;
set_window_width_height_str(ss.str().c_str());
set_display_width_height_str(ss.str().c_str());
}

void QRenderStats::m_QQuickWindow_beforeRendering()
Expand Down
7 changes: 5 additions & 2 deletions app/util/qrenderstats.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
class QRenderStats : public QObject
{
Q_OBJECT
public:
L_RO_PROP(QString, main_render_stats, set_main_render_stats, "NA")
// It can be quite nice for debugging to see what resolution QOpenHD's main window is rendered at
// Resolution of the screen / display itself
L_RO_PROP(QString, display_width_height_str, set_display_width_height_str, "NA")
L_RO_PROP(QString, screen_width_height_str, set_screen_width_height_str, "NA")
// Resolution qopenhd is rendering at
L_RO_PROP(QString, window_width_height_str, set_window_width_height_str, "NA")
L_RW_PROP(int, window_width, set_window_width, -1)
L_RW_PROP(int, window_height, set_window_height, -1)
// Time QT spent "rendering", probably aka creating the GPU command buffer
L_RO_PROP(QString, qt_rendering_time, set_qt_rendering_time, "NA")
// Time QT spent "recording the render pass"
Expand All @@ -32,8 +35,8 @@ class QRenderStats : public QObject
void register_to_root_window(QQmlApplicationEngine& engine);
// Manually regster the QML window
void registerOnWindow(QQuickWindow* window);
void set_screen_width_height(int width,int height);
void set_display_width_height(int width,int height);
void set_window_width_height(int width,int height);
public slots:
void m_QQuickWindow_beforeRendering();
void m_QQuickWindow_afterRendering();
Expand Down
7 changes: 7 additions & 0 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ ApplicationWindow {
width: (settings.general_screen_rotation == 90 || settings.general_screen_rotation == 270) ? m_window_height : m_window_width
height: (settings.general_screen_rotation == 90 || settings.general_screen_rotation == 270) ? m_window_width : m_window_height

onWidthChanged: {
_qrenderstats.set_window_width(width)
}
onHeightChanged: {
_qrenderstats.set_window_height(height)
}

contentOrientation: settings.general_screen_rotation===0 ? Qt.PortraitOrientation : Qt.LandscapeOrientation
contentItem.rotation: settings.general_screen_rotation

Expand Down
6 changes: 6 additions & 0 deletions qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,11 @@
<file>video/SecondaryVideoGstreamerPane.qml</file>
<file>ui/elements/SettingsHeaderElement.qml</file>
<file>ui/configpopup/qopenhd_settings/AppWidgetStyleSettingsView.qml</file>
<file>ui/configpopup/openhd_settings/OpenHDQuickPanel.qml</file>
<file>ui/elements/BaseHeaderItem.qml</file>
<file>ui/elements/ButtonIconInfo2.qml</file>
<file>ui/elements/CardBasic.qml</file>
<file>ui/elements/ButtonIconConnect.qml</file>
<file>ui/elements/SmallHeaderInfoRow.qml</file>
</qresource>
</RCC>
19 changes: 7 additions & 12 deletions qml/ui/configpopup/ConfigPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ import "status"
// Contains the selector on the left and a stack view for the panels on the right
Rectangle {
id: settings_form

// The connect is only needed when qopenhd is not running on the ground system itself (e.g. android)
property bool m_show_connect_option: true // _qopenhd.is_android()
//width: 1280
//height: 720
anchors.fill: parent
//width: parent.width * settings.screen_settings_overlay_size_percent / 100;
//height: parent.height * settings.screen_settings_overlay_size_percent / 100;
z: 4.0
color: "transparent"

// size of the elements in the left bar - e.g. what allows switching between all the tabs
property int left_sidebar_elements_height: 46
Expand Down Expand Up @@ -64,14 +68,6 @@ Rectangle {
}
}*/

//anchors.fill: parent
width: parent.width * settings.screen_settings_overlay_size_percent / 100;
height: parent.height * settings.screen_settings_overlay_size_percent / 100;

z: 4.0

color: "transparent"

Rectangle {
id: spacerTopSpacer
width: 132
Expand Down Expand Up @@ -210,7 +206,6 @@ Rectangle {
// We only need the connect panel on android (external device)
// On localhost, QOpenHD "automatically" connects due to udp localhost method
ConfigPopupSidebarButton{
visible: m_show_connect_option
id: connect_button
m_icon_text: "\uf6ff"
m_description_text: "Connect"
Expand Down
45 changes: 24 additions & 21 deletions qml/ui/configpopup/dev/AppDeveloperStatsPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,30 @@ Rectangle {
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: 10

Text{
text: qsTr("QOpenHD version:" + _qopenhd.version_string)
Layout.leftMargin: 12
}
Text {
id: test5
text: qsTr("FEATURES: " + get_features_string())
Layout.leftMargin: 12
}
Text {
id: test6
text: qsTr("Screen resolution: " + _qrenderstats.screen_width_height_str+" ADJ:"+_qrenderstats.display_width_height_str)
Layout.leftMargin: 12
}
Text {
id: test7
text: qsTr("Window resolution: " + _qrenderstats.window_width+"x"+_qrenderstats.window_height)
Layout.leftMargin: 12
}
Text {
id: test8
text: qsTr("You're running on: " + Qt.platform.os)
Layout.leftMargin: 12
}
Text {
id: test1
text: qsTr("Art Horizon mavlink update rate:" + _fcMavlinkSystem.curr_update_rate_mavlink_message_attitude + " Hz")
Expand Down Expand Up @@ -85,26 +108,6 @@ Rectangle {
text: qsTr("video0 FEC decode: " + _cameraStreamModelPrimary.curr_fec_decode_time_avg_min_max)
Layout.leftMargin: 12
}
Text {
id: test5
text: qsTr("FEATURES: " + get_features_string())
Layout.leftMargin: 12
}
Text {
id: test6
text: qsTr("Screen resolution: " + _qrenderstats.display_width_height_str)
Layout.leftMargin: 12
}
Text {
id: test7
text: qsTr("Window resolution: " + _qrenderstats.window_width_height_str)
Layout.leftMargin: 12
}
Text {
id: test8
text: qsTr("You're running on: " + Qt.platform.os)
Layout.leftMargin: 12
}
Button {
height: 24
text: "Restart local OHD service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Rectangle {
currentIndex: selectItemInStackLayoutBar.currentIndex

MavlinkOpenHDWBParamPanel{
//OpenHDQuickPanel{
id: mavlink_openhd_wb_param_panel
}
MavlinkParamPanel{
Expand Down
Loading
Loading