Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
431c2442
Commit
431c2442
authored
Apr 29, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New Custom Command Widget
parent
97568cf4
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
324 additions
and
0 deletions
+324
-0
QGCApplication.pro
QGCApplication.pro
+4
-0
qgroundcontrol.qrc
qgroundcontrol.qrc
+1
-0
QGCApplication.cc
src/QGCApplication.cc
+2
-0
CustomCommandWidget.cc
src/ViewWidgets/CustomCommandWidget.cc
+30
-0
CustomCommandWidget.h
src/ViewWidgets/CustomCommandWidget.h
+40
-0
CustomCommandWidget.qml
src/ViewWidgets/CustomCommandWidget.qml
+106
-0
CustomCommandWidgetController.cc
src/ViewWidgets/CustomCommandWidgetController.cc
+80
-0
CustomCommandWidgetController.h
src/ViewWidgets/CustomCommandWidgetController.h
+55
-0
MainWindow.cc
src/ui/MainWindow.cc
+5
-0
MainWindow.h
src/ui/MainWindow.h
+1
-0
No files found.
QGCApplication.pro
View file @
431c2442
...
...
@@ -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
\
...
...
qgroundcontrol.qrc
View file @
431c2442
...
...
@@ -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>
...
...
src/QGCApplication.cc
View file @
431c2442
...
...
@@ -63,6 +63,7 @@
#include "QGCLoggingCategory.h"
#include "ViewWidgetController.h"
#include "ParameterEditorController.h"
#include "CustomCommandWidgetController.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
...
...
@@ -275,6 +276,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterType
<
ScreenTools
>
(
"QGroundControl.ScreenTools"
,
1
,
0
,
"ScreenTools"
);
qmlRegisterType
<
ViewWidgetController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ViewWidgetController"
);
qmlRegisterType
<
ParameterEditorController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"ParameterEditorController"
);
qmlRegisterType
<
CustomCommandWidgetController
>
(
"QGroundControl.Controllers"
,
1
,
0
,
"CustomCommandWidgetController"
);
}
bool
QGCApplication
::
_initForNormalAppBoot
(
void
)
...
...
src/ViewWidgets/CustomCommandWidget.cc
0 → 100644
View file @
431c2442
/*=====================================================================
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"
));
}
src/ViewWidgets/CustomCommandWidget.h
0 → 100644
View file @
431c2442
/*=====================================================================
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
src/ViewWidgets/CustomCommandWidget.qml
0 → 100644
View file @
431c2442
/*=====================================================================
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
()
}
}
}
}
}
src/ViewWidgets/CustomCommandWidgetController.cc
0 → 100644
View file @
431c2442
/*=====================================================================
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
);
}
src/ViewWidgets/CustomCommandWidgetController.h
0 → 100644
View file @
431c2442
/*=====================================================================
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
src/ui/MainWindow.cc
View file @
431c2442
...
...
@@ -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
)
{
...
...
src/ui/MainWindow.h
View file @
431c2442
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment