Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ManageButton.qml « qml « resources « Marketplace « plugins - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 36022ffd541c5134af2641be045177f8ebd0311f (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
// Copyright (c) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1

import UM 1.6 as UM
import Cura 1.6 as Cura

Item
{
    id: manageButton
    property bool button_style: true
    property string text
    property bool busy: false
    property bool confirmed: false

    implicitWidth: childrenRect.width
    implicitHeight: childrenRect.height

    signal clicked()

    property Component primaryButton: Component
    {
        Cura.PrimaryButton
        {
            text: manageButton.text
            onClicked: manageButton.clicked()
        }
    }

    property Component secondaryButton: Component
    {
        Cura.SecondaryButton
        {
            text: manageButton.text
            onClicked: manageButton.clicked()
        }
    }

    property Component busyButton: Component
    {
        Item
        {
            height: UM.Theme.getSize("action_button").height
            width: childrenRect.width

            UM.RecolorImage
            {
                id: busyIndicator
                visible: parent.visible
                height: UM.Theme.getSize("action_button").height - 2 * UM.Theme.getSize("narrow_margin").height
                width: height
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter

                source: UM.Theme.getIcon("Spinner")
                color: UM.Theme.getColor("primary")

                RotationAnimator
                {
                    target: busyIndicator
                    running: parent.visible
                    from: 0
                    to: 360
                    loops: Animation.Infinite
                    duration: 2500
                }
            }
            Label
            {
                visible: parent.visible
                anchors.left: busyIndicator.right
                anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
                anchors.verticalCenter: parent.verticalCenter
                text: manageButton.text

                font: UM.Theme.getFont("medium_bold")
                color: UM.Theme.getColor("primary")
            }
        }
    }

    property Component confirmButton: Component
    {
        Item
        {
            height: UM.Theme.getSize("action_button").height
            width: childrenRect.width

            Label
            {
                anchors.verticalCenter: parent.verticalCenter
                text: manageButton.text

                font: UM.Theme.getFont("medium_bold")
                color: UM.Theme.getColor("primary")
            }
        }
    }

    Loader
    {

        sourceComponent:
        {
            if (busy) { return manageButton.busyButton; }
            else if (confirmed) { return manageButton.confirmButton; }
            else if (manageButton.button_style) { return manageButton.primaryButton; }
            else { return manageButton.secondaryButton; }
        }
    }
}