QGCQmlWidgetHolder.h 1.84 KB
Newer Older
1
2
3
4
5
6
7
8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed
9

Don Gagne's avatar
Don Gagne committed
10
11
12
13
14
15
16

#ifndef QGCQmlWidgetHolder_h
#define QGCQmlWidgetHolder_h

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

17
18
#include "QGCDockWidget.h"
#include "AutoPilotPlugin.h"
Don Gagne's avatar
Don Gagne committed
19
20
21
22
23
24
25
26
27

#include "ui_QGCQmlWidgetHolder.h"

namespace Ui {
class QGCQmlWidgetHolder;
}

/// This is used to create widgets which are implemented in QML.

28
class QGCQmlWidgetHolder : public QGCDockWidget
Don Gagne's avatar
Don Gagne committed
29
30
31
32
{
    Q_OBJECT

public:
33
34
35
36
37
    // This has a title and action since the base class is QGCDockWidget. In order to use this
    // control as a normal QWidget, not a doc widget just pass in:
    //      title = QString()
    //      action = NULL
    explicit QGCQmlWidgetHolder(const QString& title, QAction* action, QWidget *parent = 0);
Don Gagne's avatar
Don Gagne committed
38
    ~QGCQmlWidgetHolder();
dogmaphobic's avatar
dogmaphobic committed
39

Don Gagne's avatar
Don Gagne committed
40
41
42
    /// Sets the UAS into the widget which in turn will load facts into the context
    void setAutoPilot(AutoPilotPlugin* autoPilot);

dogmaphobic's avatar
dogmaphobic committed
43
    /// Get Root Context
Don Gagne's avatar
Don Gagne committed
44
    QQmlContext* getRootContext(void);
dogmaphobic's avatar
dogmaphobic committed
45

Don Gagne's avatar
Don Gagne committed
46
47
    /// Get Root Object
    QQuickItem* getRootObject(void);
dogmaphobic's avatar
dogmaphobic committed
48
49
50
51

    /// Get QML Engine
    QQmlEngine*	getEngine();

52
    /// Sets the QML into the control. Will display errors message box if error occurs loading source.
Ricardo de Almeida Gonzaga's avatar
Ricardo de Almeida Gonzaga committed
53
    /// @return true: source loaded, false: source not loaded, errors occurred
Don Gagne's avatar
Don Gagne committed
54
    bool setSource(const QUrl& qmlUrl);
dogmaphobic's avatar
dogmaphobic committed
55

Don Gagne's avatar
Don Gagne committed
56
    void setContextPropertyObject(const QString& name, QObject* object);
dogmaphobic's avatar
dogmaphobic committed
57

Don Gagne's avatar
commit    
Don Gagne committed
58
59
    /// Sets the resize mode for the QQuickWidget container
    void setResizeMode(QQuickWidget::ResizeMode resizeMode);
Don Gagne's avatar
Don Gagne committed
60
61
62
63
64
65

private:
    Ui::QGCQmlWidgetHolder _ui;
};

#endif