Skip to content

Commit

Permalink
No functional changes, QT 6 stuff (#668)
Browse files Browse the repository at this point in the history
* QT 6 stuff

* QT 6 stuff

* add error message box

* remove a few obsolete settings

* small comp fixes

* small comp fixes

* fix layouting for QT6

* fix layouting for QT6

* add QT6 CI

* add QT6 CI

* add QT6 CI

* qt 6.4 also works
  • Loading branch information
Consti10 authored Mar 1, 2024
1 parent 9f44f12 commit dd34e48
Show file tree
Hide file tree
Showing 21 changed files with 320 additions and 224 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ubuntu22_build_test_qt6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: ubuntu22_build_test_qt6

# @Rapha please keep this one without any packaging or similar ;)
# NOTE: This test only checks if the code in the repository builds under ubuntu x86 (dependencies installed)
# Which is - simply put - the most basic test. If this test fails, there is something wrong with the code.

on: [push]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
#runs-on: ubuntu-18.04
#runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: 6.5
modules: qtcharts

- name: Install non-qt dependencies
run: |
sudo ./install_qt6_build_dep.sh
- name: Build with CMake
run: |
./build_cmake.sh
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core)
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick)
find_package(Qt6 6.5 REQUIRED COMPONENTS Gui)
find_package(Qt6 6.5 REQUIRED COMPONENTS Widgets)
set(X_QT_VERSION 6.4)

qt_standard_project_setup(REQUIRES 6.5)

find_package(Qt6 ${X_QT_VERSION} REQUIRED COMPONENTS Core)
find_package(Qt6 ${X_QT_VERSION} REQUIRED COMPONENTS Quick)
find_package(Qt6 ${X_QT_VERSION} REQUIRED COMPONENTS Gui)
find_package(Qt6 ${X_QT_VERSION} REQUIRED COMPONENTS Widgets)

qt_standard_project_setup(REQUIRES ${X_QT_VERSION})

qt_add_executable(QOpenHDApp
app/main.cpp
Expand Down Expand Up @@ -74,7 +77,12 @@ qt_add_executable(QOpenHDApp
#app/videostreaming/vscommon/rtp/rtpreceiver.cpp
#app/videostreaming/vscommon/rtp/ParseRTP.cpp
app/videostreaming/vscommon/decodingstatistcs.cpp
app/videostreaming/vscommon/decodingstatistcs.h
app/videostreaming/vscommon/audio_playback.cpp
app/videostreaming/vscommon/rtp/ParseRTP.cpp
app/videostreaming/vscommon/rtp/rtpreceiver.cpp
app/videostreaming/vscommon/udp/UDPReceiver.cpp
app/videostreaming/vscommon/decodingstatistcs.cpp

##
lib/geographiclib-c-2.0/src/geodesic.c
##
Expand Down Expand Up @@ -116,6 +124,10 @@ target_link_libraries(QOpenHDApp
PRIVATE Qt6::Core Qt6::Quick Qt6::Gui Qt6::Widgets
)

include(lib/h264/h264.cmake)
include(app/videostreaming/avcodec/avcodec_video.cmake)
include(app/videostreaming/android/videostreamingandroid.cmake)

#include(GNUInstallDirs)
#install(TARGETS QOpenHD
# BUNDLE DESTINATION .
Expand Down
22 changes: 0 additions & 22 deletions app/telemetry/MavlinkTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,6 @@ void MavlinkTelemetry::process_mavlink_message(const mavlink_message_t& msg)
//qDebug()<<"MavlinkTelemetry::XonProcessMavlinkMessage"<<msg.msgid<<"compid:"<<source_compid<<" source_sysid:"<<source_sysid;
if(!m_fc_found){
// For the fc we need to wait until we got an heartbeat
/*if(msg.msgid==MAVLINK_MSG_ID_HEARTBEAT){
qDebug()<<"Got non-openhd heartbeat";
// By default, we assume there is one additional non-openhd system - the FC
bool is_fc=true;
QSettings settings;
const bool dirty_enable_mavlink_fc_sys_id_check=settings.value("dirty_enable_mavlink_fc_sys_id_check",false).toBool();
if(dirty_enable_mavlink_fc_sys_id_check){
// filtering, default off
//const auto comp_ids=system->component_ids();
//is_fc=mavsdk::helper::any_comp_id_autopilot(comp_ids);
}
if(is_fc){
qDebug()<<"Found FC";
// we got the flight controller
FCMavlinkSystem::instance().set_system_id(source_sysid);
m_fc_sys_id=source_sysid;
m_fc_comp_id=source_compid;
m_fc_found=true;
}else{
qDebug()<<"Got weird system:"<<source_sysid;
}
}*/
if(source_compid==MAV_COMP_ID_AUTOPILOT1){
FCMavlinkSystem::instance().set_system_id(source_sysid);
m_fc_sys_id=source_sysid;
Expand Down
6 changes: 3 additions & 3 deletions app/telemetry/connection/tcp_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ void TCPConnection::receive_until_stopped()
// Enough for MTU 1500 bytes.
auto buffer=std::make_unique<std::vector<uint8_t>>();
buffer->resize(1500);
struct timeval tv;
tv.tv_sec = 3;
tv.tv_usec = 0;
//struct timeval tv;
//tv.tv_sec = 3;
//tv.tv_usec = 0;
//setsockopt(m_socket_fd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
while (m_keep_receiving) {
const auto elapsed_last_message=QOpenHDMavlinkHelper::getTimeMilliseconds()-m_last_data_ms;
Expand Down
10 changes: 2 additions & 8 deletions app/telemetry/models/markermodel.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include <QThread>
// #include <QtConcurrent>
#include <QFutureWatcher>
#include <QFuture>

#include "markermodel.h"

Expand Down Expand Up @@ -43,13 +41,9 @@ int Traffic::distance() const{
}


static MarkerModel* _instance = nullptr;

MarkerModel* MarkerModel::instance() {
if (_instance == nullptr) {
_instance = new MarkerModel();
}
return _instance;
static MarkerModel m_instance{};
return &m_instance;
}

MarkerModel::MarkerModel(QObject *parent): QAbstractListModel(parent){
Expand Down
7 changes: 6 additions & 1 deletion app/telemetry/tutil/geodesi_helper.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include "geodesi_helper.h"

#include <QtGlobal>

extern "C" {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include "lib/geographiclib-c-2.0/src/geodesic.h"
//#include "geodesic.h"
#else
#include "geodesic.h"
#endif
}

double distance_between(double lat1, double lon1, double lat2, double lon2){
Expand Down
5 changes: 5 additions & 0 deletions app/util/qopenhd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ void QOpenHD::show_toast(QString message,bool long_toast)
emit signal_toast_add(message,long_toast);
}

void QOpenHD::show_error_message(QString message)
{

}

void QOpenHD::set_busy_for_milliseconds(int milliseconds,QString reason)
{
set_is_busy(true);
Expand Down
5 changes: 5 additions & 0 deletions app/util/qopenhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class QOpenHD : public QObject
//
Q_INVOKABLE void show_toast(QString message,bool long_toast=false);
L_RO_PROP(QString,version_string,set_version_string,"2.5.4-evo-alpha");
//
// Shows a message popup to the user that needs to be clicked away - use sparingly
//
Q_INVOKABLE void show_error_message(QString message);
L_RO_PROP(QString,error_message_text,set_error_message_text,"");
// Notify that something is going on for a specified amount of time
public:
Q_INVOKABLE void set_busy_for_milliseconds(int milliseconds,QString reason);
Expand Down
Empty file.
23 changes: 23 additions & 0 deletions app/videostreaming/avcodec/avcodec_video.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(AVCODEC_SOURCES
${CMAKE_CURRENT_LIST_DIR}/QSGVideoTextureItem.cpp
${CMAKE_CURRENT_LIST_DIR}/gl/gl_shaders.cpp
${CMAKE_CURRENT_LIST_DIR}/gl/gl_videorenderer.cpp
${CMAKE_CURRENT_LIST_DIR}/texturerenderer.cpp
${CMAKE_CURRENT_LIST_DIR}/avcodec_decoder.cpp
)

set(AVCODEC_HEADERS
QSGVideoTextureItem.h
)

target_sources(QOpenHDApp PRIVATE ${AVCODEC_SOURCES})

target_include_directories(QOpenHDApp
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)

target_link_libraries(QOpenHDApp PRIVATE avcodec avutil avformat)
target_link_libraries(QOpenHDApp PRIVATE GLESv2 EGL)

add_compile_definitions(QOPENHD_ENABLE_VIDEO_VIA_AVCODEC)
1 change: 1 addition & 0 deletions app/videostreaming/gstreamer/gstrtpaudioplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void GstRtpAudioPlayer::start_playing()
qDebug() << "gst_parse_launch error: " << error->message;
//on_error("audio parse launch error");
on_error(error->message);
m_gst_pipeline = nullptr;
return;
}
if(!m_gst_pipeline || !(GST_IS_PIPELINE(m_gst_pipeline))){
Expand Down
10 changes: 10 additions & 0 deletions build_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

rm -rf build
mkdir build
cd build

QT6_DIRECTORY="$HOME/Qt/6.6.2/gcc_64/lib/cmake"

cmake -DCMAKE_PREFIX_PATH=$QT6_DIRECTORY ..
make -j$($(nproc))
5 changes: 5 additions & 0 deletions install_qt6_build_dep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

apt-get install -y build-essential cmake
apt-get install -y libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-good
apt-get install -y libavcodec-dev libavformat-dev
16 changes: 16 additions & 0 deletions lib/h264/h264.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set(H264_SOURCES
${CMAKE_CURRENT_LIST_DIR}/h264_bitstream_parser.cc
${CMAKE_CURRENT_LIST_DIR}/h264_common.cc
${CMAKE_CURRENT_LIST_DIR}/pps_parser.cc
${CMAKE_CURRENT_LIST_DIR}/sps_parser.cc
${CMAKE_CURRENT_LIST_DIR}/bit_buffer.cc
${CMAKE_CURRENT_LIST_DIR}/checks.cc
${CMAKE_CURRENT_LIST_DIR}/zero_memory.cc
)

target_sources(QOpenHDApp PRIVATE ${H264_SOURCES})

target_include_directories(QOpenHDApp
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
51 changes: 24 additions & 27 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ ApplicationWindow {
_qrenderstats.set_window_height(height)
}

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

//minimumWidth: 850
//minimumHeight: 480
Expand All @@ -52,6 +52,13 @@ ApplicationWindow {
// android / ios - specifc: We need to explicitly say full screen, otherwise things might be "cut off"
visibility: (settings.dev_force_show_full_screen || QOPENHD_IS_MOBILE) ? "FullScreen" : "AutomaticVisibility"

// Local app settings. Uses the "user defaults" system on Mac/iOS, the Registry on Windows,
// and equivalent settings systems on Linux and Android
// On linux, they generally are stored under /home/username/.config/Open.HD
// See https://doc.qt.io/qt-5/qsettings.html#platform-specific-notes for more info
AppSettings {
id: settings
}
// This only exists to be able to fully rotate "everything" for users that have their screen upside down for some reason.
// Won't affect the video, but heck, then just mount your camera upside down.
// TODO: the better fix really would be to somehow the the RPI HDMI config to rotate the screen in HW - but r.n there seems to be
Expand All @@ -63,17 +70,6 @@ ApplicationWindow {
width: (settings.general_screen_rotation == 90 || settings.general_screen_rotation == 270) ? parent.height : parent.width
height: (settings.general_screen_rotation == 90 || settings.general_screen_rotation == 270) ? parent.width : parent.height

// Local app settings. Uses the "user defaults" system on Mac/iOS, the Registry on Windows,
// and equivalent settings systems on Linux and Android
// On linux, they generally are stored under /home/username/.config/Open.HD
// See https://doc.qt.io/qt-5/qsettings.html#platform-specific-notes for more info
AppSettings {
id: settings
Component.onCompleted: {
//
}
}

// Loads the proper (platform-dependent) video widget for the main (primary) video
// primary video is always full-screen and behind the HUD OSD Elements
Loader {
Expand All @@ -98,17 +94,6 @@ ApplicationWindow {
}
}

// TODO QT 6
ColorPicker {
id: colorPicker
height: 264
width: 380
z: 15.0
anchors.centerIn: parent
}

// UI areas

HUDOverlayGrid {
id: hudOverlayGrid
anchors.fill: parent
Expand All @@ -121,16 +106,28 @@ ApplicationWindow {
layer.enabled: false
}


ConfigPopup {
id: settings_panel
visible: false
}

// TODO QT 6
ColorPicker {
id: colorPicker
height: 264
width: 380
z: 15.0
anchors.centerIn: parent
}
//ColorDialoque{
//}

WorkaroundMessageBox{
id: workaroundmessagebox
}

ErrorMessageBox{
id: errorMessageBox
}
CardToast{
id: card_toast
m_text: _qopenhd.toast_text
Expand All @@ -151,7 +148,7 @@ ApplicationWindow {
}
}
AnyParamBusyIndicator{
z: 10
z: 10
}

Component.onCompleted: {
Expand Down
2 changes: 2 additions & 0 deletions qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,7 @@
<file>ui/elements/NewSpinBox.qml</file>
<file>ui/elements/NewSlider.qml</file>
<file>ui/sidebar/InfoElement2.qml</file>
<file>ui/elements/ErrorMessageBox.qml</file>
<file>ui/elements/ColorDialoque.qml</file>
</qresource>
</RCC>
Loading

0 comments on commit dd34e48

Please sign in to comment.