From 6a84a9a9b019ccf6e907c1981cf93826f2a8c122 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 5 Jan 2016 12:14:20 -0200 Subject: [PATCH] More conversions from old to new Connect syntax Signed-off-by: Tomaz Canabrava --- src/comm/QGCXPlaneLink.cc | 2 +- src/comm/SerialLink.cc | 3 +- src/comm/TCPLink.cc | 10 ++++-- src/comm/UDPLink.cc | 2 +- src/uas/UAS.cc | 4 +-- src/uas/UASMessageHandler.cc | 4 +-- src/ui/MAVLinkDecoder.cc | 2 +- src/ui/MAVLinkSettingsWidget.cc | 61 +++++++++++++++++---------------- 8 files changed, 48 insertions(+), 40 deletions(-) diff --git a/src/comm/QGCXPlaneLink.cc b/src/comm/QGCXPlaneLink.cc index 914651b99..156b2b966 100644 --- a/src/comm/QGCXPlaneLink.cc +++ b/src/comm/QGCXPlaneLink.cc @@ -248,7 +248,7 @@ void QGCXPlaneLink::run() disconnect(this, &QGCXPlaneLink::sensorHilRawImuChanged, _vehicle->uas(), &UAS::sendHilSensors); connectState = false; - disconnect(socket, SIGNAL(readyRead()), this, SLOT(readBytes())); + disconnect(socket, &QUdpSocket::readyRead, this, &QGCXPlaneLink::readBytes); socket->close(); socket->deleteLater(); diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index b64be4932..506d988aa 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -215,7 +215,8 @@ bool SerialLink::_hardwareConnect(QSerialPort::SerialPortError& error, QString& return false; // couldn't create serial port. } - QObject::connect(_port, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(linkError(QSerialPort::SerialPortError))); + QObject::connect(_port, static_cast(&QSerialPort::error), + this, &SerialLink::linkError); QObject::connect(_port, &QIODevice::readyRead, this, &SerialLink::_readBytes); // port->setCommTimeouts(QSerialPort::CtScheme_NonBlockingRead); diff --git a/src/comm/TCPLink.cc b/src/comm/TCPLink.cc index a0c315e1c..9b72c7d22 100644 --- a/src/comm/TCPLink.cc +++ b/src/comm/TCPLink.cc @@ -156,10 +156,14 @@ bool TCPLink::_hardwareConnect() { Q_ASSERT(_socket == NULL); _socket = new QTcpSocket(); - QSignalSpy errorSpy(_socket, SIGNAL(error(QAbstractSocket::SocketError))); + + QSignalSpy errorSpy(_socket, static_cast(&QTcpSocket::error)); _socket->connectToHost(_config->address(), _config->port()); - QObject::connect(_socket, SIGNAL(readyRead()), this, SLOT(readBytes())); - QObject::connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_socketError(QAbstractSocket::SocketError))); + QObject::connect(_socket, &QTcpSocket::readyRead, this, &TCPLink::readBytes); + + QObject::connect(_socket,static_cast(&QTcpSocket::error), + this, &TCPLink::_socketError); + // Give the socket a second to connect to the other side otherwise error out if (!_socket->waitForConnected(1000)) { diff --git a/src/comm/UDPLink.cc b/src/comm/UDPLink.cc index 6926f90e8..1bbcc7963 100644 --- a/src/comm/UDPLink.cc +++ b/src/comm/UDPLink.cc @@ -327,7 +327,7 @@ bool UDPLink::_hardwareConnect() _registerZeroconf(_config->localPort(), kZeroconfRegistration); //-- Connect signal if this version of Qt is not broken if(!UDP_BROKEN_SIGNAL) { - QObject::connect(_socket, SIGNAL(readyRead()), this, SLOT(readBytes())); + QObject::connect(_socket, &QUdpSocket::readyRead, this, &UDPLink::readBytes); } emit connected(); } else { diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 7e8be3234..1205dcfb7 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -185,11 +185,11 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle, FirmwarePluginManager * fi } #ifndef __mobile__ - connect(mavlink, SIGNAL(messageReceived(LinkInterface*,mavlink_message_t)), &fileManager, SLOT(receiveMessage(LinkInterface*,mavlink_message_t))); + connect(mavlink, &MAVLinkProtocol::messageReceived, &fileManager, &FileManager::receiveMessage); #endif color = UASInterface::getNextColor(); - connect(&statusTimeout, SIGNAL(timeout()), this, SLOT(updateState())); + connect(&statusTimeout, &QTimer::timeout, this, &UAS::updateState); statusTimeout.start(500); } diff --git a/src/uas/UASMessageHandler.cc b/src/uas/UASMessageHandler.cc index 79b9d9267..ab24db561 100644 --- a/src/uas/UASMessageHandler.cc +++ b/src/uas/UASMessageHandler.cc @@ -100,7 +100,7 @@ void UASMessageHandler::_activeVehicleChanged(Vehicle* vehicle) // If we were already attached to an autopilot, disconnect it. if (_activeUAS) { - disconnect(_activeUAS, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString))); + disconnect(_activeUAS, &UASInterface::textMessageReceived, this, &UASMessageHandler::handleTextMessage); _activeUAS = NULL; clearMessages(); emit textMessageReceived(NULL); @@ -113,7 +113,7 @@ void UASMessageHandler::_activeVehicleChanged(Vehicle* vehicle) // Connect to the new UAS. clearMessages(); _activeUAS = uas; - connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), this, SLOT(handleTextMessage(int,int,int,QString))); + connect(uas, &UASInterface::textMessageReceived, this, &UASMessageHandler::handleTextMessage); } } diff --git a/src/ui/MAVLinkDecoder.cc b/src/ui/MAVLinkDecoder.cc index be443803c..25a9ff1cf 100644 --- a/src/ui/MAVLinkDecoder.cc +++ b/src/ui/MAVLinkDecoder.cc @@ -52,7 +52,7 @@ MAVLinkDecoder::MAVLinkDecoder(MAVLinkProtocol* protocol, QObject *parent) : textMessageFilter.insert(MAVLINK_MSG_ID_NAMED_VALUE_INT, false); // textMessageFilter.insert(MAVLINK_MSG_ID_HIGHRES_IMU, false); - connect(protocol, SIGNAL(messageReceived(LinkInterface*,mavlink_message_t)), this, SLOT(receiveMessage(LinkInterface*,mavlink_message_t))); + connect(protocol, &MAVLinkProtocol::messageReceived, this, &MAVLinkDecoder::receiveMessage); start(LowPriority); } diff --git a/src/ui/MAVLinkSettingsWidget.cc b/src/ui/MAVLinkSettingsWidget.cc index 5faa01f5e..21178ff05 100644 --- a/src/ui/MAVLinkSettingsWidget.cc +++ b/src/ui/MAVLinkSettingsWidget.cc @@ -67,37 +67,38 @@ MAVLinkSettingsWidget::MAVLinkSettingsWidget(MAVLinkProtocol* protocol, QWidget // Connect actions // Heartbeat - connect(protocol, SIGNAL(heartbeatChanged(bool)), m_ui->heartbeatCheckBox, SLOT(setChecked(bool))); - connect(m_ui->heartbeatCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableHeartbeats(bool))); + connect(protocol, &MAVLinkProtocol::heartbeatChanged, m_ui->heartbeatCheckBox, &QCheckBox::setChecked); + connect(m_ui->heartbeatCheckBox, &QCheckBox::toggled, protocol, &MAVLinkProtocol::enableHeartbeats); + // Version check - connect(protocol, SIGNAL(versionCheckChanged(bool)), m_ui->versionCheckBox, SLOT(setChecked(bool))); - connect(m_ui->versionCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableVersionCheck(bool))); + connect(protocol, &MAVLinkProtocol::versionCheckChanged, m_ui->versionCheckBox, &QCheckBox::setChecked); + connect(m_ui->versionCheckBox, &QCheckBox::toggled, protocol, &MAVLinkProtocol::enableVersionCheck); // System ID - connect(protocol, SIGNAL(systemIdChanged(int)), m_ui->systemIdSpinBox, SLOT(setValue(int))); - connect(m_ui->systemIdSpinBox, SIGNAL(valueChanged(int)), protocol, SLOT(setSystemId(int))); + connect(protocol, &MAVLinkProtocol::systemIdChanged, m_ui->systemIdSpinBox, &QSpinBox::setValue); + connect(m_ui->systemIdSpinBox,static_cast(&QSpinBox::valueChanged), protocol, &MAVLinkProtocol::setSystemId); // Multiplexing - connect(protocol, SIGNAL(multiplexingChanged(bool)), m_ui->multiplexingCheckBox, SLOT(setChecked(bool))); + connect(protocol, &MAVLinkProtocol::multiplexingChanged, m_ui->multiplexingCheckBox, &QCheckBox::setChecked); connect(m_ui->multiplexingCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableMultiplexing(bool))); // Parameter guard - connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramGuardCheckBox, SLOT(setChecked(bool))); - connect(m_ui->paramGuardCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableParamGuard(bool))); - connect(protocol, SIGNAL(paramRetransmissionTimeoutChanged(int)), m_ui->paramRetransmissionSpinBox, SLOT(setValue(int))); - connect(m_ui->paramRetransmissionSpinBox, SIGNAL(valueChanged(int)), protocol, SLOT(setParamRetransmissionTimeout(int))); - connect(protocol, SIGNAL(paramRewriteTimeoutChanged(int)), m_ui->paramRewriteSpinBox, SLOT(setValue(int))); - connect(m_ui->paramRewriteSpinBox, SIGNAL(valueChanged(int)), protocol, SLOT(setParamRewriteTimeout(int))); + connect(protocol, &MAVLinkProtocol::paramGuardChanged, m_ui->paramGuardCheckBox, &QCheckBox::setChecked); + connect(m_ui->paramGuardCheckBox, &QCheckBox::toggled, protocol, &MAVLinkProtocol::enableParamGuard); + connect(protocol, &MAVLinkProtocol::paramRetransmissionTimeoutChanged, m_ui->paramRetransmissionSpinBox, &QSpinBox::setValue); + connect(m_ui->paramRetransmissionSpinBox, static_cast(&QSpinBox::valueChanged), protocol, &MAVLinkProtocol::setParamRetransmissionTimeout); + connect(protocol, &MAVLinkProtocol::paramRewriteTimeoutChanged, m_ui->paramRewriteSpinBox, &QSpinBox::setValue); + connect(m_ui->paramRewriteSpinBox, static_cast(&QSpinBox::valueChanged), protocol, &MAVLinkProtocol::setParamRewriteTimeout); // Action guard - connect(protocol, SIGNAL(actionGuardChanged(bool)), m_ui->actionGuardCheckBox, SLOT(setChecked(bool))); - connect(m_ui->actionGuardCheckBox, SIGNAL(toggled(bool)), protocol, SLOT(enableActionGuard(bool))); - connect(protocol, SIGNAL(actionRetransmissionTimeoutChanged(int)), m_ui->actionRetransmissionSpinBox, SLOT(setValue(int))); - connect(m_ui->actionRetransmissionSpinBox, SIGNAL(valueChanged(int)), protocol, SLOT(setActionRetransmissionTimeout(int))); + connect(protocol, &MAVLinkProtocol::actionGuardChanged, m_ui->actionGuardCheckBox, &QCheckBox::setChecked); + connect(m_ui->actionGuardCheckBox, &QCheckBox::toggled, protocol, &MAVLinkProtocol::enableActionGuard); + connect(protocol, &MAVLinkProtocol::actionRetransmissionTimeoutChanged, m_ui->actionRetransmissionSpinBox, &QSpinBox::setValue); + connect(m_ui->actionRetransmissionSpinBox, static_cast(&QSpinBox::valueChanged), protocol, &MAVLinkProtocol::setActionRetransmissionTimeout); // MAVLink AUTH - connect(protocol, SIGNAL(authChanged(bool)), m_ui->droneOSCheckBox, SLOT(setChecked(bool))); - connect(m_ui->droneOSCheckBox, SIGNAL(toggled(bool)), this, SLOT(enableDroneOS(bool))); - connect(protocol, SIGNAL(authKeyChanged(QString)), m_ui->droneOSLineEdit, SLOT(setText(QString))); - connect(m_ui->droneOSLineEdit, SIGNAL(textChanged(QString)), this, SLOT(setDroneOSKey(QString))); + connect(protocol, &MAVLinkProtocol::authChanged, m_ui->droneOSCheckBox, &QCheckBox::setChecked); + connect(m_ui->droneOSCheckBox, &QCheckBox::toggled, this, &MAVLinkSettingsWidget::enableDroneOS); + connect(protocol, &MAVLinkProtocol::authKeyChanged, m_ui->droneOSLineEdit, &QLineEdit::setText); + connect(m_ui->droneOSLineEdit, &QLineEdit::textChanged, this, &MAVLinkSettingsWidget::setDroneOSKey); // Drone OS - connect(m_ui->droneOSComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setDroneOSHost(QString))); + connect(m_ui->droneOSComboBox, static_cast(&QComboBox::currentIndexChanged), this, &MAVLinkSettingsWidget::setDroneOSHost); // FIXME Manually trigger this action here, this brings control code to UI = BAD! setDroneOSHost(m_ui->droneOSComboBox->currentText()); @@ -105,26 +106,28 @@ MAVLinkSettingsWidget::MAVLinkSettingsWidget(MAVLinkProtocol* protocol, QWidget m_ui->versionLabel->setText(tr("MAVLINK_VERSION: %1").arg(protocol->getVersion())); // Connect visibility updates - connect(protocol, SIGNAL(versionCheckChanged(bool)), m_ui->versionLabel, SLOT(setVisible(bool))); + connect(protocol, &MAVLinkProtocol::versionCheckChanged, m_ui->versionLabel, &QWidget::setVisible); m_ui->versionLabel->setVisible(protocol->versionCheckEnabled()); + // // Multiplexing visibility // connect(protocol, SIGNAL(multiplexingChanged(bool)), m_ui->multiplexingFilterCheckBox, SLOT(setVisible(bool))); // m_ui->multiplexingFilterCheckBox->setVisible(protocol->multiplexingEnabled()); // connect(protocol, SIGNAL(multiplexingChanged(bool)), m_ui->multiplexingFilterLineEdit, SLOT(setVisible(bool))); // m_ui->multiplexingFilterLineEdit->setVisible(protocol->multiplexingEnabled()); + // Param guard visibility - connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramRetransmissionSpinBox, SLOT(setVisible(bool))); + connect(protocol, &MAVLinkProtocol::paramGuardChanged, m_ui->paramRetransmissionSpinBox, &QWidget::setVisible); m_ui->paramRetransmissionSpinBox->setVisible(protocol->paramGuardEnabled()); - connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramRetransmissionLabel, SLOT(setVisible(bool))); + connect(protocol, &MAVLinkProtocol::paramGuardChanged, m_ui->paramRetransmissionLabel, &QWidget::setVisible); m_ui->paramRetransmissionLabel->setVisible(protocol->paramGuardEnabled()); - connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramRewriteSpinBox, SLOT(setVisible(bool))); + connect(protocol, &MAVLinkProtocol::paramGuardChanged, m_ui->paramRewriteSpinBox, &QWidget::setVisible); m_ui->paramRewriteSpinBox->setVisible(protocol->paramGuardEnabled()); - connect(protocol, SIGNAL(paramGuardChanged(bool)), m_ui->paramRewriteLabel, SLOT(setVisible(bool))); + connect(protocol, &MAVLinkProtocol::paramGuardChanged, m_ui->paramRewriteLabel, &QWidget::setVisible); m_ui->paramRewriteLabel->setVisible(protocol->paramGuardEnabled()); // Action guard visibility - connect(protocol, SIGNAL(actionGuardChanged(bool)), m_ui->actionRetransmissionSpinBox, SLOT(setVisible(bool))); + connect(protocol, &MAVLinkProtocol::actionGuardChanged, m_ui->actionRetransmissionSpinBox, &QWidget::setVisible); m_ui->actionRetransmissionSpinBox->setVisible(protocol->actionGuardEnabled()); - connect(protocol, SIGNAL(actionGuardChanged(bool)), m_ui->actionRetransmissionLabel, SLOT(setVisible(bool))); + connect(protocol, &MAVLinkProtocol::actionGuardChanged, m_ui->actionRetransmissionLabel, &QWidget::setVisible); m_ui->actionRetransmissionLabel->setVisible(protocol->actionGuardEnabled()); // TODO implement filtering -- 2.22.0