|
|
@ -24,87 +24,89 @@ along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
/// @file |
|
|
|
/// @file |
|
|
|
/// @author Don Gagne <don@thegagnes.com> |
|
|
|
/// @author Don Gagne <don@thegagnes.com> |
|
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.2 |
|
|
|
import QtQuick 2.5 |
|
|
|
|
|
|
|
import QtQuick.Controls 1.2 |
|
|
|
import QGroundControl.Palette 1.0 |
|
|
|
import QtQuick.Controls.Styles 1.2 |
|
|
|
import QGroundControl.Controls 1.0 |
|
|
|
import QtQuick.Dialogs 1.2 |
|
|
|
import QGroundControl.Controllers 1.0 |
|
|
|
|
|
|
|
|
|
|
|
import QGroundControl.Palette 1.0 |
|
|
|
ViewWidget { |
|
|
|
import QGroundControl.Controls 1.0 |
|
|
|
connectedComponent: commandComponenet |
|
|
|
import QGroundControl.Controllers 1.0 |
|
|
|
|
|
|
|
import QGroundControl.ScreenTools 1.0 |
|
|
|
Component { |
|
|
|
|
|
|
|
id: commandComponenet |
|
|
|
QGCView { |
|
|
|
|
|
|
|
viewPanel: panel |
|
|
|
Item { |
|
|
|
|
|
|
|
id: bogusFactPanel |
|
|
|
property real _margins: ScreenTools.defaultFontPixelHeight |
|
|
|
|
|
|
|
property string _emptyText: "<p>" + |
|
|
|
// We aren't really using the controller in a FactPanel for this usage so we |
|
|
|
"You can create your own commands and parameter editing user interface in this widget. " + |
|
|
|
// pass in a bogus item to keep it from getting upset. |
|
|
|
"You do this by providing your own Qml file. " + |
|
|
|
CustomCommandWidgetController { id: controller; factPanel: bogusFactPanel } |
|
|
|
"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. " + |
|
|
|
Item { |
|
|
|
"Doing so incorrectly may cause instability both in QGroundControl and/or your vehicle. " + |
|
|
|
anchors.top: parent.top |
|
|
|
"So make sure to test your changes thoroughly before using them in flight.</p>" + |
|
|
|
anchors.bottom: buttonRow.top |
|
|
|
"<p>Click 'Load Custom Qml file' to provide your custom qml file.</p>" + |
|
|
|
width: parent.width |
|
|
|
"<p>Click 'Reset' to reset to none.</p>" + |
|
|
|
|
|
|
|
"<p>Example usage: http://www.qgroundcontrol.org/custom_command_qml_widgets</p>" |
|
|
|
QGCLabel { |
|
|
|
|
|
|
|
id: errorOutput |
|
|
|
QGCPalette { id: qgcPal; colorGroupEnabled: enabled } |
|
|
|
anchors.fill: parent |
|
|
|
CustomCommandWidgetController { id: controller; factPanel: panel } |
|
|
|
wrapMode: Text.WordWrap |
|
|
|
|
|
|
|
visible: false |
|
|
|
QGCViewPanel { |
|
|
|
} |
|
|
|
id: panel |
|
|
|
|
|
|
|
anchors.fill: parent |
|
|
|
QGCLabel { |
|
|
|
Rectangle { |
|
|
|
id: warning |
|
|
|
anchors.fill: parent |
|
|
|
anchors.fill: parent |
|
|
|
color: qgcPal.window |
|
|
|
wrapMode: Text.WordWrap |
|
|
|
QGCLabel { |
|
|
|
visible: !controller.customQmlFile |
|
|
|
id: textOutput |
|
|
|
text: "You can create your own commands and parameter editing user interface in this widget. " + |
|
|
|
anchors.margins: _margins |
|
|
|
"You do this by providing your own Qml file. " + |
|
|
|
anchors.left: parent.left |
|
|
|
"This support is a work in progress and the details may change somewhat in the future. " + |
|
|
|
anchors.right: parent.right |
|
|
|
"By using this feature you are connecting directly to the internals of QGroundControl. " + |
|
|
|
anchors.top: parent.top |
|
|
|
"Doing so incorrectly may cause instability both in QGroundControl and/or your vehicle. " + |
|
|
|
anchors.bottom: buttonRow.top |
|
|
|
"So make sure to test your changes thoroughly before using them in flight.\n\n" + |
|
|
|
wrapMode: Text.WordWrap |
|
|
|
"Click 'Select Qml file' to provide your custom qml file.\n" + |
|
|
|
textFormat: Text.RichText |
|
|
|
"Click 'Clear Qml file' to reset to none.\n" + |
|
|
|
text: _emptyText |
|
|
|
"Example usage: http://www.qgroundcontrol.org/custom_command_qml_widgets" |
|
|
|
visible: !loader.visible |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Loader { |
|
|
|
Loader { |
|
|
|
id: loader |
|
|
|
id: loader |
|
|
|
anchors.margins: _margins |
|
|
|
anchors.fill: parent |
|
|
|
anchors.left: parent.left |
|
|
|
source: controller.customQmlFile |
|
|
|
anchors.right: parent.right |
|
|
|
visible: controller.customQmlFile |
|
|
|
anchors.top: parent.top |
|
|
|
|
|
|
|
anchors.bottom: buttonRow.top |
|
|
|
onStatusChanged: { |
|
|
|
source: controller.customQmlFile |
|
|
|
if (loader.status == Loader.Error) { |
|
|
|
visible: false |
|
|
|
if (sourceComponent.status == Component.Error) { |
|
|
|
onStatusChanged: { |
|
|
|
errorOutput.text = sourceComponent.errorString() |
|
|
|
loader.visible = true |
|
|
|
errorOutput.visible = true |
|
|
|
if (loader.status == Loader.Error) { |
|
|
|
loader.visible = false |
|
|
|
if (sourceComponent.status == Component.Error) { |
|
|
|
} |
|
|
|
textOutput.text = sourceComponent.errorString() |
|
|
|
|
|
|
|
loader.visible = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Row { |
|
|
|
Row { |
|
|
|
id: buttonRow |
|
|
|
id: buttonRow |
|
|
|
spacing: 10 |
|
|
|
spacing: ScreenTools.defaultFontPixelWidth |
|
|
|
anchors.bottom: parent.bottom |
|
|
|
anchors.margins: _margins |
|
|
|
|
|
|
|
anchors.bottom: parent.bottom |
|
|
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter |
|
|
|
QGCButton { |
|
|
|
QGCButton { |
|
|
|
text: "Select Qml file..." |
|
|
|
text: "Load Custom Qml file..." |
|
|
|
|
|
|
|
width: ScreenTools.defaultFontPixelWidth * 22 |
|
|
|
onClicked: controller.selectQmlFile() |
|
|
|
onClicked: controller.selectQmlFile() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QGCButton { |
|
|
|
QGCButton { |
|
|
|
text: "Clear Qml file" |
|
|
|
text: "Reset" |
|
|
|
|
|
|
|
width: ScreenTools.defaultFontPixelWidth * 22 |
|
|
|
onClicked: { |
|
|
|
onClicked: { |
|
|
|
errorOutput.visible = false |
|
|
|
|
|
|
|
controller.clearQmlFile() |
|
|
|
controller.clearQmlFile() |
|
|
|
|
|
|
|
loader.visible = false |
|
|
|
|
|
|
|
textOutput.text = _emptyText |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|