mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-1119 Adding dialog and qml
This commit is contained in:
parent
1b33f48048
commit
2191acd22f
@ -0,0 +1,15 @@
|
|||||||
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 1.0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 100
|
||||||
|
height: 62
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: button1
|
||||||
|
x: 8
|
||||||
|
y: 18
|
||||||
|
text: qsTr("OK")
|
||||||
|
onClicked: dialog.close()
|
||||||
|
}
|
||||||
|
}
|
5
ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc
Normal file
5
ground/openpilotgcs/src/plugins/flightlog/flightLog.qrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/flightlog">
|
||||||
|
<file>FlightLogDialog.qml</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@ -8,8 +8,16 @@ include(../../plugins/coreplugin/coreplugin.pri)
|
|||||||
include(../../plugins/uavobjects/uavobjects.pri)
|
include(../../plugins/uavobjects/uavobjects.pri)
|
||||||
|
|
||||||
HEADERS += flightlogplugin.h \
|
HEADERS += flightlogplugin.h \
|
||||||
flightlogmanager.h
|
flightlogmanager.h \
|
||||||
|
flightlogdialog.h
|
||||||
SOURCES += flightlogplugin.cpp \
|
SOURCES += flightlogplugin.cpp \
|
||||||
flightlogmanager.cpp
|
flightlogmanager.cpp \
|
||||||
|
flightlogdialog.cpp
|
||||||
|
|
||||||
OTHER_FILES += Flightlog.pluginspec
|
OTHER_FILES += Flightlog.pluginspec \
|
||||||
|
FlightLogDialog.qml
|
||||||
|
|
||||||
|
FORMS +=
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
flightLog.qrc
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file flightlogdialog.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
|
* @addtogroup [Group]
|
||||||
|
* @{
|
||||||
|
* @addtogroup FlightLogDialog
|
||||||
|
* @{
|
||||||
|
* @brief [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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "flightlogdialog.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include <QtQuick>
|
||||||
|
#include <QQuickView>
|
||||||
|
#include <QQmlEngine>
|
||||||
|
#include <QQmlContext>
|
||||||
|
|
||||||
|
FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager) :
|
||||||
|
QDialog(parent)
|
||||||
|
{
|
||||||
|
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
||||||
|
setWindowTitle(tr("Manage flight side logs"));
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
setMinimumSize(600, 400);
|
||||||
|
setMaximumSize(800, 600);
|
||||||
|
|
||||||
|
QQuickView *view = new QQuickView();
|
||||||
|
view->rootContext()->setContextProperty("dialog", this);
|
||||||
|
view->rootContext()->setContextProperty("logManager", flightLogManager);
|
||||||
|
view->setResizeMode(QQuickView::SizeRootObjectToView);
|
||||||
|
view->setSource(QUrl("qrc:/flightlog/FlightLogDialog.qml"));
|
||||||
|
|
||||||
|
QWidget * container = QWidget::createWindowContainer(view);
|
||||||
|
container->setMinimumSize(600, 400);
|
||||||
|
container->setMaximumSize(800, 600);
|
||||||
|
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
QVBoxLayout *lay = new QVBoxLayout();
|
||||||
|
lay->setContentsMargins(0,0,0,0);
|
||||||
|
setLayout(lay);
|
||||||
|
layout()->addWidget(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
FlightLogDialog::~FlightLogDialog()
|
||||||
|
{
|
||||||
|
}
|
17
ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h
Normal file
17
ground/openpilotgcs/src/plugins/flightlog/flightlogdialog.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef FLIGHTLOGDIALOG_H
|
||||||
|
#define FLIGHTLOGDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include"flightlogmanager.h"
|
||||||
|
|
||||||
|
class FlightLogDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit FlightLogDialog(QWidget *parent, FlightLogManager *flightLogManager);
|
||||||
|
~FlightLogDialog();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FLIGHTLOGDIALOG_H
|
@ -26,21 +26,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "flightlogmanager.h"
|
#include "flightlogmanager.h"
|
||||||
|
#include "extensionsystem/pluginmanager.h"
|
||||||
|
|
||||||
FlightLogEntry::FlightLogEntry(QObject *parent) :
|
#include "debuglogcontrol.h"
|
||||||
QObject(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FlightLogEntry::~FlightLogEntry()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FlightLogManager::FlightLogManager(QObject *parent) :
|
FlightLogManager::FlightLogManager(QObject *parent) :
|
||||||
QObject(parent) {
|
QObject(parent) {
|
||||||
|
|
||||||
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
|
m_objectManager = pm->getObject<UAVObjectManager>();
|
||||||
|
Q_ASSERT(m_objectManager);
|
||||||
|
|
||||||
|
m_flightLogStatus = DebugLogStatus::GetInstance(m_objectManager);
|
||||||
|
Q_ASSERT(m_flightLogStatus);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FlightLogManager::~FlightLogManager() {
|
FlightLogManager::~FlightLogManager() {
|
||||||
|
@ -31,99 +31,39 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QtDeclarative/QDeclarativeListProperty>
|
#include <QtDeclarative/QDeclarativeListProperty>
|
||||||
|
|
||||||
class FlightLogEntry : public QObject {
|
#include "uavobjectmanager.h"
|
||||||
Q_OBJECT Q_PROPERTY(int flightTime READ getFlightTime NOTIFY FlightTimeChanged)
|
#include "debuglogentry.h"
|
||||||
Q_PROPERTY(int flight READ getFlight NOTIFY FlightChanged)
|
#include "debuglogstatus.h"
|
||||||
Q_PROPERTY(int entry READ getEntry NOTIFY EntryChanged)
|
|
||||||
Q_PROPERTY(int type READ getType NOTIFY TypeChanged)
|
|
||||||
|
|
||||||
int m_flightTime;
|
|
||||||
int m_flight;
|
|
||||||
int m_entry;
|
|
||||||
int m_type;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit FlightLogEntry(QObject *parent = 0);
|
|
||||||
~FlightLogEntry();
|
|
||||||
|
|
||||||
int getFlightTime() const
|
|
||||||
{
|
|
||||||
return m_flightTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getFlight() const
|
|
||||||
{
|
|
||||||
return m_flight;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getEntry() const
|
|
||||||
{
|
|
||||||
return m_entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getType() const
|
|
||||||
{
|
|
||||||
return m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void FlightTimeChanged(int arg);
|
|
||||||
void FlightChanged(int arg);
|
|
||||||
void EntryChanged(int arg);
|
|
||||||
void TypeChanged(int arg);
|
|
||||||
};
|
|
||||||
|
|
||||||
class FlightLogManager : public QObject {
|
class FlightLogManager : public QObject {
|
||||||
Q_OBJECT Q_PROPERTY(int flightsRecorded READ flightsRecorded NOTIFY flightsRecordedChanged)
|
Q_OBJECT
|
||||||
Q_PROPERTY(int logsRecordedLastFlight READ logsRecordedLastFlight NOTIFY logsRecordedLastFlightChanged)
|
Q_PROPERTY(DebugLogStatus * flightLogStatus READ flightLogStatus)
|
||||||
Q_PROPERTY(int totalLogsRecorded READ totalLogsRecorded NOTIFY totalLogsRecordedChanged)
|
Q_PROPERTY(QDeclarativeListProperty<DebugLogEntry *> *logEntries READ logEntries)
|
||||||
Q_PROPERTY(int freeLogEntries READ freeLogEntries NOTIFY freeLogEntriesChanged)
|
|
||||||
Q_PROPERTY(QDeclarativeListProperty<FlightLogEntry *> records READ records)
|
|
||||||
|
|
||||||
int m_flightsRecorded;
|
|
||||||
int m_logsRecordedLastFlight;
|
|
||||||
int m_totalLogsRecorded;
|
|
||||||
int m_freeLogEntries;
|
|
||||||
QDeclarativeListProperty<FlightLogEntry *> m_records;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FlightLogManager(QObject *parent = 0);
|
explicit FlightLogManager(QObject *parent = 0);
|
||||||
~FlightLogManager();
|
~FlightLogManager();
|
||||||
|
|
||||||
int flightsRecorded() const
|
DebugLogStatus* flightLogStatus() const
|
||||||
{
|
{
|
||||||
return m_flightsRecorded;
|
return m_flightLogStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
int logsRecordedLastFlight() const
|
QDeclarativeListProperty<DebugLogEntry *>* logEntries() const
|
||||||
{
|
|
||||||
return m_logsRecordedLastFlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
int totalLogsRecorded() const
|
|
||||||
{
|
|
||||||
return m_totalLogsRecorded;
|
|
||||||
}
|
|
||||||
|
|
||||||
int freeLogEntries() const
|
|
||||||
{
|
|
||||||
return m_freeLogEntries;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDeclarativeListProperty<FlightLogEntry *> records() const
|
|
||||||
{
|
{
|
||||||
return m_records;
|
return m_records;
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void flightsRecordedChanged(int arg);
|
|
||||||
void logsRecordedLastFlightChanged(int arg);
|
|
||||||
void totalLogsRecordedChanged(int arg);
|
|
||||||
void freeLogEntriesChanged(int arg);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clearAllLogs();
|
void clearAllLogs();
|
||||||
void retrieveLogs(int flight = -1);
|
void retrieveLogs(int flight = -1);
|
||||||
|
|
||||||
|
private:
|
||||||
|
UAVObjectManager *m_objectManager;
|
||||||
|
DebugLogStatus *m_flightLogStatus;
|
||||||
|
QDeclarativeListProperty<DebugLogEntry *> *m_records;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLIGHTLOGMANAGER_H
|
#endif // FLIGHTLOGMANAGER_H
|
||||||
|
@ -33,15 +33,14 @@
|
|||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
|
|
||||||
FlightLogPlugin::FlightLogPlugin()
|
#include "flightlogdialog.h"
|
||||||
|
|
||||||
|
FlightLogPlugin::FlightLogPlugin() : m_logDialog(0)
|
||||||
{
|
{
|
||||||
m_manager = new FlightLogManager();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FlightLogPlugin::~FlightLogPlugin()
|
FlightLogPlugin::~FlightLogPlugin()
|
||||||
{
|
{
|
||||||
delete m_manager;
|
|
||||||
m_manager = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
|
bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
|
||||||
@ -72,7 +71,18 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
|
|||||||
|
|
||||||
void FlightLogPlugin::ShowLogManagementDialog()
|
void FlightLogPlugin::ShowLogManagementDialog()
|
||||||
{
|
{
|
||||||
|
if(!m_logDialog) {
|
||||||
|
m_logDialog = new FlightLogDialog(0, new FlightLogManager());
|
||||||
|
connect(m_logDialog, SIGNAL(finished(int)), this, SLOT(LogManagementDialogClosed()));
|
||||||
|
m_logDialog->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlightLogPlugin::LogManagementDialogClosed()
|
||||||
|
{
|
||||||
|
if(m_logDialog) {
|
||||||
|
m_logDialog = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlightLogPlugin::extensionsInitialized()
|
void FlightLogPlugin::extensionsInitialized()
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
#include "flightlogmanager.h"
|
#include "flightlogmanager.h"
|
||||||
|
#include "flightlogdialog.h"
|
||||||
|
|
||||||
class FlightLogPlugin : public ExtensionSystem::IPlugin {
|
class FlightLogPlugin : public ExtensionSystem::IPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -41,13 +42,12 @@ public:
|
|||||||
bool initialize(const QStringList & arguments, QString *errorString);
|
bool initialize(const QStringList & arguments, QString *errorString);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
private:
|
|
||||||
FlightLogManager* m_manager;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ShowLogManagementDialog();
|
void ShowLogManagementDialog();
|
||||||
|
void LogManagementDialogClosed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
FlightLogDialog* m_logDialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FLIGHTLOGPLUGIN_H_ */
|
#endif /* FLIGHTLOGPLUGIN_H_ */
|
||||||
|
@ -157,6 +157,7 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info)
|
|||||||
QString(" void %1Changed(quint32 index, %2 value);\n")
|
QString(" void %1Changed(quint32 index, %2 value);\n")
|
||||||
.arg(field->name).arg(type);
|
.arg(field->name).arg(type);
|
||||||
|
|
||||||
|
if(!field->defaultElementNames) {
|
||||||
for (int elementIndex = 0; elementIndex < field->numElements; elementIndex++) {
|
for (int elementIndex = 0; elementIndex < field->numElements; elementIndex++) {
|
||||||
QString elementName = field->elementNames[elementIndex];
|
QString elementName = field->elementNames[elementIndex];
|
||||||
properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n")
|
properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n")
|
||||||
@ -192,6 +193,7 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info)
|
|||||||
" emit %1_%3Changed(data.%1[%2]);\n")
|
" emit %1_%3Changed(data.%1[%2]);\n")
|
||||||
.arg(field->name).arg(elementIndex).arg(elementName);
|
.arg(field->name).arg(elementIndex).arg(elementName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n")
|
properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n")
|
||||||
.arg(type).arg(field->name);
|
.arg(type).arg(field->name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user