1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-1119 Adding dialog and qml

This commit is contained in:
m_thread 2013-11-20 12:24:34 +01:00
parent 1b33f48048
commit 2191acd22f
10 changed files with 188 additions and 128 deletions

View File

@ -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()
}
}

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/flightlog">
<file>FlightLogDialog.qml</file>
</qresource>
</RCC>

View File

@ -8,8 +8,16 @@ include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
HEADERS += flightlogplugin.h \
flightlogmanager.h
flightlogmanager.h \
flightlogdialog.h
SOURCES += flightlogplugin.cpp \
flightlogmanager.cpp
flightlogmanager.cpp \
flightlogdialog.cpp
OTHER_FILES += Flightlog.pluginspec
OTHER_FILES += Flightlog.pluginspec \
FlightLogDialog.qml
FORMS +=
RESOURCES += \
flightLog.qrc

View File

@ -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()
{
}

View 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

View File

@ -26,21 +26,20 @@
*/
#include "flightlogmanager.h"
#include "extensionsystem/pluginmanager.h"
FlightLogEntry::FlightLogEntry(QObject *parent) :
QObject(parent)
{
}
FlightLogEntry::~FlightLogEntry()
{
}
#include "debuglogcontrol.h"
FlightLogManager::FlightLogManager(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() {

View File

@ -31,99 +31,39 @@
#include <QObject>
#include <QtDeclarative/QDeclarativeListProperty>
class FlightLogEntry : public QObject {
Q_OBJECT Q_PROPERTY(int flightTime READ getFlightTime NOTIFY FlightTimeChanged)
Q_PROPERTY(int flight READ getFlight NOTIFY FlightChanged)
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);
};
#include "uavobjectmanager.h"
#include "debuglogentry.h"
#include "debuglogstatus.h"
class FlightLogManager : public QObject {
Q_OBJECT Q_PROPERTY(int flightsRecorded READ flightsRecorded NOTIFY flightsRecordedChanged)
Q_PROPERTY(int logsRecordedLastFlight READ logsRecordedLastFlight NOTIFY logsRecordedLastFlightChanged)
Q_PROPERTY(int totalLogsRecorded READ totalLogsRecorded NOTIFY totalLogsRecordedChanged)
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;
Q_OBJECT
Q_PROPERTY(DebugLogStatus * flightLogStatus READ flightLogStatus)
Q_PROPERTY(QDeclarativeListProperty<DebugLogEntry *> *logEntries READ logEntries)
public:
explicit FlightLogManager(QObject *parent = 0);
~FlightLogManager();
int flightsRecorded() const
DebugLogStatus* flightLogStatus() const
{
return m_flightsRecorded;
return m_flightLogStatus;
}
int logsRecordedLastFlight() const
{
return m_logsRecordedLastFlight;
}
int totalLogsRecorded() const
{
return m_totalLogsRecorded;
}
int freeLogEntries() const
{
return m_freeLogEntries;
}
QDeclarativeListProperty<FlightLogEntry *> records() const
QDeclarativeListProperty<DebugLogEntry *>* logEntries() const
{
return m_records;
}
signals:
void flightsRecordedChanged(int arg);
void logsRecordedLastFlightChanged(int arg);
void totalLogsRecordedChanged(int arg);
void freeLogEntriesChanged(int arg);
public slots:
void clearAllLogs();
void retrieveLogs(int flight = -1);
private:
UAVObjectManager *m_objectManager;
DebugLogStatus *m_flightLogStatus;
QDeclarativeListProperty<DebugLogEntry *> *m_records;
};
#endif // FLIGHTLOGMANAGER_H

View File

@ -33,15 +33,14 @@
#include <QKeySequence>
#include <coreplugin/modemanager.h>
FlightLogPlugin::FlightLogPlugin()
#include "flightlogdialog.h"
FlightLogPlugin::FlightLogPlugin() : m_logDialog(0)
{
m_manager = new FlightLogManager();
}
FlightLogPlugin::~FlightLogPlugin()
{
delete m_manager;
m_manager = 0;
}
bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
@ -72,7 +71,18 @@ bool FlightLogPlugin::initialize(const QStringList & args, QString *errMsg)
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()

View File

@ -28,6 +28,7 @@
#include <extensionsystem/iplugin.h>
#include "flightlogmanager.h"
#include "flightlogdialog.h"
class FlightLogPlugin : public ExtensionSystem::IPlugin {
Q_OBJECT
@ -41,13 +42,12 @@ public:
bool initialize(const QStringList & arguments, QString *errorString);
void shutdown();
private:
FlightLogManager* m_manager;
private slots:
void ShowLogManagementDialog();
void LogManagementDialogClosed();
private:
FlightLogDialog* m_logDialog;
};
#endif /* FLIGHTLOGPLUGIN_H_ */

View File

@ -157,6 +157,7 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info)
QString(" void %1Changed(quint32 index, %2 value);\n")
.arg(field->name).arg(type);
if(!field->defaultElementNames) {
for (int elementIndex = 0; elementIndex < field->numElements; elementIndex++) {
QString elementName = field->elementNames[elementIndex];
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")
.arg(field->name).arg(elementIndex).arg(elementName);
}
}
} else {
properties += QString(" Q_PROPERTY(%1 %2 READ get%2 WRITE set%2 NOTIFY %2Changed);\n")
.arg(type).arg(field->name);