QGCOptions.h 12.6 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9 10 11 12 13
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#pragma once

#include <QObject>
#include <QString>
14
#include <QUrl>
15
#include <QColor>
16 17

/// @file
Gus Grubba's avatar
Gus Grubba committed
18 19
/// @brief Core Plugin Interface for QGroundControl - Application Options
/// @author Gus Grubba <gus@auterion.com>
20

21
class CustomInstrumentWidget;
22 23 24 25
class QGCOptions : public QObject
{
    Q_OBJECT
public:
26
    QGCOptions(QObject* parent = nullptr);
27

28 29 30 31
    Q_PROPERTY(bool                     combineSettingsAndSetup         READ combineSettingsAndSetup        CONSTANT)
    Q_PROPERTY(double                   toolbarHeightMultiplier         READ toolbarHeightMultiplier        CONSTANT)
    Q_PROPERTY(bool                     enablePlanViewSelector          READ enablePlanViewSelector         CONSTANT)
    Q_PROPERTY(CustomInstrumentWidget*  instrumentWidget                READ instrumentWidget               CONSTANT)
32
    Q_PROPERTY(QUrl                     flyViewOverlay                  READ flyViewOverlay                 CONSTANT)
33
    Q_PROPERTY(QUrl                     preFlightChecklistUrl           READ preFlightChecklistUrl          CONSTANT)
34 35 36 37 38 39

    Q_PROPERTY(QUrl                     mainToolbarUrl                  READ mainToolbarUrl                 CONSTANT)
    Q_PROPERTY(QUrl                     planToolbarUrl                  READ planToolbarUrl                 CONSTANT)
    Q_PROPERTY(QColor                   toolbarBackgroundLight          READ toolbarBackgroundLight         CONSTANT)
    Q_PROPERTY(QColor                   toolbarBackgroundDark           READ toolbarBackgroundDark          CONSTANT)

Gus Grubba's avatar
Gus Grubba committed
40
    Q_PROPERTY(QUrl                     planToolbarIndicatorsUrl        READ planToolbarIndicatorsUrl       CONSTANT)
41 42 43 44 45
    Q_PROPERTY(bool                     showSensorCalibrationCompass    READ showSensorCalibrationCompass   NOTIFY showSensorCalibrationCompassChanged)
    Q_PROPERTY(bool                     showSensorCalibrationGyro       READ showSensorCalibrationGyro      NOTIFY showSensorCalibrationGyroChanged)
    Q_PROPERTY(bool                     showSensorCalibrationAccel      READ showSensorCalibrationAccel     NOTIFY showSensorCalibrationAccelChanged)
    Q_PROPERTY(bool                     showSensorCalibrationLevel      READ showSensorCalibrationLevel     NOTIFY showSensorCalibrationLevelChanged)
    Q_PROPERTY(bool                     showSensorCalibrationAirspeed   READ showSensorCalibrationAirspeed  NOTIFY showSensorCalibrationAirspeedChanged)
46 47
    Q_PROPERTY(bool                     sensorsHaveFixedOrientation     READ sensorsHaveFixedOrientation    CONSTANT)
    Q_PROPERTY(bool                     wifiReliableForCalibration      READ wifiReliableForCalibration     CONSTANT)
48
    Q_PROPERTY(bool                     showFirmwareUpgrade             READ showFirmwareUpgrade            NOTIFY showFirmwareUpgradeChanged)
49
    Q_PROPERTY(QString                  firmwareUpgradeSingleURL        READ firmwareUpgradeSingleURL       CONSTANT)
50 51
    Q_PROPERTY(bool                     guidedBarShowEmergencyStop      READ guidedBarShowEmergencyStop     NOTIFY guidedBarShowEmergencyStopChanged)
    Q_PROPERTY(bool                     guidedBarShowOrbit              READ guidedBarShowOrbit             NOTIFY guidedBarShowOrbitChanged)
Gus Grubba's avatar
Gus Grubba committed
52
    Q_PROPERTY(bool                     guidedBarShowROI                READ guidedBarShowROI               NOTIFY guidedBarShowROIChanged)
53
    Q_PROPERTY(bool                     missionWaypointsOnly            READ missionWaypointsOnly           NOTIFY missionWaypointsOnlyChanged)
54
    Q_PROPERTY(bool                     multiVehicleEnabled             READ multiVehicleEnabled            NOTIFY multiVehicleEnabledChanged)
55 56
    Q_PROPERTY(bool                     showOfflineMapExport            READ showOfflineMapExport           NOTIFY showOfflineMapExportChanged)
    Q_PROPERTY(bool                     showOfflineMapImport            READ showOfflineMapImport           NOTIFY showOfflineMapImportChanged)
57
    Q_PROPERTY(bool                     useMobileFileDialog             READ useMobileFileDialog            CONSTANT)
58
    Q_PROPERTY(bool                     showMissionStatus               READ showMissionStatus              CONSTANT)
59
    Q_PROPERTY(bool                     guidedActionsRequireRCRSSI      READ guidedActionsRequireRCRSSI     CONSTANT)
60
    Q_PROPERTY(bool                     showMissionAbsoluteAltitude     READ showMissionAbsoluteAltitude    NOTIFY showMissionAbsoluteAltitudeChanged)
61
    Q_PROPERTY(bool                     showSimpleMissionStart          READ showSimpleMissionStart         NOTIFY showSimpleMissionStartChanged)
62
    Q_PROPERTY(bool                     disableVehicleConnection        READ disableVehicleConnection       CONSTANT)
63 64
    Q_PROPERTY(float                    devicePixelRatio                READ devicePixelRatio               NOTIFY devicePixelRatioChanged)
    Q_PROPERTY(float                    devicePixelDensity              READ devicePixelDensity             NOTIFY devicePixelDensityChanged)
65
    Q_PROPERTY(bool                     checkFirmwareVersion            READ checkFirmwareVersion           CONSTANT)
66
    Q_PROPERTY(bool                     showMavlinkLogOptions           READ showMavlinkLogOptions          CONSTANT)
67
    Q_PROPERTY(bool                     enableMultiVehicleList          READ enableMultiVehicleList         CONSTANT)
68
    Q_PROPERTY(bool                     enableMapScale                  READ enableMapScale                 CONSTANT)
69
    Q_PROPERTY(bool                     enableSaveMainWindowPosition    READ enableSaveMainWindowPosition   CONSTANT)
70
    Q_PROPERTY(QStringList              surveyBuiltInPresetNames        READ surveyBuiltInPresetNames       CONSTANT)
71

Don Gagne's avatar
Don Gagne committed
72 73
    /// Should QGC hide its settings menu and colapse it into one single menu (Settings and Vehicle Setup)?
    /// @return true if QGC should consolidate both menus into one.
74
    virtual bool        combineSettingsAndSetup     () { return false; }
Don Gagne's avatar
Don Gagne committed
75 76 77

