summaryrefslogtreecommitdiff
path: root/src/manager-lib/qmlinprocessapplicationinterface.h
blob: 2ffe53c61bd3ebe9ddc937497acccf50960d2af6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#pragma once

#include <QVector>
#include <QPointer>
#include <QQmlParserStatus>

#include <QtAppManApplication/applicationinterface.h>
#include <QtAppManNotification/notification.h>

QT_BEGIN_NAMESPACE_AM

class QmlInProcessRuntime;
class IntentClientRequest;

class QmlInProcessNotification : public Notification // clazy:exclude=missing-qobject-macro
{
public:
    QmlInProcessNotification(QObject *parent = nullptr, ConstructionMode mode = Declarative);

    void componentComplete() override;

    static void initialize();

protected:
    uint libnotifyShow() override;
    void libnotifyClose() override;

private:
    ConstructionMode m_mode;
    QString m_appId;

    static QVector<QPointer<QmlInProcessNotification> > s_allNotifications;

    friend class QmlInProcessApplicationInterface;
};


class QmlInProcessApplicationInterface : public ApplicationInterface
{
    Q_OBJECT

public:
    explicit QmlInProcessApplicationInterface(QmlInProcessRuntime *runtime = nullptr);

    QString applicationId() const override;
    QVariantMap name() const override;
    QUrl icon() const override;
    QString version() const override;
    QVariantMap systemProperties() const override;
    QVariantMap applicationProperties() const override;

    Q_INVOKABLE QT_PREPEND_NAMESPACE_AM(Notification *) createNotification();
    Q_INVOKABLE void acknowledgeQuit();

    void finishedInitialization() override;

signals:
    void quitAcknowledged();
private:
    QmlInProcessRuntime *m_runtime;
    friend class QmlInProcessRuntime;
};

QT_END_NAMESPACE_AM