QGCOptions.h 11 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 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
class QGCOptions;

class QGCFlyViewOptions : public QObject
{
    Q_OBJECT
public:
    QGCFlyViewOptions(QGCOptions* options, QObject* parent = nullptr);

    Q_PROPERTY(bool                     showMultiVehicleList            READ showMultiVehicleList           CONSTANT)
    Q_PROPERTY(bool                     showInstrumentPanel             READ showInstrumentPanel            CONSTANT)
    Q_PROPERTY(bool                     showMapScale                    READ showMapScale                   CONSTANT)
    Q_PROPERTY(bool                     guidedBarShowEmergencyStop      READ guidedBarShowEmergencyStop     NOTIFY guidedBarShowEmergencyStopChanged)
    Q_PROPERTY(bool                     guidedBarShowOrbit              READ guidedBarShowOrbit             NOTIFY guidedBarShowOrbitChanged)
    Q_PROPERTY(bool                     guidedBarShowROI                READ guidedBarShowROI               NOTIFY guidedBarShowROIChanged)

protected:
    virtual bool    showMultiVehicleList        () const { return true; }
    virtual bool    showMapScale                () const { return true; }
    virtual bool    showInstrumentPanel         () const { return true; }
    virtual bool    guidedBarShowEmergencyStop  () const { return true; }
    virtual bool    guidedBarShowOrbit          () const { return true; }
    virtual bool    guidedBarShowROI            () const { return true; }

    QGCOptions* _options;

signals:
    void guidedBarShowEmergencyStopChanged      (bool show);
    void guidedBarShowOrbitChanged              (bool show);
    void guidedBarShowROIChanged                (bool show);
};
47 48 49 50 51

class QGCOptions : public QObject
{
    Q_OBJECT
public:
52
    QGCOptions(QObject* parent = nullptr);
53

54 55 56
    Q_PROPERTY(bool                     combineSettingsAndSetup         READ combineSettingsAndSetup        CONSTANT)
    Q_PROPERTY(double                   toolbarHeightMultiplier         READ toolbarHeightMultiplier        CONSTANT)
    Q_PROPERTY(bool                     enablePlanViewSelector          READ enablePlanViewSelector         CONSTANT)
57
    Q_PROPERTY(QUrl                     preFlightChecklistUrl           READ preFlightChecklistUrl          CONSTANT)
58 59
    Q_PROPERTY(QColor                   toolbarBackgroundLight          READ toolbarBackgroundLight         CONSTANT)
    Q_PROPERTY(QColor                   toolbarBackgroundDark           READ toolbarBackgroundDark          CONSTANT)
60 61 62 63 64
    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)
65 66
    Q_PROPERTY(bool                     sensorsHaveFixedOrientation     READ sensorsHaveFixedOrientation    CONSTANT)
    Q_PROPERTY(bool                     wifiReliableForCalibration      READ wifiReliableForCalibration     CONSTANT)
67
    Q_PROPERTY(bool                     showFirmwareUpgrade             READ showFirmwareUpgrade            NOTIFY showFirmwareUpgradeChanged)
68
    Q_PROPERTY(QString                  firmwareUpgradeSingleURL        READ firmwareUpgradeSingleURL       CONSTANT)
69
    Q_PROPERTY(bool                     missionWaypointsOnly            READ missionWaypointsOnly           NOTIFY missionWaypointsOnlyChanged)
70
    Q_PROPERTY(bool                     multiVehicleEnabled             READ multiVehicleEnabled            NOTIFY multiVehicleEnabledChanged)
71 72
    Q_PROPERTY(bool                     showOfflineMapExport            READ showOfflineMapExport           NOTIFY showOfflineMapExportChanged)
    Q_PROPERTY(bool                     showOfflineMapImport            READ showOfflineMapImport           NOTIFY showOfflineMapImportChanged)
73
    Q_PROPERTY(bool                     useMobileFileDialog             READ useMobileFileDialog            CONSTANT)
