1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

Reload PFD qml widget on the middle mouse click

Makes qml files modifications and result check much faster
This commit is contained in:
Dmytro Poplavskiy 2013-10-20 15:43:38 +10:00 committed by Alessio Morale
parent c06bbdb5cc
commit c51ea68621
2 changed files with 16 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include <QtOpenGL/QGLWidget>
#include <QtCore/qfileinfo.h>
#include <QtCore/qdir.h>
#include <QMouseEvent>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecontext.h>
@ -94,6 +95,8 @@ void PfdQmlGadgetWidget::setQmlFile(QString fn)
SvgImageProvider *svgProvider = new SvgImageProvider(fn);
engine()->addImageProvider("svg", svgProvider);
engine()->clearComponentCache();
// it's necessary to allow qml side to query svg element position
engine()->rootContext()->setContextProperty("svgRenderer", svgProvider);
engine()->setBaseUrl(QUrl::fromLocalFile(fn));
@ -184,6 +187,16 @@ void PfdQmlGadgetWidget::setActualPositionUsed(bool arg)
}
}
void PfdQmlGadgetWidget::mouseReleaseEvent(QMouseEvent *event)
{
// Reload the schene on the middle mouse button click.
if (event->button() == Qt::MiddleButton) {
setQmlFile(m_qmlFileName);
}
QDeclarativeView::mouseReleaseEvent(event);
}
void PfdQmlGadgetWidget::setLatitude(double arg)
{
// not sure qFuzzyCompare is accurate enough for geo coordinates

View File

@ -115,6 +115,9 @@ signals:
void altitudeUnitChanged(QString arg);
void altitudeFactorChanged(double arg);
protected:
void mouseReleaseEvent(QMouseEvent *event);
private:
QString m_qmlFileName;
QString m_earthFile;