diff options
Diffstat (limited to 'examples/network/network-chat')
-rw-r--r-- | examples/network/network-chat/chatdialog.cpp | 16 | ||||
-rw-r--r-- | examples/network/network-chat/chatdialog.h | 2 | ||||
-rw-r--r-- | examples/network/network-chat/client.cpp | 20 | ||||
-rw-r--r-- | examples/network/network-chat/connection.cpp | 13 | ||||
-rw-r--r-- | examples/network/network-chat/connection.h | 4 | ||||
-rw-r--r-- | examples/network/network-chat/peermanager.cpp | 8 | ||||
-rw-r--r-- | examples/network/network-chat/server.h | 2 |
7 files changed, 34 insertions, 31 deletions
diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp index 615df3a318..ce6e39a8fc 100644 --- a/examples/network/network-chat/chatdialog.cpp +++ b/examples/network/network-chat/chatdialog.cpp @@ -62,14 +62,14 @@ ChatDialog::ChatDialog(QWidget *parent) textEdit->setReadOnly(true); listWidget->setFocusPolicy(Qt::NoFocus); - connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); - connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed())); - connect(&client, SIGNAL(newMessage(QString,QString)), - this, SLOT(appendMessage(QString,QString))); - connect(&client, SIGNAL(newParticipant(QString)), - this, SLOT(newParticipant(QString))); - connect(&client, SIGNAL(participantLeft(QString)), - this, SLOT(participantLeft(QString))); + connect(lineEdit, &QLineEdit::returnPressed, + this, &ChatDialog::returnPressed); + connect(&client, &Client::newMessage, + this, &ChatDialog::appendMessage); + connect(&client, &Client::newParticipant, + this, &ChatDialog::newParticipant); + connect(&client, &Client::participantLeft, + this, &ChatDialog::participantLeft); myNickName = client.nickName(); newParticipant(myNickName); diff --git a/examples/network/network-chat/chatdialog.h b/examples/network/network-chat/chatdialog.h index c65861c6e6..27ae0ca72a 100644 --- a/examples/network/network-chat/chatdialog.h +++ b/examples/network/network-chat/chatdialog.h @@ -59,7 +59,7 @@ class ChatDialog : public QDialog, private Ui::ChatDialog Q_OBJECT public: - ChatDialog(QWidget *parent = 0); + ChatDialog(QWidget *parent = nullptr); public slots: void appendMessage(const QString &from, const QString &message); diff --git a/examples/network/network-chat/client.cpp b/examples/network/network-chat/client.cpp index b76ef18238..d451181813 100644 --- a/examples/network/network-chat/client.cpp +++ b/examples/network/network-chat/client.cpp @@ -60,10 +60,10 @@ Client::Client() peerManager->setServerPort(server.serverPort()); peerManager->startBroadcasting(); - QObject::connect(peerManager, SIGNAL(newConnection(Connection*)), - this, SLOT(newConnection(Connection*))); - QObject::connect(&server, SIGNAL(newConnection(Connection*)), - this, SLOT(newConnection(Connection*))); + connect(peerManager, &PeerManager::newConnection, + this, &Client::newConnection); + connect(&server, &Server::newConnection, + this, &Client::newConnection); } void Client::sendMessage(const QString &message) @@ -102,10 +102,10 @@ void Client::newConnection(Connection *connection) { connection->setGreetingMessage(peerManager->userName()); - connect(connection, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(connectionError(QAbstractSocket::SocketError))); - connect(connection, SIGNAL(disconnected()), this, SLOT(disconnected())); - connect(connection, SIGNAL(readyForUse()), this, SLOT(readyForUse())); + connect(connection, QOverload<QAbstractSocket::SocketError>::of(&Connection::error), + this, &Client::connectionError); + connect(connection, &Connection::disconnected, this, &Client::disconnected); + connect(connection, &Connection::readyForUse, this, &Client::readyForUse); } void Client::readyForUse() @@ -115,8 +115,8 @@ void Client::readyForUse() connection->peerPort())) return; - connect(connection, SIGNAL(newMessage(QString,QString)), - this, SIGNAL(newMessage(QString,QString))); + connect(connection, &Connection::newMessage, + this, &Client::newMessage); peers.insert(connection->peerAddress(), connection); QString nick = connection->name(); diff --git a/examples/network/network-chat/connection.cpp b/examples/network/network-chat/connection.cpp index 58cf67eb6d..cffd495349 100644 --- a/examples/network/network-chat/connection.cpp +++ b/examples/network/network-chat/connection.cpp @@ -82,11 +82,14 @@ Connection::Connection(QObject *parent) isGreetingMessageSent = false; pingTimer.setInterval(PingInterval); - QObject::connect(this, SIGNAL(readyRead()), this, SLOT(processReadyRead())); - QObject::connect(this, SIGNAL(disconnected()), &pingTimer, SLOT(stop())); - QObject::connect(&pingTimer, SIGNAL(timeout()), this, SLOT(sendPing())); - QObject::connect(this, SIGNAL(connected()), - this, SLOT(sendGreetingMessage())); + connect(this, &QTcpSocket::readyRead, this, + &Connection::processReadyRead); + connect(this, &QTcpSocket::disconnected, + &pingTimer, &QTimer::stop); + connect(&pingTimer, &QTimer::timeout, + this, &Connection::sendPing); + connect(this, &QTcpSocket::connected, + this, &Connection::sendGreetingMessage); } Connection::Connection(qintptr socketDescriptor, QObject *parent) diff --git a/examples/network/network-chat/connection.h b/examples/network/network-chat/connection.h index fa0671a522..e6f36f7cd9 100644 --- a/examples/network/network-chat/connection.h +++ b/examples/network/network-chat/connection.h @@ -79,8 +79,8 @@ public: Undefined }; - Connection(QObject *parent = 0); - Connection(qintptr socketDescriptor, QObject *parent = 0); + Connection(QObject *parent = nullptr); + Connection(qintptr socketDescriptor, QObject *parent = nullptr); ~Connection(); QString name() const; diff --git a/examples/network/network-chat/peermanager.cpp b/examples/network/network-chat/peermanager.cpp index 5c48edb1b9..2c9d182211 100644 --- a/examples/network/network-chat/peermanager.cpp +++ b/examples/network/network-chat/peermanager.cpp @@ -81,12 +81,12 @@ PeerManager::PeerManager(Client *client) broadcastSocket.bind(QHostAddress::Any, broadcastPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); - connect(&broadcastSocket, SIGNAL(readyRead()), - this, SLOT(readBroadcastDatagram())); + connect(&broadcastSocket, &QUdpSocket::readyRead, + this, &PeerManager::readBroadcastDatagram); broadcastTimer.setInterval(BroadcastInterval); - connect(&broadcastTimer, SIGNAL(timeout()), - this, SLOT(sendBroadcastDatagram())); + connect(&broadcastTimer, &QTimer::timeout, + this, &PeerManager::sendBroadcastDatagram); } void PeerManager::setServerPort(int port) diff --git a/examples/network/network-chat/server.h b/examples/network/network-chat/server.h index d86ed36bce..0a7e6e18c1 100644 --- a/examples/network/network-chat/server.h +++ b/examples/network/network-chat/server.h @@ -60,7 +60,7 @@ class Server : public QTcpServer Q_OBJECT public: - Server(QObject *parent = 0); + Server(QObject *parent = nullptr); signals: void newConnection(Connection *connection); |