    /// Main ToolBar Multiplier.
    /// @return Factor to use when computing toolbar height
78
    virtual double      toolbarHeightMultiplier     () { return 1.0; }
Don Gagne's avatar
Don Gagne committed
79 80 81

    /// Enable Plan View Selector (Mission, Fence or Rally)
    /// @return True or false
82
    virtual bool        enablePlanViewSelector      () { return true; }
Don Gagne's avatar
Don Gagne committed
83 84 85

    /// Provides an alternate instrument widget for the Fly View
    /// @return An alternate widget (see QGCInstrumentWidget.qml, the default widget)
86
    virtual CustomInstrumentWidget* instrumentWidget();
Don Gagne's avatar
Don Gagne committed
87

88 89
    /// Should the mission status indicator (Plan View) be shown?
    /// @return Yes or no
90
    virtual bool    showMissionStatus               () { return true; }
91

92 93
    /// Allows access to the full fly view window
    virtual QUrl    flyViewOverlay                  () const { return QUrl(); }
94

95 96
    /// Provides an optional, custom preflight checklist
    virtual QUrl    preFlightChecklistUrl           () const { return QUrl::fromUserInput("qrc:/qml/PreFlightCheckList.qml"); }
97

Gus Grubba's avatar
Gus Grubba committed
98
    /// Allows replacing the Main toolbar
99
    virtual QUrl    mainToolbarUrl                  () const;
Gus Grubba's avatar
Gus Grubba committed
100
    /// Allows replacing the Plan View toolbar
101
    virtual QUrl    planToolbarUrl                  () const;
Gus Grubba's avatar
Gus Grubba committed
102
    /// Allows replacing the toolbar Light Theme color
103
    virtual QColor  toolbarBackgroundLight          () const;
Gus Grubba's avatar
Gus Grubba committed
104
    /// Allows replacing the toolbar Dark Theme color
105
    virtual QColor  toolbarBackgroundDark           () const;
Gus Grubba's avatar
Gus Grubba committed
106 107
    /// Allows replacing the Plan View toolbar container
    virtual QUrl    planToolbarIndicatorsUrl        () const;
108
    /// By returning false you can hide the following sensor calibration pages
109 110 111 112 113
    virtual bool    showSensorCalibrationCompass    () const { return true; }
    virtual bool    showSensorCalibrationGyro       () const { return true; }
    virtual bool    showSensorCalibrationAccel      () const { return true; }
    virtual bool    showSensorCalibrationLevel      () const { return true; }
    virtual bool    showSensorCalibrationAirspeed   () const { return true; }
114 115
    virtual bool    wifiReliableForCalibration      () const { return false; }
    virtual bool    sensorsHaveFixedOrientation     () const { return false; }
116
    virtual bool    showFirmwareUpgrade             () const { return true; }
117 118
    virtual bool    guidedBarShowEmergencyStop      () const { return true; }
    virtual bool    guidedBarShowOrbit              () const { return true; }
Gus Grubba's avatar
Gus Grubba committed
119
    virtual bool    guidedBarShowROI                () const { return true; }
120
    virtual bool    missionWaypointsOnly            () const { return false; }  ///< true: Only allow waypoints and complex items in Plan
121
    virtual bool    multiVehicleEnabled             () const { return true; }   ///< false: multi vehicle support is disabled
122
    virtual bool    guidedActionsRequireRCRSSI      () const { return false; }  ///< true: Guided actions will be disabled is there is no RC RSSI
123 124
    virtual bool    showOfflineMapExport            () const { return true; }
    virtual bool    showOfflineMapImport            () const { return true; }
125
    virtual bool    showMissionAbsoluteAltitude     () const { return true; }
126
    virtual bool    showSimpleMissionStart          () const { return false; }
127
    virtual bool    disableVehicleConnection        () const { return false; }  ///< true: vehicle connection is disabled
128
    virtual bool    checkFirmwareVersion            () const { return true; }
129
    virtual bool    showMavlinkLogOptions           () const { return true; }
130 131
    virtual bool    enableMultiVehicleList          () const { return true; }
    virtual bool    enableMapScale                  () const { return true; }
132 133
    /// Desktop builds save the main application size and position on close (and restore it on open)
    virtual bool    enableSaveMainWindowPosition    () const { return true; }
134
    virtual QStringList surveyBuiltInPresetNames    () const { return QStringList(); } // Built in presets cannot be deleted
135

136
#if defined(__mobile__)
137
    virtual bool    useMobileFileDialog             () const { return true;}
138
#else
139
    virtual bool    useMobileFileDialog             () const { return false;}
140 141
#endif

142 143 144 145
    /// If returned QString in non-empty it means that firmware upgrade will run in a mode which only
    /// supports downloading a single firmware file from the URL. It also supports custom install through
    /// the Advanced options.
    virtual QString firmwareUpgradeSingleURL        () const { return QString(); }
146

147 148 149 150
    /// Device specific pixel ratio/density (for when Qt doesn't properly read it from the hardware)
    virtual float   devicePixelRatio                () const { return 0.0f; }
    virtual float   devicePixelDensity              () const { return 0.0f; }

151 152 153 154 155 156
signals:
    void showSensorCalibrationCompassChanged    (bool show);
    void showSensorCalibrationGyroChanged       (bool show);
    void showSensorCalibrationAccelChanged      (bool show);
    void showSensorCalibrationLevelChanged      (bool show);
    void showSensorCalibrationAirspeedChanged   (bool show);
157
    void showFirmwareUpgradeChanged             (bool show);
158
    void guidedBarShowEmergencyStopChanged      (bool show);
159
    void guidedBarShowOrbitChanged              (bool show);
Gus Grubba's avatar
Gus Grubba committed
160
    void guidedBarShowROIChanged                (bool show);
161
    void missionWaypointsOnlyChanged            (bool missionWaypointsOnly);
162
    void multiVehicleEnabledChanged             (bool multiVehicleEnabled);
163 164
    void showOfflineMapExportChanged            ();
    void showOfflineMapImportChanged            ();
165
    void showMissionAbsoluteAltitudeChanged     ();
166
    void showSimpleMissionStartChanged          ();
167 168
    void devicePixelRatioChanged                ();
    void devicePixelDensityChanged              ();
169

170 171 172 173 174 175 176 177 178 179 180
private:
    CustomInstrumentWidget* _defaultInstrumentWidget;
};

//-----------------------------------------------------------------------------
class CustomInstrumentWidget : public QObject
{
    Q_OBJECT
public:
    //-- Widget Position
    enum Pos {
Gus Grubba's avatar
Gus Grubba committed
181 182 183 184 185 186
        POS_TOP_RIGHT,
        POS_CENTER_RIGHT,
        POS_BOTTOM_RIGHT,
        POS_TOP_LEFT,
        POS_CENTER_LEFT,
        POS_BOTTOM_LEFT
187
    };
188
    Q_ENUM(Pos)
189
    CustomInstrumentWidget(QObject* parent = nullptr);
190 191 192
    Q_PROPERTY(QUrl     source  READ source CONSTANT)
    Q_PROPERTY(Pos      widgetPosition              READ widgetPosition             NOTIFY widgetPositionChanged)
    virtual QUrl        source                      () { return QUrl(); }
Gus Grubba's avatar
Gus Grubba committed
193
    virtual Pos         widgetPosition              () { return POS_TOP_RIGHT; }
194 195
signals:
    void widgetPositionChanged  ();
196
};