blob: 752e846f1ada19dc0ad6bd76c013c3fd54783a02 (
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
|
// Copyright (c) 2015 Ultimaker B.V.
// Uranium is released under the terms of the AGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.2
import UM 1.1 as UM
SettingItem
{
id: base
property var focusItem: input
contents: Rectangle
{
id: control
anchors.fill: parent
border.width: UM.Theme.getSize("default_lining").width
border.color:
{
if(!enabled)
{
return UM.Theme.getColor("setting_control_disabled_border")
}
switch(propertyProvider.properties.validationState)
{
case "ValidatorState.Exception":
case "ValidatorState.MinimumError":
case "ValidatorState.MaximumError":
return UM.Theme.getColor("setting_validation_error");
case "ValidatorState.MinimumWarning":
case "ValidatorState.MaximumWarning":
return UM.Theme.getColor("setting_validation_warning");
}
//Validation is OK.
if(hovered || input.activeFocus)
{
return UM.Theme.getColor("setting_control_border_highlight")
}
return UM.Theme.getColor("setting_control_border")
}
color: {
if(!enabled)
{
return UM.Theme.getColor("setting_control_disabled")
}
switch(propertyProvider.properties.validationState)
{
case "ValidatorState.Exception":
case "ValidatorState.MinimumError":
case "ValidatorState.MaximumError":
return UM.Theme.getColor("setting_validation_error_background")
case "ValidatorState.MinimumWarning":
case "ValidatorState.MaximumWarning":
return UM.Theme.getColor("setting_validation_warning_background")
case "ValidatorState.Valid":
return UM.Theme.getColor("setting_validation_ok")
default:
return UM.Theme.getColor("setting_control")
}
}
Rectangle
{
anchors.fill: parent;
anchors.margins: UM.Theme.getSize("default_lining").width;
color: UM.Theme.getColor("setting_control_highlight")
opacity: !control.hovered ? 0 : propertyProvider.properties.validationState == "ValidatorState.Valid" ? 1.0 : 0.35;
}
Label
{
anchors.right: parent.right;
anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width
anchors.verticalCenter: parent.verticalCenter;
text: definition.unit;
color: UM.Theme.getColor("setting_unit")
font: UM.Theme.getFont("default")
}
MouseArea
{
id: mouseArea
anchors.fill: parent;
//hoverEnabled: true;
cursorShape: Qt.IBeamCursor
}
TextInput
{
id: input
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("setting_unit_margin").width
right: parent.right
verticalCenter: parent.verticalCenter
}
Keys.onTabPressed:
{
base.setActiveFocusToNextSetting(true)
}
Keys.onBacktabPressed:
{
base.setActiveFocusToNextSetting(false)
}
Keys.onReleased:
{
propertyProvider.setPropertyValue("value", text)
}
onEditingFinished:
{
propertyProvider.setPropertyValue("value", text)
}
onActiveFocusChanged:
{
if(activeFocus)
{
base.focusReceived();
}
}
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
font: UM.Theme.getFont("default");
selectByMouse: true;
maximumLength: (definition.type == "[int]") ? 20 : (definition.type == "str") ? -1 : 10;
validator: RegExpValidator { regExp: (definition.type == "[int]") ? /^\[?(\s*-?[0-9]{0,9}\s*,)*(\s*-?[0-9]{0,9})\s*\]?$/ : (definition.type == "int") ? /^-?[0-9]{0,10}$/ : (definition.type == "float") ? /^-?[0-9]{0,9}[.,]?[0-9]{0,10}$/ : /^.*$/ } // definition.type property from parent loader used to disallow fractional number entry
Binding
{
target: input
property: "text"
value: {
// Stacklevels
// 0: user -> unsaved change
// 1: quality changes -> saved change
// 2: quality
// 3: material -> user changed material in materialspage
// 4: variant
// 5: machine_changes
// 6: machine
if ((base.resolve != "None" && base.resolve) && (stackLevel != 0) && (stackLevel != 1)) {
// We have a resolve function. Indicates that the setting is not settable per extruder and that
// we have to choose between the resolved value (default) and the global value
// (if user has explicitly set this).
return base.resolve;
} else {
return propertyProvider.properties.value;
}
}
when: !input.activeFocus
}
}
}
}
|