QGCOptions.h 10.8 KB
Newer Older
1 2
/****************************************************************************
 *
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 60 61 62
    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)
63 64
    Q_PROPERTY(bool                     sensorsHaveFixedOrientation     READ sensorsHaveFixedOrientation    CONSTANT)
    Q_PROPERTY(bool                     wifiReliableForCalibration      READ wifiReliableForCalibration     CONSTANT)
65
    Q_PROPERTY(bool                     showFirmwareUpgrade             READ showFirmwareUpgrade            NOTIFY showFirmwareUpgradeChanged)
66
    Q_PROPERTY(QString                  firmwareUpgradeSingleURL        READ firmwareUpgradeSingleURL       CONSTANT)
67
    Q_PROPERTY(bool                     missionWaypointsOnly            READ missionWaypointsOnly           NOTIFY missionWaypointsOnlyChanged)
68
    Q_PROPERTY(bool                     multiVehicleEnabled             READ multiVehicleEnabled            NOTIFY multiVehicleEnabledChanged)
69 70
    Q_PROPERTY(bool                     showOfflineMapExport            READ showOfflineMapExport           NOTIFY showOfflineMapExportChanged)
    Q_PROPERTY(bool                     showOfflineMapImport            READ showOfflineMapImport           NOTIFY showOfflineMapImportChanged)
71
    Q_PROPERTY(bool                     useMobileFileDialog             READ useMobileFileDialog            CONSTANT)
72
    Q_PROPERTY(bool                     showMissionStatus               READ showMissionStatus              CONSTANT)
73
    Q_PROPERTY(bool                     guidedActionsRequireRCRSSI      READ guidedActionsRequireRCRSSI     CONSTANT)
74
    Q_PROPERTY(bool                     showMissionAbsoluteAltitude     READ showMissionAbsoluteAltitude    NOTIFY showMissionAbsoluteAltitudeChanged)
75
    Q_PROPERTY(bool                     showSimpleMissionStart          READ showSimpleMissionStart         NOTIFY showSimpleMissionStartChanged)
76
    Q_PROPERTY(bool                     disableVehicleConnection        READ disableVehicleConnection       CONSTANT)
77 78
    Q_PROPERTY(float                    devicePixelRatio                READ devicePixelRatio               NOTIFY devicePixelRatioChanged)
    Q_PROPERTY(float                    devicePixelDensity              READ devicePixelDensity             NOTIFY devicePixelDensityChanged)
79
    Q_PROPERTY(bool                     checkFirmwareVersion            READ checkFirmwareVersion           CONSTANT)
80
    Q_PROPERTY(bool                     showMavlinkLogOptions           READ showMavlinkLogOptions          CONSTANT)
81 82 83 84
    Q_PROPERTY(bool                     enableSaveMainWindowPosition    READ enableSaveMainWindowPosition   CONSTANT)
    Q_PROPERTY(QStringList              surveyBuiltInPresetNames        READ surveyBuiltInPresetNames       CONSTANT)

    Q_PROPERTY(QGCFlyViewOptions*       flyView                         READ flyViewOptions                 CONSTANT)
85

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

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

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

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

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

    /// Allows replacing the toolbar Light Theme color
    virtual QColor  toolbarBackgroundLight          () const;
    /// Allows replacing the toolbar Dark Theme color
    virtual QColor  toolbarBackgroundDark           () const;
109
    /// By returning false you can hide the following sensor calibration pages
110 111 112 113 114
    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; }
115 116
    virtual bool    wifiReliableForCalibration      () const { return false; }
    virtual bool    sensorsHaveFixedOrientation     () const { return false; }
117
    virtual bool    showFirmwareUpgrade             () const { return true; }
118
    virtual bool    missionWaypointsOnly            () const { return false; }  ///< true: Only allow waypoints and complex items in Plan
119
    virtual bool    multiVehicleEnabled             () const { return true; }   ///< false: multi vehicle support is disabled
120
    virtual bool    guidedActionsRequireRCRSSI      () const { return false; }  ///< true: Guided actions will be disabled is there is no RC RSSI
121 122
    virtual bool    showOfflineMapExport            () const { return true; }
    virtual bool    showOfflineMapImport            () const { return true; }
123
    virtual bool    showMissionAbsoluteAltitude     () const { return true; }
124
    virtual bool    showSimpleMissionStart          () const { return false; }
125
    virtual bool    disableVehicleConnection        () const { return false; }  ///< true: vehicle connection is disabled
126
    virtual bool    checkFirmwareVersion            () const { return true; }
127
    virtual bool    showMavlinkLogOptions           () const { return true; }
128 129 130
    /// Desktop builds save the main application size and position on close (and restore it on open)
    virtual bool    enableSaveMainWindowPosition    () const { return true; }
    virtual QStringList surveyBuiltInPresetNames    () const { return QStringList(); } // Built in presets cannot be deleted
131

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

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

143 144 145 146
    /// 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; }

147 148
    virtual QGCFlyViewOptions* flyViewOptions       ();

149 150 151 152 153 154
signals:
    void showSensorCalibrationCompassChanged    (bool show);
    void showSensorCalibrationGyroChanged       (bool show);
    void showSensorCalibrationAccelChanged      (bool show);
    void showSensorCalibrationLevelChanged      (bool show);
    void showSensorCalibrationAirspeedChanged   (bool show);
155
    void showFirmwareUpgradeChanged             (bool show);
156
    void missionWaypointsOnlyChanged            (bool missionWaypointsOnly);
157
    void multiVehicleEnabledChanged             (bool multiVehicleEnabled);
158 159
    void showOfflineMapExportChanged            ();
    void showOfflineMapImportChanged            ();
160
    void showMissionAbsoluteAltitudeChanged     ();
161
    void showSimpleMissionStartChanged          ();
162 163
    void devicePixelRatioChanged                ();
    void devicePixelDensityChanged              ();
164

165 166
protected:
    QGCFlyViewOptions* _defaultFlyViewOptions = nullptr;
167
};