/**
 ******************************************************************************
 *
 * @file       quickwidgetproxy.h
 * @author     The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
 * @addtogroup
 * @{
 * @addtogroup
 * @{
 * @brief
 *****************************************************************************/
/*
 * This program 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.
 *
 * This program 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 this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#ifndef QUICKWIDGETPROXY_H_
#define QUICKWIDGETPROXY_H_

#include "utils_global.h"

#include <QWidget>
#include <QQuickWidget>
#include <QQuickView>

class QQmlEngine;

/*
 * Very crude proxy that allows to switch between QQuickView and QQuickWindow are runtime
 */
class QTCREATOR_UTILS_EXPORT QuickWidgetProxy : public QObject {
    Q_OBJECT

public:
    QuickWidgetProxy(QWidget *parent = 0);
    virtual ~QuickWidgetProxy();

    QWidget *widget();

    void setSource(const QUrl &url);
    QQmlEngine *engine() const;
    QList<QQmlError> errors() const;

public slots:
    void onStatusChanged(QQuickWidget::Status status);
    void onStatusChanged(QQuickView::Status status);
    void onSceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);

private:
    bool m_widget;

    QQuickWidget *m_quickWidget;

    QWidget *m_container;
    QQuickView *m_quickView;
};

#endif /* QUICKWIDGETPROXY_H_ */
