File indexing completed on 2024-02-25 17:31:02

0001 /*
0002  * SPDX-FileCopyrightText: 2017 Red Hat Inc
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  *
0006  * SPDX-FileCopyrightText: 2017 Jan Grulich <jgrulich@redhat.com>
0007  * SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
0008  */
0009 
0010 #ifndef XDG_DESKTOP_PORTAL_KDE_REQUEST_H
0011 #define XDG_DESKTOP_PORTAL_KDE_REQUEST_H
0012 
0013 #include <QDBusVirtualObject>
0014 #include <QObject>
0015 
0016 class QDBusObjectPath;
0017 
0018 class Request : public QDBusVirtualObject
0019 {
0020     Q_OBJECT
0021 public:
0022     explicit Request(const QDBusObjectPath &handle, QObject *parent = nullptr, const QString &portalName = QString(), const QVariant &data = QVariant());
0023     ~Request() override;
0024 
0025     bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) override;
0026     QString introspect(const QString &path) const override;
0027 
0028     template<class T>
0029     static Request *makeClosableDialogRequest(const QDBusObjectPath &handle, T *dialogAndParent)
0030     {
0031         auto request = new Request(handle, dialogAndParent);
0032         connect(request, &Request::closeRequested, dialogAndParent, &T::reject);
0033         return request;
0034     }
0035 
0036 Q_SIGNALS:
0037     void closeRequested();
0038 
0039 private:
0040     const QVariant m_data;
0041     const QString m_portalName;
0042 };
0043 
0044 #endif // XDG_DESKTOP_PORTAL_KDE_REQUEST_H