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:
parent
c06bbdb5cc
commit
c51ea68621
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user