74
    Q_PROPERTY(bool                     showMissionStatus               READ showMissionStatus              CONSTANT)
75
    Q_PROPERTY(bool                     guidedActionsRequireRCRSSI      READ guidedActionsRequireRCRSSI     CONSTANT)
76
    Q_PROPERTY(bool                     showMissionAbsoluteAltitude     READ showMissionAbsoluteAltitude    NOTIFY showMissionAbsoluteAltitudeChanged)
77
    Q_PROPERTY(bool                     showSimpleMissionStart          READ showSimpleMissionStart         NOTIFY showSimpleMissionStartChanged)
78
    Q_PROPERTY(bool                     disableVehicleConnection        READ disableVehicleConnection       CONSTANT)
79 80
    Q_PROPERTY(float                    devicePixelRatio                READ devicePixelRatio               NOTIFY devicePixelRatioChanged)
    Q_PROPERTY(float                    devicePixelDensity              READ devicePixelDensity             NOTIFY devicePixelDensityChanged)
81
    Q_PROPERTY(bool                     checkFirmwareVersion            READ checkFirmwareVersion           CONSTANT)
82
    Q_PROPERTY(bool                     showMavlinkLogOptions           READ showMavlinkLogOptions          CONSTANT)
83
    Q_PROPERTY(bool                     enableSaveMainWindowPosition    READ enableSaveMainWindowPosition   CONSTANT)
84
    Q_PROPERTY(QStringList              surveyBuiltInPresetNames        READ surveyBuiltInPresetNames       CONSTANT)
85

86 87
    Q_PROPERTY(QGCFlyViewOptions*       flyView                         READ flyViewOptions                 CONSTANT)

Don Gagne's avatar
Don Gagne committed
88 89
    /// 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.
90
    virtual bool        combineSettingsAndSetup     () { return false; }
Don Gagne's avatar
Don Gagne committed
91 92 93

    /// Main ToolBar Multiplier.
    /// @return Factor to use when computing toolbar height
94
    virtual double      toolbarHeightMultiplier     () { return 1.0; }
Don Gagne's avatar
Don Gagne committed
95 96 97

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

100 101
    /// Should the mission status indicator (Plan View) be shown?
    /// @return Yes or no
102
    virtual bool    showMissionStatus               () { return true; }
103

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

Gus Grubba's avatar
Gus Grubba committed
107
    /// Allows replacing the toolbar Light Theme color
108
    virtual QColor  toolbarBackgroundLight          () const;
Gus Grubba's avatar
Gus Grubba committed
109
    /// Allows replacing the toolbar Dark Theme color
110
    virtual QColor  toolbarBackgroundDark           () const;
111
    /// By returning false you can hide the following sensor calibration pages
112 113 114 115 116
    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; }
117 118
    virtual bool    wifiReliableForCalibration      () const { return false; }
    virtual bool    sensorsHaveFixedOrientation     () const { return false; }
119
    virtual bool    showFirmwareUpgrade             () 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
    /// Desktop builds save the main application size and position on close (and restore it on open)
    virtual bool    enableSaveMainWindowPosition    () const { return true; }
132
    virtual QStringList surveyBuiltInPresetNames    () const { return QStringList(); } // Built in presets cannot be deleted
133

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

140 141 142 143
    /// 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(); }
144

145 146 147 148
    /// 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; }

149 150
    virtual QGCFlyViewOptions* flyViewOptions       ();

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 missionWaypointsOnlyChanged            (bool missionWaypointsOnly);
159
    void multiVehicleEnabledChanged             (bool multiVehicleEnabled);
160 161
    void showOfflineMapExportChanged            ();
    void showOfflineMapImportChanged            ();
162
    void showMissionAbsoluteAltitudeChanged     ();
163
    void showSimpleMissionStartChanged          ();
164 165
    void devicePixelRatioChanged                ();
    void devicePixelDensityChanged              ();
166

167 168
protected:
    QGCFlyViewOptions* _defaultFlyViewOptions = nullptr;
169
};