diff --git a/src/Airmap/AirmapSettings.qml b/src/Airmap/AirmapSettings.qml index 30ac1eb9fa884f154831e3bd5a625e36cc9de086..eda38ccaefee581439f6c309b3b64d24d4216a8b 100644 --- a/src/Airmap/AirmapSettings.qml +++ b/src/Airmap/AirmapSettings.qml @@ -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") diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml index de45dcc04eba665b60d19c1fcae38abea6689a1b..bef117d3ac09dd7a74e9d9022c7627e150c4ab9f 100644 --- a/src/FlightDisplay/FlightDisplayViewMap.qml +++ b/src/FlightDisplay/FlightDisplayViewMap.qml @@ -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 */) diff --git a/src/MissionManager/QGCMapCircleVisuals.qml b/src/MissionManager/QGCMapCircleVisuals.qml index e650924069b33da99ed7af315cfd9450c1468890..e5946c88b05d271b803cedbb4c498ea34134794e 100644 --- a/src/MissionManager/QGCMapCircleVisuals.qml +++ b/src/MissionManager/QGCMapCircleVisuals.qml @@ -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) { diff --git a/src/QmlControls/ScreenTools.qml b/src/QmlControls/ScreenTools.qml index 34edaeb072e39e1cbf6a2885445653f4b7d0c152..a1c786cf65a7b1ea3478eb9e69929864265171c2 100644 --- a/src/QmlControls/ScreenTools.qml +++ b/src/QmlControls/ScreenTools.qml @@ -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)) diff --git a/src/QmlControls/ScreenToolsController.h b/src/QmlControls/ScreenToolsController.h index 3a7d3c130fff089ce028c3ab4ff8c6674f991383..979b04b73286fa14c5116c130e50735976332da1 100644 --- a/src/QmlControls/ScreenToolsController.h +++ b/src/QmlControls/ScreenToolsController.h @@ -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 diff --git a/src/comm/BluetoothLink.cc b/src/comm/BluetoothLink.cc index 6d3eb915003d6f5c244c2835bf1f56a071a91957..31ef9bd51343aee6ecdca0878db5bfedc67f5dda 100644 --- a/src/comm/BluetoothLink.cc +++ b/src/comm/BluetoothLink.cc @@ -26,6 +26,7 @@ #include #include +#include "QGCApplication.h" #include "BluetoothLink.h" #include "QGC.h" @@ -33,9 +34,9 @@ BluetoothLink::BluetoothLink(SharedLinkConfigurationPointer& config) : LinkInterface(config) , _config(qobject_cast(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(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(); } } diff --git a/src/comm/BluetoothLink.h b/src/comm/BluetoothLink.h index 6503afee1e5cb41d502bd71a8bec00757e2a08cd..484c372045094cf0ed35a2cf5ab423a47c51119a 100644 --- a/src/comm/BluetoothLink.h +++ b/src/comm/BluetoothLink.h @@ -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); diff --git a/src/comm/LinkConfiguration.h b/src/comm/LinkConfiguration.h index 68227be0dadc54a2fd9a2db4e17b1e40c1f5eb3d..a32e65f53e2caa0c0189315e43c3faf1a36adb30 100644 --- a/src/comm/LinkConfiguration.h +++ b/src/comm/LinkConfiguration.h @@ -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 diff --git a/src/comm/LogReplayLink.h b/src/comm/LogReplayLink.h index c28f55b66a8c7aa703343477f509c60d62305f81..6f369b35f3ca1a20d6e8be1fce605a902d9b5644 100644 --- a/src/comm/LogReplayLink.h +++ b/src/comm/LogReplayLink.h @@ -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(); diff --git a/src/comm/MockLink.h b/src/comm/MockLink.h index 3800e5fac7ebbae1ca6ee6ea0a7dd048d06ceb90..e771cd6a2888aa0878eb4018a917a5d4168140a7 100644 --- a/src/comm/MockLink.h +++ b/src/comm/MockLink.h @@ -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 (); diff --git a/src/comm/SerialLink.h b/src/comm/SerialLink.h index 47f502063af6d4dc4024ad85d1c4cdb79fe8ac3e..3d02197c93c3776322c69932561a59043c0fa78d 100644 --- a/src/comm/SerialLink.h +++ b/src/comm/SerialLink.h @@ -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 (); diff --git a/src/comm/TCPLink.h b/src/comm/TCPLink.h index 35a3c22c8a47b7222041764ce86ff83a5d0b03d5..d69e9f1c40d99a9bf653759684d8390b90d47de8 100644 --- a/src/comm/TCPLink.h +++ b/src/comm/TCPLink.h @@ -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(); diff --git a/src/comm/UDPLink.h b/src/comm/UDPLink.h index 1f76b9e2698e7deb9017da9ff3d4ca1df6dca26f..c87cd836d24d060a7c216c900390aff0f6d0dfe5 100644 --- a/src/comm/UDPLink.h +++ b/src/comm/UDPLink.h @@ -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 (); diff --git a/src/ui/preferences/BluetoothSettings.qml b/src/ui/preferences/BluetoothSettings.qml index 375759186cfe301341ff70fc7918fc8365d0ea2d..520576e98f21331ce21ae20c452f7d4b882dbb99 100644 --- a/src/ui/preferences/BluetoothSettings.qml +++ b/src/ui/preferences/BluetoothSettings.qml @@ -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 { } } } + diff --git a/src/ui/preferences/LinkSettings.qml b/src/ui/preferences/LinkSettings.qml index cb49848f172143fd7f44e2331fff75ee37ebf2bb..f02c9e4e15be7b75aca44658278ec0da3bd432de 100644 --- a/src/ui/preferences/LinkSettings.qml +++ b/src/ui/preferences/LinkSettings.qml @@ -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 + } + } } } } diff --git a/src/ui/preferences/LogReplaySettings.qml b/src/ui/preferences/LogReplaySettings.qml index 079fe5461d6738edd253d85ad127c0fe456b418e..7041213f0dd32f8007190a5a2410a7ce36fa25f7 100644 --- a/src/ui/preferences/LogReplaySettings.qml +++ b/src/ui/preferences/LogReplaySettings.qml @@ -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 } } } diff --git a/src/ui/preferences/MockLinkSettings.qml b/src/ui/preferences/MockLinkSettings.qml index ede593528b2a42d4fd5597ac0a0e2a4d8796e903..54b618add506c52e9a4908ccf33032734f2323f4 100644 --- a/src/ui/preferences/MockLinkSettings.qml +++ b/src/ui/preferences/MockLinkSettings.qml @@ -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 } } } diff --git a/src/ui/preferences/SerialSettings.qml b/src/ui/preferences/SerialSettings.qml index 0b9ba0f31e164ec3db0806003826c4e7720d8a20..a5a71b5c77136dbc032cde650eb8052481a74814 100644 --- a/src/ui/preferences/SerialSettings.qml +++ b/src/ui/preferences/SerialSettings.qml @@ -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 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 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 } } } diff --git a/src/ui/preferences/TcpSettings.qml b/src/ui/preferences/TcpSettings.qml index 6f0ac0e2d57ef50820f784181fded58f14d88a67..9ac5c4873cf856847069b0e486caddc1dd67503f 100644 --- a/src/ui/preferences/TcpSettings.qml +++ b/src/ui/preferences/TcpSettings.qml @@ -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 } } } diff --git a/src/ui/preferences/UdpSettings.qml b/src/ui/preferences/UdpSettings.qml index 6332dc964933134b017b95b9ac68944f2d238c3f..a6aacec2e9296db84405619c8cdc887b4535ec5c 100644 --- a/src/ui/preferences/UdpSettings.qml +++ b/src/ui/preferences/UdpSettings.qml @@ -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 - } - } } }