QGCToolWidget.h 2.94 KB
Newer Older
1 2 3 4 5
#ifndef QGCTOOLWIDGET_H
#define QGCTOOLWIDGET_H

#include <QWidget>
#include <QAction>
lm's avatar
lm committed
6
#include <QMap>
7
#include <QVBoxLayout>
lm's avatar
lm committed
8
#include "QGCToolWidgetItem.h"
9 10 11

#include "UAS.h"

12 13 14
namespace Ui
{
class QGCToolWidget;
15 16 17 18 19 20 21
}

class QGCToolWidget : public QWidget
{
    Q_OBJECT

public:
lm's avatar
lm committed
22
    explicit QGCToolWidget(const QString& title, QWidget *parent = 0);
23 24
    ~QGCToolWidget();

lm's avatar
lm committed
25
    /** @brief Factory method to instantiate all tool widgets */
26
    static QList<QGCToolWidget*> createWidgetsFromSettings(QWidget* parent, QString settingsFile=QString());
lm's avatar
lm committed
27 28 29 30
    /** @Give the tool widget a reference to its action in the main menu */
    void setMainMenuAction(QAction* action);
    /** @brief All instances of this class */
    static QMap<QString, QGCToolWidget*>* instances();
31 32
    /** @brief Get title of widget */
    const QString getTitle();
lm's avatar
lm committed
33

34 35 36
    int isVisible(int view) { return viewVisible.value(view, false); }
    Qt::DockWidgetArea getDockWidgetArea(int view) { return dockWidgetArea.value(view, Qt::BottomDockWidgetArea); }

37 38
public slots:
    void addUAS(UASInterface* uas);
lm's avatar
lm committed
39 40
    /** @brief Delete this widget */
    void deleteWidget();
41 42 43
    /** @brief Export this widget to a file */
    void exportWidget();
    /** @brief Import settings for this widget from a file */
44
    void importWidget();
lm's avatar
lm committed
45
    /** @brief Store all widgets of this type to QSettings */
46 47 48 49 50 51 52 53 54
    static void storeWidgetsToSettings(QString settingsFile=QString());
    /** @brief Load this widget from a QSettings object */
    void loadSettings(QSettings& settings);
    /** @brief Load this widget from a settings file */
    void loadSettings(const QString& settings);
    /** @brief Store this widget to a QSettings object */
    void storeSettings(QSettings& settings);
    /** @brief Store this widget to a settings file */
    void storeSettings(const QString& settingsFile);
55 56
    /** @brief Store the view id and dock widget area */
    void setViewVisibilityAndDockWidgetArea(int view, bool visible, Qt::DockWidgetArea area);
lm's avatar
lm committed
57 58 59

signals:
    void titleChanged(QString);
60 61 62 63

protected:
    QAction* addParamAction;
    QAction* addButtonAction;
lm's avatar
lm committed
64
    QAction* addCommandAction;
65
    QAction* setTitleAction;
lm's avatar
lm committed
66
    QAction* deleteAction;
67 68
    QAction* exportAction;
    QAction* importAction;
69 70
    QVBoxLayout* toolLayout;
    UAS* mav;
71 72 73
    QAction* mainMenuAction;             ///< Main menu action
    QMap<int, Qt::DockWidgetArea> dockWidgetArea;   ///< Dock widget area desired by this widget
    QMap<int, bool> viewVisible;  ///< Visibility in one view
74 75 76

    void contextMenuEvent(QContextMenuEvent* event);
    void createActions();
lm's avatar
lm committed
77 78 79
    QList<QGCToolWidgetItem* >* itemList();
    /** @brief Add an existing tool widget */
    void addToolWidget(QGCToolWidgetItem* widget);
80

81 82
    void hideEvent(QHideEvent* event);

83 84
protected slots:
    void addParam();
lm's avatar
lm committed
85
    /** @deprecated */
86
    void addAction();
lm's avatar
lm committed
87
    void addCommand();
88
    void setTitle();
89
    void setTitle(QString title);
90 91 92 93 94 95 96


private:
    Ui::QGCToolWidget *ui;
};

#endif // QGCTOOLWIDGET_H