summaryrefslogtreecommitdiffstats
path: root/examples/applicationmanager/intents/shared/IntentsApplicationWindow.qml
blob: 9269a2b877e5c6efbc0901d6309e6deab21739d8 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// 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 BSD-3-Clause

import QtQuick
import QtApplicationManager.Application
import QtApplicationManager

ApplicationManagerWindow {
    id: root
    property string flavor: ApplicationInterface.applicationId.split(".")[1]

    IntentsUIPage {
        id: intentPage
        anchors.fill: parent
        flavor: root.flavor
        title: ApplicationInterface.name["en"]

        //! [Send Intent]
        onRequest: (intentId, applicationId, parameters) => {
            let request = IntentClient.sendIntentRequest(intentId, applicationId, parameters)
            request.onReplyReceived.connect(function() {
                intentPage.setResult(request.requestId, request.succeeded,
                                     request.succeeded ? request.result : request.errorMessage)
            })
        }
        //! [Send Intent]

        //! [Broadcast Intent]
        onBroadcast: (intentId, parameters) => {
            IntentClient.broadcastIntentRequest(intentId, parameters)
        }
        //! [Broadcast Intent]

        //! [Intent Animation]
        RotationAnimation on rotation {
            id: rotationAnimation
            running: false
            duration: 500; from: 0; to: 360
        }
        //! [Intent Animation]

        SequentialAnimation  on scale {
            id: scaleAnimation
            running: false
            PropertyAnimation { from: 1; to: 0.5 }
            PropertyAnimation { from: 0.5; to: 1 }
        }

        SequentialAnimation on color {
            id: blinkAnimation
            running: false
            ColorAnimation { to: "black" }
            ColorAnimation { to: "white" }
        }

        SequentialAnimation on color {
            id: blueAnimation
            running: false
            ColorAnimation { to: "blue"; duration: 2000 }
            ColorAnimation { to: "white" }
        }
    }

    //! [Intent Handler]
    IntentHandler {
        intentIds: [ "rotate-window" ]
        onRequestReceived: (request) => {
            rotationAnimation.start()
            request.sendReply({ "done": true })
        }
    }
    //! [Intent Handler]

    IntentHandler {
        intentIds: [ "scale-window" ]
        onRequestReceived: (request) => {
            scaleAnimation.start()
            request.sendReply({ "done": true })
        }
    }

    IntentHandler {
        intentIds: [ "blue-window-private" ]
        onRequestReceived: (request) => {
            blueAnimation.start()
            request.sendReply({ "done": true })
        }
    }

    IntentHandler {
        intentIds: [ "broadcast/blink-window" ]
        onRequestReceived: (request) => {
            blinkAnimation.start()
        }
    }
}