Skip to content
Snippets Groups Projects
QGCQmlWidgetHolder.cpp 1.58 KiB
Newer Older
  • Learn to ignore specific revisions
  • /****************************************************************************
     *
     *   (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.
     *
     ****************************************************************************/
    
    Don Gagne's avatar
    Don Gagne committed
    
    /// @file
    ///     @author Don Gagne <don@thegagnes.com>
    
    #include "QGCQmlWidgetHolder.h"
    
    
    QGCQmlWidgetHolder::QGCQmlWidgetHolder(const QString& title, QAction* action, QWidget *parent) :
        QGCDockWidget(title, action, parent)
    
    Don Gagne's avatar
    Don Gagne committed
    {
        _ui.setupUi(this);
    
        layout()->setContentsMargins(0,0,0,0);
    
    
        if (action) {
            setWindowTitle(title);
        }
    
    Don Gagne's avatar
    Don Gagne committed
        setResizeMode(QQuickWidget::SizeRootObjectToView);
    
    Don Gagne's avatar
    Don Gagne committed
    }
    
    QGCQmlWidgetHolder::~QGCQmlWidgetHolder()
    {
    
    }
    
    void QGCQmlWidgetHolder::setAutoPilot(AutoPilotPlugin* autoPilot)
    {
    
        setContextPropertyObject("autopilot", autoPilot);
    
    Don Gagne's avatar
    Don Gagne committed
    bool QGCQmlWidgetHolder::setSource(const QUrl& qmlUrl)
    
    Don Gagne's avatar
    Don Gagne committed
    {
    
        return _ui.qmlWidget->setSource(qmlUrl);
    
    Don Gagne's avatar
    Don Gagne committed
    }
    
    
    void QGCQmlWidgetHolder::setContextPropertyObject(const QString& name, QObject* object)
    {
        _ui.qmlWidget->rootContext()->setContextProperty(name, object);
    }
    
    QQmlContext* QGCQmlWidgetHolder::getRootContext(void)
    
    dogmaphobic's avatar
    dogmaphobic committed
    {
        return _ui.qmlWidget->rootContext();
    }
    
    
    QQuickItem* QGCQmlWidgetHolder::getRootObject(void)
    {
        return _ui.qmlWidget->rootObject();
    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    dogmaphobic's avatar
    dogmaphobic committed
    QQmlEngine*	QGCQmlWidgetHolder::getEngine()
    {
        return _ui.qmlWidget->engine();
    }
    
    
    
    Don Gagne's avatar
    Don Gagne committed
    void QGCQmlWidgetHolder::setResizeMode(QQuickWidget::ResizeMode resizeMode)
    {
        _ui.qmlWidget->setResizeMode(resizeMode);