Clean up unneeded version checks
With the min. version bumped, those can be safely removed
This commit is contained in:
parent
1ee75463e0
commit
ac3d439a2a
4 changed files with 2 additions and 32 deletions
|
@ -9,17 +9,12 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
#include <kcoreaddons_version.h>
|
|
||||||
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "kdeconnectcore_export.h"
|
#include "kdeconnectcore_export.h"
|
||||||
#include "kdeconnectpluginconfig.h"
|
#include "kdeconnectpluginconfig.h"
|
||||||
#include "networkpacket.h"
|
#include "networkpacket.h"
|
||||||
|
|
||||||
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 44, 0)
|
|
||||||
#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile) K_PLUGIN_FACTORY_WITH_JSON(classname##Factory, jsonFile, registerPlugin<classname>();)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct KdeConnectPluginPrivate;
|
struct KdeConnectPluginPrivate;
|
||||||
|
|
||||||
class KDECONNECTCORE_EXPORT KdeConnectPlugin : public QObject
|
class KDECONNECTCORE_EXPORT KdeConnectPlugin : public QObject
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
|
|
||||||
#include "kcoreaddons_version.h"
|
#include "kcoreaddons_version.h"
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 86, 0)
|
|
||||||
#include <KPluginLoader>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PluginModel::PluginModel(QObject *parent)
|
PluginModel::PluginModel(QObject *parent)
|
||||||
: QAbstractListModel(parent)
|
: QAbstractListModel(parent)
|
||||||
|
@ -21,11 +18,7 @@ PluginModel::PluginModel(QObject *parent)
|
||||||
connect(this, &QAbstractItemModel::rowsRemoved, this, &PluginModel::rowsChanged);
|
connect(this, &QAbstractItemModel::rowsRemoved, this, &PluginModel::rowsChanged);
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 84, 0)
|
|
||||||
m_plugins = KPluginLoader::findPlugins(QStringLiteral("kdeconnect/"));
|
|
||||||
#else
|
|
||||||
m_plugins = KPluginMetaData::findPlugins(QStringLiteral("kdeconnect/"));
|
m_plugins = KPluginMetaData::findPlugins(QStringLiteral("kdeconnect/"));
|
||||||
#endif
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,9 @@
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
#include "plugin_notification_debug.h"
|
#include "plugin_notification_debug.h"
|
||||||
|
|
||||||
#include "knotifications_version.h"
|
|
||||||
#include <KNotification>
|
|
||||||
#if KNOTIFICATIONS_VERSION >= QT_VERSION_CHECK(5, 81, 0)
|
|
||||||
#include <KNotificationReplyAction>
|
|
||||||
#endif
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <KNotification>
|
||||||
|
#include <KNotificationReplyAction>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
@ -49,13 +46,6 @@ Notification::Notification(const NetworkPacket &np, const Device *device, QObjec
|
||||||
createKNotification(np);
|
createKNotification(np);
|
||||||
|
|
||||||
connect(m_notification, &KNotification::activated, this, [this](unsigned int actionIndex) {
|
connect(m_notification, &KNotification::activated, this, [this](unsigned int actionIndex) {
|
||||||
// Since 5.81 we use KNotification's inline reply instead of our own action
|
|
||||||
#if KNOTIFICATIONS_VERSION < QT_VERSION_CHECK(5, 81, 0)
|
|
||||||
// Do nothing for our own reply action
|
|
||||||
if (!m_requestReplyId.isEmpty() && actionIndex == 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Notification action indices start at 1
|
// Notification action indices start at 1
|
||||||
Q_EMIT actionTriggered(m_internalId, m_actions[actionIndex - 1]);
|
Q_EMIT actionTriggered(m_internalId, m_actions[actionIndex - 1]);
|
||||||
});
|
});
|
||||||
|
@ -120,17 +110,12 @@ void Notification::createKNotification(const NetworkPacket &np)
|
||||||
m_notification->setHint(QStringLiteral("x-kde-origin-name"), m_device->name());
|
m_notification->setHint(QStringLiteral("x-kde-origin-name"), m_device->name());
|
||||||
|
|
||||||
if (!m_requestReplyId.isEmpty()) {
|
if (!m_requestReplyId.isEmpty()) {
|
||||||
#if KNOTIFICATIONS_VERSION >= QT_VERSION_CHECK(5, 81, 0)
|
|
||||||
auto replyAction = std::make_unique<KNotificationReplyAction>(i18nc("@action:button", "Reply"));
|
auto replyAction = std::make_unique<KNotificationReplyAction>(i18nc("@action:button", "Reply"));
|
||||||
replyAction->setPlaceholderText(i18nc("@info:placeholder", "Reply to %1...", m_appName));
|
replyAction->setPlaceholderText(i18nc("@info:placeholder", "Reply to %1...", m_appName));
|
||||||
replyAction->setFallbackBehavior(KNotificationReplyAction::FallbackBehavior::UseRegularAction);
|
replyAction->setFallbackBehavior(KNotificationReplyAction::FallbackBehavior::UseRegularAction);
|
||||||
QObject::connect(replyAction.get(), &KNotificationReplyAction::replied, this, &Notification::replied);
|
QObject::connect(replyAction.get(), &KNotificationReplyAction::replied, this, &Notification::replied);
|
||||||
QObject::connect(replyAction.get(), &KNotificationReplyAction::activated, this, &Notification::reply);
|
QObject::connect(replyAction.get(), &KNotificationReplyAction::activated, this, &Notification::reply);
|
||||||
m_notification->setReplyAction(std::move(replyAction));
|
m_notification->setReplyAction(std::move(replyAction));
|
||||||
#else
|
|
||||||
m_actions.prepend(i18n("Reply"));
|
|
||||||
connect(m_notification, &KNotification::action1Activated, this, &Notification::reply, Qt::UniqueConnection);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_notification->setActions(m_actions);
|
m_notification->setActions(m_actions);
|
||||||
|
|
|
@ -77,10 +77,7 @@ void RunCommandPlugin::sendConfig()
|
||||||
{
|
{
|
||||||
QString commands = config()->getString(QStringLiteral("commands"), QStringLiteral("{}"));
|
QString commands = config()->getString(QStringLiteral("commands"), QStringLiteral("{}"));
|
||||||
NetworkPacket np(PACKET_TYPE_RUNCOMMAND, {{QStringLiteral("commandList"), commands}});
|
NetworkPacket np(PACKET_TYPE_RUNCOMMAND, {{QStringLiteral("commandList"), commands}});
|
||||||
|
|
||||||
#if KCMUTILS_VERSION >= QT_VERSION_CHECK(5, 45, 0)
|
|
||||||
np.set<bool>(QStringLiteral("canAddCommand"), true);
|
np.set<bool>(QStringLiteral("canAddCommand"), true);
|
||||||
#endif
|
|
||||||
|
|
||||||
sendPacket(np);
|
sendPacket(np);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue