Commit c6f4d7fb authored by Gus Grubba's avatar Gus Grubba

Cleaning up comm link settings

parent cafc8cee
......@@ -78,6 +78,7 @@ Item {
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
......
......@@ -36,6 +36,7 @@ public:
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)
......@@ -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,46 +17,15 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
Column {
id: _btSettings
width: parent ? parent.width : 0
height: btColumn.height
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
}
QGCLabel {
id: btLabel
text: qsTr("Bluetooth Link Settings")
}
Rectangle {
height: 1
width: btLabel.width
color: qgcPal.button
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
......@@ -160,5 +129,5 @@ Item {
}
}
}
}
}
......@@ -150,18 +150,21 @@ Rectangle {
Component {
id: commSettings
Rectangle {
id: settingsRect
color: qgcPal.window
anchors.fill: parent
property real _panelWidth: width * 0.8
Component.onCompleted: {
// If editing, create copy for editing
if(linkConfig) {
editConfig = QGroundControl.linkManager.startConfigurationEditing(linkConfig)
} else {
// Create new link configuration
if(ScreenTools.isiOS)
editConfig = QGroundControl.linkManager.createConfiguration(LinkConfiguration.TypeUdp, "Unnamed")
else
if(ScreenTools.isSerialAvailable) {
editConfig = QGroundControl.linkManager.createConfiguration(LinkConfiguration.TypeSerial, "Unnamed")
} else {
editConfig = QGroundControl.linkManager.createConfiguration(LinkConfiguration.TypeUdp, "Unnamed")
}
}
}
Component.onDestruction: {
......@@ -170,12 +173,25 @@ Rectangle {
editConfig = null
}
}
Column {
id: settingsTitle
spacing: ScreenTools.defaultFontPixelHeight * 0.5
QGCLabel {
text: linkConfig ? qsTr("Edit Link Configuration Settings") : qsTr("Create New Link Configuration")
font.pointSize: ScreenTools.mediumFontPointSize
}
Rectangle {
height: 1
width: settingsRect.width
color: qgcPal.button
}
}
QGCFlickable {
id: settingsFlick
clip: true
anchors.top: parent.top
anchors.top: settingsTitle.bottom
anchors.bottom: commButtonRow.top
width: parent.width
height: parent.height - commButtonRow.height
anchors.margins: ScreenTools.defaultFontPixelWidth
contentHeight: commSettingsColumn.height
contentWidth: _linkRoot.width
......@@ -185,20 +201,31 @@ Rectangle {
id: commSettingsColumn
width: _linkRoot.width
anchors.margins: ScreenTools.defaultFontPixelWidth
spacing: ScreenTools.defaultFontPixelHeight / 2
spacing: ScreenTools.defaultFontPixelHeight * 0.5
//-----------------------------------------------------------------
//-- General
Item {
width: _panelWidth
height: generalLabel.height
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: linkConfig ? qsTr("Edit Link Configuration Settings (WIP)") : qsTr("Create New Link Configuration (WIP)")
font.pointSize: ScreenTools.mediumFontPointSize
}
Rectangle {
height: 1
width: parent.width
color: qgcPal.button
id: generalLabel
text: qsTr("General")
font.family: ScreenTools.demiboldFontFamily
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Rectangle {
height: generalCol.height + (ScreenTools.defaultFontPixelHeight * 2)
width: _panelWidth
color: qgcPal.windowShade
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
Column {
id: generalCol
anchors.centerIn: parent
anchors.margins: ScreenTools.defaultFontPixelWidth
spacing: ScreenTools.defaultFontPixelHeight * 0.5
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
......@@ -273,9 +300,9 @@ Rectangle {
}
//-- Auto Connect on Start
QGCCheckBox {
text: "Automatically Connect on Start"
text: qsTr("Automatically Connect on Start")
checked: false
visible: editConfig ? editConfig.autoConnectAllowed : false
enabled: editConfig ? editConfig.autoConnectAllowed : false
onCheckedChanged: {
if(editConfig) {
editConfig.autoConnect = checked
......@@ -286,18 +313,59 @@ Rectangle {
checked = editConfig.autoConnect
}
}
QGCCheckBox {
text: qsTr("High Latency")
checked: false
enabled: editConfig ? editConfig.highLatencyAllowed : false
onCheckedChanged: {
if(editConfig) {
editConfig.highLatency = checked
}
}
Component.onCompleted: {
if(editConfig)
checked = editConfig.highLatency
}
}
}
}
Item {
height: ScreenTools.defaultFontPixelHeight
width: parent.width
}
//-----------------------------------------------------------------
//-- Link Specific Settings
Item {
width: _panelWidth
height: linkLabel.height
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
id: linkLabel
text: editConfig ? editConfig.settingsTitle : ""
visible: linkSettingLoader.source != ""
font.family: ScreenTools.demiboldFontFamily
}
}
Rectangle {
height: linkSettingLoader.height + (ScreenTools.defaultFontPixelHeight * 2)
width: _panelWidth
color: qgcPal.windowShade
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
Item {
height: linkSettingLoader.height
width: linkSettingLoader.width
anchors.centerIn: parent
Loader {
id: linkSettingLoader
width: parent.width
visible: false
property var subEditConfig: editConfig
}
}
}
}
}
Row {
id: commButtonRow
spacing: ScreenTools.defaultFontPixelWidth
......
......@@ -17,27 +17,14 @@ 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
QGCLabel {
text: qsTr("Log Replay Link Settings")
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
......@@ -74,5 +61,4 @@ Item {
fileDialog.visible = false
}
}
}
}
......@@ -17,11 +17,10 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
Column {
id: mockLinkSettings
width: parent ? parent.width : 0
height: mockColumn.height
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,30 +47,12 @@ 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")
checked: false
}
QGCCheckBox {
id: highLatency
text: qsTr("High latency")
checked: false
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
......@@ -123,5 +102,4 @@ Item {
exclusiveGroup: apmVehicleGroup
}
}
}
}
......@@ -17,32 +17,13 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
Column {
id: serialLinkSettings
width: parent ? parent.width : 0
height: serialColumn.height
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
function saveSettings() {
// No Need
}
Column {
id: serialColumn
width: serialLinkSettings.width
spacing: ScreenTools.defaultFontPixelHeight / 2
QGCLabel {
id: serialLabel
text: qsTr("Serial Link Settings")
}
Rectangle {
height: 1
width: serialLabel.width
color: qgcPal.button
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
......@@ -52,14 +33,13 @@ Item {
}
QGCLabel {
text: qsTr("No serial ports available");
visible: QGroundControl.linkManager.serialPortStrings.length == 0
visible: QGroundControl.linkManager.serialPortStrings.length === 0
}
QGCComboBox {
id: commPortCombo
anchors.verticalCenter: parent.verticalCenter
width: _secondColumn
visible: QGroundControl.linkManager.serialPortStrings.length > 0
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
......@@ -74,11 +54,9 @@ Item {
Component.onCompleted: {
var index
var serialPorts = [ ]
for (var i=0; i<QGroundControl.linkManager.serialPortStrings.length; i++) {
serialPorts.push(QGroundControl.linkManager.serialPortStrings[i])
}
if (subEditConfig != null) {
if (subEditConfig.portDisplayName === "" && QGroundControl.linkManager.serialPorts.length > 0) {
subEditConfig.portName = QGroundControl.linkManager.serialPorts[0]
......@@ -91,7 +69,6 @@ Item {
} else {
index = 0
}
commPortCombo.model = serialPorts
commPortCombo.currentIndex = index
}
......@@ -250,19 +227,4 @@ Item {
}
}
}
QGCCheckBox {
text: "High Latency"
checked: false
visible: editConfig ? editConfig.highLatencyAllowed : false
onCheckedChanged: {
if(editConfig) {
editConfig.highLatency = checked
}
}
Component.onCompleted: {
if(editConfig)
checked = editConfig.highLatency
}
}
}
}
......@@ -17,35 +17,16 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
Column {
id: tcpLinkSettings
width: parent ? parent.width : 0
height: tcpColumn.height
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
function saveSettings() {
if(subEditConfig) {
subEditConfig.host = hostField.text
subEditConfig.port = parseInt(portField.text)
}
}
Column {
id: tcpColumn
width: tcpLinkSettings.width
spacing: ScreenTools.defaultFontPixelHeight / 2
QGCLabel {
id: tcpLabel
text: qsTr("TCP Link Settings")
}
Rectangle {
height: 1
width: tcpLabel.width
color: qgcPal.button
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
......@@ -75,19 +56,4 @@ Item {
anchors.verticalCenter: parent.verticalCenter
}
}
QGCCheckBox {
text: "High Latency"
checked: false
visible: editConfig ? editConfig.highLatencyAllowed : false
onCheckedChanged: {
if(editConfig) {
editConfig.highLatency = checked
}
}
Component.onCompleted: {
if(editConfig)
checked = editConfig.highLatency
}
}
}
}
......@@ -17,41 +17,19 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
Column {
id: _udpSetting
width: parent ? parent.width : 0
height: udpColumn.height
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
function saveSettings() {
// No need
}
property var _currentHost: ""
Column {
id: udpColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
property string _currentHost: ""
ExclusiveGroup { id: linkGroup }
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
}
QGCLabel {
id: udpLabel
text: qsTr("UDP Link Settings")
}
Rectangle {
height: 1
width: udpLabel.width
color: qgcPal.button
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
......@@ -175,19 +153,4 @@ Item {
}
}
}
QGCCheckBox {
text: "High Latency"
checked: false
visible: editConfig ? editConfig.highLatencyAllowed : false
onCheckedChanged: {
if(editConfig) {
editConfig.highLatency = checked
}
}
Component.onCompleted: {
if(editConfig)
checked = editConfig.highLatency
}
}
}
}
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