QGroundControlQmlGlobal.h 7.42 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 30 31
 ======================================================================*/

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

#ifndef QGroundControlQmlGlobal_H
#define QGroundControlQmlGlobal_H

#include <QObject>

dogmaphobic's avatar
dogmaphobic committed
32 33
#include "QGCApplication.h"
#include "MainWindow.h"
Don Gagne's avatar
Don Gagne committed
34
#include "LinkManager.h"
35
#include "HomePositionManager.h"
36
#include "FlightMapSettings.h"
37

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

42 43
class QGCToolbox;

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

public:
49
    QGroundControlQmlGlobal(QGCToolbox* toolbox, QObject* parent = NULL);
Gus Grubba's avatar
Gus Grubba committed
50

Don Gagne's avatar
Don Gagne committed
51 52
    Q_PROPERTY(LinkManager*         linkManager         READ linkManager            CONSTANT)
    Q_PROPERTY(MultiVehicleManager* multiVehicleManager READ multiVehicleManager    CONSTANT)
53 54
    Q_PROPERTY(HomePositionManager* homePositionManager READ homePositionManager    CONSTANT)
    Q_PROPERTY(FlightMapSettings*   flightMapSettings   READ flightMapSettings      CONSTANT)
Gus Grubba's avatar
Gus Grubba committed
55 56 57 58 59

    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

dogmaphobic's avatar
dogmaphobic committed
60 61 62
    /// Global "Advance Mode" preference. Certain UI elements and features are different based on this.
    Q_PROPERTY(bool                 isAdvancedMode      READ isAdvancedMode         CONSTANT)

63 64 65 66 67
    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);

68 69 70 71 72 73
    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);

74
    // Property accesors
Gus Grubba's avatar
Gus Grubba committed
75

Don Gagne's avatar
Don Gagne committed
76 77
    LinkManager*            linkManager ()              { return _linkManager; }
    MultiVehicleManager*    multiVehicleManager ()      { return _multiVehicleManager; }
Gus Grubba's avatar
Gus Grubba committed
78 79 80 81 82 83 84
    HomePositionManager*    homePositionManager ()      { return _homePositionManager; }
    FlightMapSettings*      flightMapSettings   ()      { return _flightMapSettings; }

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

dogmaphobic's avatar
dogmaphobic committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
    //-- TODO: This should be in ScreenTools but I don't understand the changes done there (ScreenToolsController versus ScreenTools)
    Q_PROPERTY(bool     isDarkStyle         READ isDarkStyle     WRITE setIsDarkStyle    NOTIFY isDarkStyleChanged)
    bool    isDarkStyle         ()              { return qgcApp()->styleIsDark(); }
    void    setIsDarkStyle      (bool dark)     { qgcApp()->setStyle(dark); }

    //-- Audio Muting
    Q_PROPERTY(bool     isAudioMuted        READ isAudioMuted    WRITE setIsAudioMuted    NOTIFY isAudioMutedChanged)
    bool    isAudioMuted        ()              { return qgcApp()->toolbox()->audioOutput()->isMuted(); }
    void    setIsAudioMuted     (bool muted)    { qgcApp()->toolbox()->audioOutput()->mute(muted); }

    //-- Low power mode
    Q_PROPERTY(bool     isLowPowerMode      READ isLowPowerMode  WRITE setIsLowPowerMode   NOTIFY isLowPowerModeChanged)
    bool    isLowPowerMode      ()              { return MainWindow::instance()->lowPowerModeEnabled(); }
    void    setIsLowPowerMode   (bool low)      { MainWindow::instance()->enableLowPowerMode(low); }

    //-- Prompt save log
    Q_PROPERTY(bool     isSaveLogPrompt     READ isSaveLogPrompt WRITE setIsSaveLogPrompt  NOTIFY isSaveLogPromptChanged)
    bool    isSaveLogPrompt     ()              { return qgcApp()->promptFlightDataSave(); }
    void    setIsSaveLogPrompt  (bool prompt)   { qgcApp()->setPromptFlightDataSave(prompt); }

    //-- ClearSettings
    Q_INVOKABLE void    deleteAllSettingsNextBoot       () { qgcApp()->deleteAllSettingsNextBoot(); }
    Q_INVOKABLE void    clearDeleteAllSettingsNextBoot  () { qgcApp()->clearDeleteAllSettingsNextBoot(); }

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

dogmaphobic's avatar
dogmaphobic committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
    //
    //-- Mavlink Protocol
    //

    //-- Emit heartbeat
    Q_PROPERTY(bool     isHeartBeatEnabled  READ isHeartBeatEnabled  WRITE setIsHeartBeatEnabled  NOTIFY isHeartBeatEnabledChanged)
    bool    isHeartBeatEnabled     ()              { return qgcApp()->toolbox()->mavlinkProtocol()->heartbeatsEnabled(); }
    void    setIsHeartBeatEnabled  (bool enable)   { qgcApp()->toolbox()->mavlinkProtocol()->enableHeartbeats(enable); }

    //-- Multiplexing
    Q_PROPERTY(bool     isMultiplexingEnabled  READ isMultiplexingEnabled  WRITE setIsMultiplexingEnabled  NOTIFY isMultiplexingEnabledChanged)
    bool    isMultiplexingEnabled   ()              { return qgcApp()->toolbox()->mavlinkProtocol()->multiplexingEnabled(); }
    void    setIsMultiplexingEnabled(bool enable)   { qgcApp()->toolbox()->mavlinkProtocol()->enableMultiplexing(enable); }

    //-- Version Check
    Q_PROPERTY(bool     isVersionCheckEnabled  READ isVersionCheckEnabled  WRITE setIsVersionCheckEnabled  NOTIFY isVersionCheckEnabledChanged)
    bool    isVersionCheckEnabled   ()              { return qgcApp()->toolbox()->mavlinkProtocol()->versionCheckEnabled(); }
    void    setIsVersionCheckEnabled(bool enable)   { qgcApp()->toolbox()->mavlinkProtocol()->enableVersionCheck(enable); }

signals:
    void isDarkStyleChanged             (bool dark);
    void isAudioMutedChanged            (bool muted);
    void isLowPowerModeChanged          (bool lowPower);
    void isSaveLogPromptChanged         (bool prompt);
    void isHeartBeatEnabledChanged      (bool enabled);
    void isMultiplexingEnabledChanged   (bool enabled);
    void isVersionCheckEnabledChanged   (bool enabled);

140
private:
141 142 143 144
#ifdef QT_DEBUG
    void _startMockLink(MockConfiguration* mockConfig);
#endif

Don Gagne's avatar
Don Gagne committed
145 146
    MultiVehicleManager*    _multiVehicleManager;
    LinkManager*            _linkManager;
147
    HomePositionManager*    _homePositionManager;
148
    FlightMapSettings*      _flightMapSettings;
149 150 151
};

#endif