Drop Qt5-only code branches

This commit is contained in:
Aleix Pol 2024-04-21 17:19:34 +02:00
parent d5e8bb6e31
commit 5921ab6f2a
17 changed files with 0 additions and 130 deletions

View file

@ -22,8 +22,6 @@
int main(int argc, char *argv[])
{
QIcon::setFallbackThemeName(QStringLiteral("breeze"));
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
KLocalizedString::setApplicationDomain("kdeconnect-app");

View file

@ -81,12 +81,7 @@ void BluetoothLinkProvider::connectError()
disconnect(socket, &QBluetoothSocket::connected, this, nullptr);
disconnect(socket, &QBluetoothSocket::readyRead, this, nullptr);
#if QT_VERSION_MAJOR == 5
disconnect(socket, QOverload<QBluetoothSocket::SocketError>::of(&QBluetoothSocket::error), this, nullptr);
#else
disconnect(socket, QOverload<QBluetoothSocket::SocketError>::of(&QBluetoothSocket::errorOccurred), this, nullptr);
#endif
mSockets.remove(socket->peerAddress());
socket->deleteLater();
@ -129,11 +124,7 @@ void BluetoothLinkProvider::serviceDiscovered(const QBluetoothServiceInfo &old_i
});
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::serviceDiscovered about to call connect";
#if QT_VERSION_MAJOR == 5
connect(socket, QOverload<QBluetoothSocket::SocketError>::of(&QBluetoothSocket::error), this, &BluetoothLinkProvider::connectError);
#else
connect(socket, QOverload<QBluetoothSocket::SocketError>::of(&QBluetoothSocket::errorOccurred), this, &BluetoothLinkProvider::connectError);
#endif
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::serviceDiscovered about to call connectToService";

View file

@ -236,13 +236,8 @@ QBluetoothUuid ConnectionMultiplexer::newChannel()
message[0] = MESSAGE_OPEN_CHANNEL;
qToBigEndian<uint16_t>(0, &message.data()[1]);
#if QT_VERSION_MAJOR == 5
quint128 id_raw = new_id.toUInt128();
message.append((const char *)id_raw.data, 16);
#else
const auto channelBytes = new_id.toByteArray();
message.append(channelBytes.constData(), 16);
#endif
to_write_bytes.append(message);
// Add the channel ourselves
@ -350,13 +345,8 @@ void ConnectionMultiplexer::channelCanRead(QBluetoothUuid channelId)
QByteArray message(3, (char)0);
message[0] = MESSAGE_READ;
qToBigEndian<uint16_t>(2, &message.data()[1]);
#if QT_VERSION_MAJOR == 5
quint128 id_raw = channelId.toUInt128();
message.append((const char *)id_raw.data, 16);
#else
const auto channelBytes = channelId.toByteArray();
message.append(channelBytes.constData(), 16);
#endif
message.append(2, 0);
qToBigEndian<int16_t>(read_amount, &message.data()[19]);
to_write_bytes.append(message);
@ -385,14 +375,8 @@ void ConnectionMultiplexer::channelCanWrite(QBluetoothUuid channelId)
message[0] = MESSAGE_WRITE;
qToBigEndian<uint16_t>(amount, &message.data()[1]);
#if QT_VERSION_MAJOR == 5
quint128 id_raw = channelId.toUInt128();
message.append((const char *)id_raw.data, 16);
#else
const auto channelBytes = channelId.toByteArray();
message.append(channelBytes.constData(), 16);
#endif
message.append(data);
to_write_bytes.append(message);
// Try to send it immediately
@ -429,13 +413,8 @@ void ConnectionMultiplexer::closeChannel(QBluetoothUuid channelId)
message[0] = MESSAGE_CLOSE_CHANNEL;
qToBigEndian<uint16_t>(0, &message.data()[1]);
#if QT_VERSION_MAJOR == 5
quint128 id_raw = channelId.toUInt128();
message.append((const char *)id_raw.data, 16);
#else
const auto channelBytes = channelId.toByteArray();
message.append(channelBytes.constData(), 16);
#endif
to_write_bytes.append(message);
// Try to send it immediately
bytesWritten();

View file

@ -67,14 +67,6 @@ LanLinkProvider::LanLinkProvider(bool testMode)
qWarning() << "Error sending UDP packet:" << socketError;
});
#if QT_VERSION_MAJOR < 6
QNetworkConfigurationManager *networkManager = new QNetworkConfigurationManager(this);
connect(networkManager, &QNetworkConfigurationManager::configurationChanged, this, [this](QNetworkConfiguration config) {
if (config.state() == QNetworkConfiguration::Active) {
onNetworkChange();
}
});
#else
const auto checkNetworkChange = [this]() {
if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) {
onNetworkChange();
@ -86,7 +78,6 @@ LanLinkProvider::LanLinkProvider(bool testMode)
// We want to know if our current network reachability has changed, or if we change from one network to another
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, checkNetworkChange);
connect(QNetworkInformation::instance(), &QNetworkInformation::transportMediumChanged, this, checkNetworkChange);
#endif
}
LanLinkProvider::~LanLinkProvider()

