MainToolBarController.h 4.9 KB
Newer Older
dogmaphobic's avatar
dogmaphobic committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    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.

    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.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief QGC Main Tool Bar
 *   @author Gus Grubba <mavlink@grubba.com>
 */

30 31
#ifndef MainToolBarController_H
#define MainToolBarController_H
dogmaphobic's avatar
dogmaphobic committed
32

33 34 35 36
#include <QObject>

#include "Vehicle.h"
#include "UASMessageView.h"
dogmaphobic's avatar
dogmaphobic committed
37

38 39 40 41 42
#define TOOL_BAR_SETTINGS_GROUP "TOOLBAR_SETTINGS_GROUP"
#define TOOL_BAR_SHOW_BATTERY   "ShowBattery"
#define TOOL_BAR_SHOW_GPS       "ShowGPS"
#define TOOL_BAR_SHOW_MAV       "ShowMav"
#define TOOL_BAR_SHOW_MESSAGES  "ShowMessages"
43
#define TOOL_BAR_SHOW_RSSI      "ShowRSSI"
44

45
class MainToolBarController : public QObject
dogmaphobic's avatar
dogmaphobic committed
46 47
{
    Q_OBJECT
48

49 50 51
public:
    MainToolBarController(QObject* parent = NULL);
    ~MainToolBarController();
52

dogmaphobic's avatar
dogmaphobic committed
53 54 55 56
    Q_INVOKABLE void    onSetupView();
    Q_INVOKABLE void    onPlanView();
    Q_INVOKABLE void    onFlyView();
    Q_INVOKABLE void    onConnect(QString conf);
dogmaphobic's avatar
dogmaphobic committed
57
    Q_INVOKABLE void    onDisconnect(QString conf);
58
    Q_INVOKABLE void    onToolBarMessageClosed(void);
Don Gagne's avatar
Don Gagne committed
59
    Q_INVOKABLE void    showSettings(void);
dogmaphobic's avatar
dogmaphobic committed
60

Don Gagne's avatar
Don Gagne committed
61 62 63 64 65 66 67 68
    Q_PROPERTY(double       height              MEMBER _toolbarHeight           NOTIFY heightChanged)
    Q_PROPERTY(QStringList  configList          MEMBER _linkConfigurations      NOTIFY configListChanged)
    Q_PROPERTY(int          connectionCount     READ connectionCount            NOTIFY connectionCountChanged)
    Q_PROPERTY(QStringList  connectedList       MEMBER _connectedList           NOTIFY connectedListChanged)
    Q_PROPERTY(float        progressBarValue    MEMBER _progressBarValue        NOTIFY progressBarValueChanged)
    Q_PROPERTY(int          remoteRSSI          READ remoteRSSI                 NOTIFY remoteRSSIChanged)
    Q_PROPERTY(int          telemetryRRSSI      READ telemetryRRSSI             NOTIFY telemetryRRSSIChanged)
    Q_PROPERTY(int          telemetryLRSSI      READ telemetryLRSSI             NOTIFY telemetryLRSSIChanged)
69

70
    void        viewStateChanged        (const QString& key, bool value);
71 72 73
    int         remoteRSSI              () { return _remoteRSSI; }
    int         telemetryRRSSI          () { return _telemetryRRSSI; }
    int         telemetryLRSSI          () { return _telemetryLRSSI; }
74
    int         connectionCount         () { return _connectionCount; }
dogmaphobic's avatar
dogmaphobic committed
75

76
    void showToolBarMessage(const QString& message);
dogmaphobic's avatar
dogmaphobic committed
77

dogmaphobic's avatar
dogmaphobic committed
78 79 80 81
signals:
    void connectionCountChanged         (int count);
    void configListChanged              ();
    void connectedListChanged           (QStringList connectedList);
82
    void progressBarValueChanged        (float value);
83 84 85
    void remoteRSSIChanged              (int value);
    void telemetryRRSSIChanged          (int value);
    void telemetryLRSSIChanged          (int value);
Don Gagne's avatar
Don Gagne committed
86
    void heightChanged                  (double height);
dogmaphobic's avatar
dogmaphobic committed
87

Don Gagne's avatar
Don Gagne committed
88 89
    /// Shows a non-modal message below the toolbar
    void showMessage(const QString& message);
dogmaphobic's avatar
dogmaphobic committed
90 91

private slots:
92
    void _activeVehicleChanged          (Vehicle* vehicle);
dogmaphobic's avatar
dogmaphobic committed
93 94 95
    void _updateConfigurations          ();
    void _linkConnected                 (LinkInterface* link);
    void _linkDisconnected              (LinkInterface* link);
96
    void _setProgressBarValue           (float value);
97
    void _remoteControlRSSIChanged      (uint8_t rssi);
98
    void _telemetryChanged              (LinkInterface* link, unsigned rxerrors, unsigned fixed, unsigned rssi, unsigned remrssi, unsigned txbuf, unsigned noise, unsigned remnoise);
99
    void _delayedShowToolBarMessage     (void);
dogmaphobic's avatar
dogmaphobic committed
100 101 102 103 104

private:
    void _updateConnection              (LinkInterface *disconnectedLink = NULL);

private:
105
    Vehicle*        _vehicle;
dogmaphobic's avatar
dogmaphobic committed
106 107 108 109
    UASInterface*   _mav;
    QStringList     _linkConfigurations;
    int             _connectionCount;
    QStringList     _connectedList;
110
    float           _progressBarValue;
111
    int             _remoteRSSI;
dogmaphobic's avatar
dogmaphobic committed
112
    double          _remoteRSSIstore;
113 114
    int             _telemetryRRSSI;
    int             _telemetryLRSSI;
Don Gagne's avatar
Don Gagne committed
115
    double          _toolbarHeight;
dogmaphobic's avatar
dogmaphobic committed
116

117 118 119
    bool            _toolbarMessageVisible;
    QStringList     _toolbarMessageQueue;
    QMutex          _toolbarMessageQueueMutex;
dogmaphobic's avatar
dogmaphobic committed
120 121
};

122
#endif // MainToolBarController_H