summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video/recorder/RecordButton.qml
blob: 5296a30282f6be89ba2ee5c524465c372d0cd4c8 (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import QtMultimedia

Item {
    id: root
    width: outerRadius * 2
    height: outerRadius * 2

    required property bool recording

    property int outerRadius: Style.height
    property int innerRadius: mouse.pressedButtons === Qt.LeftButton ? outerRadius - 6 : outerRadius - 5

    signal clicked

    Rectangle {
        anchors.fill: parent
        radius: outerRadius
        opacity: 0.5
        border.color: "black"
        border.width: 1
    }

    Rectangle {
        anchors.centerIn: parent
        width: recording ? innerRadius * 2 - 15 : innerRadius * 2
        height: recording ? innerRadius * 2 - 15 : innerRadius * 2
        radius: recording ? 2 : innerRadius
        color: "red"

        Behavior on width { NumberAnimation { duration: 100 }}
        Behavior on height { NumberAnimation { duration: 100 }}
        Behavior on radius { NumberAnimation { duration: 100 }}

        MouseArea {
            id: mouse
            anchors.fill: parent
            onClicked: root.clicked()
        }
    }
}