Make sure we are not using deprecated APIs

Bumps the deprecation values in line with the APIs we depend on.
This commit is contained in:
Aleix Pol 2024-04-21 17:45:08 +02:00
parent 5921ab6f2a
commit a0d93fa537
12 changed files with 29 additions and 25 deletions

View file

@ -38,8 +38,8 @@ ecm_setup_version(${RELEASE_SERVICE_VERSION}
) )
ecm_set_disabled_deprecation_versions( ecm_set_disabled_deprecation_versions(
QT 5.15 QT 6.6
KF 5.110 KF 6.0
) )
# Make the version header available by linking against kdeconnectversion # Make the version header available by linking against kdeconnectversion

View file

@ -166,6 +166,10 @@ Kirigami.ScrollablePage {
} }
} }
QQC2.Button {
text: "banana"
Accessible.description: "Can you see me"
}
Kirigami.PlaceholderMessage { Kirigami.PlaceholderMessage {
// FIXME: not accessible. screen readers won't read this. // FIXME: not accessible. screen readers won't read this.
// https://invent.kde.org/frameworks/kirigami/-/merge_requests/1482 // https://invent.kde.org/frameworks/kirigami/-/merge_requests/1482

View file

@ -211,7 +211,7 @@ int main(int argc, char **argv)
msg.setArguments(QVariantList{QVariant(urls)}); msg.setArguments(QVariantList{QVariant(urls)});
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); 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; QTextStream(stdout) << i18n("Shared %1", url) << Qt::endl;
} }
} else if (parser.isSet(QStringLiteral("share-text"))) { } else if (parser.isSet(QStringLiteral("share-text"))) {

View file

@ -173,7 +173,7 @@ void Discoverer::stopDiscovering()
void Discoverer::stopListeningForQueryResponses() void Discoverer::stopListeningForQueryResponses()
{ {
qCDebug(KDECONNECT_CORE) << "Closing" << responseSocketNotifiers.size() << "sockets"; qCDebug(KDECONNECT_CORE) << "Closing" << responseSocketNotifiers.size() << "sockets";
for (QSocketNotifier *socketNotifier : qAsConst(responseSocketNotifiers)) { for (QSocketNotifier *socketNotifier : std::as_const(responseSocketNotifiers)) {
mdns_socket_close(socketNotifier->socket()); mdns_socket_close(socketNotifier->socket());
delete socketNotifier; delete socketNotifier;
} }
@ -247,7 +247,7 @@ void Discoverer::sendQuery(const QString &serviceType)
query.type = MDNS_RECORDTYPE_PTR; query.type = MDNS_RECORDTYPE_PTR;
static char buffer[2048]; static char buffer[2048];
for (QSocketNotifier *socketNotifier : qAsConst(responseSocketNotifiers)) { for (QSocketNotifier *socketNotifier : std::as_const(responseSocketNotifiers)) {
int socket = socketNotifier->socket(); int socket = socketNotifier->socket();
qCDebug(KDECONNECT_CORE) << "Sending mDNS query via socket" << socket; qCDebug(KDECONNECT_CORE) << "Sending mDNS query via socket" << socket;
int ret = mdns_multiquery_send(socket, &query, 1, buffer, sizeof(buffer), 0); int ret = mdns_multiquery_send(socket, &query, 1, buffer, sizeof(buffer), 0);

View file

@ -87,7 +87,7 @@ void Daemon::init()
} }
// Listen to new devices // 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); connect(a, &LinkProvider::onConnectionReceived, this, &Daemon::onNewDeviceLink);
a->onStart(); a->onStart();
} }
@ -108,14 +108,14 @@ void Daemon::removeDevice(Device *device)
void Daemon::forceOnNetworkChange() void Daemon::forceOnNetworkChange()
{ {
qCDebug(KDECONNECT_CORE) << "Sending onNetworkChange to" << d->m_linkProviders.size() << "LinkProviders"; 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(); a->onNetworkChange();
} }
} }
Device *Daemon::getDevice(const QString &deviceId) 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) { if (device->id() == deviceId) {
return device; return device;
} }
@ -131,7 +131,7 @@ QSet<LinkProvider *> Daemon::getLinkProviders() const
QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const
{ {
QStringList ret; QStringList ret;
for (Device *device : qAsConst(d->m_devices)) { for (Device *device : std::as_const(d->m_devices)) {
if (onlyReachable && !device->isReachable()) if (onlyReachable && !device->isReachable())
continue; continue;
if (onlyTrusted && !device->isPaired()) if (onlyTrusted && !device->isPaired())
@ -144,7 +144,7 @@ QStringList Daemon::devices(bool onlyReachable, bool onlyTrusted) const
QMap<QString, QString> Daemon::deviceNames(bool onlyReachable, bool onlyTrusted) const QMap<QString, QString> Daemon::deviceNames(bool onlyReachable, bool onlyTrusted) const
{ {
QMap<QString, QString> ret; QMap<QString, QString> ret;
for (Device *device : qAsConst(d->m_devices)) { for (Device *device : std::as_const(d->m_devices)) {
if (onlyReachable && !device->isReachable()) if (onlyReachable && !device->isReachable())
continue; continue;
if (onlyTrusted && !device->isPaired()) if (onlyTrusted && !device->isPaired())
@ -239,7 +239,7 @@ QList<Device *> Daemon::devicesList() const
QString Daemon::deviceIdByName(const QString &name) 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()) if (device->name() == name && device->isPaired())
return device->id(); return device->id();
} }
@ -266,7 +266,7 @@ void Daemon::addDevice(Device *device)
QStringList Daemon::pairingRequests() const QStringList Daemon::pairingRequests() const
{ {
QStringList ret; QStringList ret;
for (Device *dev : qAsConst(d->m_devices)) { for (Device *dev : std::as_const(d->m_devices)) {
if (dev->isPairRequestedByPeer()) if (dev->isPairRequestedByPeer())
ret += dev->id(); ret += dev->id();
} }

View file

@ -159,7 +159,7 @@ void Device::reloadPlugins()
PluginLoader *loader = PluginLoader::instance(); 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 KPluginMetaData service = loader->getPluginInfo(pluginName);
const bool pluginEnabled = isPluginEnabled(pluginName); const bool pluginEnabled = isPluginEnabled(pluginName);
@ -194,7 +194,7 @@ void Device::reloadPlugins()
// Recreate dbus paths for all plugins (new and existing) // Recreate dbus paths for all plugins (new and existing)
QDBusConnection bus = QDBusConnection::sessionBus(); 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(); const QString dbusPath = plugin->dbusPath();
if (!dbusPath.isEmpty()) { if (!dbusPath.isEmpty()) {
bus.registerObject(dbusPath, bus.registerObject(dbusPath,
@ -343,7 +343,7 @@ bool Device::sendPacket(NetworkPacket &np)
Q_ASSERT(isPaired() || np.type() == PACKET_TYPE_PAIR); 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 // 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)) if (dl->sendPacket(np))
return true; return true;
} }
@ -396,7 +396,7 @@ bool Device::isPairRequestedByPeer() const
QHostAddress Device::getLocalIpAddress() 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<LanDeviceLink *>(dl); LanDeviceLink *ldl = dynamic_cast<LanDeviceLink *>(dl);
if (ldl) { if (ldl) {
return ldl->hostAddress(); return ldl->hostAddress();

View file

@ -106,8 +106,8 @@ void DBusAsyncResponse::onTimeout()
const QDBusPendingCall *DBusResponseWaiter::extractPendingCall(QVariant &variant) const const QDBusPendingCall *DBusResponseWaiter::extractPendingCall(QVariant &variant) const
{ {
for (int type : qAsConst(m_registered)) { for (int type : std::as_const(m_registered)) {
if (variant.canConvert(QVariant::Type(type))) { if (variant.typeId() == type) {
return reinterpret_cast<const QDBusPendingCall *>(variant.constData()); return reinterpret_cast<const QDBusPendingCall *>(variant.constData());
} }
} }

View file

@ -204,7 +204,7 @@ int NotificationsModel::rowCount(const QModelIndex &parent) const
bool NotificationsModel::isAnyDimissable() const bool NotificationsModel::isAnyDimissable() const
{ {
for (NotificationDbusInterface *notification : qAsConst(m_notificationList)) { for (NotificationDbusInterface *notification : std::as_const(m_notificationList)) {
if (notification->dismissable()) { if (notification->dismissable()) {
return true; return true;
} }
@ -214,7 +214,7 @@ bool NotificationsModel::isAnyDimissable() const
void NotificationsModel::dismissAll() void NotificationsModel::dismissAll()
{ {
for (NotificationDbusInterface *notification : qAsConst(m_notificationList)) { for (NotificationDbusInterface *notification : std::as_const(m_notificationList)) {
if (notification->dismissable()) { if (notification->dismissable()) {
notification->dismiss(); notification->dismiss();
} }

View file

@ -76,7 +76,7 @@ KdeConnectKcm::KdeConnectKcm(QObject *parent, const KPluginMetaData &md, const Q
connect(kcmUi.renameShow_button, &QAbstractButton::clicked, this, &KdeConnectKcm::renameShow); connect(kcmUi.renameShow_button, &QAbstractButton::clicked, this, &KdeConnectKcm::renameShow);
connect(kcmUi.pluginSelector, &KPluginWidget::changed, this, &KdeConnectKcm::pluginsConfigChanged); 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<QString>()) {
const QString input = args.first().toString(); const QString input = args.first().toString();
const auto colonIdx = input.indexOf(QLatin1Char(':')); const auto colonIdx = input.indexOf(QLatin1Char(':'));
const QString deviceId = input.left(colonIdx); const QString deviceId = input.left(colonIdx);

View file

@ -51,8 +51,8 @@ void FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/)
mutedSinks.append(sink); mutedSinks.append(sink);
} }
} }
connect(player, &QMediaPlayer::stateChanged, this, [mutedSinks] { connect(player, &QMediaPlayer::playbackStateChanged, this, [mutedSinks] {
for (auto sink : qAsConst(mutedSinks)) { for (auto sink : std::as_const(mutedSinks)) {
sink->setMuted(true); sink->setMuted(true);
} }
}); });

View file

@ -94,7 +94,7 @@ void PauseMusicPlugin::receivePacket(const NetworkPacket &np)
if (pause && !pausedSources.empty()) { if (pause && !pausedSources.empty()) {
if (autoResume) { 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()); OrgMprisMediaPlayer2PlayerInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), QDBusConnection::sessionBus());
mprisInterface.Play(); mprisInterface.Play();
} }

View file

@ -120,7 +120,7 @@ void ConversationsDbusInterface::addMessages(const QList<ConversationMessage> &m
m_known_messages[threadId].insert(message.uID()); 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 // 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 // Tell the world about what just happened
if (newConversation) { if (newConversation) {