From a0d93fa5378ee25bc93a46d39e9824d78189cebf Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sun, 21 Apr 2024 17:45:08 +0200 Subject: [PATCH] Make sure we are not using deprecated APIs Bumps the deprecation values in line with the APIs we depend on. --- CMakeLists.txt | 4 ++-- app/qml/DevicePage.qml | 4 ++++ cli/kdeconnect-cli.cpp | 2 +- core/backends/lan/mdns_wrapper.cpp | 4 ++-- core/daemon.cpp | 14 +++++++------- core/device.cpp | 8 ++++---- declarativeplugin/responsewaiter.cpp | 4 ++-- interfaces/notificationsmodel.cpp | 4 ++-- kcm/kcm.cpp | 2 +- plugins/findthisdevice/findthisdeviceplugin.cpp | 4 ++-- plugins/pausemusic/pausemusicplugin.cpp | 2 +- plugins/sms/conversationsdbusinterface.cpp | 2 +- 12 files changed, 29 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d63484b7..a810ba528 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,8 @@ ecm_setup_version(${RELEASE_SERVICE_VERSION} ) ecm_set_disabled_deprecation_versions( - QT 5.15 - KF 5.110 + QT 6.6 + KF 6.0 ) # Make the version header available by linking against kdeconnectversion diff --git a/app/qml/DevicePage.qml b/app/qml/DevicePage.qml index 07747592a..fd1cefbdd 100644 --- a/app/qml/DevicePage.qml +++ b/app/qml/DevicePage.qml @@ -166,6 +166,10 @@ Kirigami.ScrollablePage { } } + QQC2.Button { + text: "banana" + Accessible.description: "Can you see me" + } Kirigami.PlaceholderMessage { // FIXME: not accessible. screen readers won't read this. // https://invent.kde.org/frameworks/kirigami/-/merge_requests/1482 diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp index cdbeba026..68fa91a81 100644 --- a/cli/kdeconnect-cli.cpp +++ b/cli/kdeconnect-cli.cpp @@ -211,7 +211,7 @@ int main(int argc, char **argv) msg.setArguments(QVariantList{QVariant(urls)}); blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); - for (const QString &url : qAsConst(urls)) { + for (const QString &url : std::as_const(urls)) { QTextStream(stdout) << i18n("Shared %1", url) << Qt::endl; } } else if (parser.isSet(QStringLiteral("share-text"))) { diff --git a/core/backends/lan/mdns_wrapper.cpp b/core/backends/lan/mdns_wrapper.cpp index 826c44a88..9c343a33c 100644 --- a/core/backends/lan/mdns_wrapper.cpp +++ b/core/backends/lan/mdns_wrapper.cpp @@ -173,7 +173,7 @@ void Discoverer::stopDiscovering() void Discoverer::stopListeningForQueryResponses() { qCDebug(KDECONNECT_CORE) << "Closing" << responseSocketNotifiers.size() << "sockets"; - for (QSocketNotifier *socketNotifier : qAsConst(responseSocketNotifiers)) { + for (QSocketNotifier *socketNotifier : std::as_const(responseSocketNotifiers)) { mdns_socket_close(socketNotifier->socket()); delete socketNotifier; } @@ -247,7 +247,7 @@ void Discoverer::sendQuery(const QString &serviceType) query.type = MDNS_RECORDTYPE_PTR; static char buffer[2048]; - for (QSocketNotifier *socketNotifier : qAsConst(responseSocketNotifiers)) { + for (QSocketNotifier *socketNotifier : std::as_const(responseSocketNotifiers)) { int socket = socketNotifier->socket(); qCDebug(KDECONNECT_CORE) << "Sending mDNS query via socket" << socket; int ret = mdns_multiquery_send(socket, &query, 1, buffer, sizeof(buffer), 0); diff --git a/core/daemon.cpp b/core/daemon.cpp index fb6b3d3a7..d6a024bde 100644 --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -87,7 +87,7 @@ void Daemon::init() } // Listen to new devices - for (LinkProvider *a : qAsConst(d->m_linkProviders)) { + for (LinkProvider *a : std::as_const(d->m_linkProviders)) { connect(a, &LinkProvider::onConnectionReceived, this, &Daemon::onNewDeviceLink); a->onStart(); } @@ -108,14 +108,14 @@ void Daemon::removeDevice(Device *device) void Daemon::forceOnNetworkChange() { qCDebug(KDECONNECT_CORE) << "Sending onNetworkChange to" << d->m_linkProviders.size() << "LinkProviders"; - for (LinkProvider *a : qAsConst(d->m_linkProviders)) { + for (LinkProvider *a : std::as_const(d->m_linkProviders)) { a->onNetworkChange(); } } Device *Daemon::getDevice(const QString &deviceId) { - for (Device *device : qAsConst(d->m_devices)) { + for (Device *device : std::as_const(d->m_devices)) { if (device->id() == deviceId) { return device; } @@ -131,7 +131,7 @@ QSet Daemon::getLinkProviders() const QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const { QStringList ret; - for (Device *device : qAsConst(d->m_devices)) { + for (Device *device : std::as_const(d->m_devices)) { if (onlyReachable && !device->isReachable()) continue; if (onlyTrusted && !device->isPaired()) @@ -144,7 +144,7 @@ QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const QMap Daemon::deviceNames(bool onlyReachable, bool onlyTrusted) const { QMap ret; - for (Device *device : qAsConst(d->m_devices)) { + for (Device *device : std::as_const(d->m_devices)) { if (onlyReachable && !device->isReachable()) continue; if (onlyTrusted && !device->isPaired()) @@ -239,7 +239,7 @@ QList Daemon::devicesList() const QString Daemon::deviceIdByName(const QString &name) const { - for (Device *device : qAsConst(d->m_devices)) { + for (Device *device : std::as_const(d->m_devices)) { if (device->name() == name && device->isPaired()) return device->id(); } @@ -266,7 +266,7 @@ void Daemon::addDevice(Device *device) QStringList Daemon::pairingRequests() const { QStringList ret; - for (Device *dev : qAsConst(d->m_devices)) { + for (Device *dev : std::as_const(d->m_devices)) { if (dev->isPairRequestedByPeer()) ret += dev->id(); } diff --git a/core/device.cpp b/core/device.cpp index a45f2fa87..6b5edae2a 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -159,7 +159,7 @@ void Device::reloadPlugins() PluginLoader *loader = PluginLoader::instance(); - for (const QString &pluginName : qAsConst(d->m_supportedPlugins)) { + for (const QString &pluginName : std::as_const(d->m_supportedPlugins)) { const KPluginMetaData service = loader->getPluginInfo(pluginName); const bool pluginEnabled = isPluginEnabled(pluginName); @@ -194,7 +194,7 @@ void Device::reloadPlugins() // Recreate dbus paths for all plugins (new and existing) QDBusConnection bus = QDBusConnection::sessionBus(); - for (KdeConnectPlugin *plugin : qAsConst(d->m_plugins)) { + for (KdeConnectPlugin *plugin : std::as_const(d->m_plugins)) { const QString dbusPath = plugin->dbusPath(); if (!dbusPath.isEmpty()) { bus.registerObject(dbusPath, @@ -343,7 +343,7 @@ bool Device::sendPacket(NetworkPacket &np) Q_ASSERT(isPaired() || np.type() == PACKET_TYPE_PAIR); // Maybe we could block here any packet that is not an identity or a pairing packet to prevent sending non encrypted data - for (DeviceLink *dl : qAsConst(d->m_deviceLinks)) { + for (DeviceLink *dl : std::as_const(d->m_deviceLinks)) { if (dl->sendPacket(np)) return true; } @@ -396,7 +396,7 @@ bool Device::isPairRequestedByPeer() const QHostAddress Device::getLocalIpAddress() const { - for (DeviceLink *dl : qAsConst(d->m_deviceLinks)) { + for (DeviceLink *dl : std::as_const(d->m_deviceLinks)) { LanDeviceLink *ldl = dynamic_cast(dl); if (ldl) { return ldl->hostAddress(); diff --git a/declarativeplugin/responsewaiter.cpp b/declarativeplugin/responsewaiter.cpp index 87750c53a..d81584489 100644 --- a/declarativeplugin/responsewaiter.cpp +++ b/declarativeplugin/responsewaiter.cpp @@ -106,8 +106,8 @@ void DBusAsyncResponse::onTimeout() const QDBusPendingCall *DBusResponseWaiter::extractPendingCall(QVariant &variant) const { - for (int type : qAsConst(m_registered)) { - if (variant.canConvert(QVariant::Type(type))) { + for (int type : std::as_const(m_registered)) { + if (variant.typeId() == type) { return reinterpret_cast(variant.constData()); } } diff --git a/interfaces/notificationsmodel.cpp b/interfaces/notificationsmodel.cpp index b74fead6f..b0b2616b1 100644 --- a/interfaces/notificationsmodel.cpp +++ b/interfaces/notificationsmodel.cpp @@ -204,7 +204,7 @@ int NotificationsModel::rowCount(const QModelIndex &parent) const bool NotificationsModel::isAnyDimissable() const { - for (NotificationDbusInterface *notification : qAsConst(m_notificationList)) { + for (NotificationDbusInterface *notification : std::as_const(m_notificationList)) { if (notification->dismissable()) { return true; } @@ -214,7 +214,7 @@ bool NotificationsModel::isAnyDimissable() const void NotificationsModel::dismissAll() { - for (NotificationDbusInterface *notification : qAsConst(m_notificationList)) { + for (NotificationDbusInterface *notification : std::as_const(m_notificationList)) { if (notification->dismissable()) { notification->dismiss(); } diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp index 5e1cdd708..8698501ca 100644 --- a/kcm/kcm.cpp +++ b/kcm/kcm.cpp @@ -76,7 +76,7 @@ KdeConnectKcm::KdeConnectKcm(QObject *parent, const KPluginMetaData &md, const Q connect(kcmUi.renameShow_button, &QAbstractButton::clicked, this, &KdeConnectKcm::renameShow); connect(kcmUi.pluginSelector, &KPluginWidget::changed, this, &KdeConnectKcm::pluginsConfigChanged); - if (!args.isEmpty() && args.first().type() == QVariant::String) { + if (!args.isEmpty() && !args.first().isNull() && args.first().canConvert()) { const QString input = args.first().toString(); const auto colonIdx = input.indexOf(QLatin1Char(':')); const QString deviceId = input.left(colonIdx); diff --git a/plugins/findthisdevice/findthisdeviceplugin.cpp b/plugins/findthisdevice/findthisdeviceplugin.cpp index 3e3ec9702..ddce10da1 100644 --- a/plugins/findthisdevice/findthisdeviceplugin.cpp +++ b/plugins/findthisdevice/findthisdeviceplugin.cpp @@ -51,8 +51,8 @@ void FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/) mutedSinks.append(sink); } } - connect(player, &QMediaPlayer::stateChanged, this, [mutedSinks] { - for (auto sink : qAsConst(mutedSinks)) { + connect(player, &QMediaPlayer::playbackStateChanged, this, [mutedSinks] { + for (auto sink : std::as_const(mutedSinks)) { sink->setMuted(true); } }); diff --git a/plugins/pausemusic/pausemusicplugin.cpp b/plugins/pausemusic/pausemusicplugin.cpp index 1488e7439..9b15109db 100644 --- a/plugins/pausemusic/pausemusicplugin.cpp +++ b/plugins/pausemusic/pausemusicplugin.cpp @@ -94,7 +94,7 @@ void PauseMusicPlugin::receivePacket(const NetworkPacket &np) if (pause && !pausedSources.empty()) { if (autoResume) { - for (const QString &iface : qAsConst(pausedSources)) { + for (const QString &iface : std::as_const(pausedSources)) { OrgMprisMediaPlayer2PlayerInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), QDBusConnection::sessionBus()); mprisInterface.Play(); } diff --git a/plugins/sms/conversationsdbusinterface.cpp b/plugins/sms/conversationsdbusinterface.cpp index 6533909fb..4a0ad5fb1 100644 --- a/plugins/sms/conversationsdbusinterface.cpp +++ b/plugins/sms/conversationsdbusinterface.cpp @@ -120,7 +120,7 @@ void ConversationsDbusInterface::addMessages(const QList &m m_known_messages[threadId].insert(message.uID()); // If this message was inserted at the end of the list, it is the latest message in the conversation - bool latestMessage = threadPosition == m_conversations[threadId].end() - 1; + const bool latestMessage = std::distance(threadPosition, m_conversations[threadId].end()) == 1; // Tell the world about what just happened if (newConversation) {