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

SettingCategory.qml « Settings « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5676bcedf9e1a90ce448a9ad5ad8f4b7a1e75f81 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.7
import QtQuick.Controls 2.0

import UM 1.1 as UM
import Cura 1.0 as Cura

Button
{
    id: base
    anchors.left: parent.left
    anchors.right: parent.right
    // To avoid overlaping with the scrollBars
    anchors.rightMargin: 2 * UM.Theme.getSize("thin_margin").width
    hoverEnabled: true

    background: Rectangle
    {
        id: backgroundRectangle
        implicitHeight: UM.Theme.getSize("section").height
        color:
        {
            if (base.color)
            {
                return base.color
            }
            else if (!base.enabled)
            {
                return UM.Theme.getColor("setting_category_disabled")
            }
            else if (base.hovered && base.checkable && base.checked)
            {
                return UM.Theme.getColor("setting_category_active_hover")
            }
            else if (base.pressed || (base.checkable && base.checked))
            {
                return UM.Theme.getColor("setting_category_active")
            }
            else if (base.hovered)
            {
                return UM.Theme.getColor("setting_category_hover")
            }
            return UM.Theme.getColor("setting_category")
        }
        Behavior on color { ColorAnimation { duration: 50; } }
    }

    signal showTooltip(string text)
    signal hideTooltip()
    signal contextMenuRequested()
    signal showAllHiddenInheritedSettings(string category_id)
    signal focusReceived()
    signal setActiveFocusToNextSetting(bool forward)

    property var focusItem: base

    contentItem: Item
    {
        anchors.fill: parent

        Label
        {
            id: settingNameLabel
            anchors
            {
                left: parent.left
                leftMargin: 2 * UM.Theme.getSize("default_margin").width + UM.Theme.getSize("section_icon").width
                right: parent.right
                verticalCenter: parent.verticalCenter
            }
            text: definition.label
            textFormat: Text.PlainText
            renderType: Text.NativeRendering
            font: UM.Theme.getFont("setting_category")
            color:
            {
                if (!base.enabled)
                {
                    return UM.Theme.getColor("setting_category_disabled_text")
                } else if ((base.hovered || base.activeFocus) && base.checkable && base.checked)
                {
                    return UM.Theme.getColor("setting_category_active_hover_text")
                } else if (base.pressed || (base.checkable && base.checked))
                {
                    return UM.Theme.getColor("setting_category_active_text")
                } else if (base.hovered || base.activeFocus)
                {
                    return UM.Theme.getColor("setting_category_hover_text")
                } else
                {
                    return UM.Theme.getColor("setting_category_text")
                }
            }
            fontSizeMode: Text.HorizontalFit
            minimumPointSize: 8
        }

        UM.RecolorImage
        {
            id: category_arrow
            anchors.verticalCenter: parent.verticalCenter
            anchors.right: parent.right
            anchors.rightMargin: UM.Theme.getSize("default_margin").width
            width: UM.Theme.getSize("standard_arrow").width
            height: UM.Theme.getSize("standard_arrow").height
            sourceSize.height: width
            color:
            {
                if (!base.enabled)
                {
                    return UM.Theme.getColor("setting_category_disabled_text")
                }
                else if ((base.hovered || base.activeFocus) && base.checkable && base.checked)
                {
                    return UM.Theme.getColor("setting_category_active_hover_text")
                }
                else if (base.pressed || (base.checkable && base.checked))
                {
                    return UM.Theme.getColor("setting_category_active_text")
                }
                else if (base.hovered || base.activeFocus)
                {
                    return UM.Theme.getColor("setting_category_hover_text")
                }
                return UM.Theme.getColor("setting_category_text")
            }
            source: base.checked ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
        }
    }

    UM.RecolorImage
    {
        id: icon
        anchors.verticalCenter: parent.verticalCenter
        anchors.left: parent.left
        anchors.leftMargin: UM.Theme.getSize("thin_margin").width
        color:
        {
            if (!base.enabled)
            {
                return UM.Theme.getColor("setting_category_disabled_text")
            }
            else if((base.hovered || base.activeFocus) && base.checkable && base.checked)
            {
                return UM.Theme.getColor("setting_category_active_hover_text")
            }
            else if(base.pressed || (base.checkable && base.checked))
            {
                return UM.Theme.getColor("setting_category_active_text")
            }
            else if(base.hovered || base.activeFocus)
            {
                return UM.Theme.getColor("setting_category_hover_text")
            }
            return UM.Theme.getColor("setting_category_text")
        }
        source: UM.Theme.getIcon(definition.icon)
        width: UM.Theme.getSize("section_icon").width
        height: UM.Theme.getSize("section_icon").height
        sourceSize.width: width + 15 * screenScaleFactor
        sourceSize.height: width + 15 * screenScaleFactor
    }

    checkable: true
    checked: definition.expanded

    onClicked:
    {
        if (definition.expanded)
        {
            settingDefinitionsModel.collapse(definition.key)
        }
        else
        {
            settingDefinitionsModel.expandRecursive(definition.key)
        }
        //Set focus so that tab navigation continues from this point on.
        //NB: This must be set AFTER collapsing/expanding the category so that the scroll position is correct.
        forceActiveFocus()
    }
    onActiveFocusChanged:
    {
        if (activeFocus)
        {
            base.focusReceived()
        }
    }

    Keys.onTabPressed: base.setActiveFocusToNextSetting(true)
    Keys.onBacktabPressed: base.setActiveFocusToNextSetting(false)

    UM.SimpleButton
    {
        id: settingsButton

        visible: base.hovered || settingsButton.hovered
        height: Math.round(base.height * 0.6)
        width: Math.round(base.height * 0.6)

        anchors
        {
            right: inheritButton.visible ? inheritButton.left : parent.right
            // Use 1.9 as the factor because there is a 0.1 difference between the settings and inheritance warning icons
            rightMargin: inheritButton.visible ? Math.round(UM.Theme.getSize("default_margin").width / 2) : category_arrow.width + Math.round(UM.Theme.getSize("default_margin").width * 1.9)
            verticalCenter: parent.verticalCenter
        }

        color: UM.Theme.getColor("setting_control_button")
        hoverColor: UM.Theme.getColor("setting_control_button_hover")
        iconSource: UM.Theme.getIcon("settings")

        onClicked: Cura.Actions.configureSettingVisibility.trigger(definition)
    }

    UM.SimpleButton
    {
        id: inheritButton

        anchors.verticalCenter: parent.verticalCenter
        anchors.right: parent.right
        anchors.rightMargin: category_arrow.width + UM.Theme.getSize("default_margin").width * 2

        visible:
        {
            if (Cura.SettingInheritanceManager.settingsWithInheritanceWarning.indexOf(definition.key) >= 0)
            {
                var children_with_override = Cura.SettingInheritanceManager.getChildrenKeysWithOverride(definition.key)
                for (var i = 0; i < children_with_override.length; i++)
                {
                    if (!settingDefinitionsModel.getVisible(children_with_override[i]))
                    {
                        return true
                    }
                }
                return false
            }
            return false
        }

        height: Math.round(parent.height / 2)
        width: height

        onClicked:
        {
            settingDefinitionsModel.expandRecursive(definition.key)
            base.checked = true
            base.showAllHiddenInheritedSettings(definition.key)
        }

        color: UM.Theme.getColor("setting_control_button")
        hoverColor: UM.Theme.getColor("setting_control_button_hover")
        iconSource: UM.Theme.getIcon("notice")

        onEntered: base.showTooltip(catalog.i18nc("@label","Some hidden settings use values different from their normal calculated value.\n\nClick to make these settings visible."))

        onExited: base.hideTooltip()

        UM.I18nCatalog { id: catalog; name: "cura" }
    }
}