Unverified Commit 5ab7d32c authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #7080 from mavlink/commsCleanup

Comms cleanup
parents cafc8cee c40fc59e
......@@ -69,7 +69,6 @@ QGCView {
height: generalLabel.height
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
visible: QGroundControl.settingsManager.unitsSettings.visible
QGCLabel {
id: generalLabel
text: qsTr("General")
......
......@@ -357,7 +357,7 @@ FlightMap {
// Used to show orbit status telemetry from the vehicle
QGCMapCircleVisuals {
mapControl: parent
mapCircle: _activeVehicle.orbitMapCircle
mapCircle: _activeVehicle ? _activeVehicle.orbitMapCircle : null
visible: _activeVehicle ? _activeVehicle.orbitActive : false
}
......@@ -396,7 +396,7 @@ FlightMap {
onClicked: {
if (guidedActionsController.guidedUIVisible || (!guidedActionsController.showGotoLocation && !guidedActionsController.showOrbit)) {
return
}
}
orbitMapCircle.hide()
gotoLocationItem.hide()
var clickCoord = flightMap.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */)
......
......@@ -22,9 +22,9 @@ import QGroundControl.FlightMap 1.0
Item {
id: _root
property var mapControl ///< Map control to place item in
property var mapCircle ///< QGCMapCircle object
property bool interactive: mapCircle.interactive /// true: user can manipulate polygon
property var mapControl ///< Map control to place item in
property var mapCircle ///< QGCMapCircle object
property bool interactive: mapCircle ? mapCircle.interactive : 0 /// true: user can manipulate polygon
property color interiorColor: "transparent"
property real interiorOpacity: 1
property int borderWidth: 2
......@@ -34,7 +34,7 @@ Item {
property var _topRotationIndicatorComponent
property var _bottomRotationIndicatorComponent
property var _dragHandlesComponent
property real _radius: mapCircle.radius.rawValue
property real _radius: mapCircle ? mapCircle.radius.rawValue : 0
function addVisuals() {
if (!_circleComponent) {
......
......@@ -69,18 +69,19 @@ Item {
return Screen.pixelDensity
}
property bool isAndroid: ScreenToolsController.isAndroid
property bool isiOS: ScreenToolsController.isiOS
property bool isMobile: ScreenToolsController.isMobile
property bool isWindows: ScreenToolsController.isWindows
property bool isDebug: ScreenToolsController.isDebug
property bool isMac: ScreenToolsController.isMacOS
property bool isTinyScreen: (Screen.width / realPixelDensity) < 120 // 120mm
property bool isShortScreen: ScreenToolsController.isMobile && ((Screen.height / Screen.width) < 0.6) // Nexus 7 for example
property bool isHugeScreen: (Screen.width / realPixelDensity) >= (23.5 * 25.4) // 27" monitor
readonly property real minTouchMillimeters: 10 ///< Minimum touch size in millimeters
property real minTouchPixels: 0 ///< Minimum touch size in pixels
property bool isAndroid: ScreenToolsController.isAndroid
property bool isiOS: ScreenToolsController.isiOS
property bool isMobile: ScreenToolsController.isMobile
property bool isWindows: ScreenToolsController.isWindows
property bool isDebug: ScreenToolsController.isDebug
property bool isMac: ScreenToolsController.isMacOS
property bool isTinyScreen: (Screen.width / realPixelDensity) < 120 // 120mm
property bool isShortScreen: ScreenToolsController.isMobile && ((Screen.height / Screen.width) < 0.6) // Nexus 7 for example
property bool isHugeScreen: (Screen.width / realPixelDensity) >= (23.5 * 25.4) // 27" monitor
property bool isSerialAvailable: ScreenToolsController.isSerialAvailable
readonly property real minTouchMillimeters: 10 ///< Minimum touch size in millimeters
property real minTouchPixels: 0 ///< Minimum touch size in pixels
// The implicit heights/widths for our custom control set
property real implicitButtonWidth: Math.round(defaultFontPixelWidth * (isMobile ? 7.0 : 5.0))
......
......@@ -29,15 +29,16 @@ class ScreenToolsController : public QQuickItem
public:
ScreenToolsController();
Q_PROPERTY(bool isAndroid READ isAndroid CONSTANT)
Q_PROPERTY(bool isiOS READ isiOS CONSTANT)
Q_PROPERTY(bool isMobile READ isMobile CONSTANT)
Q_PROPERTY(bool isDebug READ isDebug CONSTANT)
Q_PROPERTY(bool isMacOS READ isMacOS CONSTANT)
Q_PROPERTY(bool isLinux READ isLinux CONSTANT)
Q_PROPERTY(bool isWindows READ isWindows CONSTANT)
Q_PROPERTY(QString iOSDevice READ iOSDevice CONSTANT)
Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily CONSTANT)
Q_PROPERTY(bool isAndroid READ isAndroid CONSTANT)
Q_PROPERTY(bool isiOS READ isiOS CONSTANT)
Q_PROPERTY(bool isMobile READ isMobile CONSTANT)
Q_PROPERTY(bool isDebug READ isDebug CONSTANT)
Q_PROPERTY(bool isMacOS READ isMacOS CONSTANT)
Q_PROPERTY(bool isLinux READ isLinux CONSTANT)
Q_PROPERTY(bool isWindows READ isWindows CONSTANT)
Q_PROPERTY(bool isSerialAvailable READ isSerialAvailable CONSTANT)
Q_PROPERTY(QString iOSDevice READ iOSDevice CONSTANT)
Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily CONSTANT)
// Returns current mouse position
Q_INVOKABLE int mouseX(void) { return QCursor::pos().x(); }
......@@ -87,6 +88,12 @@ public:
bool isWindows () { return false; }
#endif
#if defined(NO_SERIAL_LINK)
bool isSerialAvailable () { return false; }
#else
bool isSerialAvailable () { return true; }
#endif
#ifdef QT_DEBUG
bool isDebug () { return true; }
#else
......
......@@ -26,6 +26,7 @@
#include <QtBluetooth/QBluetoothUuid>
#include <QtBluetooth/QBluetoothSocket>
#include "QGCApplication.h"
#include "BluetoothLink.h"
#include "QGC.h"
......@@ -33,9 +34,9 @@ BluetoothLink::BluetoothLink(SharedLinkConfigurationPointer& config)
: LinkInterface(config)
, _config(qobject_cast<BluetoothConfiguration*>(config.data()))
, _connectState(false)
, _targetSocket(NULL)
, _targetSocket(nullptr)
#ifdef __ios__
, _discoveryAgent(NULL)
, _discoveryAgent(nullptr)
#endif
, _shutDown(false)
{
......@@ -50,7 +51,7 @@ BluetoothLink::~BluetoothLink()
_shutDown = true;
_discoveryAgent->stop();
_discoveryAgent->deleteLater();
_discoveryAgent = NULL;
_discoveryAgent = nullptr;
}
#endif
}
......@@ -104,13 +105,13 @@ void BluetoothLink::_disconnect(void)
_shutDown = true;
_discoveryAgent->stop();
_discoveryAgent->deleteLater();
_discoveryAgent = NULL;
_discoveryAgent = nullptr;
}
#endif
if(_targetSocket)
{
_targetSocket->deleteLater();
_targetSocket = NULL;
_targetSocket = nullptr;
emit disconnected();
}
_connectState = false;
......@@ -129,7 +130,7 @@ bool BluetoothLink::_hardwareConnect()
_shutDown = true;
_discoveryAgent->stop();
_discoveryAgent->deleteLater();
_discoveryAgent = NULL;
_discoveryAgent = nullptr;
}
_discoveryAgent = new QBluetoothServiceDiscoveryAgent(this);
QObject::connect(_discoveryAgent, &QBluetoothServiceDiscoveryAgent::serviceDiscovered, this, &BluetoothLink::serviceDiscovered);
......@@ -149,7 +150,7 @@ void BluetoothLink::_createSocket()
if(_targetSocket)
{
delete _targetSocket;
_targetSocket = NULL;
_targetSocket = nullptr;
}
_targetSocket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this);
QObject::connect(_targetSocket, &QBluetoothSocket::connected, this, &BluetoothLink::deviceConnected);
......@@ -182,7 +183,7 @@ void BluetoothLink::discoveryFinished()
{
_shutDown = true;
_discoveryAgent->deleteLater();
_discoveryAgent = NULL;
_discoveryAgent = nullptr;
if(!_targetSocket)
{
_connectState = false;
......@@ -236,14 +237,14 @@ qint64 BluetoothLink::getCurrentOutDataRate() const
BluetoothConfiguration::BluetoothConfiguration(const QString& name)
: LinkConfiguration(name)
, _deviceDiscover(NULL)
, _deviceDiscover(nullptr)
{
}
BluetoothConfiguration::BluetoothConfiguration(BluetoothConfiguration* source)
: LinkConfiguration(source)
, _deviceDiscover(NULL)
, _deviceDiscover(nullptr)
, _device(source->device())
{
}
......@@ -257,11 +258,20 @@ BluetoothConfiguration::~BluetoothConfiguration()
}
}
QString BluetoothConfiguration::settingsTitle()
{
if(qgcApp()->toolbox()->linkManager()->isBluetoothAvailable()) {
return tr("Bluetooth Link Settings");
} else {
return tr("Bluetooth Not Available");
}
}
void BluetoothConfiguration::copyFrom(LinkConfiguration *source)
{
LinkConfiguration::copyFrom(source);
BluetoothConfiguration* usource = dynamic_cast<BluetoothConfiguration*>(source);
Q_ASSERT(usource != NULL);
Q_ASSERT(usource != nullptr);
_device = usource->device();
}
......@@ -306,7 +316,7 @@ void BluetoothConfiguration::stopScan()
{
_deviceDiscover->stop();
_deviceDiscover->deleteLater();
_deviceDiscover = NULL;
_deviceDiscover = nullptr;
emit scanningChanged();
}
}
......@@ -366,7 +376,7 @@ void BluetoothConfiguration::doneScanning()
if(_deviceDiscover)
{
_deviceDiscover->deleteLater();
_deviceDiscover = NULL;
_deviceDiscover = nullptr;
emit scanningChanged();
}
}
......
......@@ -104,6 +104,7 @@ public:
void saveSettings (QSettings& settings, const QString& root);
void updateSettings ();
QString settingsURL () { return "BluetoothSettings.qml"; }
QString settingsTitle ();
public slots:
void deviceDiscovered (QBluetoothDeviceInfo info);
......
......@@ -31,6 +31,7 @@ public:
Q_PROPERTY(bool autoConnect READ isAutoConnect WRITE setAutoConnect NOTIFY autoConnectChanged)
Q_PROPERTY(bool autoConnectAllowed READ isAutoConnectAllowed CONSTANT)
Q_PROPERTY(QString settingsURL READ settingsURL CONSTANT)
Q_PROPERTY(QString settingsTitle READ settingsTitle CONSTANT)
Q_PROPERTY(bool highLatency READ isHighLatency WRITE setHighLatency NOTIFY highLatencyChanged)
Q_PROPERTY(bool highLatencyAllowed READ isHighLatencyAllowed CONSTANT)
......@@ -146,7 +147,14 @@ public:
*
* Pure virtual method providing the URL for the (QML) settings dialog
*/
virtual QString settingsURL() = 0;
virtual QString settingsURL () = 0;
/*!
* @brief Settings Title
*
* Pure virtual method providing the Title for the (QML) settings dialog
*/
virtual QString settingsTitle () = 0;
/*!
* @brief Update settings
......
......@@ -40,6 +40,7 @@ public:
void saveSettings (QSettings& settings, const QString& root);
void updateSettings ();
QString settingsURL () { return "LogReplaySettings.qml"; }
QString settingsTitle () { return tr("Log Replay Link Settings"); }
signals:
void fileNameChanged();
......
......@@ -70,6 +70,7 @@ public:
void saveSettings (QSettings& settings, const QString& root);
void updateSettings (void);
QString settingsURL () { return "MockLinkSettings.qml"; }
QString settingsTitle () { return tr("Mock Link Settings"); }
signals:
void firmwareChanged ();
......
......@@ -90,6 +90,7 @@ public:
void saveSettings (QSettings& settings, const QString& root);
void updateSettings ();
QString settingsURL () { return "SerialSettings.qml"; }
QString settingsTitle () { return tr("Serial Link Settings"); }
signals:
void baudChanged ();
......
......@@ -101,6 +101,7 @@ public:
void saveSettings (QSettings& settings, const QString& root);
void updateSettings ();
QString settingsURL () { return "TcpSettings.qml"; }
QString settingsTitle () { return tr("TCP Link Settings"); }
signals:
void portChanged();
......
......@@ -127,6 +127,7 @@ public:
bool isAutoConnectAllowed () { return true; }
bool isHighLatencyAllowed () { return true; }
QString settingsURL () { return "UdpSettings.qml"; }
QString settingsTitle () { return tr("UDP Link Settings"); }
signals:
void localPortChanged ();
......
......@@ -17,143 +17,111 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
id: _btSettings
width: parent ? parent.width : 0
height: btColumn.height
Column {
id: _btSettings
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.linkManager.isBluetoothAvailable
function saveSettings() {
// No need
}
QGCLabel {
text: qsTr("Bluetooth Not Available")
visible: !QGroundControl.linkManager.isBluetoothAvailable
anchors.centerIn: parent
}
Column {
id: btColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
visible: QGroundControl.linkManager.isBluetoothAvailable
ExclusiveGroup { id: linkGroup }
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
}
ExclusiveGroup { id: linkGroup }
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
id: btLabel
text: qsTr("Bluetooth Link Settings")
text: qsTr("Device:")
width: _firstColumn
}
Rectangle {
height: 1
width: btLabel.width
color: qgcPal.button
QGCLabel {
id: deviceField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.devName : ""
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Row {
visible: !ScreenTools.isiOS
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Address:")
width: _firstColumn
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Device:")
width: _firstColumn
}
QGCLabel {
id: deviceField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.devName : ""
}
QGCLabel {
id: addressField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.address : ""
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
QGCLabel {
text: qsTr("Bluetooth Devices:")
}
Item {
width: hostRow.width
height: hostRow.height
Row {
visible: !ScreenTools.isiOS
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Address:")
id: hostRow
spacing: ScreenTools.defaultFontPixelWidth
Item {
height: 1
width: _firstColumn
}
QGCLabel {
id: addressField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.address : ""
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
QGCLabel {
text: qsTr("Bluetooth Devices:")
}
Item {
width: hostRow.width
height: hostRow.height
Row {
id: hostRow
spacing: ScreenTools.defaultFontPixelWidth
Item {
height: 1
width: _firstColumn
Column {
id: hostColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
Rectangle {
height: 1
width: _secondColumn
color: qgcPal.button
visible: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && subEditConfig.nameList.length > 0
}
Column {
id: hostColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
Rectangle {
height: 1
width: _secondColumn
color: qgcPal.button
visible: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && subEditConfig.nameList.length > 0
Repeater {
model: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.nameList : ""
delegate:
QGCButton {
text: modelData
width: _secondColumn
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
exclusiveGroup: linkGroup
onClicked: {
checked = true
if(subEditConfig && modelData !== "")
subEditConfig.devName = modelData
}
}
Repeater {
model: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.nameList : ""
delegate:
}
Rectangle {
height: 1
width: _secondColumn
color: qgcPal.button
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Item {
width: _secondColumn
height: udpButtonRow.height
Row {
id: udpButtonRow
spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCButton {
text: modelData
width: _secondColumn
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
exclusiveGroup: linkGroup
width: ScreenTools.defaultFontPixelWidth * 10
text: qsTr("Scan")
enabled: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && !subEditConfig.scanning
onClicked: {
checked = true
if(subEditConfig && modelData !== "")
subEditConfig.devName = modelData
if(subEditConfig)
subEditConfig.startScan()
}
}
}
Rectangle {
height: 1
width: _secondColumn
color: qgcPal.button
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Item {
width: _secondColumn
height: udpButtonRow.height
Row {
id: udpButtonRow
spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCButton {
width: ScreenTools.defaultFontPixelWidth * 10
text: qsTr("Scan")
enabled: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && !subEditConfig.scanning
onClicked: {
if(subEditConfig)
subEditConfig.startScan()
}
}
QGCButton {
width: ScreenTools.defaultFontPixelWidth * 10
text: qsTr("Stop")
enabled: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && subEditConfig.scanning
onClicked: {
if(subEditConfig)
subEditConfig.stopScan()
}
QGCButton {
width: ScreenTools.defaultFontPixelWidth * 10
text: qsTr("Stop")
enabled: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && subEditConfig.scanning
onClicked: {
if(subEditConfig)
subEditConfig.stopScan()
}
}
}
......@@ -162,3 +130,4 @@ Item {
}
}
}
This diff is collapsed.
......@@ -17,62 +17,48 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
width: parent ? parent.width : 0
height: logColumn.height
Column {
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
function saveSettings() {
if(subEditConfig) {
subEditConfig.filename = logField.text
}
}
Column {
id: logColumn
width: parent.width
spacing: ScreenTools.defaultFontPixelHeight / 2
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Log Replay Link Settings")
text: qsTr("Log File:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
QGCTextField {
id: logField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeLogReplay ? subEditConfig.fileName : ""
width: _secondColumn
anchors.verticalCenter: parent.verticalCenter
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Log File:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCTextField {
id: logField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeLogReplay ? subEditConfig.fileName : ""
width: _secondColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCButton {
text: qsTr("Browse")
onClicked: {
fileDialog.visible = true
}
QGCButton {
text: qsTr("Browse")
onClicked: {
fileDialog.visible = true
}
}
FileDialog {
id: fileDialog
title: qsTr("Please choose a file")
folder: shortcuts.home
visible: false
selectExisting: true
onAccepted: {
if(subEditConfig) {
subEditConfig.fileName = fileDialog.fileUrl.toString().replace("file://", "")
}
fileDialog.visible = false
}
onRejected: {
fileDialog.visible = false
}
FileDialog {
id: fileDialog
title: qsTr("Please choose a file")
folder: shortcuts.home
visible: false
selectExisting: true
onAccepted: {
if(subEditConfig) {
subEditConfig.fileName = fileDialog.fileUrl.toString().replace("file://", "")
}
fileDialog.visible = false
}
onRejected: {
fileDialog.visible = false
}
}
}
......@@ -17,11 +17,10 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
id: mockLinkSettings
width: parent ? parent.width : 0
height: mockColumn.height
Column {
id: mockLinkSettings
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
function saveSettings() {
if(px4Firmware.checked)
subEditConfig.firmware = 12 // Hardcoded MAV_AUTOPILOT_PX4
......@@ -35,9 +34,7 @@ Item {
else
subEditConfig.firmware = 0
subEditConfig.sendStatus = sendStatus.checked
subEditConfig.highLatency = highLatency.checked
}
Component.onCompleted: {
if(subEditConfig.firmware === 12) // Hardcoded MAV_AUTOPILOT_PX4
px4Firmware.checked = true
......@@ -50,78 +47,59 @@ Item {
else
copterVehicle.checked = true
sendStatus.checked = subEditConfig.sendStatus
highLatency.checked = subEditConfig.highLatency
}
Column {
id: mockColumn
width: mockLinkSettings.width
spacing: ScreenTools.defaultFontPixelHeight / 2
QGCLabel {
text: qsTr("Mock Link Settings")
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
QGCCheckBox {
id: sendStatus
text: qsTr("Send Status Text and Voice")
QGCCheckBox {
id: sendStatus
text: qsTr("Send Status Text and Voice")
checked: false
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
ColumnLayout {
ExclusiveGroup { id: autoPilotGroup }