Move setWhenAvailable from dbusinterfaces to dbushelpers

This commit is contained in:
Albert Vaca Cintora 2023-07-23 16:53:57 +02:00
parent 7860280158
commit bd72602875
5 changed files with 13 additions and 12 deletions

View file

@ -31,4 +31,15 @@ void blockOnReply(QDBusPendingReply<void> reply)
} }
} }
template<typename T, typename W>
static void setWhenAvailable(const QDBusPendingReply<T> &pending, W func, QObject *parent)
{
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, parent);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, parent, [func](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
QDBusPendingReply<T> reply = *watcher;
func(reply.value());
});
}
#endif #endif

View file

@ -5,7 +5,6 @@
*/ */
#include "dbusinterfaces.h" #include "dbusinterfaces.h"
#include <dbushelper.h>
QString DaemonDbusInterface::activatedService() QString DaemonDbusInterface::activatedService()
{ {

View file

@ -265,17 +265,6 @@ public:
~VirtualmonitorDbusInterface() override; ~VirtualmonitorDbusInterface() override;
}; };
template<typename T, typename W>
static void setWhenAvailable(const QDBusPendingReply<T> &pending, W func, QObject *parent)
{
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending, parent);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, parent, [func](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
QDBusPendingReply<T> reply = *watcher;
func(reply.value());
});
}
class KDECONNECTINTERFACES_EXPORT ClipboardDbusInterface : public OrgKdeKdeconnectDeviceClipboardInterface class KDECONNECTINTERFACES_EXPORT ClipboardDbusInterface : public OrgKdeKdeconnectDeviceClipboardInterface
{ {
Q_OBJECT Q_OBJECT

View file

@ -14,6 +14,7 @@
#include <KPluginMetaData> #include <KPluginMetaData>
#include <kcmutils_version.h> #include <kcmutils_version.h>
#include "dbushelpers.h"
#include "dbusinterfaces.h" #include "dbusinterfaces.h"
#include "devicesmodel.h" #include "devicesmodel.h"
#include "devicessortproxymodel.h" #include "devicessortproxymodel.h"

View file

@ -12,6 +12,7 @@
#include <KLocalizedString> #include <KLocalizedString>
#include "dbushelpers.h"
#include "interfaces/conversationmessage.h" #include "interfaces/conversationmessage.h"
#include "interfaces/dbusinterfaces.h" #include "interfaces/dbusinterfaces.h"
#include "sms_conversations_list_debug.h" #include "sms_conversations_list_debug.h"