Commit c6f4d7fb authored by Gus Grubba's avatar Gus Grubba

Cleaning up comm link settings

parent cafc8cee
......@@ -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 {
}
}
}
......@@ -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,116 +201,168 @@ Rectangle {
id: commSettingsColumn
width: _linkRoot.width
anchors.margins: ScreenTools.defaultFontPixelWidth
spacing: ScreenTools.defaultFontPixelHeight / 2
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
}
spacing: ScreenTools.defaultFontPixelHeight * 0.5
//-----------------------------------------------------------------
//-- General
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
width: _panelWidth
height: generalLabel.height
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: qsTr("Name:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCTextField {
id: nameField
text: editConfig ? editConfig.name : ""
width: _secondColumn
anchors.verticalCenter: parent.verticalCenter
id: generalLabel
text: qsTr("General")
font.family: ScreenTools.demiboldFontFamily
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Type:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
//-----------------------------------------------------
// When editing, you can't change the link type
QGCLabel {
text: linkConfig ? QGroundControl.linkManager.linkTypeStrings[linkConfig.linkType] : ""
visible: linkConfig != null
width: _secondColumn
anchors.verticalCenter: parent.verticalCenter
Component.onCompleted: {
if(linkConfig != null) {
linkSettingLoader.source = linkConfig.settingsURL
linkSettingLoader.visible = true
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 {
text: qsTr("Name:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCTextField {
id: nameField
text: editConfig ? editConfig.name : ""
width: _secondColumn
anchors.verticalCenter: parent.verticalCenter
}
}
}
//-----------------------------------------------------
// When creating, select a link type
QGCComboBox {
id: linkTypeCombo
width: _secondColumn
visible: linkConfig == null
model: QGroundControl.linkManager.linkTypeStrings
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1 && index !== editConfig.linkType) {
// Destroy current panel
linkSettingLoader.source = ""
linkSettingLoader.visible = false
// Save current name
var name = editConfig.name
// Discard link configuration (old type)
QGroundControl.linkManager.cancelConfigurationEditing(editConfig)
// Create new link configuration
editConfig = QGroundControl.linkManager.createConfiguration(index, name)
// Load appropriate configuration panel
linkSettingLoader.source = editConfig.settingsURL
linkSettingLoader.visible = true
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Type:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
//-----------------------------------------------------
// When editing, you can't change the link type
QGCLabel {
text: linkConfig ? QGroundControl.linkManager.linkTypeStrings[linkConfig.linkType] : ""
visible: linkConfig != null
width: _secondColumn
anchors.verticalCenter: parent.verticalCenter
Component.onCompleted: {
if(linkConfig != null) {
linkSettingLoader.source = linkConfig.settingsURL
linkSettingLoader.visible = true
}
}
}
//-----------------------------------------------------
// When creating, select a link type
QGCComboBox {
id: linkTypeCombo
width: _secondColumn
visible: linkConfig == null
model: QGroundControl.linkManager.linkTypeStrings
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1 && index !== editConfig.linkType) {
// Destroy current panel
linkSettingLoader.source = ""
linkSettingLoader.visible = false
// Save current name
var name = editConfig.name
// Discard link configuration (old type)
QGroundControl.linkManager.cancelConfigurationEditing(editConfig)
// Create new link configuration
editConfig = QGroundControl.linkManager.createConfiguration(index, name)
// Load appropriate configuration panel
linkSettingLoader.source = editConfig.settingsURL
linkSettingLoader.visible = true
}
}
Component.onCompleted: {
if(linkConfig == null) {
linkTypeCombo.currentIndex = 0
linkSettingLoader.source = editConfig.settingsURL
linkSettingLoader.visible = true
}
}
}
}
Item {
height: ScreenTools.defaultFontPixelHeight * 0.5
width: parent.width
}
Component.onCompleted: {
if(linkConfig == null) {
linkTypeCombo.currentIndex = 0
linkSettingLoader.source = editConfig.settingsURL
linkSettingLoader.visible = true
//-- Auto Connect on Start
QGCCheckBox {
text: qsTr("Automatically Connect on Start")
checked: false
enabled: editConfig ? editConfig.autoConnectAllowed : false
onCheckedChanged: {
if(editConfig) {
editConfig.autoConnect = checked
}
}
Component.onCompleted: {
if(editConfig)
checked = editConfig.autoConnect
}
}
}
}
Item {
height: ScreenTools.defaultFontPixelHeight * 0.5
width: parent.width
}
//-- Auto Connect on Start
QGCCheckBox {
text: "Automatically Connect on Start"
checked: false
visible: editConfig ? editConfig.autoConnectAllowed : false
onCheckedChanged: {
if(editConfig) {
editConfig.autoConnect = checked
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
}
}
}
Component.onCompleted: {
if(editConfig)
checked = editConfig.autoConnect
}
}
Item {
height: ScreenTools.defaultFontPixelHeight
width: parent.width
}
Loader {
id: linkSettingLoader
width: parent.width
visible: false
property var subEditConfig: editConfig
//-----------------------------------------------------------------
//-- 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
visible: false
property var subEditConfig: editConfig
}
}
}
}
}
......
......@@ -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 }
QGCRadioButton {
id: px4Firmware
text: qsTr("PX4 Firmware")
checked: false
exclusiveGroup: autoPilotGroup
}
QGCCheckBox {
id: highLatency
text: qsTr("High latency")
QGCRadioButton {
id: apmFirmware
text: qsTr("APM Firmware")
checked: false
exclusiveGroup: autoPilotGroup
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
ColumnLayout {
ExclusiveGroup { id: autoPilotGroup }
QGCRadioButton {
id: px4Firmware
text: qsTr("PX4 Firmware")
checked: false
exclusiveGroup: autoPilotGroup
}
QGCRadioButton {
id: apmFirmware
text: qsTr("APM Firmware")
checked: false
exclusiveGroup: autoPilotGroup
}
QGCRadioButton {
id: genericFirmware
text: qsTr("Generic Firmware")
checked: false
exclusiveGroup: autoPilotGroup
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
QGCRadioButton {
id: genericFirmware
text: qsTr("Generic Firmware")
checked: false
exclusiveGroup: autoPilotGroup
}
QGCLabel {
text: qsTr("APM Vehicle Type")
visible: apmFirmware.checked
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
QGCLabel {
text: qsTr("APM Vehicle Type")
visible: apmFirmware.checked
}
ColumnLayout {
visible: apmFirmware.checked
ExclusiveGroup { id: apmVehicleGroup }
QGCRadioButton {
id: copterVehicle
text: qsTr("ArduCopter")
checked: false
exclusiveGroup: apmVehicleGroup
}
ColumnLayout {
visible: apmFirmware.checked
ExclusiveGroup { id: apmVehicleGroup }
QGCRadioButton {
id: copterVehicle
text: qsTr("ArduCopter")
checked: false
exclusiveGroup: apmVehicleGroup
}
QGCRadioButton {
id: planeVehicle
text: qsTr("ArduPlane")
checked: false
exclusiveGroup: apmVehicleGroup
}
QGCRadioButton {
id: planeVehicle
text: qsTr("ArduPlane")
checked: false
exclusiveGroup: apmVehicleGroup
}
}
}
......@@ -17,251 +17,213 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
id: serialLinkSettings
width: parent ? parent.width : 0
height: serialColumn.height
Column {
id: serialLinkSettings
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
function saveSettings() {
// No Need
}
Column {
id: serialColumn
width: serialLinkSettings.width
spacing: ScreenTools.defaultFontPixelHeight / 2
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
id: serialLabel
text: qsTr("Serial Link Settings")
text: qsTr("Serial Port:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
Rectangle {
height: 1
width: serialLabel.width
color: qgcPal.button
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
QGCLabel {
text: qsTr("No serial ports available");
visible: QGroundControl.linkManager.serialPortStrings.length === 0
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Serial Port:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCLabel {
text: qsTr("No serial ports available");
visible: QGroundControl.linkManager.serialPortStrings.length == 0
}
QGCComboBox {
id: commPortCombo
anchors.verticalCenter: parent.verticalCenter
width: _secondColumn
visible: QGroundControl.linkManager.serialPortStrings.length > 0
QGCComboBox {
id: commPortCombo
width: _secondColumn
visible: QGroundControl.linkManager.serialPortStrings.length > 0
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
if (index >= QGroundControl.linkManager.serialPortStrings.length) {
// This item was adding at the end, must use added text as name
subEditConfig.portName = commPortCombo.textAt(index)
} else {
subEditConfig.portName = QGroundControl.linkManager.serialPorts[index]
}
}
}
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]
}
index = serialPorts.indexOf(subEditConfig.portDisplayName)
if (index === -1) {
serialPorts.push(subEditConfig.portName)
index = serialPorts.indexOf(subEditConfig.portName)
}
onActivated: {
if (index != -1) {
if (index >= QGroundControl.linkManager.serialPortStrings.length) {
// This item was adding at the end, must use added text as name
subEditConfig.portName = commPortCombo.textAt(index)
} else {
index = 0
subEditConfig.portName = QGroundControl.linkManager.serialPorts[index]
}
commPortCombo.model = serialPorts
commPortCombo.currentIndex = index
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Baud Rate:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCComboBox {
id: baudCombo
width: _secondColumn
model: QGroundControl.linkManager.serialBaudRates
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
subEditConfig.baud = parseInt(QGroundControl.linkManager.serialBaudRates[index])
}
Component.onCompleted: {
var index
var serialPorts = [ ]
for (var i=0; i<QGroundControl.linkManager.serialPortStrings.length; i++) {
serialPorts.push(QGroundControl.linkManager.serialPortStrings[i])
}
Component.onCompleted: {
var baud = "57600"
if(subEditConfig != null) {
baud = subEditConfig.baud.toString()
if (subEditConfig != null) {
if (subEditConfig.portDisplayName === "" && QGroundControl.linkManager.serialPorts.length > 0) {
subEditConfig.portName = QGroundControl.linkManager.serialPorts[0]
}
var index = baudCombo.find(baud)
index = serialPorts.indexOf(subEditConfig.portDisplayName)
if (index === -1) {
console.warn(qsTr("Baud rate name not in combo box"), baud)
} else {
baudCombo.currentIndex = index
serialPorts.push(subEditConfig.portName)
index = serialPorts.indexOf(subEditConfig.portName)
}
} else {
index = 0
}
commPortCombo.model = serialPorts
commPortCombo.currentIndex = index
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
//-----------------------------------------------------------------
//-- Advanced Serial Settings
QGCCheckBox {
id: showAdvanced
text: qsTr("Show Advanced Serial Settings")
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Baud Rate:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
//-- Flow Control
QGCCheckBox {
text: qsTr("Enable Flow Control")
checked: subEditConfig ? subEditConfig.flowControl !== 0 : false
visible: showAdvanced.checked
onCheckedChanged: {
if(subEditConfig) {
subEditConfig.flowControl = checked ? 1 : 0
QGCComboBox {
id: baudCombo
width: _secondColumn
model: QGroundControl.linkManager.serialBaudRates
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
subEditConfig.baud = parseInt(QGroundControl.linkManager.serialBaudRates[index])
}
}
}
//-- Parity
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: showAdvanced.checked
QGCLabel {
text: qsTr("Parity:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCComboBox {
id: parityCombo
width: _firstColumn
model: [qsTr("None"), qsTr("Even"), qsTr("Odd")]
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
// Hard coded values from qserialport.h
if(index == 0)
subEditConfig.parity = 0
else if(index == 1)
subEditConfig.parity = 2
else
subEditConfig.parity = 3
}
Component.onCompleted: {
var baud = "57600"
if(subEditConfig != null) {
baud = subEditConfig.baud.toString()
}
Component.onCompleted: {
var index = 0
if(subEditConfig != null) {
index = subEditConfig.parity
}
if(index > 1) {
index = index - 2
}
parityCombo.currentIndex = index
var index = baudCombo.find(baud)
if (index === -1) {
console.warn(qsTr("Baud rate name not in combo box"), baud)
} else {
baudCombo.currentIndex = index
}
}
}
//-- Data Bits
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: showAdvanced.checked
QGCLabel {
text: "Data Bits:"
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
//-----------------------------------------------------------------
//-- Advanced Serial Settings
QGCCheckBox {
id: showAdvanced
text: qsTr("Show Advanced Serial Settings")
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
//-- Flow Control
QGCCheckBox {
text: qsTr("Enable Flow Control")
checked: subEditConfig ? subEditConfig.flowControl !== 0 : false
visible: showAdvanced.checked
onCheckedChanged: {
if(subEditConfig) {
subEditConfig.flowControl = checked ? 1 : 0
}
QGCComboBox {
id: dataCombo
width: _firstColumn
model: ["5", "6", "7", "8"]
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
subEditConfig.dataBits = index + 5
}
}
}
//-- Parity
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: showAdvanced.checked
QGCLabel {
text: qsTr("Parity:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCComboBox {
id: parityCombo
width: _firstColumn
model: [qsTr("None"), qsTr("Even"), qsTr("Odd")]
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
// Hard coded values from qserialport.h
if(index == 0)
subEditConfig.parity = 0
else if(index == 1)
subEditConfig.parity = 2
else
subEditConfig.parity = 3
}
Component.onCompleted: {
var index = 3
if(subEditConfig != null) {
index = subEditConfig.parity - 5
if(index < 0)
index = 3
}
dataCombo.currentIndex = index
}
Component.onCompleted: {
var index = 0
if(subEditConfig != null) {
index = subEditConfig.parity
}
if(index > 1) {
index = index - 2
}
parityCombo.currentIndex = index
}
}
//-- Stop Bits
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: showAdvanced.checked
QGCLabel {
text: qsTr("Stop Bits:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCComboBox {
id: stopCombo
width: _firstColumn
model: ["1", "2"]
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
subEditConfig.stopBits = index + 1
}
}
//-- Data Bits
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: showAdvanced.checked
QGCLabel {
text: "Data Bits:"
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCComboBox {
id: dataCombo
width: _firstColumn
model: ["5", "6", "7", "8"]
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
subEditConfig.dataBits = index + 5
}
Component.onCompleted: {
var index = 0
if(subEditConfig != null) {
index = subEditConfig.stopBits - 1
if(index < 0)
index = 0
}
stopCombo.currentIndex = index
}
Component.onCompleted: {
var index = 3
if(subEditConfig != null) {
index = subEditConfig.parity - 5
if(index < 0)
index = 3
}
dataCombo.currentIndex = index
}
}
QGCCheckBox {
text: "High Latency"
checked: false
visible: editConfig ? editConfig.highLatencyAllowed : false
onCheckedChanged: {
if(editConfig) {
editConfig.highLatency = checked
}
//-- Stop Bits
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: showAdvanced.checked
QGCLabel {
text: qsTr("Stop Bits:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCComboBox {
id: stopCombo
width: _firstColumn
model: ["1", "2"]
anchors.verticalCenter: parent.verticalCenter
onActivated: {
if (index != -1) {
subEditConfig.stopBits = index + 1
}
}
Component.onCompleted: {
if(editConfig)
checked = editConfig.highLatency
var index = 0
if(subEditConfig != null) {
index = subEditConfig.stopBits - 1
if(index < 0)
index = 0
}
stopCombo.currentIndex = index
}
}
}
......
......@@ -17,77 +17,43 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
id: tcpLinkSettings
width: parent ? parent.width : 0
height: tcpColumn.height
Column {
id: tcpLinkSettings
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
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
id: tcpLabel
text: qsTr("TCP Link Settings")
}
Rectangle {
height: 1
width: tcpLabel.width
color: qgcPal.button
text: qsTr("Host Address:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
QGCTextField {
id: hostField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeTcp ? subEditConfig.host : ""
width: _secondColumn
anchors.verticalCenter: parent.verticalCenter
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Host Address:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCTextField {
id: hostField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeTcp ? subEditConfig.host : ""
width: _secondColumn
anchors.verticalCenter: parent.verticalCenter
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("TCP Port:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCTextField {
id: portField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeTcp ? subEditConfig.port.toString() : ""
width: _firstColumn
inputMethodHints: Qt.ImhFormattedNumbersOnly
anchors.verticalCenter: parent.verticalCenter
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("TCP Port:")
width: _firstColumn
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
}
QGCTextField {
id: portField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeTcp ? subEditConfig.port.toString() : ""
width: _firstColumn
inputMethodHints: Qt.ImhFormattedNumbersOnly
anchors.verticalCenter: parent.verticalCenter
}
}
}
......@@ -17,177 +17,140 @@ import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Item {
id: _udpSetting
width: parent ? parent.width : 0
height: udpColumn.height
Column {
id: _udpSetting
spacing: ScreenTools.defaultFontPixelHeight * 0.5
anchors.margins: ScreenTools.defaultFontPixelWidth
function saveSettings() {
// No need
}
property var _currentHost: ""
property string _currentHost: ""
Column {
id: udpColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
ExclusiveGroup { id: linkGroup }
QGCPalette {
id: qgcPal
colorGroupEnabled: enabled
}
ExclusiveGroup { id: linkGroup }
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
id: udpLabel
text: qsTr("UDP Link Settings")
text: qsTr("Listening Port:")
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
Rectangle {
height: 1
width: udpLabel.width
color: qgcPal.button
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
QGCTextField {
id: portField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeUdp ? subEditConfig.localPort.toString() : ""
focus: true
width: _firstColumn
inputMethodHints: Qt.ImhFormattedNumbersOnly
anchors.verticalCenter: parent.verticalCenter
onTextChanged: {
if(subEditConfig) {
subEditConfig.localPort = parseInt(portField.text)
}
}
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
QGCLabel {
text: qsTr("Target Hosts:")
}
Item {
width: hostRow.width
height: hostRow.height
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Listening Port:")
id: hostRow
spacing: ScreenTools.defaultFontPixelWidth
Item {
height: 1
width: _firstColumn
anchors.verticalCenter: parent.verticalCenter
}
QGCTextField {
id: portField
text: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeUdp ? subEditConfig.localPort.toString() : ""
focus: true
width: _firstColumn
inputMethodHints: Qt.ImhFormattedNumbersOnly
anchors.verticalCenter: parent.verticalCenter
onTextChanged: {
if(subEditConfig) {
subEditConfig.localPort = parseInt(portField.text)
Column {
id: hostColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
Rectangle {
height: 1
width: _secondColumn
color: qgcPal.button
visible: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeUdp && subEditConfig.hostList.length > 0
}
Repeater {
model: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeUdp ? subEditConfig.hostList : ""
delegate:
QGCButton {
text: modelData
width: _secondColumn
anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
exclusiveGroup: linkGroup
onClicked: {
checked = true
_udpSetting._currentHost = modelData
}
}
}
}
}
Item {
height: ScreenTools.defaultFontPixelHeight / 2
width: parent.width
}
QGCLabel {
text: qsTr("Target Hosts:")
}
Item {
width: hostRow.width
height: hostRow.height
Row {
id: hostRow
spacing: ScreenTools.defaultFontPixelWidth
Item {
QGCTextField {
id: hostField
focus: true
visible: false
width: ScreenTools.defaultFontPixelWidth * 30
onEditingFinished: {
if(subEditConfig) {
if(hostField.text !== "") {
subEditConfig.addHost(hostField.text)
hostField.text = ""
}
hostField.visible = false
}
}
Keys.onReleased: {
if (event.key === Qt.Key_Escape) {
hostField.text = ""
hostField.visible = false
}
}
}
Rectangle {
height: 1
width: _firstColumn
width: _secondColumn
color: qgcPal.button
}
Column {
id: hostColumn
spacing: ScreenTools.defaultFontPixelHeight / 2
Rectangle {
height: 1
width: _secondColumn
color: qgcPal.button
visible: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeUdp && subEditConfig.hostList.length > 0
}
Repeater {
model: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeUdp ? subEditConfig.hostList : ""
delegate:
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("Add")
onClicked: {
checked = true
_udpSetting._currentHost = modelData
}
}
}
QGCTextField {
id: hostField
focus: true
visible: false
width: ScreenTools.defaultFontPixelWidth * 30
onEditingFinished: {
if(subEditConfig) {
if(hostField.text !== "") {
if(hostField.visible && hostField.text !== "") {
subEditConfig.addHost(hostField.text)
hostField.text = ""
}
hostField.visible = false
}
}
Keys.onReleased: {
if (event.key === Qt.Key_Escape) {
hostField.text = ""
hostField.visible = false
hostField.visible = false
} else
hostField.visible = true
}
}
}
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("Add")
onClicked: {
if(hostField.visible && hostField.text !== "") {
subEditConfig.addHost(hostField.text)
hostField.text = ""
hostField.visible = false
} else
hostField.visible = true
}
}
QGCButton {
width: ScreenTools.defaultFontPixelWidth * 10
enabled: _udpSetting._currentHost && _udpSetting._currentHost !== ""
text: qsTr("Remove")
onClicked: {
subEditConfig.removeHost(_udpSetting._currentHost)
}
QGCButton {
width: ScreenTools.defaultFontPixelWidth * 10
enabled: _udpSetting._currentHost && _udpSetting._currentHost !== ""
text: qsTr("Remove")
onClicked: {
subEditConfig.removeHost(_udpSetting._currentHost)
}
}
}
}
}
}
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