Commit 0e63bc31 authored by Don Gagne's avatar Don Gagne

New Custom Command Widget

parent 5ae769a1
......@@ -354,6 +354,8 @@ HEADERS += \
src/ui/WaypointList.h \
src/ui/WaypointViewOnlyView.h \
src/ViewWidgets/ParameterEditorWidget.h \
src/ViewWidgets/CustomCommandWidget.h \
src/ViewWidgets/CustomCommandWidgetController.h \
src/ViewWidgets/ViewWidgetController.h \
src/Waypoint.h \
......@@ -489,6 +491,8 @@ SOURCES += \
src/ui/WaypointList.cc \
src/ui/WaypointViewOnlyView.cc \
src/ViewWidgets/ParameterEditorWidget.cc \
src/ViewWidgets/CustomCommandWidget.cc \
src/ViewWidgets/CustomCommandWidgetController.cc \
src/ViewWidgets/ViewWidgetController.cc \
src/Waypoint.cc \
......
......@@ -34,6 +34,7 @@
<file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file>
<file alias="ParameterEditorWidget.qml">src/ViewWidgets/ParameterEditorWidget.qml</file>
<file alias="CustomCommandWidget.qml">src/ViewWidgets/CustomCommandWidget.qml</file>
<file alias="SetupViewButtonsConnected.qml">src/VehicleSetup/SetupViewButtonsConnected.qml</file>
<file alias="SetupViewButtonsDisconnected.qml">src/VehicleSetup/SetupViewButtonsDisconnected.qml</file>
......
......@@ -63,6 +63,7 @@
#include "QGCLoggingCategory.h"
#include "ViewWidgetController.h"
#include "ParameterEditorController.h"
#include "CustomCommandWidgetController.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
......@@ -286,9 +287,10 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<QGCPalette>("QGroundControl.Palette", 1, 0, "QGCPalette");
qmlRegisterType<ViewWidgetController>("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController>("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
qmlRegisterType<CustomCommandWidgetController>("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
//-- Create QML Singleton Interfaces
qmlRegisterSingletonType<ScreenTools>("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory);
}
bool QGCApplication::_initForNormalAppBoot(void)
......
/*=====================================================================
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"));
}
/*=====================================================================
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
/*=====================================================================
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()
}
}
}
}
}
/*=====================================================================
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);
}
/*=====================================================================
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
\ No newline at end of file
......@@ -70,6 +70,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
#include "QGCDockWidget.h"
#include "CustomCommandWidget.h"
#ifdef UNITTEST_BUILD
#include "QmlControls/QmlTestWidget.h"
......@@ -109,6 +110,7 @@ const char* MainWindow::_uasListDockWidgetName = "UNMANNED_SYSTEM_LIST_DOCKWIDGE
const char* MainWindow::_waypointsDockWidgetName = "WAYPOINT_LIST_DOCKWIDGET";
const char* MainWindow::_mavlinkDockWidgetName = "MAVLINK_INSPECTOR_DOCKWIDGET";
const char* MainWindow::_parametersDockWidgetName = "PARAMETER_INTERFACE_DOCKWIDGET";
const char* MainWindow::_customCommandWidgetName = "CUSTOM_COMMAND_DOCKWIDGET";
const char* MainWindow::_filesDockWidgetName = "FILE_VIEW_DOCKWIDGET";
const char* MainWindow::_uasStatusDetailsDockWidgetName = "UAS_STATUS_DETAILS_DOCKWIDGET";
const char* MainWindow::_mapViewDockWidgetName = "MAP_VIEW_DOCKWIDGET";
......@@ -440,6 +442,7 @@ void MainWindow::_buildCommonWidgets(void)
{ _waypointsDockWidgetName, "Mission Plan", Qt::BottomDockWidgetArea },
{ _mavlinkDockWidgetName, "MAVLink Inspector", Qt::RightDockWidgetArea },
{ _parametersDockWidgetName, "Parameter Editor", Qt::RightDockWidgetArea },
{ _customCommandWidgetName, "Custom Command", Qt::RightDockWidgetArea },
{ _filesDockWidgetName, "Onboard Files", Qt::RightDockWidgetArea },
{ _uasStatusDetailsDockWidgetName, "Status Details", Qt::RightDockWidgetArea },
{ _mapViewDockWidgetName, "Map view", Qt::RightDockWidgetArea },
......@@ -556,6 +559,8 @@ void MainWindow::_createInnerDockWidget(const QString& widgetName)
widget = new QGCMAVLinkInspector(MAVLinkProtocol::instance(),this);
} else if (widgetName == _parametersDockWidgetName) {
widget = new ParameterEditorWidget(this);
} else if (widgetName == _customCommandWidgetName) {
widget = new CustomCommandWidget(this);
} else if (widgetName == _filesDockWidgetName) {
widget = new QGCUASFileViewMulti(this);
} else if (widgetName == _uasStatusDetailsDockWidgetName) {
......
......@@ -328,6 +328,7 @@ private:
static const char* _waypointsDockWidgetName;
static const char* _mavlinkDockWidgetName;
static const char* _parametersDockWidgetName;
static const char* _customCommandWidgetName;
static const char* _filesDockWidgetName;
static const char* _uasStatusDetailsDockWidgetName;
static const char* _mapViewDockWidgetName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment