Skip to content

Commit

Permalink
Merge branch 'master' into AndroidOverrides
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey authored Nov 29, 2024
2 parents 7861ae5 + 1de8d27 commit 8924771
Show file tree
Hide file tree
Showing 164 changed files with 1,405 additions and 1,414 deletions.
36 changes: 31 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ if(QGC_DISABLE_APM_MAVLINK)
add_compile_definitions(NO_ARDUPILOT_DIALECT)
endif()

if(QGC_VIEWER3D)
add_compile_definitions(QGC_VIEWER3D)
endif()

if("${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm64;x86_64" OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES "x86_64;arm64")
set(MACOS_UNIVERSAL_BUILD ON CACHE INTERNAL "" FORCE)
endif()
Expand All @@ -246,10 +250,6 @@ if(QGC_CUSTOM_BUILD)
add_subdirectory(custom)
endif()

if(QGC_DISABLE_APM_MAVLINK)
add_compile_definitions(NO_ARDUPILOT_DIALECT)
endif()

#######################################################
# QGroundControl Resources
#######################################################
Expand Down Expand Up @@ -416,12 +416,38 @@ elseif(ANDROID)
endif()
set(ANDROID_VERSION_CODE "${ANDROID_PLATFORM_ARCHITECTURE_CODE}${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}")

if(NOT QGC_CUSTOM_BUILD)
set(QGC_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/android)
else()
set(CUSTOM_ANDROID_DIR "${CMAKE_SOURCE_DIR}/custom/android")
if(EXISTS "${CUSTOM_ANDROID_DIR}")
file(GLOB CUSTOM_ANDROID_FILES "${CUSTOM_ANDROID_DIR}/*")
if(CUSTOM_ANDROID_FILES)
message(STATUS "Custom Android package template found. Overlaying custom files...")
set(DEFAULT_ANDROID_DIR "${CMAKE_SOURCE_DIR}/android")
set(FINAL_ANDROID_DIR "${CMAKE_BINARY_DIR}/custom/android")
file(COPY "${DEFAULT_ANDROID_DIR}/." DESTINATION "${FINAL_ANDROID_DIR}")
file(COPY "${CUSTOM_ANDROID_DIR}/." DESTINATION "${FINAL_ANDROID_DIR}")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${DEFAULT_ANDROID_DIR}/"
"${CUSTOM_ANDROID_DIR}/"
)
set(QGC_ANDROID_PACKAGE_SOURCE_DIR "${FINAL_ANDROID_DIR}" CACHE STRING "Path to a custom Android package template" FORCE)
message(STATUS "Android package template path will be set to: ${QGC_ANDROID_PACKAGE_SOURCE_DIR}")
else()
message(STATUS "Custom Android package template empty. Using default.")
endif()
else()
message(STATUS "No custom Android package template found. Using default.")
endif()
endif()

set_target_properties(${PROJECT_NAME}
PROPERTIES
# QT_ANDROID_ABIS ${ANDROID_ABI}
QT_ANDROID_MIN_SDK_VERSION ${QGC_QT_ANDROID_MIN_SDK_VERSION}
QT_ANDROID_TARGET_SDK_VERSION ${QGC_QT_ANDROID_TARGET_SDK_VERSION}
QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/android
QT_ANDROID_PACKAGE_SOURCE_DIR "${QGC_ANDROID_PACKAGE_SOURCE_DIR}"
QT_ANDROID_VERSION_NAME ${CMAKE_PROJECT_VERSION}
QT_ANDROID_VERSION_CODE ${ANDROID_VERSION_CODE}
# QT_QML_ROOT_PATH ${CMAKE_SOURCE_DIR}
Expand Down
1 change: 0 additions & 1 deletion custom-example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ target_link_libraries(CustomPlugin
PUBLIC
Qt6::Core
MAVLink
QGC
Settings
)

Expand Down
109 changes: 109 additions & 0 deletions custom-example/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mavlink.qgroundcontrol"
android:installLocation="auto"
android:versionCode="-- %%INSERT_VERSION_CODE%% --"
android:versionName="-- %%INSERT_VERSION_NAME%% --">

<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />

<!-- %%INSERT_PERMISSIONS -->

<uses-permission android:name="android.permission.USB_PERMISSION" />
<!-- Need MulticastLock to receive broadcast UDP packets -->
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<!-- Needed to keep working while 'asleep' -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- %%INSERT_FEATURES -->

<uses-feature android:name="android.hardware.audio.output" android:required="false" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.usb.host" android:required="false" />
<uses-feature android:name="android.hardware.wifi" android:required="false" />

<application
android:name="org.qtproject.qt.android.bindings.QtApplication"
android:hardwareAccelerated="true"
android:label="Custom QGroundControl"
android:requestLegacyExternalStorage="true"
android:allowBackup="true"
android:fullBackupOnly="false"
android:icon="@drawable/icon"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config">
<!-- android:theme="@style/AppTheme" -->

<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/" /> -->

<activity
android:name="org.mavlink.qgroundcontrol.QGCActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:label="Custom QGroundControl"
android:launchMode="singleTop"
android:screenOrientation="sensorLandscape"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
<!-- TODO: CMake configure xml file -->
<!-- %%QGC_INSERT_ACTIVITY_INTENT_FILTER -->
</intent-filter>

<!-- %%QGC_INSERT_ACTIVITY_META_DATA -->
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
android:resource="@xml/device_filter" />

<meta-data
android:name="android.app.lib_name"
android:value="-- %%INSERT_APP_LIB_NAME%% --" />
<meta-data
android:name="android.app.arguments"
android:value="-- %%INSERT_APP_ARGUMENTS%% --" />
<meta-data
android:name="android.app.extract_android_style"
android:value="minimal" />
<meta-data
android:name="android.app.splash_screen_drawable"
android:resource="@drawable/splashscreen" />
<!-- <meta-data android:name="android.app.splash_screen_drawable_portrait" -->
<!-- <meta-data android:name="android.app.splash_screen_drawable_landscape" -->
<meta-data
android:name="android.app.splash_screen_sticky"
android:value="false" />
<!-- <meta-data android:name="android.app.background_running" -->
<!-- <meta-data android:name="android.app.trace_location" -->
</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.qtprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/qtprovider_paths" />
</provider>

</application>

</manifest>
6 changes: 6 additions & 0 deletions custom-example/qgcimages.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<file alias="attitudePointer.svg">../src/FlightMap/Images/attitudePointer.svg</file>
<file alias="AwarenessAircraft.svg">../src/FlightMap/Images/AwarenessAircraft.svg</file>
<file alias="Battery.svg">../src/UI/toolbar/Images/Battery.svg</file>
<file alias="BatteryGreen.svg">../src/UI/toolbar/Images/BatteryGreen.svg</file>
<file alias="BatteryYellowGreen.svg">../src/UI/toolbar/Images/BatteryYellowGreen.svg</file>
<file alias="BatteryYellow.svg">../src/UI/toolbar/Images/BatteryYellow.svg</file>
<file alias="BatteryOrange.svg">../src/UI/toolbar/Images/BatteryOrange.svg</file>
<file alias="BatteryCritical.svg">../src/UI/toolbar/Images/BatteryCritical.svg</file>
<file alias="BatteryEMERGENCY.svg">../src/UI/toolbar/Images/BatteryEMERGENCY.svg</file>
<file alias="camera.svg">../resources/camera.svg</file>
<file alias="camera_photo.svg">../src/Camera/images/camera_photo.svg</file>
<file alias="camera_video.svg">../src/Camera/images/camera_video.svg</file>
Expand Down
2 changes: 1 addition & 1 deletion custom-example/qgcresources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<file alias="SplashScreen">../resources/SplashScreen.png</file>
<file alias="Stop">../resources/Stop.svg</file>
<file alias="takeoff.svg">../resources/takeoff.svg</file>
<file alias="terrain.svg">resources/terrain.svg</file>
<file alias="terrain.svg">../resources/terrain.svg</file>
<file alias="TrashDelete.svg">../resources/TrashDelete.svg</file>
<file alias="waves.svg">../resources/waves.svg</file>
<file alias="wind-guru.svg">../resources/wind-guru.svg</file>
Expand Down
6 changes: 4 additions & 2 deletions custom-example/qgroundcontrol.qrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<RCC>
<qresource prefix="/toolbar">
<file alias="ArmedIndicator.qml">../src/UI/toolbar/ArmedIndicator.qml</file>
<file alias="GPSIndicator.qml">../src/UI/toolbar/GPSIndicator.qml</file>
<file alias="GPSRTKIndicator.qml">../src/UI/toolbar/GPSRTKIndicator.qml</file>
<file alias="RTKGPSIndicator.qml">../src/UI/toolbar/RTKGPSIndicator.qml</file>
<file alias="VehicleGPSIndicator.qml">../src/UI/toolbar/VehicleGPSIndicator.qml</file>
<file alias="JoystickIndicator.qml">../src/UI/toolbar/JoystickIndicator.qml</file>
<file alias="LinkIndicator.qml">../src/UI/toolbar/LinkIndicator.qml</file>
<file alias="MessageIndicator.qml">../src/UI/toolbar/MessageIndicator.qml</file>
Expand Down Expand Up @@ -103,6 +103,7 @@
<file alias="QGroundControl/Controls/FlightModeDropdown.qml">../src/QmlControls/FlightModeDropdown.qml</file>
<file alias="QGroundControl/Controls/FlightModeMenu.qml">../src/QmlControls/FlightModeMenu.qml</file>
<file alias="QGroundControl/Controls/FWLandingPatternMapVisual.qml">../src/PlanView/FWLandingPatternMapVisual.qml</file>
<file alias="QGroundControl/Controls/GPSIndicator.qml">../src/UI/toolbar/GPSIndicator.qml</file>
<file alias="QGroundControl/Controls/GPSIndicatorPage.qml">../src/UI/toolbar/GPSIndicatorPage.qml</file>
<file alias="QGroundControl/Controls/GeoFenceEditor.qml">../src/PlanView/GeoFenceEditor.qml</file>
<file alias="QGroundControl/Controls/GeoFenceMapVisuals.qml">../src/PlanView/GeoFenceMapVisuals.qml</file>
Expand Down Expand Up @@ -418,6 +419,7 @@
<file alias="VTOLLandingPattern.FactMetaData.json">../src/MissionManager/VTOLLandingPattern.FactMetaData.json</file>
<file alias="Viewer3D.SettingsGroup.json">../src/Settings/Viewer3D.SettingsGroup.json</file>
<file alias="GimbalController.SettingsGroup.json">../src/Settings/GimbalController.SettingsGroup.json</file>
<file alias="CameraMetaData.json">../src/Camera/CameraMetaData.json</file>
</qresource>
<qresource prefix="/MockLink">
<file alias="APMArduSubMockLink.params">../src/Comms/MockLink/APMArduSubMockLink.params</file>
Expand Down
5 changes: 2 additions & 3 deletions custom-example/src/AutoPilotPlugin/CustomAutoPilotPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@

#include "CustomAutoPilotPlugin.h"
#include "ParameterManager.h"
#include "QGCApplication.h"
#include "QGCCorePlugin.h"
#include "Vehicle.h"

CustomAutoPilotPlugin::CustomAutoPilotPlugin(Vehicle* vehicle, QObject* parent)
: PX4AutoPilotPlugin(vehicle, parent)
{
// Whenever we go on/out of advanced mode the available list of settings pages will change
connect(qgcApp()->toolbox()->corePlugin(), &QGCCorePlugin::showAdvancedUIChanged, this, &CustomAutoPilotPlugin::_advancedChanged);
connect(QGCCorePlugin::instance(), &QGCCorePlugin::showAdvancedUIChanged, this, &CustomAutoPilotPlugin::_advancedChanged);
}

// This signals that when Advanced Mode changes the list of Vehicle Settings page also changed
Expand All @@ -35,7 +34,7 @@ const QVariantList& CustomAutoPilotPlugin::vehicleComponents()
{
if (_components.count() == 0 && !_incorrectParameterVersion) {
if (_vehicle) {
bool showAdvanced = qgcApp()->toolbox()->corePlugin()->showAdvancedUI();
bool showAdvanced = QGCCorePlugin::instance()->showAdvancedUI();
if (_vehicle->parameterManager()->parametersReady()) {
if (showAdvanced) {
_airframeComponent = new AirframeComponent(_vehicle, this);
Expand Down
30 changes: 17 additions & 13 deletions custom-example/src/CustomPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@
*/

#include "CustomPlugin.h"
#include "QGCApplication.h"
#include "QmlComponentInfo.h"
#include "QGCPalette.h"
#include "QGCMAVLink.h"
#include "AppSettings.h"
#include "BrandImageSettings.h"

#include <QtCore/qapplicationstatic.h>
#include <QtQml/QQmlApplicationEngine>

QGC_LOGGING_CATEGORY(CustomLog, "gcs.custom.customplugin")

Q_APPLICATION_STATIC(CustomPlugin, _customPluginInstance);

CustomFlyViewOptions::CustomFlyViewOptions(CustomOptions* options, QObject* parent)
: QGCFlyViewOptions(options, parent)
{
Expand All @@ -37,9 +41,11 @@ bool CustomFlyViewOptions::showInstrumentPanel(void) const
return false;
}

CustomOptions::CustomOptions(CustomPlugin*, QObject* parent)
CustomOptions::CustomOptions(CustomPlugin *plugin, QObject *parent)
: QGCOptions(parent)
, _plugin(plugin)
{
Q_CHECK_PTR(_plugin);
}

QGCFlyViewOptions* CustomOptions::flyViewOptions(void)
Expand All @@ -53,7 +59,7 @@ QGCFlyViewOptions* CustomOptions::flyViewOptions(void)
// Firmware upgrade page is only shown in Advanced Mode.
bool CustomOptions::showFirmwareUpgrade() const
{
return qgcApp()->toolbox()->corePlugin()->showAdvancedUI();
return _plugin->showAdvancedUI();
}

// Normal QGC needs to work with an ESP8266 WiFi thing which is remarkably crappy. This in turns causes PX4 Pro calibration to fail
Expand All @@ -64,23 +70,21 @@ bool CustomOptions::wifiReliableForCalibration(void) const
return true;
}

CustomPlugin::CustomPlugin(QGCApplication *app, QGCToolbox* toolbox)
: QGCCorePlugin(app, toolbox)
CustomPlugin::CustomPlugin(QObject *parent)
: QGCCorePlugin(parent)
, _options(new CustomOptions(this, this))
{
_options = new CustomOptions(this, this);
_showAdvancedUI = false;
connect(this, &QGCCorePlugin::showAdvancedUIChanged, this, &CustomPlugin::_advancedChanged);
}

CustomPlugin::~CustomPlugin()
{
}

void CustomPlugin::setToolbox(QGCToolbox* toolbox)
QGCCorePlugin *CustomPlugin::instance()
{
QGCCorePlugin::setToolbox(toolbox);

// Allows us to be notified when the user goes in/out out advanced mode
connect(qgcApp()->toolbox()->corePlugin(), &QGCCorePlugin::showAdvancedUIChanged, this, &CustomPlugin::_advancedChanged);
return _customPluginInstance();
}

void CustomPlugin::_advancedChanged(bool changed)
Expand Down Expand Up @@ -116,7 +120,7 @@ QString CustomPlugin::brandImageOutdoor(void) const
return QStringLiteral("/custom/img/dronecode-black.svg");
}

bool CustomPlugin::overrideSettingsGroupVisibility(QString name)
bool CustomPlugin::overrideSettingsGroupVisibility(const QString &name)
{
// We have set up our own specific brand imaging. Hide the brand image settings such that the end user
// can't change it.
Expand Down Expand Up @@ -147,7 +151,7 @@ bool CustomPlugin::adjustSettingMetaData(const QString& settingsGroup, FactMetaD
}

// This modifies QGC colors palette to match possible custom corporate branding
void CustomPlugin::paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo)
void CustomPlugin::paletteOverride(const QString &colorName, QGCPalette::PaletteColorInfo_t& colorInfo)
{
if (colorName == QStringLiteral("window")) {
colorInfo[QGCPalette::Dark][QGCPalette::ColorGroupEnabled] = QColor("#212529");
Expand Down
18 changes: 9 additions & 9 deletions custom-example/src/CustomPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "QGCCorePlugin.h"
#include "QGCOptions.h"
#include <QGCLoggingCategory.h>
#include "QGCLoggingCategory.h"

class CustomOptions;
class CustomPlugin;
Expand All @@ -37,36 +37,36 @@ class CustomFlyViewOptions : public QGCFlyViewOptions
class CustomOptions : public QGCOptions
{
public:
CustomOptions(CustomPlugin*, QObject* parent = nullptr);
CustomOptions(CustomPlugin *plugin, QObject* parent = nullptr);

// Overrides from QGCOptions
bool wifiReliableForCalibration (void) const final;
bool showFirmwareUpgrade (void) const final;
QGCFlyViewOptions* flyViewOptions(void) final;

private:
CustomFlyViewOptions* _flyViewOptions = nullptr;
QGCCorePlugin *_plugin = nullptr;
CustomFlyViewOptions *_flyViewOptions = nullptr;
};

class CustomPlugin : public QGCCorePlugin
{
Q_OBJECT
public:
CustomPlugin(QGCApplication* app, QGCToolbox *toolbox);
CustomPlugin(QObject *parent = nullptr);
~CustomPlugin();

static QGCCorePlugin *instance();

// Overrides from QGCCorePlugin
QGCOptions* options (void) final;
QString brandImageIndoor (void) const final;
QString brandImageOutdoor (void) const final;
bool overrideSettingsGroupVisibility (QString name) final;
bool overrideSettingsGroupVisibility (const QString &name) final;
bool adjustSettingMetaData (const QString& settingsGroup, FactMetaData& metaData) final;
void paletteOverride (QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo) final;
void paletteOverride (const QString &colorName, QGCPalette::PaletteColorInfo_t& colorInfo) final;
QQmlApplicationEngine* createQmlApplicationEngine (QObject* parent) final;

// Overrides from QGCTool
void setToolbox (QGCToolbox* toolbox);

private slots:
void _advancedChanged(bool advanced);

Expand Down
Loading

0 comments on commit 8924771

Please sign in to comment.