diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 98dc921a741789bd76a1d412d8792936169f2081..e29b81351e628a825905bc36c547d1152cf791ee 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -193,11 +193,6 @@ FORMS += \ src/ui/MainWindow.ui \ src/QGCQmlWidgetHolder.ui \ -DebugBuild { -FORMS += \ - src/ui/MockLinkConfiguration.ui \ -} - !iOSBuild { FORMS += \ src/ui/SerialSettings.ui \ @@ -208,21 +203,16 @@ FORMS += \ src/ui/uas/QGCUnconnectedInfoWidget.ui \ src/ui/uas/UASMessageView.ui \ src/ui/Linechart.ui \ - src/ui/LogReplayLinkConfigurationWidget.ui \ src/ui/MultiVehicleDockWidget.ui \ src/ui/MAVLinkSettingsWidget.ui \ - src/ui/QGCCommConfiguration.ui \ src/ui/QGCDataPlot2D.ui \ src/ui/QGCHilConfiguration.ui \ src/ui/QGCHilFlightGearConfiguration.ui \ src/ui/QGCHilJSBSimConfiguration.ui \ src/ui/QGCHilXPlaneConfiguration.ui \ - src/ui/QGCLinkConfiguration.ui \ src/ui/QGCMapRCToParamDialog.ui \ src/ui/QGCMAVLinkInspector.ui \ src/ui/QGCMAVLinkLogPlayer.ui \ - src/ui/QGCTCPLinkConfiguration.ui \ - src/ui/QGCUDPLinkConfiguration.ui \ src/ui/QGCTabbedInfoView.ui \ src/ui/QGCUASFileView.ui \ src/ui/QGCUASFileViewMulti.ui \ @@ -287,7 +277,6 @@ HEADERS += \ src/comm/MockLink.h \ src/comm/MockLinkFileServer.h \ src/comm/MockLinkMissionItemHandler.h \ - src/ui/MockLinkConfiguration.h \ } WindowsBuild { @@ -325,17 +314,12 @@ HEADERS += \ src/ui/linechart/LinechartWidget.h \ src/ui/linechart/Scrollbar.h \ src/ui/linechart/ScrollZoomer.h \ - src/ui/LogReplayLinkConfigurationWidget.h \ src/ui/MainWindow.h \ src/ui/MAVLinkDecoder.h \ src/ui/MAVLinkSettingsWidget.h \ src/ui/MultiVehicleDockWidget.h \ - src/ui/QGCCommConfiguration.h \ - src/ui/QGCLinkConfiguration.h \ src/ui/QGCMAVLinkLogPlayer.h \ src/ui/QGCMapRCToParamDialog.h \ - src/ui/QGCTCPLinkConfiguration.h \ - src/ui/QGCUDPLinkConfiguration.h \ src/ui/SettingsDialog.h \ src/ui/uas/UASMessageView.h \ src/ui/uas/QGCUnconnectedInfoWidget.h \ @@ -409,7 +393,6 @@ SOURCES += \ src/comm/MockLink.cc \ src/comm/MockLinkFileServer.cc \ src/comm/MockLinkMissionItemHandler.cc \ - src/ui/MockLinkConfiguration.cc \ } !iOSBuild { @@ -430,16 +413,11 @@ SOURCES += \ src/uas/FileManager.cc \ src/ui/uas/QGCUnconnectedInfoWidget.cc \ src/ui/SettingsDialog.cc \ - src/ui/QGCTCPLinkConfiguration.cc \ - src/ui/QGCUDPLinkConfiguration.cc \ src/ui/MAVLinkDecoder.cc \ src/ui/MAVLinkSettingsWidget.cc \ - src/ui/QGCCommConfiguration.cc \ - src/ui/QGCLinkConfiguration.cc \ src/ui/QGCMapRCToParamDialog.cpp \ src/comm/LogReplayLink.cc \ src/QGCFileDialog.cc \ - src/ui/LogReplayLinkConfigurationWidget.cc \ src/ui/QGCMAVLinkLogPlayer.cc \ src/comm/QGCFlightGearLink.cc \ src/comm/QGCJSBSimLink.cc \ diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc index 67e64834311cf18a3d7b907d5d0d21af1b895e7b..e5270782df5ba173282c3d6b613757c2ce693bc9 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.cc +++ b/src/QmlControls/QGroundControlQmlGlobal.cc @@ -168,6 +168,12 @@ void QGroundControlQmlGlobal::setIsVersionCheckEnabled(bool enable) emit isVersionCheckEnabledChanged(enable); } +void QGroundControlQmlGlobal::setMavlinkSystemID(int id) +{ + qgcApp()->toolbox()->mavlinkProtocol()->setSystemId(id); + emit mavlinkSystemIDChanged(id); +} + void QGroundControlQmlGlobal::setVirtualTabletJoystick(bool enabled) { if (_virtualTabletJoystick != enabled) { diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h index ab7057ff006373a2f3db458b769849e4a1c7622c..599474cae5f24ee5f81e326bd6642c60fbffdd0b 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.h +++ b/src/QmlControls/QGroundControlQmlGlobal.h @@ -64,10 +64,13 @@ public: Q_PROPERTY(bool isAudioMuted READ isAudioMuted WRITE setIsAudioMuted NOTIFY isAudioMutedChanged) Q_PROPERTY(bool isSaveLogPrompt READ isSaveLogPrompt WRITE setIsSaveLogPrompt NOTIFY isSaveLogPromptChanged) Q_PROPERTY(bool isSaveLogPromptNotArmed READ isSaveLogPromptNotArmed WRITE setIsSaveLogPromptNotArmed NOTIFY isSaveLogPromptNotArmedChanged) + Q_PROPERTY(bool virtualTabletJoystick READ virtualTabletJoystick WRITE setVirtualTabletJoystick NOTIFY virtualTabletJoystickChanged) + + // MavLink Protocol Q_PROPERTY(bool isHeartBeatEnabled READ isHeartBeatEnabled WRITE setIsHeartBeatEnabled NOTIFY isHeartBeatEnabledChanged) Q_PROPERTY(bool isMultiplexingEnabled READ isMultiplexingEnabled WRITE setIsMultiplexingEnabled NOTIFY isMultiplexingEnabledChanged) Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged) - Q_PROPERTY(bool virtualTabletJoystick READ virtualTabletJoystick WRITE setVirtualTabletJoystick NOTIFY virtualTabletJoystickChanged) + Q_PROPERTY(int mavlinkSystemID READ mavlinkSystemID WRITE setMavlinkSystemID NOTIFY mavlinkSystemIDChanged) Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value); Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue); @@ -99,10 +102,12 @@ public: bool isAudioMuted () { return qgcApp()->toolbox()->audioOutput()->isMuted(); } bool isSaveLogPrompt () { return qgcApp()->promptFlightDataSave(); } bool isSaveLogPromptNotArmed () { return qgcApp()->promptFlightDataSaveNotArmed(); } + bool virtualTabletJoystick () { return _virtualTabletJoystick; } + bool isHeartBeatEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->heartbeatsEnabled(); } bool isMultiplexingEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->multiplexingEnabled(); } bool isVersionCheckEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->versionCheckEnabled(); } - bool virtualTabletJoystick () { return _virtualTabletJoystick; } + int mavlinkSystemID () { return qgcApp()->toolbox()->mavlinkProtocol()->getSystemId(); } //-- TODO: Make this into an actual preference. bool isAdvancedMode () { return false; } @@ -111,20 +116,23 @@ public: void setIsAudioMuted (bool muted); void setIsSaveLogPrompt (bool prompt); void setIsSaveLogPromptNotArmed (bool prompt); + void setVirtualTabletJoystick (bool enabled); + void setIsHeartBeatEnabled (bool enable); void setIsMultiplexingEnabled (bool enable); void setIsVersionCheckEnabled (bool enable); - void setVirtualTabletJoystick (bool enabled); + void setMavlinkSystemID (int id); signals: void isDarkStyleChanged (bool dark); void isAudioMutedChanged (bool muted); void isSaveLogPromptChanged (bool prompt); void isSaveLogPromptNotArmedChanged (bool prompt); + void virtualTabletJoystickChanged (bool enabled); void isHeartBeatEnabledChanged (bool enabled); void isMultiplexingEnabledChanged (bool enabled); void isVersionCheckEnabledChanged (bool enabled); - void virtualTabletJoystickChanged (bool enabled); + void mavlinkSystemIDChanged (int id); private: diff --git a/src/ui/LogReplayLinkConfigurationWidget.cc b/src/ui/LogReplayLinkConfigurationWidget.cc deleted file mode 100644 index 8bff2dbf9150d488243670f44d0e0218c3196c39..0000000000000000000000000000000000000000 --- a/src/ui/LogReplayLinkConfigurationWidget.cc +++ /dev/null @@ -1,53 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009, 2015 QGROUNDCONTROL PROJECT - - This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - - ======================================================================*/ - -#include "LogReplayLinkConfigurationWidget.h" -#include "QGCFileDialog.h" -#include "QGCApplication.h" - -LogReplayLinkConfigurationWidget::LogReplayLinkConfigurationWidget(LogReplayLinkConfiguration *config, QWidget *parent, Qt::WindowFlags flags) : - QWidget(parent, flags) -{ - _ui.setupUi(this); - - Q_ASSERT(config != NULL); - _config = config; - - _ui.logFilename->setText(_config->logFilename()); - - connect(_ui.selectLogFileButton, &QPushButton::clicked, this, &LogReplayLinkConfigurationWidget::_selectLogFile); -} - -void LogReplayLinkConfigurationWidget::_selectLogFile(bool checked) -{ - Q_UNUSED(checked); - - QString logFile = QGCFileDialog::getOpenFileName(this, - "Select log file to replay", - qgcApp()->mavlinkLogFilesLocation(), - "MAVLink Log Files (*.mavlink);;All Files (*)"); - if (!logFile.isEmpty()) { - _ui.logFilename->setText(logFile); - _config->setLogFilename(logFile); - } -} \ No newline at end of file diff --git a/src/ui/LogReplayLinkConfigurationWidget.h b/src/ui/LogReplayLinkConfigurationWidget.h deleted file mode 100644 index 6d36abb078a2c6d3bb4595ca1ce9ca76587db7e7..0000000000000000000000000000000000000000 --- a/src/ui/LogReplayLinkConfigurationWidget.h +++ /dev/null @@ -1,48 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009, 2015 QGROUNDCONTROL PROJECT - - This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - - ======================================================================*/ - -#ifndef _LogReplayLinkConfigurationWidget_H_ -#define _LogReplayLinkConfigurationWidget_H_ - -#include - -#include "LogReplayLink.h" -#include "ui_LogReplayLinkConfigurationWidget.h" - -class LogReplayLinkConfigurationWidget : public QWidget -{ - Q_OBJECT - -public: - LogReplayLinkConfigurationWidget(LogReplayLinkConfiguration* config, QWidget *parent = 0, Qt::WindowFlags flags = Qt::Sheet); - -private slots: - void _selectLogFile(bool checked); - -private: - Ui::LogReplayLinkConfigurationWidget _ui; - LogReplayLinkConfiguration* _config; -}; - - -#endif diff --git a/src/ui/LogReplayLinkConfigurationWidget.ui b/src/ui/LogReplayLinkConfigurationWidget.ui deleted file mode 100644 index cd876d5d6a2b8f0e6ee56ec5b047c865a182bbb0..0000000000000000000000000000000000000000 --- a/src/ui/LogReplayLinkConfigurationWidget.ui +++ /dev/null @@ -1,142 +0,0 @@ - - - LogReplayLinkConfigurationWidget - - - - 0 - 0 - 325 - 347 - - - - Form - - - - - - - - - 0 - 0 - - - - Log File: - - - - - - - - - - 0 - 0 - - - - - 0 - 60 - - - - - - - true - - - - - - - Select Log File - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Delete - - - Delete this link - - - Delete this link - - - Link delete button - - - - - Connect - - - Connect this link - - - Connect this link - - - Connect this link - - - - - Close - - - Close the configuration window - - - Close the configuration window - - - Close the configuration window - - - - - - - actionClose - triggered() - LogReplayLinkConfigurationWidget - close() - - - -1 - -1 - - - 224 - 195 - - - - - diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index b577618de8a9f95c626e5a1abea7183b8b98cb51..86d57730d690939d01c141c8d28bb203f55dd552 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -536,9 +536,6 @@ void MainWindow::configureWindowName() **/ void MainWindow::connectCommonActions() { - // Connect actions from ui - connect(_ui.actionAdd_Link, SIGNAL(triggered()), this, SLOT(manageLinks())); - // Audio output _ui.actionMuteAudioOutput->setChecked(qgcApp()->toolbox()->audioOutput()->isMuted()); connect(qgcApp()->toolbox()->audioOutput(), SIGNAL(mutedChanged(bool)), _ui.actionMuteAudioOutput, SLOT(setChecked(bool))); @@ -581,13 +578,6 @@ void MainWindow::showSettings() SettingsDialog settings(this); settings.exec(); } - -void MainWindow::manageLinks() -{ - SettingsDialog settings(this, SettingsDialog::ShowCommLinks); - settings.exec(); -} - #endif void MainWindow::_vehicleAdded(Vehicle* vehicle) diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 4077f05dda570ed9867c662785a69deaea22e69e..5becbc8330ba72fa2ac5526eae26f9a3d423439e 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -104,7 +104,6 @@ public: public slots: #ifndef __mobile__ void showSettings(); - void manageLinks(); #endif /** @brief Save power by reducing update rates */ diff --git a/src/ui/MainWindow.ui b/src/ui/MainWindow.ui index c4d0880d4763ff35119ca1d42def0b89cded88a6..ac5712277c3328c064ee1c56a83eb4e5c869db68 100644 --- a/src/ui/MainWindow.ui +++ b/src/ui/MainWindow.ui @@ -60,7 +60,6 @@ - diff --git a/src/ui/MockLinkConfiguration.cc b/src/ui/MockLinkConfiguration.cc deleted file mode 100644 index cccc75f4c7fb348292816cc930c517ab136ffa30..0000000000000000000000000000000000000000 --- a/src/ui/MockLinkConfiguration.cc +++ /dev/null @@ -1,109 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -#include "MockLinkConfiguration.h" -#include "ui_MockLinkConfiguration.h" - -MockLinkConfiguration::MockLinkConfiguration(MockConfiguration *config, QWidget *parent) - : QWidget(parent) - , _ui(new Ui::MockLinkConfiguration) - , _config(config) -{ - _ui->setupUi(this); - - switch (config->firmwareType()) { - case MAV_AUTOPILOT_PX4: - _ui->px4Radio->setChecked(true); - break; - case MAV_AUTOPILOT_ARDUPILOTMEGA: - _ui->apmRadio->setChecked(true); - break; - default: - _ui->genericRadio->setChecked(true); - break; - } - - switch (config->vehicleType()) { - case MAV_TYPE_FIXED_WING: - _ui->apmArduPlaneRadio->setChecked(true); - break; - default: - _ui->apmArduCopterRadio->setChecked(true); - break; - } - - _ui->sendStatusTextCheckBox->setChecked(config->sendStatusText()); - - connect(_ui->px4Radio, &QRadioButton::clicked, this, &MockLinkConfiguration::_px4RadioClicked); - connect(_ui->apmRadio, &QRadioButton::clicked, this, &MockLinkConfiguration::_apmRadioClicked); - connect(_ui->genericRadio, &QRadioButton::clicked, this, &MockLinkConfiguration::_genericRadioClicked); - connect(_ui->apmArduCopterRadio, &QRadioButton::clicked, this, &MockLinkConfiguration::_apmArduCopterRadioClicked); - connect(_ui->apmArduPlaneRadio, &QRadioButton::clicked, this, &MockLinkConfiguration::_apmArduPlaneRadioClicked); - connect(_ui->genericRadio, &QRadioButton::clicked, this, &MockLinkConfiguration::_genericRadioClicked); - connect(_ui->sendStatusTextCheckBox, &QCheckBox::clicked, this, &MockLinkConfiguration::_sendStatusTextClicked); -} - -MockLinkConfiguration::~MockLinkConfiguration() -{ - delete _ui; -} - -void MockLinkConfiguration::_px4RadioClicked(bool checked) -{ - if (checked) { - _config->setFirmwareType(MAV_AUTOPILOT_PX4); - } -} - -void MockLinkConfiguration::_apmRadioClicked(bool checked) -{ - if (checked) { - _config->setFirmwareType(MAV_AUTOPILOT_ARDUPILOTMEGA); - } -} - -void MockLinkConfiguration::_genericRadioClicked(bool checked) -{ - if (checked) { - _config->setFirmwareType(MAV_AUTOPILOT_GENERIC); - } -} - -void MockLinkConfiguration::_apmArduCopterRadioClicked(bool checked) -{ - if (checked) { - _config->setVehicleType(MAV_TYPE_QUADROTOR); - } -} - -void MockLinkConfiguration::_apmArduPlaneRadioClicked(bool checked) -{ - if (checked) { - _config->setVehicleType(MAV_TYPE_FIXED_WING); - } -} - -void MockLinkConfiguration::_sendStatusTextClicked(bool checked) -{ - _config->setSendStatusText(checked); -} diff --git a/src/ui/MockLinkConfiguration.h b/src/ui/MockLinkConfiguration.h deleted file mode 100644 index e60a18781d24d06bbcb2fd0bf47caa5c8f5d72de..0000000000000000000000000000000000000000 --- a/src/ui/MockLinkConfiguration.h +++ /dev/null @@ -1,56 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -#ifndef MockLinkConfiguration_H -#define MockLinkConfiguration_H - -#include - -#include "MockLink.h" - -namespace Ui -{ -class MockLinkConfiguration; -} - -class MockLinkConfiguration : public QWidget -{ - Q_OBJECT -public: - explicit MockLinkConfiguration(MockConfiguration *config, QWidget *parent = 0); - ~MockLinkConfiguration(); - -private slots: - void _px4RadioClicked(bool checked); - void _apmRadioClicked(bool checked); - void _genericRadioClicked(bool checked); - void _apmArduCopterRadioClicked(bool checked); - void _apmArduPlaneRadioClicked(bool checked); - void _sendStatusTextClicked(bool checked); - -private: - Ui::MockLinkConfiguration* _ui; - MockConfiguration* _config; -}; - -#endif // MockLinkConfiguration_H diff --git a/src/ui/MockLinkConfiguration.ui b/src/ui/MockLinkConfiguration.ui deleted file mode 100644 index 83c6e220785d68a8870d6023342401c1be563cbd..0000000000000000000000000000000000000000 --- a/src/ui/MockLinkConfiguration.ui +++ /dev/null @@ -1,72 +0,0 @@ - - - MockLinkConfiguration - - - - 0 - 0 - 238 - 188 - - - - Form - - - - - - PX4 Firmware - - - - - - - APM Firmware - - - - - - - Generic Firmware - - - - - - - Send status text + voice - - - - - - - APM vehicle type - - - - - - ArduCopter - - - - - - - ArduPlane - - - - - - - - - - - diff --git a/src/ui/QGCCommConfiguration.cc b/src/ui/QGCCommConfiguration.cc deleted file mode 100644 index 85f7594309d0f75aee052814a5f27b638da24365..0000000000000000000000000000000000000000 --- a/src/ui/QGCCommConfiguration.cc +++ /dev/null @@ -1,215 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009 - 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Comm Link Configuration - * @author Gus Grubba - * - */ - -#include - -#ifndef __ios__ -#include "SerialLink.h" -#include "SerialConfigurationWindow.h" -#endif -#include "QGCUDPLinkConfiguration.h" -#include "QGCTCPLinkConfiguration.h" -#ifdef QT_DEBUG -#include "MockLinkConfiguration.h" -#endif -#ifndef __mobile__ -#include "LogReplayLinkConfigurationWidget.h" -#endif -#include "QGCCommConfiguration.h" -#include "ui_QGCCommConfiguration.h" - -QGCCommConfiguration::QGCCommConfiguration(QWidget *parent, LinkConfiguration *config) : - QDialog(parent), - _ui(new Ui::QGCCommConfiguration) -{ - _ui->setupUi(this); - // Add link types - _config = config; - _ui->typeCombo->addItem(tr("Select Type"), LinkConfiguration::TypeLast); -#ifndef __ios__ - _ui->typeCombo->addItem(tr("Serial"), LinkConfiguration::TypeSerial); -#endif - _ui->typeCombo->addItem(tr("UDP"), LinkConfiguration::TypeUdp); - _ui->typeCombo->addItem(tr("TCP"), LinkConfiguration::TypeTcp); -#ifndef __mobile__ - _ui->typeCombo->addItem(tr("Log replay"), LinkConfiguration::TypeLogReplay); -#endif -#ifdef QT_DEBUG - _ui->typeCombo->addItem(tr("Mock"), LinkConfiguration::TypeMock); -#endif - -#if 0 - -#ifdef QGC_RTLAB_ENABLED - _ui->typeCombo->addItem(tr("Opal-RT Link"), LinkConfiguration::TypeOpal); -#endif -#ifdef QGC_XBEE_ENABLED - _ui->typeCombo->addItem(tr("Xbee API"), LinkConfiguration::TypeXbee); -#endif -#endif - - _ui->typeCombo->setEditable(false); - if(config && !config->name().isEmpty()) { - _ui->nameEdit->setText(config->name()); - } else { - _ui->nameEdit->setText(tr("Unnamed")); - } - if(!config) { - setWindowTitle(tr("Add New Communication Link")); - } else { - setWindowTitle(tr("Edit Communication Link")); - _loadTypeConfigWidget(config->type()); - _ui->typeCombo->setEnabled(false); - } - _updateUI(); -} - -QGCCommConfiguration::~QGCCommConfiguration() -{ - delete _ui; -} - -void QGCCommConfiguration::on_typeCombo_currentIndexChanged(int index) -{ - int type = _ui->typeCombo->itemData(index).toInt(); - _changeLinkType(type); -} - -void QGCCommConfiguration::_changeLinkType(int type) -{ - //-- Do we need to change anything? - if(type == LinkConfiguration::TypeLast || (_config && _config->type() == type)) { - return; - } - // Switching connection type. Delete old config. - delete _config; - // Create new config instance - QString name = _ui->nameEdit->text(); - if(name.isEmpty()) { - name = tr("Untitled"); - _ui->nameEdit->setText(name); - } - _config = LinkConfiguration::createSettings(type, name); - Q_ASSERT(_config != NULL); - _loadTypeConfigWidget(type); - _updateUI(); -} - -void QGCCommConfiguration::_loadTypeConfigWidget(int type) -{ - Q_ASSERT(_config != NULL); - switch(type) { -#ifndef __ios__ - case LinkConfiguration::TypeSerial: { - QWidget* conf = new SerialConfigurationWindow((SerialConfiguration*)_config, this); - _ui->linkScrollArea->setWidget(conf); - _ui->linkGroupBox->setTitle(tr("Serial Link")); - _ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeSerial)); - } - break; -#endif - case LinkConfiguration::TypeUdp: { - QWidget* conf = new QGCUDPLinkConfiguration((UDPConfiguration*)_config, this); - _ui->linkScrollArea->setWidget(conf); - _ui->linkGroupBox->setTitle(tr("UDP Link")); - _ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeUdp)); - } - break; - case LinkConfiguration::TypeTcp: { - QWidget* conf = new QGCTCPLinkConfiguration((TCPConfiguration*)_config, this); - _ui->linkScrollArea->setWidget(conf); - _ui->linkGroupBox->setTitle(tr("TCP Link")); - _ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeTcp)); - } - break; -#ifndef __mobile__ - case LinkConfiguration::TypeLogReplay: { - QWidget* conf = new LogReplayLinkConfigurationWidget((LogReplayLinkConfiguration*)_config, this); - _ui->linkScrollArea->setWidget(conf); - _ui->linkGroupBox->setTitle("Log Replay"); - _ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeLogReplay)); - } - break; -#endif -#ifdef QT_DEBUG - case LinkConfiguration::TypeMock: { - QWidget* conf = new MockLinkConfiguration((MockConfiguration*)_config, this); - _ui->linkScrollArea->setWidget(conf); - _ui->linkGroupBox->setTitle(tr("Mock Link")); - _ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeMock)); - } - break; -#endif - // Cannot be the case, but in case it gets here, we cannot continue. - default: - reject(); - break; - } - // Remove "Select Type" once something is selected - int idx = _ui->typeCombo->findData(LinkConfiguration::TypeLast); - if(idx >= 0) { - _ui->typeCombo->removeItem(idx); - } -} - -void QGCCommConfiguration::_updateUI() -{ - bool enableOK = false; - if(_config) { - if(!_ui->nameEdit->text().isEmpty()) { - enableOK = true; - } - } - QPushButton* ok = _ui->buttonBox->button(QDialogButtonBox::Ok); - Q_ASSERT(ok != NULL); - ok->setEnabled(enableOK); -} - -void QGCCommConfiguration::on_buttonBox_accepted() -{ - if(_config) { - _config->setName(_ui->nameEdit->text()); - } - accept(); -} - -void QGCCommConfiguration::on_buttonBox_rejected() -{ - reject(); -} - -void QGCCommConfiguration::on_nameEdit_textEdited(const QString &arg1) -{ - Q_UNUSED(arg1); - _updateUI(); - if(_config) { - _config->setDynamic(false); - } -} diff --git a/src/ui/QGCCommConfiguration.h b/src/ui/QGCCommConfiguration.h deleted file mode 100644 index 5e9cf1944b46a03b0c46b7db732641f103efd1f4..0000000000000000000000000000000000000000 --- a/src/ui/QGCCommConfiguration.h +++ /dev/null @@ -1,85 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009 - 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Comm Link Configuration - * @author Gus Grubba - * - */ - -#ifndef QGCCOMMCONFIGURATION_H -#define QGCCOMMCONFIGURATION_H - -#include -#include - -#include "LinkConfiguration.h" - -namespace Ui { -class QGCCommConfiguration; -} - -class QGCCommConfiguration : public QDialog -{ - Q_OBJECT - -public: - explicit QGCCommConfiguration(QWidget *parent, LinkConfiguration* config = 0); - ~QGCCommConfiguration(); - - enum { - QGC_LINK_SERIAL, - QGC_LINK_UDP, - QGC_LINK_TCP, - QGC_LINK_SIMULATION, - QGC_LINK_FORWARDING, -#ifdef QT_DEBUG - QGC_LINK_MOCK, -#endif -#ifdef QGC_XBEE_ENABLED - QGC_LINK_XBEE, -#endif -#ifdef QGC_RTLAB_ENABLED - QGC_LINK_OPAL -#endif - }; - - LinkConfiguration* getConfig() { return _config; } - -private slots: - void on_typeCombo_currentIndexChanged(int index); - void on_buttonBox_accepted(); - void on_buttonBox_rejected(); - void on_nameEdit_textEdited(const QString &arg1); - -private: - void _changeLinkType(int type); - void _loadTypeConfigWidget(int type); - void _updateUI(); - - Ui::QGCCommConfiguration* _ui; - LinkConfiguration* _config; -}; - -#endif // QGCCOMMCONFIGURATION_H diff --git a/src/ui/QGCCommConfiguration.ui b/src/ui/QGCCommConfiguration.ui deleted file mode 100644 index 6c8e3f877797b061f2a274692ba88e82803a2c72..0000000000000000000000000000000000000000 --- a/src/ui/QGCCommConfiguration.ui +++ /dev/null @@ -1,139 +0,0 @@ - - - QGCCommConfiguration - - - - 0 - 0 - 450 - 450 - - - - - 450 - 450 - - - - - 600 - 600 - - - - Form - - - - - - - - - - - 160 - 0 - - - - Link Name: - - - - - - - - 0 - 0 - - - - - - - - - - - - - 160 - 0 - - - - Link Type: - - - - - - - - 0 - 0 - - - - - - - - - - - - Link - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - - - 0 - 0 - 418 - 304 - - - - - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - diff --git a/src/ui/QGCLinkConfiguration.cc b/src/ui/QGCLinkConfiguration.cc deleted file mode 100644 index 279a66a48be925baa2fa417a4ef551d245d227f4..0000000000000000000000000000000000000000 --- a/src/ui/QGCLinkConfiguration.cc +++ /dev/null @@ -1,293 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Implementation of QGCLinkConfiguration - * @author Gus Grubba - */ - -#include "SettingsDialog.h" -#include "QGCLinkConfiguration.h" -#include "ui_QGCLinkConfiguration.h" -#include "QGCCommConfiguration.h" -#include "QGCMessageBox.h" -#include "UDPLink.h" -#include "TCPLink.h" - -QGCLinkConfiguration::QGCLinkConfiguration(QWidget *parent) : - QWidget(parent), - _ui(new Ui::QGCLinkConfiguration) -{ - // Stop automatic link updates while this UI is up - qgcApp()->toolbox()->linkManager()->suspendConfigurationUpdates(true); - _ui->setupUi(this); - _viewModel = new LinkViewModel; - _ui->linkView->setModel(_viewModel); - _ui->connectLinkButton->setEnabled(false); - _ui->delLinkButton->setEnabled(false); - _ui->editLinkButton->setEnabled(false); -} - -QGCLinkConfiguration::~QGCLinkConfiguration() -{ - if(_viewModel) delete _viewModel; - if(_ui) delete _ui; - // Resume automatic link updates - qgcApp()->toolbox()->linkManager()->suspendConfigurationUpdates(false); -} - -void QGCLinkConfiguration::on_delLinkButton_clicked() -{ - QModelIndex index = _ui->linkView->currentIndex(); - if(index.row() >= 0) { - LinkConfiguration* config = _viewModel->getConfiguration(index.row()); - if(config) { - // Ask user if they are sure - QMessageBox::StandardButton button = QGCMessageBox::question( - tr("Delete Link Configuration"), - tr("Are you sure you want to delete %1?\nDeleting a configuration will also disconnect it if connected.").arg(config->name()), - QMessageBox::Yes | QMessageBox::Cancel, - QMessageBox::Cancel); - if (button == QMessageBox::Yes) { - // Get link attached to this configuration (if any) - LinkInterface* iface = config->link(); - if(iface) { - qgcApp()->toolbox()->linkManager()->disconnectLink(iface); - } - _viewModel->beginChange(); - - // Remove configuration - QmlObjectListModel* linkConfigurations = qgcApp()->toolbox()->linkManager()->linkConfigurations(); - linkConfigurations->removeOne(config); - delete config; - - // Save list - qgcApp()->toolbox()->linkManager()->saveLinkConfigurationList(); - _viewModel->endChange(); - } - } - } - _updateButtons(); -} - -void QGCLinkConfiguration::on_linkView_clicked(const QModelIndex&) -{ - _updateButtons(); -} - -void QGCLinkConfiguration::on_connectLinkButton_clicked() -{ - QModelIndex index = _ui->linkView->currentIndex(); - if(index.row() >= 0) { - LinkConfiguration* config = _viewModel->getConfiguration(index.row()); - if(config) { - LinkInterface* link = config->link(); - if(link) { - // Disconnect Link - if (link->isConnected()) { - qgcApp()->toolbox()->linkManager()->disconnectLink(link); - } - } else { - LinkInterface* link = qgcApp()->toolbox()->linkManager()->createConnectedLink(config); - if(link) { - // Now go hunting for the parent so we can shut this down - QWidget* pQw = parentWidget(); - while(pQw) { - SettingsDialog* pDlg = dynamic_cast(pQw); - if(pDlg) { - pDlg->accept(); - break; - } - pQw = pQw->parentWidget(); - } - } - } - } - } - _updateButtons(); -} - -void QGCLinkConfiguration::on_editLinkButton_clicked() -{ - QModelIndex index = _ui->linkView->currentIndex(); - _editLink(index.row()); -} - -void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config) -{ - Q_ASSERT(config != NULL); - //-- Check for "Unnamed" - if (config->name() == tr("Unnamed")) { - switch(config->type()) { -#ifndef __ios__ - case LinkConfiguration::TypeSerial: { - QString tname = dynamic_cast(config)->portName(); -#ifdef Q_OS_WIN - tname.replace("\\\\.\\", ""); -#else - tname.replace("/dev/cu.", ""); - tname.replace("/dev/", ""); -#endif - config->setName(QString("Serial Device on %1").arg(tname)); - break; - } -#endif - case LinkConfiguration::TypeUdp: - config->setName( - QString("UDP Link on Port %1").arg(dynamic_cast(config)->localPort())); - break; - case LinkConfiguration::TypeTcp: { - TCPConfiguration* tconfig = dynamic_cast(config); - if(tconfig) { - config->setName( - QString("TCP Link %1:%2").arg(tconfig->address().toString()).arg((int)tconfig->port())); - } - } - break; -#ifndef __mobile__ - case LinkConfiguration::TypeLogReplay: { - LogReplayLinkConfiguration* tconfig = dynamic_cast(config); - if(tconfig) { - config->setName(QString("Log Replay %1").arg(tconfig->logFilenameShort())); - } - } - break; -#endif -#ifdef QT_DEBUG - case LinkConfiguration::TypeMock: - config->setName( - QString("Mock Link")); - break; -#endif - case LinkConfiguration::TypeLast: - default: - break; - } - } -} - -void QGCLinkConfiguration::on_addLinkButton_clicked() -{ - QGCCommConfiguration* commDialog = new QGCCommConfiguration(this); - if(commDialog->exec() == QDialog::Accepted) { - // Save changes (if any) - LinkConfiguration* config = commDialog->getConfig(); - if(config) { - _fixUnnamed(config); - _viewModel->beginChange(); - qgcApp()->toolbox()->linkManager()->linkConfigurations()->append(commDialog->getConfig()); - qgcApp()->toolbox()->linkManager()->saveLinkConfigurationList(); - _viewModel->endChange(); - } - } - _updateButtons(); -} - -void QGCLinkConfiguration::on_linkView_doubleClicked(const QModelIndex &index) -{ - _editLink(index.row()); -} - -void QGCLinkConfiguration::_editLink(int row) -{ - if(row >= 0) { - LinkConfiguration* config = _viewModel->getConfiguration(row); - if(config) { - LinkConfiguration* tmpConfig = LinkConfiguration::duplicateSettings(config); - QGCCommConfiguration* commDialog = new QGCCommConfiguration(this, tmpConfig); - if(commDialog->exec() == QDialog::Accepted) { - // Save changes (if any) - if(commDialog->getConfig()) { - _fixUnnamed(tmpConfig); - _viewModel->beginChange(); - config->copyFrom(tmpConfig); - // Save it - qgcApp()->toolbox()->linkManager()->saveLinkConfigurationList(); - _viewModel->endChange(); - // Tell link about changes (if any) - config->updateSettings(); - } - } - // Discard temporary duplicate - if(commDialog->getConfig()) - delete commDialog->getConfig(); - } - } - _updateButtons(); -} - -void QGCLinkConfiguration::_updateButtons() -{ - LinkConfiguration* config = NULL; - QModelIndex index = _ui->linkView->currentIndex(); - bool enabled = (index.row() >= 0); - bool deleteEnabled = true; - if(enabled) { - config = _viewModel->getConfiguration(index.row()); - if(config) { - // Can't delete a dynamic link - if(config->isDynamic()) { - deleteEnabled = false; - } - LinkInterface* link = config->link(); - if(link) { - _ui->connectLinkButton->setText("Disconnect"); - } else { - _ui->connectLinkButton->setText("Connect"); - } - } - } - _ui->connectLinkButton->setEnabled(enabled); - _ui->delLinkButton->setEnabled(config != NULL && deleteEnabled); - _ui->editLinkButton->setEnabled(config != NULL); -} - -LinkViewModel::LinkViewModel(QObject *parent) : QAbstractListModel(parent) -{ - Q_UNUSED(parent); -} - -int LinkViewModel::rowCount( const QModelIndex & parent) const -{ - Q_UNUSED(parent); - return qgcApp()->toolbox()->linkManager()->linkConfigurations()->count(); -} - -QVariant LinkViewModel::data( const QModelIndex & index, int role) const -{ - if (role == Qt::DisplayRole && index.row() < rowCount()) { - QString name(qgcApp()->toolbox()->linkManager()->linkConfigurations()->value(index.row())->name()); - return name; - } - return QVariant(); -} - -LinkConfiguration* LinkViewModel::getConfiguration(int row) -{ - if(row < rowCount()) { - return qgcApp()->toolbox()->linkManager()->linkConfigurations()->value(row); - } - return NULL; -} - diff --git a/src/ui/QGCLinkConfiguration.h b/src/ui/QGCLinkConfiguration.h deleted file mode 100644 index 245abd010c3f0918f31acb74e1e5899704937b42..0000000000000000000000000000000000000000 --- a/src/ui/QGCLinkConfiguration.h +++ /dev/null @@ -1,80 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Implementation of QGCLinkConfiguration - * @author Gus Grubba - */ - -#ifndef QGCLINKCONFIGURATION_H -#define QGCLINKCONFIGURATION_H - -#include -#include - -#include "LinkManager.h" - -namespace Ui { -class QGCLinkConfiguration; -} - -class LinkViewModel; - -class QGCLinkConfiguration : public QWidget -{ - Q_OBJECT - -public: - explicit QGCLinkConfiguration(QWidget *parent = 0); - ~QGCLinkConfiguration(); - -private slots: - void on_delLinkButton_clicked(); - void on_editLinkButton_clicked(); - void on_addLinkButton_clicked(); - void on_linkView_doubleClicked(const QModelIndex &index); - void on_linkView_clicked(const QModelIndex &index); - void on_connectLinkButton_clicked(); - -private: - void _editLink(int row); - void _fixUnnamed(LinkConfiguration* config); - void _updateButtons(); - - Ui::QGCLinkConfiguration* _ui; - LinkViewModel* _viewModel; -}; - -class LinkViewModel : public QAbstractListModel -{ -public: - LinkViewModel(QObject *parent = 0); - int rowCount ( const QModelIndex & parent = QModelIndex() ) const; - QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; - LinkConfiguration* getConfiguration(int row); - void beginChange() { beginResetModel(); } - void endChange() { endResetModel(); } -}; - -#endif // QGCLINKCONFIGURATION_H diff --git a/src/ui/QGCLinkConfiguration.ui b/src/ui/QGCLinkConfiguration.ui deleted file mode 100644 index de16788ec414f422c6794a40dad236ceac424b25..0000000000000000000000000000000000000000 --- a/src/ui/QGCLinkConfiguration.ui +++ /dev/null @@ -1,67 +0,0 @@ - - - QGCLinkConfiguration - - - - 0 - 0 - 400 - 391 - - - - Form - - - - - - - - - 1 - 1 - - - - - - - - - - - - Delete - - - - - - - Edit - - - - - - - Add - - - - - - - Connect - - - - - - - - - - diff --git a/src/ui/QGCTCPLinkConfiguration.cc b/src/ui/QGCTCPLinkConfiguration.cc deleted file mode 100644 index 722f460e1e04a8ad2ee9235d21f1a06a020efb15..0000000000000000000000000000000000000000 --- a/src/ui/QGCTCPLinkConfiguration.cc +++ /dev/null @@ -1,74 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Implementation of QGCTCPLinkConfiguration - * @author Gus Grubba - */ - -#include - -#include "QGCTCPLinkConfiguration.h" -#include "ui_QGCTCPLinkConfiguration.h" - -QGCTCPLinkConfiguration::QGCTCPLinkConfiguration(TCPConfiguration *config, QWidget *parent) - : QWidget(parent) - , _ui(new Ui::QGCTCPLinkConfiguration) - , _config(config) -{ - Q_ASSERT(_config != NULL); - _ui->setupUi(this); - quint16 port = config->port(); - _ui->portSpinBox->setValue(port); - QString addr = config->address().toString(); - _ui->hostAddressLineEdit->setText(addr); -} - -QGCTCPLinkConfiguration::~QGCTCPLinkConfiguration() -{ - delete _ui; -} - -void QGCTCPLinkConfiguration::changeEvent(QEvent *e) -{ - QWidget::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - _ui->retranslateUi(this); - break; - default: - break; - } -} - -void QGCTCPLinkConfiguration::on_portSpinBox_valueChanged(int arg1) -{ - _config->setPort(arg1); -} - -void QGCTCPLinkConfiguration::on_hostAddressLineEdit_textChanged(const QString &arg1) -{ - QHostAddress add(arg1); - _config->setAddress(add); -} diff --git a/src/ui/QGCTCPLinkConfiguration.h b/src/ui/QGCTCPLinkConfiguration.h deleted file mode 100644 index a971547e9028a66c79aba6fde6cf340ac20e1750..0000000000000000000000000000000000000000 --- a/src/ui/QGCTCPLinkConfiguration.h +++ /dev/null @@ -1,61 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Implementation of QGCTCPLinkConfiguration - * @author Gus Grubba - */ - -#ifndef QGCTCPLINKCONFIGURATION_H -#define QGCTCPLINKCONFIGURATION_H - -#include - -#include "TCPLink.h" - -namespace Ui -{ -class QGCTCPLinkConfiguration; -} - -class QGCTCPLinkConfiguration : public QWidget -{ - Q_OBJECT -public: - explicit QGCTCPLinkConfiguration(TCPConfiguration *config, QWidget *parent = 0); - ~QGCTCPLinkConfiguration(); - -protected: - void changeEvent(QEvent *e); - -private slots: - void on_portSpinBox_valueChanged(int arg1); - void on_hostAddressLineEdit_textChanged(const QString &arg1); - -private: - Ui::QGCTCPLinkConfiguration* _ui; - TCPConfiguration* _config; -}; - -#endif // QGCTCPLINKCONFIGURATION_H diff --git a/src/ui/QGCTCPLinkConfiguration.ui b/src/ui/QGCTCPLinkConfiguration.ui deleted file mode 100644 index d5879289041693bba48d336748d187da2d49a961..0000000000000000000000000000000000000000 --- a/src/ui/QGCTCPLinkConfiguration.ui +++ /dev/null @@ -1,61 +0,0 @@ - - - QGCTCPLinkConfiguration - - - - 0 - 0 - 400 - 300 - - - - Form - - - - QFormLayout::FieldsStayAtSizeHint - - - - - TCP Port - - - - - - - 1024 - - - 65535 - - - 3000 - - - - - - - Host Address - - - - - - - - 200 - 0 - - - - - - - - - diff --git a/src/ui/QGCUDPLinkConfiguration.cc b/src/ui/QGCUDPLinkConfiguration.cc deleted file mode 100644 index fb9074de67e6f041f12a8262f0195190651c196c..0000000000000000000000000000000000000000 --- a/src/ui/QGCUDPLinkConfiguration.cc +++ /dev/null @@ -1,157 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Implementation of QGCUDPLinkConfiguration - * @author Gus Grubba - */ - -#include - -#include "QGCUDPLinkConfiguration.h" -#include "ui_QGCUDPLinkConfiguration.h" - -QGCUDPLinkConfiguration::QGCUDPLinkConfiguration(UDPConfiguration *config, QWidget *parent) - : QWidget(parent) - , _inConstructor(true) - , _ui(new Ui::QGCUDPLinkConfiguration) -{ - _config = config; - _ui->setupUi(this); - _viewModel = new UPDViewModel; - _ui->listView->setModel(_viewModel); - _ui->removeHost->setEnabled(false); - _ui->editHost->setEnabled(false); - _ui->portNumber->setRange(1024, 65535); - _ui->portNumber->setValue(_config->localPort()); - _reloadList(); - _inConstructor = false; -} - -QGCUDPLinkConfiguration::~QGCUDPLinkConfiguration() -{ - delete _ui; -} - -void QGCUDPLinkConfiguration::_reloadList() -{ - QString host; - int port; - if(_config->firstHost(host, port)) { - _viewModel->beginChange(); - _viewModel->hosts.clear(); - do { - _viewModel->hosts.append(QString("%1:%2").arg(host, QString::number(port))); - } while (_config->nextHost(host, port)); - _viewModel->endChange(); - } -} - -void QGCUDPLinkConfiguration::_editHost(int row) -{ - if(row < _viewModel->hosts.count()) { - bool ok; - QString oldName = _viewModel->hosts.at(row); - QString hostName = QInputDialog::getText( - this, tr("Edit a MAVLink host target"), - tr("Host (hostname:port): "), QLineEdit::Normal, oldName, &ok); - if (ok && !hostName.isEmpty()) { - _viewModel->beginChange(); - _viewModel->hosts.replace(row, hostName); - _viewModel->endChange(); - _config->removeHost(oldName); - _config->addHost(hostName); - } - } -} - -void QGCUDPLinkConfiguration::on_portNumber_valueChanged(int arg1) -{ - if(!_inConstructor) { - _config->setLocalPort(arg1); - _config->setDynamic(false); - } -} - -void QGCUDPLinkConfiguration::on_listView_clicked(const QModelIndex &index) -{ - bool enabled = index.row() < _viewModel->hosts.count(); - _ui->removeHost->setEnabled(enabled); - _ui->editHost->setEnabled(enabled); -} - -void QGCUDPLinkConfiguration::on_listView_doubleClicked(const QModelIndex &index) -{ - _editHost(index.row()); -} - -void QGCUDPLinkConfiguration::on_addHost_clicked() -{ - bool ok; - QString hostName = QInputDialog::getText( - this, tr("Add a host target to MAVLink"), - tr("Host (hostname:port): "), - QLineEdit::Normal, QString("localhost:%1").arg(QGC_UDP_TARGET_PORT), &ok); - if (ok && !hostName.isEmpty()) { - _config->addHost(hostName); - _reloadList(); - } -} - -void QGCUDPLinkConfiguration::on_removeHost_clicked() -{ - QModelIndex index = _ui->listView->currentIndex(); - if(index.row() < _viewModel->hosts.count()) { - QString oldName = _viewModel->hosts.at(index.row()); - _viewModel->hosts.removeAt(index.row()); - _config->removeHost(oldName); - _reloadList(); - } -} - -void QGCUDPLinkConfiguration::on_editHost_clicked() -{ - QModelIndex index = _ui->listView->currentIndex(); - _editHost(index.row()); -} - - -UPDViewModel::UPDViewModel(QObject *parent) : QAbstractListModel(parent) -{ - Q_UNUSED(parent); -} - -int UPDViewModel::rowCount( const QModelIndex & parent) const -{ - Q_UNUSED(parent); - return hosts.count(); -} - -QVariant UPDViewModel::data( const QModelIndex & index, int role) const -{ - if (role == Qt::DisplayRole && index.row() < hosts.count()) { - return hosts.at(index.row()); - } - return QVariant(); -} diff --git a/src/ui/QGCUDPLinkConfiguration.h b/src/ui/QGCUDPLinkConfiguration.h deleted file mode 100644 index 35e8d709aa27f40b2c23960ea4fc8f8ab15a022b..0000000000000000000000000000000000000000 --- a/src/ui/QGCUDPLinkConfiguration.h +++ /dev/null @@ -1,83 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief Implementation of QGCUDPLinkConfiguration - * @author Gus Grubba - */ - -#ifndef QGCUDPLINKCONFIGURATION_H -#define QGCUDPLINKCONFIGURATION_H - -#include -#include - -#include "UDPLink.h" - -namespace Ui { -class QGCUDPLinkConfiguration; -} - -class UPDViewModel; - -class QGCUDPLinkConfiguration : public QWidget -{ - Q_OBJECT - -public: - explicit QGCUDPLinkConfiguration(UDPConfiguration* config, QWidget *parent = 0); - ~QGCUDPLinkConfiguration(); - -private slots: - void on_addHost_clicked(); - void on_removeHost_clicked(); - void on_editHost_clicked(); - void on_listView_clicked(const QModelIndex &index); - void on_listView_doubleClicked(const QModelIndex &index); - - void on_portNumber_valueChanged(int arg1); - -private: - - void _reloadList(); - void _editHost(int row); - - bool _inConstructor; - Ui::QGCUDPLinkConfiguration* _ui; - UDPConfiguration* _config; - UPDViewModel* _viewModel; -}; - -class UPDViewModel : public QAbstractListModel -{ -public: - UPDViewModel(QObject *parent = 0); - int rowCount ( const QModelIndex & parent = QModelIndex() ) const; - QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; - void beginChange() { beginResetModel(); } - void endChange() { endResetModel(); } - QStringList hosts; -}; - -#endif // QGCUDPLINKCONFIGURATION_H diff --git a/src/ui/QGCUDPLinkConfiguration.ui b/src/ui/QGCUDPLinkConfiguration.ui deleted file mode 100644 index e5351d92557ffdf078406663676582a2870a2daf..0000000000000000000000000000000000000000 --- a/src/ui/QGCUDPLinkConfiguration.ui +++ /dev/null @@ -1,90 +0,0 @@ - - - QGCUDPLinkConfiguration - - - - 0 - 0 - 314 - 285 - - - - Form - - - - - - - - Listening Port: - - - - - - - - 80 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Target Hosts - - - - - - - - - - - - Add - - - - - - - Remove - - - - - - - Edit - - - - - - - - - - diff --git a/src/ui/SettingsDialog.cc b/src/ui/SettingsDialog.cc index 0d9bc946ad97c5cf62dbdf2d7351399985f8aa3b..e4216cb423e2ddacfbf589daa1b4815b3eb11bf9 100644 --- a/src/ui/SettingsDialog.cc +++ b/src/ui/SettingsDialog.cc @@ -31,7 +31,6 @@ #include "LinkManager.h" #include "MAVLinkProtocol.h" #include "MAVLinkSettingsWidget.h" -#include "QGCLinkConfiguration.h" #include "GAudioOutput.h" #include "QGCApplication.h" #include "QGCFileDialog.h" @@ -53,11 +52,8 @@ SettingsDialog::SettingsDialog(QWidget *parent, int showTab, Qt::WindowFlags fla position.moveCenter(QApplication::desktop()->availableGeometry(screen).center()); move(position.topLeft()); - QGCLinkConfiguration* pLinkConf = new QGCLinkConfiguration(this); MAVLinkSettingsWidget* pMavsettings = new MAVLinkSettingsWidget(qgcApp()->toolbox()->mavlinkProtocol(), this); - // Add the link settings pane - _ui->tabWidget->addTab(pLinkConf, "Comm Links"); // Add the MAVLink settings pane _ui->tabWidget->addTab(pMavsettings, "MAVLink"); @@ -68,14 +64,9 @@ SettingsDialog::SettingsDialog(QWidget *parent, int showTab, Qt::WindowFlags fla // Connect signals connect(_ui->browseSavedFilesLocation, &QPushButton::clicked, this, &SettingsDialog::_selectSavedFilesDirectory); connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::_validateBeforeClose); - - switch (showTab) { - case ShowCommLinks: - _ui->tabWidget->setCurrentWidget(pLinkConf); - break; - case ShowMavlink: - _ui->tabWidget->setCurrentWidget(pMavsettings); - break; + + if (showTab == ShowMavlink) { + _ui->tabWidget->setCurrentWidget(pMavsettings); } } diff --git a/src/ui/SettingsDialog.h b/src/ui/SettingsDialog.h index cd7647103aae5c304a632c93257e935f9859d934..7e8432747e7f03b8ec754a0fb450b83d986b8762 100644 --- a/src/ui/SettingsDialog.h +++ b/src/ui/SettingsDialog.h @@ -43,7 +43,6 @@ public: enum { ShowDefault, - ShowCommLinks, ShowControllers, ShowMavlink }; diff --git a/src/ui/preferences/BluetoothSettings.qml b/src/ui/preferences/BluetoothSettings.qml index c821ad4a44b1b283a42780085f0b051cdb090dc0..e6d7e18ccdb5d4c6021baaaa0c4ded788a8b3b72 100644 --- a/src/ui/preferences/BluetoothSettings.qml +++ b/src/ui/preferences/BluetoothSettings.qml @@ -75,6 +75,7 @@ Item { } } Row { + visible: !ScreenTools.isiOS spacing: ScreenTools.defaultFontPixelWidth QGCLabel { text: "Address:" diff --git a/src/ui/preferences/LinkSettings.qml b/src/ui/preferences/LinkSettings.qml index 9afbbecbcf0d57ee6a1475af4d9a43495af312c0..a016aa3fde8099d93c1be2a807ccb3d5b0cc5e75 100644 --- a/src/ui/preferences/LinkSettings.qml +++ b/src/ui/preferences/LinkSettings.qml @@ -74,7 +74,7 @@ Rectangle { anchors.margins: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelHeight / 2 QGCLabel { - text: "Comm Link Settings (WIP)" + text: "Comm Link Settings" font.pixelSize: ScreenTools.mediumFontPixelSize } Rectangle { diff --git a/src/ui/preferences/MavlinkSettings.qml b/src/ui/preferences/MavlinkSettings.qml index 0bd4daceb96dd2694258a85835b4cffb48b1a9d9..6852f4eb819e0f92a4fa26ecc50c7891cff830e2 100644 --- a/src/ui/preferences/MavlinkSettings.qml +++ b/src/ui/preferences/MavlinkSettings.qml @@ -67,6 +67,25 @@ Rectangle { color: qgcPal.button } //----------------------------------------------------------------- + //-- System ID + Row { + spacing: ScreenTools.defaultFontPixelWidth + QGCLabel { + text: "Ground Station MavLink System ID:" + anchors.verticalCenter: parent.verticalCenter + } + QGCTextField { + id: sysidField + text: QGroundControl.mavlinkSystemID.toString() + width: ScreenTools.defaultFontPixelWidth * 6 + inputMethodHints: Qt.ImhFormattedNumbersOnly + anchors.verticalCenter: parent.verticalCenter + onEditingFinished: { + QGroundControl.mavlinkSystemID = parseInt(sysidField.text) + } + } + } + //----------------------------------------------------------------- //-- Mavlink Heartbeats QGCCheckBox { text: "Emit heartbeat"