summaryrefslogtreecommitdiffstats
path: root/tools/qqem/qml/StatusBar.qml
blob: e5aeff0a5460eb66e4478df19d9b4105f5e32b17 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick

Item {
    id: rootItem

    anchors.bottom: parent.bottom
    // Currently StatusBar is only visible when there are errors to show
    anchors.bottomMargin: (errorMessageItem.errorString == "") ? -height : 0
    anchors.left: parent.left
    anchors.right: parent.right
    height: 32 + errorMessageTextItem.lineCount * 14

    Behavior on anchors.bottomMargin {
        NumberAnimation {
            duration: 200
            easing.type: Easing.InOutQuad
        }
    }

    Rectangle {
        anchors.fill: parent
        color: mainView.backgroundColor2
    }

    Item {
        id: errorMessageItem
        property var error: effectManager.effectError
        property string errorString: error.message
        // Helper so when error disappears we can smoothly animate it away
        property string visibleErrorString

        function updateErrorString() {
            if (errorString === "") {
                showMessageAnimation.stop();
                hideMessageAnimation.restart();
            } else {
                hideMessageAnimation.stop();
                showMessageAnimation.restart();
            }
        }

        anchors.fill: parent
        opacity: 0

        onErrorStringChanged: {
            updateErrorString();
        }

        SequentialAnimation {
            id: showMessageAnimation
            ScriptAction {
                script: {
                    errorMessageItem.visibleErrorString = errorMessageItem.errorString;
                }
            }
            NumberAnimation {
                target: errorMessageItem
                property: "opacity"
                to: 1.0
                duration: 500
                easing.type: Easing.InOutQuad
            }
        }
        SequentialAnimation {
            id: hideMessageAnimation
            NumberAnimation {
                target: errorMessageItem
                property: "opacity"
                to: 0.0
                duration: 500
                easing.type: Easing.InOutQuad
            }
            ScriptAction {
                script: errorMessageItem.visibleErrorString = "";
            }
        }

        Image {
            id: errorIcon
            anchors.verticalCenter: parent.verticalCenter
            anchors.left: parent.left
            anchors.leftMargin: 10
            height: 32
            width: height
            source: "images/icon_error.png"
            mipmap: true
        }
        Text {
            id: errorMessageTextItem
            anchors.verticalCenter: parent.verticalCenter
            anchors.left: errorIcon.right
            anchors.leftMargin: 10
            anchors.right: showErrorButton.left
            anchors.rightMargin: 10
            font.pixelSize: 14
            text: errorMessageItem.visibleErrorString
            color: mainView.foregroundColor2
            elide: Text.ElideRight
            maximumLineCount: 3
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere
        }
        CustomIconButton {
            id: showErrorButton
            anchors.verticalCenter: parent.verticalCenter
            anchors.right: parent.right
            anchors.rightMargin: 10
            height: 40
            width: height * (288 / 128)
            icon: "images/button_show.png"
            description: "Show Error"
            enabled: errorMessageItem.error.line > -1
            onClicked: {
                mainView.outputView.showCodePreview();
                outputEditorView.showErrorCodeLine();
            }
        }
    }
}