View file

@ -62,7 +62,6 @@ public:
oc.openConfiguration(deviceId);
};
#if QT_VERSION_MAJOR == 6
KNotificationAction *openSettingsAction = notification->addDefaultAction(i18n("Open"));
connect(openSettingsAction, &KNotificationAction::activated, openSettings);
@ -74,15 +73,6 @@ public:
KNotificationAction *viewKeyAction = notification->addAction(i18n("View key"));
connect(viewKeyAction, &KNotificationAction::activated, openSettings);
#else
notification->setDefaultAction(i18n("Open"));
notification->setActions(QStringList() << i18n("Accept") << i18n("Reject") << i18n("View key"));
connect(notification, &KNotification::action1Activated, device, &Device::acceptPairing);
connect(notification, &KNotification::action2Activated, device, &Device::cancelPairing);
connect(notification, &KNotification::action3Activated, openSettings);
connect(notification, &KNotification::activated, openSettings);
#endif
notification->sendEvent();
}
@ -147,11 +137,7 @@ int main(int argc, char *argv[])
#endif
detectPlatform(argc, argv);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#if QT_VERSION_MAJOR == 6
QGuiApplication::setQuitLockEnabled(false);
#endif
QApplication app(argc, argv);
KAboutData aboutData(QStringLiteral("kdeconnect.daemon"),

View file

@ -45,8 +45,6 @@ int main(int argc, char **argv)
#endif
QIcon::setFallbackThemeName(QStringLiteral("breeze"));
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
KAboutData about(QStringLiteral("kdeconnect-indicator"),

View file

@ -7,11 +7,7 @@
#include "kdeconnectpluginkcm.h"
KdeConnectPluginKcm::KdeConnectPluginKcm(QObject *parent, const KPluginMetaData &data, const QVariantList &args)
#if QT_VERSION_MAJOR < 6
: KCModule(qobject_cast<QWidget *>(parent), args)
#else
: KCModule(parent)
#endif
, m_deviceId(args.at(0).toString())
// The plugin name is the KCMs ID with the postfix removed
, m_config(new KdeConnectPluginConfig(m_deviceId, data.pluginId().remove(QLatin1String("_config")), this))

View file

@ -14,9 +14,7 @@
#include <QMediaPlayer>
#include <QStandardPaths>
#if QT_VERSION_MAJOR == 6
#include <QAudioOutput>
#endif
K_PLUGIN_CLASS(FindThisDeviceConfig)
@ -64,20 +62,12 @@ void FindThisDeviceConfig::save()
void FindThisDeviceConfig::playSound(const QUrl &soundUrl)
{
QMediaPlayer *player = new QMediaPlayer;
#if QT_VERSION_MAJOR < 6
player->setAudioRole(QAudio::Role(QAudio::NotificationRole));
player->setMedia(soundUrl);
player->setVolume(100);
player->play();
connect(player, &QMediaPlayer::stateChanged, player, &QObject::deleteLater);
#else
auto audioOutput = new QAudioOutput();
audioOutput->setVolume(100);
player->setSource(soundUrl);
player->setAudioOutput(audioOutput);
player->play();
connect(player, &QMediaPlayer::playingChanged, player, &QObject::deleteLater);
#endif
}
#include "findthisdevice_config.moc"

View file

@ -20,9 +20,7 @@
#include <QDBusConnection>
#include <QMediaPlayer>
#if QT_VERSION_MAJOR == 6
#include <QAudioOutput>
#endif
K_PLUGIN_CLASS_WITH_JSON(FindThisDevicePlugin, "kdeconnect_findthisdevice.json")
@ -37,17 +35,11 @@ void FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/)
}
QMediaPlayer *player = new QMediaPlayer;
#if QT_VERSION_MAJOR < 6
player->setAudioRole(QAudio::Role(QAudio::NotificationRole));
player->setMedia(soundURL);
player->setVolume(100);
#else
auto audioOutput = new QAudioOutput();
audioOutput->setVolume(100);
player->setSource(soundURL);
player->setAudioOutput(audioOutput);
connect(player, &QMediaPlayer::playingChanged, player, &QObject::deleteLater);
#endif
player->play();
#ifndef Q_OS_WIN
@ -59,11 +51,7 @@ void FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/)
mutedSinks.append(sink);
}
}
#if QT_VERSION_MAJOR < 6
connect(player, &QMediaPlayer::stateChanged, this, [mutedSinks] {
#else
connect(player, &QMediaPlayer::playingChanged, this, [mutedSinks] {
#endif
for (auto sink : qAsConst(mutedSinks)) {
sink->setMuted(true);
}
@ -71,11 +59,7 @@ void FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/)
#endif
player->play();
#if QT_VERSION_MAJOR < 6
connect(player, &QMediaPlayer::stateChanged, player, &QObject::deleteLater);
#else
connect(player, &QMediaPlayer::playingChanged, player, &QObject::deleteLater);
#endif
// TODO: ensure to use built-in loudspeakers
}

View file

@ -44,13 +44,6 @@ Notification::Notification(const NetworkPacket &np, const Device *device, QObjec
parseNetworkPacket(np);
createKNotification(np);
#if QT_VERSION_MAJOR == 5
connect(m_notification, &KNotification::activated, this, [this](unsigned int actionIndex) {
// Notification action indices start at 1
Q_EMIT actionTriggered(m_internalId, m_actions[actionIndex - 1]);
});
#endif
}
void Notification::dismiss()
@ -120,7 +113,6 @@ void Notification::createKNotification(const NetworkPacket &np)
m_notification->setReplyAction(std::move(replyAction));
}
#if QT_VERSION_MAJOR == 6
m_notification->clearActions();
for (const QString &actionId : std::as_const(m_actions)) {
KNotificationAction *action = m_notification->addAction(actionId);
@ -129,9 +121,6 @@ void Notification::createKNotification(const NetworkPacket &np)
Q_EMIT actionTriggered(m_internalId, actionId);
});
}
#else
m_notification->setActions(m_actions);
#endif
m_hasIcon = m_hasIcon && !m_payloadHash.isEmpty();

