From 5921ab6f2a1f5551d64c82d8ac7a1ba77a6e1506 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sun, 21 Apr 2024 17:19:34 +0200 Subject: [PATCH] Drop Qt5-only code branches --- app/main.cpp | 2 -- .../bluetooth/bluetoothlinkprovider.cpp | 9 -------- .../bluetooth/connectionmultiplexer.cpp | 21 ------------------- core/backends/lan/lanlinkprovider.cpp | 9 -------- daemon/kdeconnectd.cpp | 14 ------------- indicator/main.cpp | 2 -- kcmplugin/kdeconnectpluginkcm.cpp | 4 ---- .../findthisdevice/findthisdevice_config.cpp | 10 --------- .../findthisdevice/findthisdeviceplugin.cpp | 16 -------------- plugins/notifications/notification.cpp | 11 ---------- plugins/presenter/presenterplugin.cpp | 3 --- plugins/share/shareplugin.cpp | 14 ------------- plugins/telephony/telephonyplugin.cpp | 5 ----- settings/main.cpp | 2 -- smsapp/conversationssortfilterproxymodel.cpp | 4 ---- smsapp/main.cpp | 2 -- urlhandler/kdeconnect-handler.cpp | 2 -- 17 files changed, 130 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index de083ce32..3cd3e54dc 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -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"); diff --git a/core/backends/bluetooth/bluetoothlinkprovider.cpp b/core/backends/bluetooth/bluetoothlinkprovider.cpp index 85373ea01..bd779a6de 100644 --- a/core/backends/bluetooth/bluetoothlinkprovider.cpp +++ b/core/backends/bluetooth/bluetoothlinkprovider.cpp @@ -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::of(&QBluetoothSocket::error), this, nullptr); -#else disconnect(socket, QOverload::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::of(&QBluetoothSocket::error), this, &BluetoothLinkProvider::connectError); -#else connect(socket, QOverload::of(&QBluetoothSocket::errorOccurred), this, &BluetoothLinkProvider::connectError); -#endif qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::serviceDiscovered about to call connectToService"; diff --git a/core/backends/bluetooth/connectionmultiplexer.cpp b/core/backends/bluetooth/connectionmultiplexer.cpp index dfea4032c..6b1191efd 100644 --- a/core/backends/bluetooth/connectionmultiplexer.cpp +++ b/core/backends/bluetooth/connectionmultiplexer.cpp @@ -236,13 +236,8 @@ QBluetoothUuid ConnectionMultiplexer::newChannel() message[0] = MESSAGE_OPEN_CHANNEL; qToBigEndian(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(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(read_amount, &message.data()[19]); to_write_bytes.append(message); @@ -385,14 +375,8 @@ void ConnectionMultiplexer::channelCanWrite(QBluetoothUuid channelId) message[0] = MESSAGE_WRITE; qToBigEndian(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(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(); diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index 8b4793e52..c4f0193e7 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -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() diff --git a/daemon/kdeconnectd.cpp b/daemon/kdeconnectd.cpp index 2b5bef72d..b887aaa24 100644 --- a/daemon/kdeconnectd.cpp +++ b/daemon/kdeconnectd.cpp @@ -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"), diff --git a/indicator/main.cpp b/indicator/main.cpp index 17d5e62f9..eec24c837 100644 --- a/indicator/main.cpp +++ b/indicator/main.cpp @@ -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"), diff --git a/kcmplugin/kdeconnectpluginkcm.cpp b/kcmplugin/kdeconnectpluginkcm.cpp index 66e7481c9..049f7a539 100644 --- a/kcmplugin/kdeconnectpluginkcm.cpp +++ b/kcmplugin/kdeconnectpluginkcm.cpp @@ -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(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)) diff --git a/plugins/findthisdevice/findthisdevice_config.cpp b/plugins/findthisdevice/findthisdevice_config.cpp index e550e9356..e5d06ef1b 100644 --- a/plugins/findthisdevice/findthisdevice_config.cpp +++ b/plugins/findthisdevice/findthisdevice_config.cpp @@ -14,9 +14,7 @@ #include #include -#if QT_VERSION_MAJOR == 6 #include -#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" diff --git a/plugins/findthisdevice/findthisdeviceplugin.cpp b/plugins/findthisdevice/findthisdeviceplugin.cpp index fcaa4bfb8..3e3ec9702 100644 --- a/plugins/findthisdevice/findthisdeviceplugin.cpp +++ b/plugins/findthisdevice/findthisdeviceplugin.cpp @@ -20,9 +20,7 @@ #include #include -#if QT_VERSION_MAJOR == 6 #include -#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 } diff --git a/plugins/notifications/notification.cpp b/plugins/notifications/notification.cpp index 82b12537b..e254f17d4 100644 --- a/plugins/notifications/notification.cpp +++ b/plugins/notifications/notification.cpp @@ -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(); diff --git a/plugins/presenter/presenterplugin.cpp b/plugins/presenter/presenterplugin.cpp index f1c8a25b5..410f6dbac 100644 --- a/plugins/presenter/presenterplugin.cpp +++ b/plugins/presenter/presenterplugin.cpp @@ -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); diff --git a/plugins/share/shareplugin.cpp b/plugins/share/shareplugin.cpp index 2cd982d52..66811a30a 100644 --- a/plugins/share/shareplugin.cpp +++ b/plugins/share/shareplugin.cpp @@ -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"))) { diff --git a/plugins/telephony/telephonyplugin.cpp b/plugins/telephony/telephonyplugin.cpp index 206702caf..885cf7af7 100644 --- a/plugins/telephony/telephonyplugin.cpp +++ b/plugins/telephony/telephonyplugin.cpp @@ -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(); diff --git a/settings/main.cpp b/settings/main.cpp index f8a63c65f..f5002a267 100644 --- a/settings/main.cpp +++ b/settings/main.cpp @@ -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"))); diff --git a/smsapp/conversationssortfilterproxymodel.cpp b/smsapp/conversationssortfilterproxymodel.cpp index 5492e38bf..a4b2ab8d8 100644 --- a/smsapp/conversationssortfilterproxymodel.cpp +++ b/smsapp/conversationssortfilterproxymodel.cpp @@ -58,11 +58,7 @@ bool ConversationsSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QM const QList addressList = sourceModel()->data(index, ConversationListModel::AddressesRole).value>(); 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; } } diff --git a/smsapp/main.cpp b/smsapp/main.cpp index c31e1e7fa..4fc4709ec 100644 --- a/smsapp/main.cpp +++ b/smsapp/main.cpp @@ -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"))); diff --git a/urlhandler/kdeconnect-handler.cpp b/urlhandler/kdeconnect-handler.cpp index 041a9e187..d356069a7 100644 --- a/urlhandler/kdeconnect-handler.cpp +++ b/urlhandler/kdeconnect-handler.cpp @@ -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");