From 5cc2043c35359c34fb3b87691ca8acd2884f5258 Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Tue, 8 Aug 2023 22:51:30 +0200 Subject: [PATCH] Update old-style connect/disconnect where possible --- core/backends/bluetooth/bluetoothlinkprovider.cpp | 12 ++++++------ indicator/deviceindicator.cpp | 2 +- interfaces/devicesmodel.cpp | 2 +- kcm/kcm.cpp | 8 ++++---- plugins/sms/smsplugin.cpp | 2 +- smsapp/conversationlistmodel.cpp | 8 ++++---- smsapp/conversationmodel.cpp | 14 +++++++------- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/core/backends/bluetooth/bluetoothlinkprovider.cpp b/core/backends/bluetooth/bluetoothlinkprovider.cpp index 7afe0918f..44325a950 100644 --- a/core/backends/bluetooth/bluetoothlinkprovider.cpp +++ b/core/backends/bluetooth/bluetoothlinkprovider.cpp @@ -39,7 +39,7 @@ void BluetoothLinkProvider::onStart() mBluetoothServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this); mBluetoothServer->setSecurityFlags(QBluetooth::Security::Encryption | QBluetooth::Security::Secure); - connect(mBluetoothServer, SIGNAL(newConnection()), this, SLOT(serverNewConnection())); + connect(mBluetoothServer, &QBluetoothServer::newConnection, this, &BluetoothLinkProvider::serverNewConnection); mServiceDiscoveryAgent->start(); @@ -73,9 +73,9 @@ void BluetoothLinkProvider::connectError() qCWarning(KDECONNECT_CORE) << "Couldn't connect to socket:" << socket->errorString(); - disconnect(socket, SIGNAL(connected()), this, SLOT(clientConnected())); - disconnect(socket, SIGNAL(readyRead()), this, SLOT(serverDataReceived())); - disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError())); + disconnect(socket, &QBluetoothSocket::connected, this, nullptr); + disconnect(socket, &QBluetoothSocket::readyRead, this, nullptr); + disconnect(socket, QOverload::of(&QBluetoothSocket::error), this, nullptr); mSockets.remove(socket->peerAddress()); socket->deleteLater(); @@ -105,7 +105,7 @@ void BluetoothLinkProvider::serviceDiscovered(const QBluetoothServiceInfo &old_i clientConnected(deleteableSocket); }); }); - connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError())); + connect(socket, QOverload::of(&QBluetoothSocket::error), this, &BluetoothLinkProvider::connectError); socket->connectToService(info); @@ -180,7 +180,7 @@ void BluetoothLinkProvider::clientIdentityReceived(const QBluetoothAddress &peer qCDebug(KDECONNECT_CORE) << "Received identity packet from" << peer; // TODO? - // disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError())); + // disconnect(socket, &QAbstractSocket::error, this, &BluetoothLinkProvider::connectError); QSslCertificate receivedCertificate(receivedPacket.get(QStringLiteral("certificate")).toLatin1()); DeviceInfo deviceInfo = deviceInfo.FromIdentityPacketAndCert(receivedPacket, receivedCertificate); diff --git a/indicator/deviceindicator.cpp b/indicator/deviceindicator.cpp index 14c25333b..1fcfce92c 100644 --- a/indicator/deviceindicator.cpp +++ b/indicator/deviceindicator.cpp @@ -24,7 +24,7 @@ DeviceIndicator::DeviceIndicator(DeviceDbusInterface *device) { setIcon(QIcon::fromTheme(device->iconName())); - connect(device, SIGNAL(nameChanged(QString)), this, SLOT(setText(QString))); + connect(device, &DeviceDbusInterface::nameChanged, this, &DeviceIndicator::setText); // Battery status auto battery = new BatteryAction(device); diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp index 88a4ba5d8..03282ffc3 100644 --- a/interfaces/devicesmodel.cpp +++ b/interfaces/devicesmodel.cpp @@ -27,7 +27,7 @@ DevicesModel::DevicesModel(QObject *parent) connect(this, &QAbstractItemModel::rowsRemoved, this, &DevicesModel::rowsChanged); connect(this, &QAbstractItemModel::rowsInserted, this, &DevicesModel::rowsChanged); - connect(m_dbusInterface, SIGNAL(deviceAdded(QString)), this, SLOT(deviceAdded(QString))); + connect(m_dbusInterface, &OrgKdeKdeconnectDaemonInterface::deviceAdded, this, &DevicesModel::deviceAdded); connect(m_dbusInterface, &OrgKdeKdeconnectDaemonInterface::deviceVisibilityChanged, this, &DevicesModel::deviceUpdated); connect(m_dbusInterface, &OrgKdeKdeconnectDaemonInterface::deviceRemoved, this, &DevicesModel::deviceRemoved); diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 64c7a013d..cf4df9e97 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -56,8 +56,8 @@ KdeConnectKcm::KdeConnectKcm(QObject *parent, const QVariantList &args) kcmUi.rename_edit->setText(announcedName); }, this); - connect(daemon, SIGNAL(announcedNameChanged(QString)), kcmUi.rename_edit, SLOT(setText(QString))); - connect(daemon, SIGNAL(announcedNameChanged(QString)), kcmUi.rename_label, SLOT(setText(QString))); + connect(daemon, &DaemonDbusInterface::announcedNameChanged, kcmUi.rename_edit, &QLineEdit::setText); + connect(daemon, &DaemonDbusInterface::announcedNameChanged, kcmUi.rename_label, &QLabel::setText); setRenameMode(false); setButtons(KCModule::Help | KCModule::NoAdditionalButton); @@ -164,8 +164,8 @@ void KdeConnectKcm::deviceSelected(const QModelIndex ¤t) kcmUi.messages->setVisible(false); resetDeviceView(); - connect(currentDevice, SIGNAL(pluginsChanged()), this, SLOT(resetCurrentDevice())); - connect(currentDevice, SIGNAL(pairingFailed(QString)), this, SLOT(pairingFailed(QString))); + connect(currentDevice, &DeviceDbusInterface::pluginsChanged, this, &KdeConnectKcm::resetCurrentDevice); + connect(currentDevice, &DeviceDbusInterface::pairingFailed, this, &KdeConnectKcm::pairingFailed); connect(currentDevice, &DeviceDbusInterface::pairStateChanged, this, &KdeConnectKcm::setCurrentDevicePairState); } diff --git a/plugins/sms/smsplugin.cpp b/plugins/sms/smsplugin.cpp index a14d07789..820eda6b9 100644 --- a/plugins/sms/smsplugin.cpp +++ b/plugins/sms/smsplugin.cpp @@ -121,7 +121,7 @@ void SmsPlugin::forwardToTelepathy(const ConversationMessage &message) return; qCDebug(KDECONNECT_PLUGIN_SMS) << "Passing a text message to the telepathy interface"; - connect(&m_telepathyInterface, SIGNAL(messageReceived(QString, QString)), SLOT(sendSms(QString, QString)), Qt::UniqueConnection); + connect(&m_telepathyInterface, SIGNAL(messageReceived(QString, QString)), this, SLOT(sendSms(QString, QString)), Qt::UniqueConnection); const QString messageBody = message.body(); const QString contactName; // TODO: When telepathy support is improved, look up the contact with KPeople const QString phoneNumber = message.addresses()[0].address(); diff --git a/smsapp/conversationlistmodel.cpp b/smsapp/conversationlistmodel.cpp index 05696fe2d..af357565c 100644 --- a/smsapp/conversationlistmodel.cpp +++ b/smsapp/conversationlistmodel.cpp @@ -56,8 +56,8 @@ void ConversationListModel::setDeviceId(const QString &deviceId) qCDebug(KDECONNECT_SMS_CONVERSATIONS_LIST_MODEL) << "setDeviceId" << deviceId << "of" << this; if (m_conversationsInterface) { - disconnect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleCreatedConversation(QDBusVariant))); - disconnect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdated(QDBusVariant))); + disconnect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationCreated, this, &ConversationListModel::handleCreatedConversation); + disconnect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationUpdated, this, &ConversationListModel::handleConversationUpdated); delete m_conversationsInterface; m_conversationsInterface = nullptr; } @@ -73,8 +73,8 @@ void ConversationListModel::setDeviceId(const QString &deviceId) Q_EMIT deviceIdChanged(); m_conversationsInterface = new DeviceConversationsDbusInterface(deviceId, this); - connect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleCreatedConversation(QDBusVariant))); - connect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdated(QDBusVariant))); + connect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationCreated, this, &ConversationListModel::handleCreatedConversation); + connect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationUpdated, this, &ConversationListModel::handleConversationUpdated); refresh(); } diff --git a/smsapp/conversationmodel.cpp b/smsapp/conversationmodel.cpp index 9a7a3c714..523729be6 100644 --- a/smsapp/conversationmodel.cpp +++ b/smsapp/conversationmodel.cpp @@ -61,20 +61,20 @@ void ConversationModel::setDeviceId(const QString &deviceId) qCDebug(KDECONNECT_SMS_CONVERSATION_MODEL) << "setDeviceId" << "of" << this; if (m_conversationsInterface) { - disconnect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdate(QDBusVariant))); - disconnect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64))); - disconnect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleConversationCreated(QDBusVariant))); + disconnect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationUpdated, this, &ConversationModel::handleConversationUpdate); + disconnect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationLoaded, this, &ConversationModel::handleConversationLoaded); + disconnect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationCreated, this, &ConversationModel::handleConversationCreated); delete m_conversationsInterface; } m_deviceId = deviceId; m_conversationsInterface = new DeviceConversationsDbusInterface(deviceId, this); - connect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdate(QDBusVariant))); - connect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64))); - connect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleConversationCreated(QDBusVariant))); + connect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationUpdated, this, &ConversationModel::handleConversationUpdate); + connect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationLoaded, this, &ConversationModel::handleConversationLoaded); + connect(m_conversationsInterface, &DeviceConversationsDbusInterface::conversationCreated, this, &ConversationModel::handleConversationCreated); - connect(m_conversationsInterface, SIGNAL(attachmentReceived(QString, QString)), this, SIGNAL(filePathReceived(QString, QString))); + connect(m_conversationsInterface, &DeviceConversationsDbusInterface::attachmentReceived, this, &ConversationModel::filePathReceived); QQmlApplicationEngine *engine = qobject_cast(QQmlEngine::contextForObject(this)->engine()); m_thumbnailsProvider = dynamic_cast(engine->imageProvider(QStringLiteral("thumbnailsProvider")));