From 14d8b2a3994adf8f2f94b065288980d5e61e0ba0 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Fri, 3 Jul 2015 13:05:18 +0300 Subject: Use the new signal/slot syntax everywhere Change-Id: Ia9868d010106abbfeb8f8d24e84adf37de879991 Reviewed-by: Alex Blasche --- examples/serialport/blockingmaster/dialog.cpp | 12 ++++------- examples/serialport/blockingslave/dialog.cpp | 23 +++++++++------------- .../serialport/creaderasync/serialportreader.cpp | 7 ++++--- .../serialport/cwriterasync/serialportwriter.cpp | 7 ++++--- examples/serialport/master/dialog.cpp | 9 +++------ examples/serialport/slave/dialog.cpp | 22 +++++++++------------ examples/serialport/terminal/mainwindow.cpp | 22 ++++++++++----------- examples/serialport/terminal/settingsdialog.cpp | 16 +++++++-------- 8 files changed, 52 insertions(+), 66 deletions(-) (limited to 'examples/serialport') diff --git a/examples/serialport/blockingmaster/dialog.cpp b/examples/serialport/blockingmaster/dialog.cpp index 6355429e..86020a1e 100644 --- a/examples/serialport/blockingmaster/dialog.cpp +++ b/examples/serialport/blockingmaster/dialog.cpp @@ -78,14 +78,10 @@ Dialog::Dialog(QWidget *parent) setWindowTitle(tr("Blocking Master")); serialPortComboBox->setFocus(); - connect(runButton, SIGNAL(clicked()), - this, SLOT(transaction())); - connect(&thread, SIGNAL(response(QString)), - this, SLOT(showResponse(QString))); - connect(&thread, SIGNAL(error(QString)), - this, SLOT(processError(QString))); - connect(&thread, SIGNAL(timeout(QString)), - this, SLOT(processTimeout(QString))); + connect(runButton, &QPushButton::clicked, this, &Dialog::transaction); + connect(&thread, &MasterThread::response, this, &Dialog::showResponse); + connect(&thread, &MasterThread::error, this, &Dialog::processError); + connect(&thread, &MasterThread::timeout, this, &Dialog::processTimeout); } void Dialog::transaction() diff --git a/examples/serialport/blockingslave/dialog.cpp b/examples/serialport/blockingslave/dialog.cpp index 9933e058..78c2ec04 100644 --- a/examples/serialport/blockingslave/dialog.cpp +++ b/examples/serialport/blockingslave/dialog.cpp @@ -78,21 +78,16 @@ Dialog::Dialog(QWidget *parent) setWindowTitle(tr("Blocking Slave")); serialPortComboBox->setFocus(); - connect(runButton, SIGNAL(clicked()), - this, SLOT(startSlave())); - connect(&thread, SIGNAL(request(QString)), - this, SLOT(showRequest(QString))); - connect(&thread, SIGNAL(error(QString)), - this, SLOT(processError(QString))); - connect(&thread, SIGNAL(timeout(QString)), - this, SLOT(processTimeout(QString))); + connect(runButton, &QPushButton::clicked, this, &Dialog::startSlave); + connect(&thread, &SlaveThread::request, this,&Dialog::showRequest); + connect(&thread, &SlaveThread::error, this, &Dialog::processError); + connect(&thread, &SlaveThread::timeout, this, &Dialog::processTimeout); - connect(serialPortComboBox, SIGNAL(currentIndexChanged(QString)), - this, SLOT(activateRunButton())); - connect(waitRequestSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(activateRunButton())); - connect(responseLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(activateRunButton())); + connect(serialPortComboBox, static_cast(&QComboBox::currentIndexChanged), + this, &Dialog::activateRunButton); + connect(waitRequestSpinBox, static_cast(&QSpinBox::valueChanged), + this, &Dialog::activateRunButton); + connect(responseLineEdit, &QLineEdit::textChanged, this, &Dialog::activateRunButton); } void Dialog::startSlave() diff --git a/examples/serialport/creaderasync/serialportreader.cpp b/examples/serialport/creaderasync/serialportreader.cpp index 815ff8c3..5188c69c 100644 --- a/examples/serialport/creaderasync/serialportreader.cpp +++ b/examples/serialport/creaderasync/serialportreader.cpp @@ -42,9 +42,10 @@ SerialPortReader::SerialPortReader(QSerialPort *serialPort, QObject *parent) , m_serialPort(serialPort) , m_standardOutput(stdout) { - connect(m_serialPort, SIGNAL(readyRead()), SLOT(handleReadyRead())); - connect(m_serialPort, SIGNAL(error(QSerialPort::SerialPortError)), SLOT(handleError(QSerialPort::SerialPortError))); - connect(&m_timer, SIGNAL(timeout()), SLOT(handleTimeout())); + connect(m_serialPort, &QSerialPort::readyRead, this, &SerialPortReader::handleReadyRead); + connect(m_serialPort, static_cast(&QSerialPort::error), + this, &SerialPortReader::handleError); + connect(&m_timer, &QTimer::timeout, this, &SerialPortReader::handleTimeout); m_timer.start(5000); } diff --git a/examples/serialport/cwriterasync/serialportwriter.cpp b/examples/serialport/cwriterasync/serialportwriter.cpp index b50b3539..4b222592 100644 --- a/examples/serialport/cwriterasync/serialportwriter.cpp +++ b/examples/serialport/cwriterasync/serialportwriter.cpp @@ -44,9 +44,10 @@ SerialPortWriter::SerialPortWriter(QSerialPort *serialPort, QObject *parent) , m_bytesWritten(0) { m_timer.setSingleShot(true); - connect(m_serialPort, SIGNAL(bytesWritten(qint64)), SLOT(handleBytesWritten(qint64))); - connect(m_serialPort, SIGNAL(error(QSerialPort::SerialPortError)), SLOT(handleError(QSerialPort::SerialPortError))); - connect(&m_timer, SIGNAL(timeout()), SLOT(handleTimeout())); + connect(m_serialPort, &QSerialPort::bytesWritten, this, &SerialPortWriter::handleBytesWritten); + connect(m_serialPort, static_cast(&QSerialPort::error), + this, &SerialPortWriter::handleError); + connect(&m_timer, &QTimer::timeout, this, &SerialPortWriter::handleTimeout); } SerialPortWriter::~SerialPortWriter() diff --git a/examples/serialport/master/dialog.cpp b/examples/serialport/master/dialog.cpp index c292b66a..847635af 100644 --- a/examples/serialport/master/dialog.cpp +++ b/examples/serialport/master/dialog.cpp @@ -80,12 +80,9 @@ Dialog::Dialog(QWidget *parent) timer.setSingleShot(true); - connect(runButton, SIGNAL(clicked()), - this, SLOT(sendRequest())); - connect(&serial, SIGNAL(readyRead()), - this, SLOT(readResponse())); - connect(&timer, SIGNAL(timeout()), - this, SLOT(processTimeout())); + connect(runButton, &QPushButton::clicked, this, &Dialog::sendRequest); + connect(&serial, &QSerialPort::readyRead, this, &Dialog::readResponse); + connect(&timer, &QTimer::timeout, this, &Dialog::processTimeout); } void Dialog::sendRequest() diff --git a/examples/serialport/slave/dialog.cpp b/examples/serialport/slave/dialog.cpp index 34118dee..2d5d81d1 100644 --- a/examples/serialport/slave/dialog.cpp +++ b/examples/serialport/slave/dialog.cpp @@ -80,19 +80,15 @@ Dialog::Dialog(QWidget *parent) timer.setSingleShot(true); - connect(runButton, SIGNAL(clicked()), - this, SLOT(startSlave())); - connect(&serial, SIGNAL(readyRead()), - this, SLOT(readRequest())); - connect(&timer, SIGNAL(timeout()), - this, SLOT(processTimeout())); - - connect(serialPortComboBox, SIGNAL(currentIndexChanged(QString)), - this, SLOT(activateRunButton())); - connect(waitRequestSpinBox, SIGNAL(valueChanged(int)), - this, SLOT(activateRunButton())); - connect(responseLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(activateRunButton())); + connect(runButton, &QPushButton::clicked, this, &Dialog::startSlave); + connect(&serial, &QSerialPort::readyRead, this, &Dialog::readRequest); + connect(&timer, &QTimer::timeout, this, &Dialog::processTimeout); + + connect(serialPortComboBox, static_cast(&QComboBox::currentIndexChanged), + this, &Dialog::activateRunButton); + connect(waitRequestSpinBox, static_cast(&QSpinBox::valueChanged), + this, &Dialog::activateRunButton); + connect(responseLineEdit, &QLineEdit::textChanged, this, &Dialog::activateRunButton); } void Dialog::startSlave() diff --git a/examples/serialport/terminal/mainwindow.cpp b/examples/serialport/terminal/mainwindow.cpp index 3630b1f8..b26b8845 100644 --- a/examples/serialport/terminal/mainwindow.cpp +++ b/examples/serialport/terminal/mainwindow.cpp @@ -66,13 +66,13 @@ MainWindow::MainWindow(QWidget *parent) : initActionsConnections(); - connect(serial, SIGNAL(error(QSerialPort::SerialPortError)), this, - SLOT(handleError(QSerialPort::SerialPortError))); + connect(serial, static_cast(&QSerialPort::error), + this, &MainWindow::handleError); //! [2] - connect(serial, SIGNAL(readyRead()), this, SLOT(readData())); + connect(serial, &QSerialPort::readyRead, this, &MainWindow::readData); //! [2] - connect(console, SIGNAL(getData(QByteArray)), this, SLOT(writeData(QByteArray))); + connect(console, &Console::getData, this, &MainWindow::writeData); //! [3] } //! [3] @@ -158,13 +158,13 @@ void MainWindow::handleError(QSerialPort::SerialPortError error) void MainWindow::initActionsConnections() { - connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(openSerialPort())); - connect(ui->actionDisconnect, SIGNAL(triggered()), this, SLOT(closeSerialPort())); - connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close())); - connect(ui->actionConfigure, SIGNAL(triggered()), settings, SLOT(show())); - connect(ui->actionClear, SIGNAL(triggered()), console, SLOT(clear())); - connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); - connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(ui->actionConnect, &QAction::triggered, this, &MainWindow::openSerialPort); + connect(ui->actionDisconnect, &QAction::triggered, this, &MainWindow::closeSerialPort); + connect(ui->actionQuit, &QAction::triggered, this, &MainWindow::close); + connect(ui->actionConfigure, &QAction::triggered, settings, &MainWindow::show); + connect(ui->actionClear, &QAction::triggered, console, &Console::clear); + connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::about); + connect(ui->actionAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt); } void MainWindow::showStatusMessage(const QString &message) diff --git a/examples/serialport/terminal/settingsdialog.cpp b/examples/serialport/terminal/settingsdialog.cpp index 900d2fec..cd7211d9 100644 --- a/examples/serialport/terminal/settingsdialog.cpp +++ b/examples/serialport/terminal/settingsdialog.cpp @@ -53,14 +53,14 @@ SettingsDialog::SettingsDialog(QWidget *parent) : ui->baudRateBox->setInsertPolicy(QComboBox::NoInsert); - connect(ui->applyButton, SIGNAL(clicked()), - this, SLOT(apply())); - connect(ui->serialPortInfoListBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(showPortInfo(int))); - connect(ui->baudRateBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(checkCustomBaudRatePolicy(int))); - connect(ui->serialPortInfoListBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(checkCustomDevicePathPolicy(int))); + connect(ui->applyButton, &QPushButton::clicked, + this, &SettingsDialog::apply); + connect(ui->serialPortInfoListBox, static_cast(&QComboBox::currentIndexChanged), + this, &SettingsDialog::showPortInfo); + connect(ui->baudRateBox, static_cast(&QComboBox::currentIndexChanged), + this, &SettingsDialog::checkCustomBaudRatePolicy); + connect(ui->serialPortInfoListBox, static_cast(&QComboBox::currentIndexChanged), + this, &SettingsDialog::checkCustomDevicePathPolicy); fillPortsParameters(); fillPortsInfo(); -- cgit v1.2.3