11 changed files with 232 additions and 67 deletions
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
#include "MissionCommandTreeEditorTest.h" |
||||
#include "QGCApplication.h" |
||||
#include "QGCCorePlugin.h" |
||||
#include "SimpleMissionItem.h" |
||||
#include "PlanMasterController.h" |
||||
|
||||
MissionCommandTreeEditorTest::MissionCommandTreeEditorTest(void) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void MissionCommandTreeEditorTest::_testEditorsWorker(QGCMAVLink::FirmwareClass_t firmwareClass, QGCMAVLink::VehicleClass_t vehicleClass) |
||||
{ |
||||
QString firmwareClassString = QGCMAVLink::firmwareClassToString(firmwareClass).replace(" ", ""); |
||||
QString vehicleClassString = QGCMAVLink::vehicleClassToString(vehicleClass).replace(" ", ""); |
||||
|
||||
AppSettings* appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); |
||||
appSettings->offlineEditingFirmwareClass()->setRawValue(firmwareClass); |
||||
appSettings->offlineEditingVehicleClass()->setRawValue(vehicleClass); |
||||
PlanMasterController* masterController = new PlanMasterController(); |
||||
|
||||
FirmwarePlugin* firmwarePlugin = qgcApp()->toolbox()->firmwarePluginManager()->firmwarePluginForAutopilot(QGCMAVLink::firmwareClassToAutopilot(firmwareClass), QGCMAVLink::vehicleClassToMavType(vehicleClass)); |
||||
if (firmwarePlugin->supportedMissionCommands().count() == 0) { |
||||
firmwarePlugin = qgcApp()->toolbox()->firmwarePluginManager()->firmwarePluginForAutopilot(QGCMAVLink::firmwareClassToAutopilot(QGCMAVLink::FirmwareClassPX4), QGCMAVLink::vehicleClassToMavType(vehicleClass)); |
||||
} |
||||
int cColumns = firmwarePlugin->supportedMissionCommands().count(); |
||||
|
||||
QVariantList varSimpleItems; |
||||
for (MAV_CMD command: firmwarePlugin->supportedMissionCommands()) { |
||||
SimpleMissionItem* simpleItem = new SimpleMissionItem(masterController, false /* flyView */, false /* forLoad */, this); |
||||
simpleItem->setCommand(command); |
||||
varSimpleItems.append(QVariant::fromValue(simpleItem)); |
||||
} |
||||
|
||||
QQmlApplicationEngine* qmlAppEngine = qgcApp()->toolbox()->corePlugin()->createQmlApplicationEngine(this); |
||||
qmlAppEngine->rootContext()->setContextProperty("planMasterController", masterController); |
||||
qmlAppEngine->rootContext()->setContextProperty("missionItems", varSimpleItems); |
||||
qmlAppEngine->rootContext()->setContextProperty("cColumns", cColumns); |
||||
qmlAppEngine->rootContext()->setContextProperty("imagePath", QStringLiteral("/home/parallels/Downloads/%1-%2.png").arg(firmwareClassString).arg(vehicleClassString)); |
||||
qmlAppEngine->load(QUrl(QStringLiteral("qrc:/qml/MissionCommandTreeEditorTestWindow.qml"))); |
||||
|
||||
QTest::qWait(1000); |
||||
|
||||
delete qmlAppEngine; |
||||
} |
||||
|
||||
void MissionCommandTreeEditorTest::testEditors(void) |
||||
{ |
||||
for (const QGCMAVLink::FirmwareClass_t& firmwareClass: QGCMAVLink::allFirmwareClasses()) { |
||||
for (const QGCMAVLink::VehicleClass_t& vehicleClass: QGCMAVLink::allVehicleClasses()) { |
||||
_testEditorsWorker(firmwareClass, vehicleClass); |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
#pragma once |
||||
|
||||
#include "UnitTest.h" |
||||
|
||||
/// This unit test is meant to be used stand-alone to generate images for each mission item editor for review
|
||||
class MissionCommandTreeEditorTest : public UnitTest |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
MissionCommandTreeEditorTest(void); |
||||
|
||||
private slots: |
||||
void testEditors(void); |
||||
|
||||
private: |
||||
void _testEditorsWorker(QGCMAVLink::FirmwareClass_t firmwareClass, QGCMAVLink::VehicleClass_t vehicleClass); |
||||
}; |
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
/**************************************************************************** |
||||
* |
||||
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> |
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
import QtQuick 2.12 |
||||
import QtQuick.Controls 2.4 |
||||
import QtQuick.Dialogs 1.3 |
||||
import QtQuick.Layouts 1.11 |
||||
import QtQuick.Window 2.11 |
||||
|
||||
import QGroundControl 1.0 |
||||
import QGroundControl.Palette 1.0 |
||||
import QGroundControl.Controls 1.0 |
||||
import QGroundControl.ScreenTools 1.0 |
||||
import QGroundControl.FlightDisplay 1.0 |
||||
import QGroundControl.FlightMap 1.0 |
||||
import QGroundControl.Controllers 1.0 |
||||
|
||||
ApplicationWindow { |
||||
id: _root |
||||
visible: true |
||||
visibility: Qt.WindowFullScreen |
||||
color: qgcPal.window |
||||
|
||||
property real editorWidth: ScreenTools.defaultFontPixelWidth * 30 |
||||
|
||||
QGCPalette { id: qgcPal; colorGroupEnabled: true } |
||||
|
||||
Timer { |
||||
id: timer |
||||
interval: 100 |
||||
onTriggered: { |
||||
var success = fullImage.grabToImage(function(result) { result.saveToFile(imagePath) }) |
||||
console.log(success) |
||||
} |
||||
} |
||||
|
||||
Component.onCompleted: timer.start() |
||||
|
||||
Flow { |
||||
id: fullImage |
||||
anchors.fill: parent |
||||
|
||||
Repeater { |
||||
model: missionItems |
||||
|
||||
Column { |
||||
QGCLabel { text: modelData.commandName; color: "black" } |
||||
|
||||
Loader { |
||||
id: editorLoader |
||||
source: modelData.editorQml |
||||
|
||||
property var missionItem: modelData |
||||
property var masterController: planMasterController |
||||
property real availableWidth: editorWidth |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue