Commit ec3047af authored by Gus Grubba's avatar Gus Grubba
Browse files

Merge pull request #2374 from dogmaphobic/commSettings

Removing old comm link settings.
parents 90222306 6a1fe19d
...@@ -193,11 +193,6 @@ FORMS += \ ...@@ -193,11 +193,6 @@ FORMS += \
src/ui/MainWindow.ui \ src/ui/MainWindow.ui \
src/QGCQmlWidgetHolder.ui \ src/QGCQmlWidgetHolder.ui \
DebugBuild {
FORMS += \
src/ui/MockLinkConfiguration.ui \
}
!iOSBuild { !iOSBuild {
FORMS += \ FORMS += \
src/ui/SerialSettings.ui \ src/ui/SerialSettings.ui \
...@@ -208,21 +203,16 @@ FORMS += \ ...@@ -208,21 +203,16 @@ FORMS += \
src/ui/uas/QGCUnconnectedInfoWidget.ui \ src/ui/uas/QGCUnconnectedInfoWidget.ui \
src/ui/uas/UASMessageView.ui \ src/ui/uas/UASMessageView.ui \
src/ui/Linechart.ui \ src/ui/Linechart.ui \
src/ui/LogReplayLinkConfigurationWidget.ui \
src/ui/MultiVehicleDockWidget.ui \ src/ui/MultiVehicleDockWidget.ui \
src/ui/MAVLinkSettingsWidget.ui \ src/ui/MAVLinkSettingsWidget.ui \
src/ui/QGCCommConfiguration.ui \
src/ui/QGCDataPlot2D.ui \ src/ui/QGCDataPlot2D.ui \
src/ui/QGCHilConfiguration.ui \ src/ui/QGCHilConfiguration.ui \
src/ui/QGCHilFlightGearConfiguration.ui \ src/ui/QGCHilFlightGearConfiguration.ui \
src/ui/QGCHilJSBSimConfiguration.ui \ src/ui/QGCHilJSBSimConfiguration.ui \
src/ui/QGCHilXPlaneConfiguration.ui \ src/ui/QGCHilXPlaneConfiguration.ui \
src/ui/QGCLinkConfiguration.ui \
src/ui/QGCMapRCToParamDialog.ui \ src/ui/QGCMapRCToParamDialog.ui \
src/ui/QGCMAVLinkInspector.ui \ src/ui/QGCMAVLinkInspector.ui \
src/ui/QGCMAVLinkLogPlayer.ui \ src/ui/QGCMAVLinkLogPlayer.ui \
src/ui/QGCTCPLinkConfiguration.ui \
src/ui/QGCUDPLinkConfiguration.ui \
src/ui/QGCTabbedInfoView.ui \ src/ui/QGCTabbedInfoView.ui \
src/ui/QGCUASFileView.ui \ src/ui/QGCUASFileView.ui \
src/ui/QGCUASFileViewMulti.ui \ src/ui/QGCUASFileViewMulti.ui \
...@@ -287,7 +277,6 @@ HEADERS += \ ...@@ -287,7 +277,6 @@ HEADERS += \
src/comm/MockLink.h \ src/comm/MockLink.h \
src/comm/MockLinkFileServer.h \ src/comm/MockLinkFileServer.h \
src/comm/MockLinkMissionItemHandler.h \ src/comm/MockLinkMissionItemHandler.h \
src/ui/MockLinkConfiguration.h \
} }
WindowsBuild { WindowsBuild {
...@@ -325,17 +314,12 @@ HEADERS += \ ...@@ -325,17 +314,12 @@ HEADERS += \
src/ui/linechart/LinechartWidget.h \ src/ui/linechart/LinechartWidget.h \
src/ui/linechart/Scrollbar.h \ src/ui/linechart/Scrollbar.h \
src/ui/linechart/ScrollZoomer.h \ src/ui/linechart/ScrollZoomer.h \
src/ui/LogReplayLinkConfigurationWidget.h \
src/ui/MainWindow.h \ src/ui/MainWindow.h \
src/ui/MAVLinkDecoder.h \ src/ui/MAVLinkDecoder.h \
src/ui/MAVLinkSettingsWidget.h \ src/ui/MAVLinkSettingsWidget.h \
src/ui/MultiVehicleDockWidget.h \ src/ui/MultiVehicleDockWidget.h \
src/ui/QGCCommConfiguration.h \
src/ui/QGCLinkConfiguration.h \
src/ui/QGCMAVLinkLogPlayer.h \ src/ui/QGCMAVLinkLogPlayer.h \
src/ui/QGCMapRCToParamDialog.h \ src/ui/QGCMapRCToParamDialog.h \
src/ui/QGCTCPLinkConfiguration.h \
src/ui/QGCUDPLinkConfiguration.h \
src/ui/SettingsDialog.h \ src/ui/SettingsDialog.h \
src/ui/uas/UASMessageView.h \ src/ui/uas/UASMessageView.h \
src/ui/uas/QGCUnconnectedInfoWidget.h \ src/ui/uas/QGCUnconnectedInfoWidget.h \
...@@ -409,7 +393,6 @@ SOURCES += \ ...@@ -409,7 +393,6 @@ SOURCES += \
src/comm/MockLink.cc \ src/comm/MockLink.cc \
src/comm/MockLinkFileServer.cc \ src/comm/MockLinkFileServer.cc \
src/comm/MockLinkMissionItemHandler.cc \ src/comm/MockLinkMissionItemHandler.cc \
src/ui/MockLinkConfiguration.cc \
} }
!iOSBuild { !iOSBuild {
...@@ -430,16 +413,11 @@ SOURCES += \ ...@@ -430,16 +413,11 @@ SOURCES += \
src/uas/FileManager.cc \ src/uas/FileManager.cc \
src/ui/uas/QGCUnconnectedInfoWidget.cc \ src/ui/uas/QGCUnconnectedInfoWidget.cc \
src/ui/SettingsDialog.cc \ src/ui/SettingsDialog.cc \
src/ui/QGCTCPLinkConfiguration.cc \
src/ui/QGCUDPLinkConfiguration.cc \
src/ui/MAVLinkDecoder.cc \ src/ui/MAVLinkDecoder.cc \
src/ui/MAVLinkSettingsWidget.cc \ src/ui/MAVLinkSettingsWidget.cc \
src/ui/QGCCommConfiguration.cc \
src/ui/QGCLinkConfiguration.cc \
src/ui/QGCMapRCToParamDialog.cpp \ src/ui/QGCMapRCToParamDialog.cpp \
src/comm/LogReplayLink.cc \ src/comm/LogReplayLink.cc \
src/QGCFileDialog.cc \ src/QGCFileDialog.cc \
src/ui/LogReplayLinkConfigurationWidget.cc \
src/ui/QGCMAVLinkLogPlayer.cc \ src/ui/QGCMAVLinkLogPlayer.cc \
src/comm/QGCFlightGearLink.cc \ src/comm/QGCFlightGearLink.cc \
src/comm/QGCJSBSimLink.cc \ src/comm/QGCJSBSimLink.cc \
......
...@@ -168,6 +168,12 @@ void QGroundControlQmlGlobal::setIsVersionCheckEnabled(bool enable) ...@@ -168,6 +168,12 @@ void QGroundControlQmlGlobal::setIsVersionCheckEnabled(bool enable)
emit isVersionCheckEnabledChanged(enable); emit isVersionCheckEnabledChanged(enable);
} }
void QGroundControlQmlGlobal::setMavlinkSystemID(int id)
{
qgcApp()->toolbox()->mavlinkProtocol()->setSystemId(id);
emit mavlinkSystemIDChanged(id);
}
void QGroundControlQmlGlobal::setVirtualTabletJoystick(bool enabled) void QGroundControlQmlGlobal::setVirtualTabletJoystick(bool enabled)
{ {
if (_virtualTabletJoystick != enabled) { if (_virtualTabletJoystick != enabled) {
......
...@@ -64,10 +64,13 @@ public: ...@@ -64,10 +64,13 @@ public:
Q_PROPERTY(bool isAudioMuted READ isAudioMuted WRITE setIsAudioMuted NOTIFY isAudioMutedChanged) Q_PROPERTY(bool isAudioMuted READ isAudioMuted WRITE setIsAudioMuted NOTIFY isAudioMutedChanged)
Q_PROPERTY(bool isSaveLogPrompt READ isSaveLogPrompt WRITE setIsSaveLogPrompt NOTIFY isSaveLogPromptChanged) Q_PROPERTY(bool isSaveLogPrompt READ isSaveLogPrompt WRITE setIsSaveLogPrompt NOTIFY isSaveLogPromptChanged)
Q_PROPERTY(bool isSaveLogPromptNotArmed READ isSaveLogPromptNotArmed WRITE setIsSaveLogPromptNotArmed NOTIFY isSaveLogPromptNotArmedChanged) 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 isHeartBeatEnabled READ isHeartBeatEnabled WRITE setIsHeartBeatEnabled NOTIFY isHeartBeatEnabledChanged)
Q_PROPERTY(bool isMultiplexingEnabled READ isMultiplexingEnabled WRITE setIsMultiplexingEnabled NOTIFY isMultiplexingEnabledChanged) Q_PROPERTY(bool isMultiplexingEnabled READ isMultiplexingEnabled WRITE setIsMultiplexingEnabled NOTIFY isMultiplexingEnabledChanged)
Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged) 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 void saveGlobalSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue); Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue);
...@@ -99,10 +102,12 @@ public: ...@@ -99,10 +102,12 @@ public:
bool isAudioMuted () { return qgcApp()->toolbox()->audioOutput()->isMuted(); } bool isAudioMuted () { return qgcApp()->toolbox()->audioOutput()->isMuted(); }
bool isSaveLogPrompt () { return qgcApp()->promptFlightDataSave(); } bool isSaveLogPrompt () { return qgcApp()->promptFlightDataSave(); }
bool isSaveLogPromptNotArmed () { return qgcApp()->promptFlightDataSaveNotArmed(); } bool isSaveLogPromptNotArmed () { return qgcApp()->promptFlightDataSaveNotArmed(); }
bool virtualTabletJoystick () { return _virtualTabletJoystick; }
bool isHeartBeatEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->heartbeatsEnabled(); } bool isHeartBeatEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->heartbeatsEnabled(); }
bool isMultiplexingEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->multiplexingEnabled(); } bool isMultiplexingEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->multiplexingEnabled(); }
bool isVersionCheckEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->versionCheckEnabled(); } 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. //-- TODO: Make this into an actual preference.
bool isAdvancedMode () { return false; } bool isAdvancedMode () { return false; }
...@@ -111,20 +116,23 @@ public: ...@@ -111,20 +116,23 @@ public:
void setIsAudioMuted (bool muted); void setIsAudioMuted (bool muted);
void setIsSaveLogPrompt (bool prompt); void setIsSaveLogPrompt (bool prompt);
void setIsSaveLogPromptNotArmed (bool prompt); void setIsSaveLogPromptNotArmed (bool prompt);
void setVirtualTabletJoystick (bool enabled);
void setIsHeartBeatEnabled (bool enable); void setIsHeartBeatEnabled (bool enable);
void setIsMultiplexingEnabled (bool enable); void setIsMultiplexingEnabled (bool enable);
void setIsVersionCheckEnabled (bool enable); void setIsVersionCheckEnabled (bool enable);
void setVirtualTabletJoystick (bool enabled); void setMavlinkSystemID (int id);
signals: signals:
void isDarkStyleChanged (bool dark); void isDarkStyleChanged (bool dark);
void isAudioMutedChanged (bool muted); void isAudioMutedChanged (bool muted);
void isSaveLogPromptChanged (bool prompt); void isSaveLogPromptChanged (bool prompt);
void isSaveLogPromptNotArmedChanged (bool prompt); void isSaveLogPromptNotArmedChanged (bool prompt);
void virtualTabletJoystickChanged (bool enabled);
void isHeartBeatEnabledChanged (bool enabled); void isHeartBeatEnabledChanged (bool enabled);
void isMultiplexingEnabledChanged (bool enabled); void isMultiplexingEnabledChanged (bool enabled);
void isVersionCheckEnabledChanged (bool enabled); void isVersionCheckEnabledChanged (bool enabled);
void virtualTabletJoystickChanged (bool enabled); void mavlinkSystemIDChanged (int id);
private: private:
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
#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
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef _LogReplayLinkConfigurationWidget_H_
#define _LogReplayLinkConfigurationWidget_H_
#include <QWidget>
#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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LogReplayLinkConfigurationWidget</class>
<widget class="QWidget" name="LogReplayLinkConfigurationWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>325</width>
<height>347</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Log File:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="logFilename">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="selectLogFileButton">
<property name="text">
<string>Select Log File</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
<action name="actionDelete">
<property name="text">
<string>Delete</string>
</property>
<property name="toolTip">
<string>Delete this link</string>
</property>
<property name="statusTip">
<string>Delete this link</string>
</property>
<property name="whatsThis">
<string>Link delete button</string>
</property>
</action>
<action name="actionConnect">
<property name="text">
<string>Connect</string>
</property>
<property name="toolTip">
<string>Connect this link</string>
</property>
<property name="statusTip">
<string>Connect this link</string>
</property>
<property name="whatsThis">
<string>Connect this link</string>
</property>
</action>
<action name="actionClose">
<property name="text">
<string>Close</string>
</property>
<property name="toolTip">
<string>Close the configuration window</string>
</property>
<property name="statusTip">
<string>Close the configuration window</string>
</property>
<property name="whatsThis">
<string>Close the configuration window</string>
</property>
</action>
</widget>
<resources/>
<connections>
<connection>
<sender>actionClose</sender>
<signal>triggered()</signal>
<receiver>LogReplayLinkConfigurationWidget</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>224</x>
<y>195</y>
</hint>
</hints>
</connection>
</connections>
</ui>
...@@ -536,9 +536,6 @@ void MainWindow::configureWindowName() ...@@ -536,9 +536,6 @@ void MainWindow::configureWindowName()
**/ **/
void MainWindow::connectCommonActions() void MainWindow::connectCommonActions()
{ {
// Connect actions from ui
connect(_ui.actionAdd_Link, SIGNAL(triggered()), this, SLOT(manageLinks()));
// Audio output // Audio output
_ui.actionMuteAudioOutput->setChecked(qgcApp()->toolbox()->audioOutput()->isMuted()); _ui.actionMuteAudioOutput->setChecked(qgcApp()->toolbox()->audioOutput()->isMuted());
connect(qgcApp()->toolbox()->audioOutput(), SIGNAL(mutedChanged(bool)), _ui.actionMuteAudioOutput, SLOT(setChecked(bool))); connect(qgcApp()->toolbox()->audioOutput(), SIGNAL(mutedChanged(bool)), _ui.actionMuteAudioOutput, SLOT(setChecked(bool)));
...@@ -581,13 +578,6 @@ void MainWindow::showSettings() ...@@ -581,13 +578,6 @@ void MainWindow::showSettings()
SettingsDialog settings(this); SettingsDialog settings(this);
settings.exec(); settings.exec();
} }
void MainWindow::manageLinks()
{
SettingsDialog settings(this, SettingsDialog::ShowCommLinks);
settings.exec();
}
#endif #endif
void MainWindow::_vehicleAdded(Vehicle* vehicle) void MainWindow::_vehicleAdded(Vehicle* vehicle)
......
...@@ -104,7 +104,6 @@ public: ...@@ -104,7 +104,6 @@ public:
public slots: public slots:
#ifndef __mobile__ #ifndef __mobile__
void showSettings(); void showSettings();
void manageLinks();
#endif #endif
/** @brief Save power by reducing update rates */ /** @brief Save power by reducing update rates */
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
</property> </property>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionMuteAudioOutput"/> <addaction name="actionMuteAudioOutput"/>
<addaction name="actionAdd_Link"/>
<addaction name="actionSettings"/> <addaction name="actionSettings"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
#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);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef MockLinkConfiguration_H
#define MockLinkConfiguration_H
#include <QWidget>
#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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MockLinkConfiguration</class>
<widget class="QWidget" name="MockLinkConfiguration">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>238</width>
<height>188</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="px4Radio">
<property name="text">
<string>PX4 Firmware</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="apmRadio">
<property name="text">
<string>APM Firmware</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="genericRadio">
<property name="text">
<string>Generic Firmware</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="sendStatusTextCheckBox">
<property name="text">
<string>Send status text + voice</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>APM vehicle type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="apmArduCopterRadio">
<property name="text">
<string>ArduCopter</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="apmArduPlaneRadio">
<property name="text">
<string>ArduPlane</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Comm Link Configuration
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#include <QPushButton>
#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);
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Comm Link Configuration
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#ifndef QGCCOMMCONFIGURATION_H
#define QGCCOMMCONFIGURATION_H
#include <QWidget>
#include <QDialog>
#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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCCommConfiguration</class>
<widget class="QWidget" name="QGCCommConfiguration">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>450</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>450</width>
<height>450</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="nameLabel">
<property name="minimumSize">
<size>
<width>160</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Link Name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="nameEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="typeLabel_3">
<property name="minimumSize">
<size>
<width>160</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Link Type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="typeCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="linkGroupBox">
<property name="title">
<string>Link</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="linkScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>304</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of QGCLinkConfiguration
* @author Gus Grubba <mavlink@grubba.com>
*/
#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<SettingsDialog*>(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<SerialConfiguration*>(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<UDPConfiguration*>(config)->localPort()));
break;
case LinkConfiguration::TypeTcp: {
TCPConfiguration* tconfig = dynamic_cast<TCPConfiguration*>(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<LogReplayLinkConfiguration*>(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<LinkConfiguration*>(index.row())->name());
return name;
}
return QVariant();
}
LinkConfiguration* LinkViewModel::getConfiguration(int row)
{
if(row < rowCount()) {
return qgcApp()->toolbox()->linkManager()->linkConfigurations()->value<LinkConfiguration*>(row);
}
return NULL;
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of QGCLinkConfiguration
* @author Gus Grubba <mavlink@grubba.com>
*/
#ifndef QGCLINKCONFIGURATION_H
#define QGCLINKCONFIGURATION_H
#include <QWidget>
#include <QListView>
#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
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCLinkConfiguration</class>
<widget class="QWidget" name="QGCLinkConfiguration">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>391</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListView" name="linkView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="delLinkButton">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editLinkButton">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addLinkButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="connectLinkButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of QGCTCPLinkConfiguration
* @author Gus Grubba <mavlink@grubba.com>
*/
#include <QInputDialog>
#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);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Implementation of QGCTCPLinkConfiguration
* @author Gus Grubba <mavlink@grubba.com>
*/
#ifndef QGCTCPLINKCONFIGURATION_H
#define QGCTCPLINKCONFIGURATION_H
#include <QWidget>
#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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment