10 changed files with 325 additions and 1 deletions
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL 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. |
||||
|
||||
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
#include "CustomCommandWidget.h" |
||||
|
||||
CustomCommandWidget::CustomCommandWidget(QWidget *parent) : |
||||
QGCQmlWidgetHolder(parent) |
||||
{ |
||||
setSource(QUrl::fromUserInput("qrc:/qml/CustomCommandWidget.qml")); |
||||
} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL 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. |
||||
|
||||
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/// @file
|
||||
/// @author Don Gagne <don@thegagnes.com>
|
||||
|
||||
#ifndef CustomCommandWidget_H |
||||
#define CustomCommandWidget_H |
||||
|
||||
#include "QGCQmlWidgetHolder.h" |
||||
|
||||
class CustomCommandWidget : public QGCQmlWidgetHolder |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
CustomCommandWidget(QWidget *parent = 0); |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,106 @@
@@ -0,0 +1,106 @@
|
||||
/*===================================================================== |
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> |
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL 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. |
||||
|
||||
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. |
||||
|
||||
======================================================================*/ |
||||
|
||||
/// @file |
||||
/// @author Don Gagne <don@thegagnes.com> |
||||
|
||||
import QtQuick 2.2 |
||||
|
||||
import QGroundControl.Palette 1.0 |
||||
import QGroundControl.Controls 1.0 |
||||
import QGroundControl.Controllers 1.0 |
||||
|
||||
ViewWidget { |
||||
connectedComponent: commandComponenet |
||||
|
||||
Component { |
||||
id: commandComponenet |
||||
|
||||
Item { |
||||
|
||||
CustomCommandWidgetController { id: controller } |
||||
|
||||
Item { |
||||
anchors.top: parent.top |
||||
anchors.bottom: buttonRow.top |
||||
width: parent.width |
||||
|
||||
QGCLabel { |
||||
id: errorOutput |
||||
anchors.fill: parent |
||||
wrapMode: Text.WordWrap |
||||
visible: false |
||||
} |
||||
|
||||
QGCLabel { |
||||
id: warning |
||||
anchors.fill: parent |
||||
wrapMode: Text.WordWrap |
||||
visible: !controller.customQmlFile |
||||
text: "You can create your own commands and parameter editing user interface in this widget. " + |
||||
"You do this by providing your own Qml file. " + |
||||
"This support is a work in progress and the details may change somewhat in the future. " + |
||||
"By using this feature you are connecting directly to the internals of QGroundControl. " + |
||||
"Doing so incorrectly may cause instability both in QGroundControl and/or your vehicle. " + |
||||
"So make sure to test your changes thoroughly before using them in flight.\n\n" + |
||||
"Click 'Select Qml file' to provide your custom qml file.\n" + |
||||
"Click 'Clear Qml file' to reset to none.\n" + |
||||
"Example usage: http://www.qgroundcontrol.org/custom_command_qml_widgets" |
||||
} |
||||
|
||||
Loader { |
||||
id: loader |
||||
anchors.fill: parent |
||||
source: controller.customQmlFile |
||||
visible: controller.customQmlFile |
||||
|
||||
onStatusChanged: { |
||||
if (loader.status == Loader.Error) { |
||||
if (sourceComponent.status == Component.Error) { |
||||
errorOutput.text = sourceComponent.errorString() |
||||
errorOutput.visible = true |
||||
loader.visible = false |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
Row { |
||||
id: buttonRow |
||||
spacing: 10 |
||||
anchors.bottom: parent.bottom |
||||
|
||||
QGCButton { |
||||
text: "Select Qml file..." |
||||
onClicked: controller.selectQmlFile() |
||||
} |
||||
|
||||
QGCButton { |
||||
text: "Clear Qml file" |
||||
onClicked: controller.clearQmlFile() |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL 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. |
||||
|
||||
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
#include "CustomCommandWidgetController.h" |
||||
#include "UASManager.h" |
||||
#include "QGCMAVLink.h" |
||||
#include "QGCFileDialog.h" |
||||
|
||||
#include <QSettings> |
||||
|
||||
const char* CustomCommandWidgetController::_settingsKey = "CustomCommand.QmlFile"; |
||||
|
||||
CustomCommandWidgetController::CustomCommandWidgetController(void) : |
||||
_uas(NULL) |
||||
{ |
||||
_uas = UASManager::instance()->getActiveUAS(); |
||||
Q_ASSERT(_uas); |
||||
|
||||
QSettings settings; |
||||
_customQmlFile = settings.value(_settingsKey).toString(); |
||||
} |
||||
|
||||
void CustomCommandWidgetController::sendCommand(int commandId, QVariant componentId, QVariant confirm, QVariant param1, QVariant param2, QVariant param3, QVariant param4, QVariant param5, QVariant param6, QVariant param7) |
||||
{ |
||||
Q_UNUSED(commandId); |
||||
Q_UNUSED(componentId); |
||||
Q_UNUSED(confirm); |
||||
Q_UNUSED(param1); |
||||
Q_UNUSED(param2); |
||||
Q_UNUSED(param3); |
||||
Q_UNUSED(param4); |
||||
Q_UNUSED(param5); |
||||
Q_UNUSED(param6); |
||||
Q_UNUSED(param7); |
||||
_uas->executeCommand((MAV_CMD)commandId, confirm.toInt(), param1.toFloat(), param2.toFloat(), param3.toFloat(), param4.toFloat(), param5.toFloat(), param6.toFloat(), param7.toFloat(), componentId.toInt()); |
||||
} |
||||
|
||||
void CustomCommandWidgetController::selectQmlFile(void) |
||||
{ |
||||
QSettings settings; |
||||
|
||||
QString qmlFile = QGCFileDialog::getOpenFileName(NULL, "Select custom Qml file", QString(), "Qml files (*.qml)"); |
||||
if (qmlFile.isEmpty()) { |
||||
_customQmlFile.clear(); |
||||
settings.remove(_settingsKey); |
||||
} else { |
||||
_customQmlFile = QString("file:%1").arg(qmlFile); |
||||
settings.setValue(_settingsKey, _customQmlFile); |
||||
} |
||||
|
||||
emit customQmlFileChanged(_customQmlFile); |
||||
} |
||||
|
||||
void CustomCommandWidgetController::clearQmlFile(void) |
||||
{ |
||||
_customQmlFile.clear(); |
||||
QSettings settings; |
||||
settings.remove(_settingsKey); |
||||
emit customQmlFileChanged(_customQmlFile); |
||||
} |
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
|
||||
This file is part of the QGROUNDCONTROL project |
||||
|
||||
QGROUNDCONTROL 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. |
||||
|
||||
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
#ifndef CustomCommandWidgetController_H |
||||
#define CustomCommandWidgetController_H |
||||
|
||||
#include <QObject> |
||||
|
||||
#include "UASInterface.h" |
||||
#include "AutoPilotPlugin.h" |
||||
#include "UASManagerInterface.h" |
||||
|
||||
class CustomCommandWidgetController : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
CustomCommandWidgetController(void); |
||||
|
||||
Q_PROPERTY(QString customQmlFile MEMBER _customQmlFile NOTIFY customQmlFileChanged) |
||||
|
||||
Q_INVOKABLE void sendCommand(int commandId, QVariant componentId, QVariant confirm, QVariant param1, QVariant param2, QVariant param3, QVariant param4, QVariant param5, QVariant param6, QVariant param7); |
||||
Q_INVOKABLE void selectQmlFile(void); |
||||
Q_INVOKABLE void clearQmlFile(void); |
||||
|
||||
signals: |
||||
void customQmlFileChanged(const QString& customQmlFile); |
||||
|
||||
private: |
||||
UASInterface* _uas; |
||||
QString _customQmlFile; |
||||
static const char* _settingsKey; |
||||
}; |
||||
|
||||
#endif |
Loading…
Reference in new issue