QGroundControlQmlGlobal.h 8.8 KB
Newer Older
1
/*=====================================================================
Gus Grubba's avatar
Gus Grubba committed
2

3
 QGroundControl Open Source Ground Control Station
Gus Grubba's avatar
Gus Grubba committed
4

5
 (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
Gus Grubba's avatar
Gus Grubba committed
6

7
 This file is part of the QGROUNDCONTROL project
Gus Grubba's avatar
Gus Grubba committed
8

9 10 11 12
 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
Gus Grubba's avatar
Gus Grubba committed
13

14 15 16 17
 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
Gus Grubba's avatar
Gus Grubba committed
18

19 20
 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
Gus Grubba's avatar
Gus Grubba committed
21

22 23 24 25 26 27 28 29
 ======================================================================*/

/// @file
///     @author Don Gagne <don@thegagnes.com>

#ifndef QGroundControlQmlGlobal_H
#define QGroundControlQmlGlobal_H

30
#include "QGCToolbox.h"
dogmaphobic's avatar
dogmaphobic committed
31
#include "QGCApplication.h"
Don Gagne's avatar
Don Gagne committed
32
#include "LinkManager.h"
33
#include "HomePositionManager.h"
34
#include "FlightMapSettings.h"
Don Gagne's avatar
Don Gagne committed
35
#include "MissionCommands.h"
36
#include "SettingsFact.h"
37

38 39 40 41
#ifdef QT_DEBUG
#include "MockLink.h"
#endif

42 43
class QGCToolbox;

44
class QGroundControlQmlGlobal : public QGCTool
45 46 47 48
{
    Q_OBJECT

public:
49 50 51
    QGroundControlQmlGlobal(QGCApplication* app);
    ~QGroundControlQmlGlobal();

Gus Grubba's avatar
Gus Grubba committed
52

Don Gagne's avatar
Don Gagne committed
53 54
    Q_PROPERTY(FlightMapSettings*   flightMapSettings   READ flightMapSettings      CONSTANT)
    Q_PROPERTY(HomePositionManager* homePositionManager READ homePositionManager    CONSTANT)
Don Gagne's avatar
Don Gagne committed
55
    Q_PROPERTY(LinkManager*         linkManager         READ linkManager            CONSTANT)
Don Gagne's avatar
Don Gagne committed
56
    Q_PROPERTY(MissionCommands*     missionCommands     READ missionCommands        CONSTANT)
Don Gagne's avatar
Don Gagne committed
57
    Q_PROPERTY(MultiVehicleManager* multiVehicleManager READ multiVehicleManager    CONSTANT)
dogmaphobic's avatar
dogmaphobic committed
58
    Q_PROPERTY(QGCMapEngineManager*  mapEngineManager  READ mapEngineManager     CONSTANT)
Gus Grubba's avatar
Gus Grubba committed
59 60 61 62 63

    Q_PROPERTY(qreal                zOrderTopMost       READ zOrderTopMost          CONSTANT) ///< z order for top most items, toolbar, main window sub view
    Q_PROPERTY(qreal                zOrderWidgets       READ zOrderWidgets          CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss
    Q_PROPERTY(qreal                zOrderMapItems      READ zOrderMapItems         CONSTANT) ///< z order value for map items, for example: mission item indicators

64 65 66 67 68 69
    // Various QGC settings exposed to Qml
    Q_PROPERTY(bool     isAdvancedMode          READ isAdvancedMode                                                 CONSTANT)                               ///< Global "Advance Mode" preference. Certain UI elements and features are different based on this.
    Q_PROPERTY(bool     isDarkStyle             READ isDarkStyle                WRITE setIsDarkStyle                NOTIFY isDarkStyleChanged)              // TODO: Should be in ScreenTools?
    Q_PROPERTY(bool     isAudioMuted            READ isAudioMuted               WRITE setIsAudioMuted               NOTIFY isAudioMutedChanged)
    Q_PROPERTY(bool     isSaveLogPrompt         READ isSaveLogPrompt            WRITE setIsSaveLogPrompt            NOTIFY isSaveLogPromptChanged)
    Q_PROPERTY(bool     isSaveLogPromptNotArmed READ isSaveLogPromptNotArmed    WRITE setIsSaveLogPromptNotArmed    NOTIFY isSaveLogPromptNotArmedChanged)
70 71 72
    Q_PROPERTY(bool     virtualTabletJoystick   READ virtualTabletJoystick      WRITE setVirtualTabletJoystick      NOTIFY virtualTabletJoystickChanged)

    // MavLink Protocol
73 74
    Q_PROPERTY(bool     isMultiplexingEnabled   READ isMultiplexingEnabled      WRITE setIsMultiplexingEnabled      NOTIFY isMultiplexingEnabledChanged)
    Q_PROPERTY(bool     isVersionCheckEnabled   READ isVersionCheckEnabled      WRITE setIsVersionCheckEnabled      NOTIFY isVersionCheckEnabledChanged)
75
    Q_PROPERTY(int      mavlinkSystemID         READ mavlinkSystemID            WRITE setMavlinkSystemID            NOTIFY mavlinkSystemIDChanged)
dogmaphobic's avatar
dogmaphobic committed
76

77 78
    Q_PROPERTY(Fact*    offlineEditingFirmwareType READ offlineEditingFirmwareType CONSTANT)

79
    Q_PROPERTY(QGeoCoordinate lastKnownHomePosition READ lastKnownHomePosition CONSTANT)
80
    Q_PROPERTY(QGeoCoordinate flightMapPosition MEMBER _flightMapPosition NOTIFY flightMapPositionChanged)
Don Gagne's avatar
Don Gagne committed
81

82 83 84
    /// @ return: true: experimental survey ip code is turned on
    Q_PROPERTY(bool experimentalSurvey READ experimentalSurvey WRITE setExperimentalSurvey NOTIFY experimentalSurveyChanged)

85 86 87 88 89
    Q_INVOKABLE void    saveGlobalSetting       (const QString& key, const QString& value);
    Q_INVOKABLE QString loadGlobalSetting       (const QString& key, const QString& defaultValue);
    Q_INVOKABLE void    saveBoolGlobalSetting   (const QString& key, bool value);
    Q_INVOKABLE bool    loadBoolGlobalSetting   (const QString& key, bool defaultValue);

90 91
    Q_INVOKABLE void    deleteAllSettingsNextBoot       () { _app->deleteAllSettingsNextBoot(); }
    Q_INVOKABLE void    clearDeleteAllSettingsNextBoot  () { _app->clearDeleteAllSettingsNextBoot(); }
92

93 94 95 96 97 98
    Q_INVOKABLE void    startPX4MockLink            (bool sendStatusText);
    Q_INVOKABLE void    startGenericMockLink        (bool sendStatusText);
    Q_INVOKABLE void    startAPMArduCopterMockLink  (bool sendStatusText);
    Q_INVOKABLE void    startAPMArduPlaneMockLink   (bool sendStatusText);
    Q_INVOKABLE void    stopAllMockLinks            (void);

99
    // Property accesors
Gus Grubba's avatar
Gus Grubba committed
100

Don Gagne's avatar
Don Gagne committed
101 102
    FlightMapSettings*      flightMapSettings   ()      { return _flightMapSettings; }
    HomePositionManager*    homePositionManager ()      { return _homePositionManager; }
dogmaphobic's avatar
dogmaphobic committed
103 104
    LinkManager*            linkManager         ()      { return _linkManager; }
    MissionCommands*        missionCommands     ()      { return _missionCommands; }
Don Gagne's avatar
Don Gagne committed
105
    MultiVehicleManager*    multiVehicleManager ()      { return _multiVehicleManager; }
dogmaphobic's avatar
dogmaphobic committed
106
    QGCMapEngineManager*     mapEngineManager  ()      { return _mapEngineManager; }
Gus Grubba's avatar
Gus Grubba committed
107 108 109 110 111

    qreal                   zOrderTopMost       ()      { return 1000; }
    qreal                   zOrderWidgets       ()      { return 100; }
    qreal                   zOrderMapItems      ()      { return 50; }

112 113 114 115
    bool    isDarkStyle             () { return _app->styleIsDark(); }
    bool    isAudioMuted            () { return _toolbox->audioOutput()->isMuted(); }
    bool    isSaveLogPrompt         () { return _app->promptFlightDataSave(); }
    bool    isSaveLogPromptNotArmed () { return _app->promptFlightDataSaveNotArmed(); }
116 117
    bool    virtualTabletJoystick   () { return _virtualTabletJoystick; }

118 119 120 121
    bool    isMultiplexingEnabled   () { return _toolbox->mavlinkProtocol()->multiplexingEnabled(); }
    bool    isVersionCheckEnabled   () { return _toolbox->mavlinkProtocol()->versionCheckEnabled(); }
    int     mavlinkSystemID         () { return _toolbox->mavlinkProtocol()->getSystemId(); }

122
    QGeoCoordinate lastKnownHomePosition() { return qgcApp()->lastKnownHomePosition(); }
Don Gagne's avatar
Don Gagne committed
123

124
    Fact*   offlineEditingFirmwareType () { return &_offlineEditingFirmwareTypeFact; }
dogmaphobic's avatar
dogmaphobic committed
125

dogmaphobic's avatar
dogmaphobic committed
126
    //-- TODO: Make this into an actual preference.
127
    bool    isAdvancedMode          () { return false; }
dogmaphobic's avatar
dogmaphobic committed
128

129 130 131 132
    void    setIsDarkStyle              (bool dark);
    void    setIsAudioMuted             (bool muted);
    void    setIsSaveLogPrompt          (bool prompt);
    void    setIsSaveLogPromptNotArmed  (bool prompt);
133 134
    void    setVirtualTabletJoystick    (bool enabled);

135 136
    void    setIsMultiplexingEnabled    (bool enable);
    void    setIsVersionCheckEnabled    (bool enable);
137
    void    setMavlinkSystemID          (int  id);
dogmaphobic's avatar
dogmaphobic committed
138

139 140 141
    bool experimentalSurvey(void) const;
    void setExperimentalSurvey(bool experimentalSurvey);

142 143 144
    // Overrides from QGCTool
    virtual void setToolbox(QGCToolbox* toolbox);

dogmaphobic's avatar
dogmaphobic committed
145 146 147 148
signals:
    void isDarkStyleChanged             (bool dark);
    void isAudioMutedChanged            (bool muted);
    void isSaveLogPromptChanged         (bool prompt);
149
    void isSaveLogPromptNotArmedChanged (bool prompt);
150
    void virtualTabletJoystickChanged   (bool enabled);
dogmaphobic's avatar
dogmaphobic committed
151 152
    void isMultiplexingEnabledChanged   (bool enabled);
    void isVersionCheckEnabledChanged   (bool enabled);
153
    void mavlinkSystemIDChanged         (int id);
154
    void flightMapPositionChanged       (QGeoCoordinate flightMapPosition);
155
    void experimentalSurveyChanged      (bool experimentalSurvey);
dogmaphobic's avatar
dogmaphobic committed
156

157
private:
158
    FlightMapSettings*      _flightMapSettings;
Don Gagne's avatar
Don Gagne committed
159 160 161 162
    HomePositionManager*    _homePositionManager;
    LinkManager*            _linkManager;
    MissionCommands*        _missionCommands;
    MultiVehicleManager*    _multiVehicleManager;
dogmaphobic's avatar
dogmaphobic committed
163
    QGCMapEngineManager*     _mapEngineManager;
164 165 166

    bool _virtualTabletJoystick;

167 168
    QGeoCoordinate _flightMapPosition;

169 170 171
    SettingsFact    _offlineEditingFirmwareTypeFact;
    FactMetaData    _offlineEditingFirmwareTypeMetaData;

172
    static const char*  _virtualTabletJoystickKey;
173 174 175
};

#endif