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

SettingVisibilityItem.qml « Preferences « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8905c151249e139a3382b431fea244933ba2b94d (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
// Copyright (c) 2022 Ultimaker B.V.
// Uranium is released under the terms of the LGPLv3 or higher.

import QtQuick 2.1
import QtQuick.Controls 2.1

import UM 1.5 as UM

Item
{
    // Use the depth of the model to move the item, but also leave space for the visibility / enabled exclamation mark.

    // Align checkbox with SettingVisibilityCategory icon with + 5
    x: definition ? definition.depth * UM.Theme.getSize("narrow_margin").width : UM.Theme.getSize("default_margin").width

    UM.TooltipArea
    {
        text: definition ? definition.description : ""

        width: childrenRect.width;
        height: childrenRect.height;
        id: checkboxTooltipArea
        UM.CheckBox
        {
            id: check

            text: definition ? definition.label: ""
            checked: definition ? definition.visible: false
            enabled: definition ? !definition.prohibited: false

            MouseArea
            {
                anchors.fill: parent
                onClicked: definitionsModel.setVisible(definition.key, !check.checked)
            }
        }
    }

    UM.TooltipArea
    {
        width: height
        height: check.height
        anchors.left: checkboxTooltipArea.right
        anchors.leftMargin: 2 * screenScaleFactor

        text:
        {
            if(provider.properties.enabled == "True")
            {
                return ""
            }
            var key = definition ? definition.key : ""
            var requires = settingDefinitionsModel.getRequires(key, "enabled")
            if (requires.length == 0)
            {
                return catalog.i18nc("@item:tooltip", "This setting has been hidden by the active machine and will not be visible.");
            }
            else
            {
                var requires_text = ""
                for (var i in requires)
                {
                    if (requires_text == "")
                    {
                        requires_text = requires[i].label
                    }
                    else
                    {
                        requires_text += ", " + requires[i].label
                    }
                }

                return catalog.i18ncp("@item:tooltip %1 is list of setting names", "This setting has been hidden by the value of %1. Change the value of that setting to make this setting visible.", "This setting has been hidden by the values of %1. Change the values of those settings to make this setting visible.", requires.length) .arg(requires_text);
            }
        }

        UM.ColorImage
        {
            anchors.centerIn: parent
            width: Math.round(check.height * 0.75) | 0
            height: width

            source: UM.Theme.getIcon("Information")

            color: UM.Theme.getColor("primary_button_text")
        }

        visible: provider.properties.enabled == "False"
    }

    UM.SettingPropertyProvider
    {
        id: provider

        containerStackId: "global"
        watchedProperties: [ "enabled" ]
        key: definition ? definition.key : ""
    }
}