View file

@ -34,9 +34,6 @@ public:
windowFlags |= Qt::WindowTransparentForInput;
#endif
setFlags(windowFlags);
#if QT_VERSION_MAJOR < 6
setClearBeforeRendering(true);
#endif
setColor(QColor(Qt::transparent));
setResizeMode(QQuickView::SizeViewToRootObject);

View file

@ -188,7 +188,6 @@ void SharePlugin::receivePacket(const NetworkPacket &np)
Q_EMIT shareReceived(url.toString());
};
#if QT_VERSION_MAJOR == 6
KNotificationAction *textEditorAction = notif->addAction(i18nc("@action:button Edit text with default text editor", "Open in Text Editor"));
connect(textEditorAction, &KNotificationAction::activated, this, openTextEditor);
@ -196,19 +195,6 @@ void SharePlugin::receivePacket(const NetworkPacket &np)
KNotificationAction *openLinkAction = notif->addAction(i18nc("@action:button Open URL with default app", "Open Link"));
connect(openLinkAction, &KNotificationAction::activated, this, openUrl);
}
#else
QStringList actions;
actions << i18nc("@action:button Edit text with default text editor", "Open in Text Editor");
if (url.isValid() && (url.scheme() == QStringLiteral("http") || url.scheme() == QStringLiteral("https"))) {
actions << i18nc("@action:button Open URL with default app", "Open Link");
}
notif->setActions(actions);
connect(notif, &KNotification::action1Activated, this, openTextEditor);
connect(notif, &KNotification::action2Activated, this, openUrl);
#endif
notif->sendEvent();
} else if (np.has(QStringLiteral("url"))) {

View file

@ -61,14 +61,9 @@ void TelephonyPlugin::createNotification(const NetworkPacket &np)
m_currentCallNotification->setText(content);
if (event == QLatin1String("ringing")) {
#if QT_VERSION_MAJOR == 6
m_currentCallNotification->clearActions();
KNotificationAction *muteAction = m_currentCallNotification->addAction(i18n("Mute Call"));
connect(muteAction, &KNotificationAction::activated, this, &TelephonyPlugin::sendMutePacket);
#else
m_currentCallNotification->setActions(QStringList(i18n("Mute Call")));
connect(m_currentCallNotification, &KNotification::action1Activated, this, &TelephonyPlugin::sendMutePacket);
#endif
}
m_currentCallNotification->sendEvent();

View file

@ -19,8 +19,6 @@
int main(int argc, char **argv)
{
QIcon::setFallbackThemeName(QStringLiteral("breeze"));
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kdeconnect")));

View file

@ -58,11 +58,7 @@ bool ConversationsSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QM
const QList<ConversationAddress> addressList = sourceModel()->data(index, ConversationListModel::AddressesRole).value<QList<ConversationAddress>>();
for (const ConversationAddress &address : addressList) {
QString canonicalAddress = SmsHelper::canonicalizePhoneNumber(address.address());
#if QT_VERSION_MAJOR < 6
if (canonicalAddress.contains(filterRegExp())) {
#else
if (canonicalAddress.contains(filterRegularExpression())) {
#endif
return true;
}
}

View file

@ -42,8 +42,6 @@ int main(int argc, char *argv[])
{
QIcon::setFallbackThemeName(QStringLiteral("breeze"));
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
KLocalizedString::setApplicationDomain("kdeconnect-sms");
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kdeconnect")));

View file

@ -36,8 +36,6 @@
int main(int argc, char **argv)
{
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kdeconnect")));
const QString description = i18n("KDE Connect URL handler");