mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 16:35:58 +08:00
Import Uranium's SettingView related files and start making them work
This is too cura-specific now so we should not put it in Uranium.
This commit is contained in:
parent
199a30099e
commit
fa7e186b2f
79
resources/qml/Settings/SettingCategory.qml
Normal file
79
resources/qml/Settings/SettingCategory.qml
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// 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.1
|
||||||
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
|
import UM 1.1 as UM
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: base;
|
||||||
|
|
||||||
|
style: UM.Theme.styles.sidebar_category;
|
||||||
|
|
||||||
|
signal showTooltip();
|
||||||
|
signal hideTooltip();
|
||||||
|
signal contextMenuRequested()
|
||||||
|
|
||||||
|
text: definition.label
|
||||||
|
iconSource: UM.Theme.getIcon(definition.icon)
|
||||||
|
|
||||||
|
checkable: true
|
||||||
|
checked: definition.expanded
|
||||||
|
|
||||||
|
onClicked: definition.expanded ? settingDefinitionsModel.collapse(definition.key) : settingDefinitionsModel.expandAll(definition.key)
|
||||||
|
|
||||||
|
UM.SimpleButton {
|
||||||
|
id: settingsButton
|
||||||
|
|
||||||
|
visible: base.hovered || settingsButton.hovered
|
||||||
|
height: base.height * 0.6
|
||||||
|
width: base.height * 0.6
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
right: inheritButton.visible ? inheritButton.left : parent.right
|
||||||
|
rightMargin: inheritButton.visible? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("setting_preferences_button_margin").width
|
||||||
|
verticalCenter: parent.verticalCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
color: UM.Theme.getColor("setting_control_button");
|
||||||
|
hoverColor: UM.Theme.getColor("setting_control_button_hover")
|
||||||
|
iconSource: UM.Theme.getIcon("settings");
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
Actions.configureSettingVisibility()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UM.SimpleButton
|
||||||
|
{
|
||||||
|
// This button shows when the setting has an inherited function, but is overriden by profile.
|
||||||
|
id: inheritButton;
|
||||||
|
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: UM.Theme.getSize("setting_preferences_button_margin").width
|
||||||
|
|
||||||
|
visible: hiddenValuesCount > 0
|
||||||
|
height: parent.height / 2;
|
||||||
|
width: height;
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
base.showAllHidenInheritedSettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
color: UM.Theme.getColor("setting_control_button")
|
||||||
|
hoverColor: UM.Theme.getColor("setting_control_button_hover")
|
||||||
|
iconSource: UM.Theme.getIcon("notice")
|
||||||
|
|
||||||
|
onEntered: {
|
||||||
|
base.showTooltip()
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
base.hideTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
77
resources/qml/Settings/SettingCheckBox.qml
Normal file
77
resources/qml/Settings/SettingCheckBox.qml
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// Copyright (c) 2015 Ultimaker B.V.
|
||||||
|
// Uranium is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Controls 1.1
|
||||||
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
|
||||||
|
import UM 1.2 as UM
|
||||||
|
|
||||||
|
SettingItem
|
||||||
|
{
|
||||||
|
id: base
|
||||||
|
|
||||||
|
MouseArea
|
||||||
|
{
|
||||||
|
id: control
|
||||||
|
|
||||||
|
property bool checked:
|
||||||
|
{
|
||||||
|
if(value == "True")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(value == "False")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
anchors
|
||||||
|
{
|
||||||
|
top: parent.top
|
||||||
|
bottom: parent.bottom
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
width: height
|
||||||
|
|
||||||
|
color:
|
||||||
|
{
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return base.style.controlDisabledColor
|
||||||
|
}
|
||||||
|
if(base.containsMouse || base.activeFocus)
|
||||||
|
{
|
||||||
|
return base.style.controlHighlightColor
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return base.style.controlColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
border.width: base.style.controlBorderWidth;
|
||||||
|
border.color: !enabled ? base.style.controlDisabledBorderColor : control.containsMouse ? base.style.controlBorderHighlightColor : base.style.controlBorderColor;
|
||||||
|
|
||||||
|
UM.RecolorImage {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
width: parent.width/2.5
|
||||||
|
height: parent.height/2.5
|
||||||
|
sourceSize.width: width
|
||||||
|
sourceSize.height: width
|
||||||
|
color: !enabled ? base.style.controlDisabledTextColor : base.style.controlTextColor;
|
||||||
|
source: UM.Theme.getIcon("check")
|
||||||
|
opacity: control.checked
|
||||||
|
Behavior on opacity { NumberAnimation { duration: 100; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
114
resources/qml/Settings/SettingComboBox.qml
Normal file
114
resources/qml/Settings/SettingComboBox.qml
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
// Copyright (c) 2015 Ultimaker B.V.
|
||||||
|
// Uranium is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import QtQuick.Controls 1.1
|
||||||
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
|
||||||
|
import UM 1.1 as UM
|
||||||
|
|
||||||
|
SettingItem
|
||||||
|
{
|
||||||
|
id: base
|
||||||
|
|
||||||
|
ComboBox
|
||||||
|
{
|
||||||
|
// signal valueChanged(string value);
|
||||||
|
// id: base
|
||||||
|
model: definition.options
|
||||||
|
textRole: "name";
|
||||||
|
|
||||||
|
MouseArea
|
||||||
|
{
|
||||||
|
anchors.fill: parent;
|
||||||
|
acceptedButtons: Qt.NoButton;
|
||||||
|
onWheel: wheel.accepted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
style: ComboBoxStyle
|
||||||
|
{
|
||||||
|
background: Rectangle
|
||||||
|
{
|
||||||
|
color:
|
||||||
|
{
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return base.style.controlDisabledColor
|
||||||
|
}
|
||||||
|
if(control.hovered || base.activeFocus)
|
||||||
|
{
|
||||||
|
return base.style.controlHighlightColor
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return base.style.controlColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
border.width: base.style.controlBorderWidth;
|
||||||
|
border.color: !enabled ? base.style.controlDisabledBorderColor : control.hovered ? base.style.controlBorderHighlightColor : base.style.controlBorderColor;
|
||||||
|
}
|
||||||
|
label: Item
|
||||||
|
{
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: base.style.controlBorderWidth
|
||||||
|
anchors.right: downArrow.left;
|
||||||
|
anchors.rightMargin: base.style.controlBorderWidth;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
|
||||||
|
text: control.currentText;
|
||||||
|
font: base.style.controlFont;
|
||||||
|
color: !enabled ? base.style.controlDisabledTextColor : base.style.controlTextColor;
|
||||||
|
|
||||||
|
elide: Text.ElideRight;
|
||||||
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
UM.RecolorImage
|
||||||
|
{
|
||||||
|
id: downArrow
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.rightMargin: base.style.controlBorderWidth * 2;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
|
||||||
|
source: UM.Theme.getIcon("arrow_bottom")
|
||||||
|
width: UM.Theme.getSize("standard_arrow").width
|
||||||
|
height: UM.Theme.getSize("standard_arrow").height
|
||||||
|
sourceSize.width: width + 5
|
||||||
|
sourceSize.height: width + 5
|
||||||
|
|
||||||
|
color: base.style.controlTextColor;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
onActivated: {
|
||||||
|
valueChanged(options.getItem(index).value);
|
||||||
|
}
|
||||||
|
|
||||||
|
onModelChanged: {
|
||||||
|
updateCurrentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
parent.parent.valueChanged.connect(updateCurrentIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCurrentIndex() {
|
||||||
|
if (!options) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var i = 0; i < options.rowCount(); ++i) {
|
||||||
|
if(options.getItem(i).value == value) {
|
||||||
|
currentIndex = i;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentIndex = -1;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
168
resources/qml/Settings/SettingItem.qml
Normal file
168
resources/qml/Settings/SettingItem.qml
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
// Copyright (c) 2015 Ultimaker B.V.
|
||||||
|
// Uranium is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Controls 1.1
|
||||||
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
|
||||||
|
import UM 1.1 as UM
|
||||||
|
|
||||||
|
import "."
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: base;
|
||||||
|
|
||||||
|
height: UM.Theme.getSize("section").height;
|
||||||
|
|
||||||
|
property alias contents: controlContainer.children
|
||||||
|
|
||||||
|
signal contextMenuRequested()
|
||||||
|
signal showTooltip(var position);
|
||||||
|
signal hideTooltip();
|
||||||
|
|
||||||
|
MouseArea
|
||||||
|
{
|
||||||
|
id: mouse;
|
||||||
|
|
||||||
|
anchors.fill: parent;
|
||||||
|
|
||||||
|
acceptedButtons: Qt.RightButton;
|
||||||
|
hoverEnabled: true;
|
||||||
|
|
||||||
|
onClicked: base.contextMenuRequested();
|
||||||
|
|
||||||
|
onEntered: {
|
||||||
|
hoverTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
if(controlContainer.item && controlContainer.item.hovered) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hoverTimer.stop();
|
||||||
|
base.hideTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: hoverTimer;
|
||||||
|
interval: 500;
|
||||||
|
repeat: false;
|
||||||
|
|
||||||
|
onTriggered: base.showTooltip({ x: mouse.mouseX, y: mouse.mouseY });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
id: label;
|
||||||
|
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: (UM.Theme.getSize("section_icon_column").width + 5) + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width)
|
||||||
|
anchors.right: settingControls.left;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
height: UM.Theme.getSize("section").height;
|
||||||
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
|
||||||
|
text: definition.label
|
||||||
|
elide: Text.ElideMiddle;
|
||||||
|
|
||||||
|
color: UM.Theme.getColor("setting_control_text");
|
||||||
|
font: UM.Theme.getFont("default");
|
||||||
|
}
|
||||||
|
|
||||||
|
Row
|
||||||
|
{
|
||||||
|
id: settingControls
|
||||||
|
|
||||||
|
height: parent.height / 2
|
||||||
|
spacing: UM.Theme.getSize("default_margin").width / 2
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
right: controlContainer.left
|
||||||
|
rightMargin: UM.Theme.getSize("default_margin").width / 2
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
UM.SimpleButton
|
||||||
|
{
|
||||||
|
id: revertButton;
|
||||||
|
|
||||||
|
// visible: base.overridden && base.is_enabled
|
||||||
|
|
||||||
|
height: parent.height;
|
||||||
|
width: height;
|
||||||
|
|
||||||
|
backgroundColor: UM.Theme.getColor("setting_control");
|
||||||
|
hoverBackgroundColor: UM.Theme.getColor("setting_control_highlight")
|
||||||
|
color: UM.Theme.getColor("setting_control_button")
|
||||||
|
hoverColor: UM.Theme.getColor("setting_control_button_hover")
|
||||||
|
|
||||||
|
iconSource: UM.Theme.getIcon("reset")
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
base.resetRequested()
|
||||||
|
controlContainer.notifyReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
onEntered: base.showResetTooltip({ x: mouse.mouseX, y: mouse.mouseY })
|
||||||
|
onExited:
|
||||||
|
{
|
||||||
|
if(controlContainer.item && controlContainer.item.hovered)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.hovered = false;
|
||||||
|
base.hideTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UM.SimpleButton
|
||||||
|
{
|
||||||
|
// This button shows when the setting has an inherited function, but is overriden by profile.
|
||||||
|
id: inheritButton;
|
||||||
|
|
||||||
|
// visible: has_profile_value && base.has_inherit_function && base.is_enabled
|
||||||
|
height: parent.height;
|
||||||
|
width: height;
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
base.resetToDefaultRequested();
|
||||||
|
controlContainer.notifyReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
backgroundColor: UM.Theme.getColor("setting_control");
|
||||||
|
hoverBackgroundColor: UM.Theme.getColor("setting_control_highlight")
|
||||||
|
color: UM.Theme.getColor("setting_control_button")
|
||||||
|
hoverColor: UM.Theme.getColor("setting_control_button_hover")
|
||||||
|
|
||||||
|
iconSource: UM.Theme.getIcon("notice");
|
||||||
|
|
||||||
|
onEntered: base.showInheritanceTooltip({ x: mouse.mouseX, y: mouse.mouseY })
|
||||||
|
|
||||||
|
onExited: {
|
||||||
|
if(controlContainer.item && controlContainer.item.hovered) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.hovered = false;
|
||||||
|
base.hideTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
id: controlContainer;
|
||||||
|
|
||||||
|
color: "red"
|
||||||
|
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
width: UM.Theme.getSize("setting_control").width;
|
||||||
|
height: UM.Theme.getSize("setting_contorl").height
|
||||||
|
}
|
||||||
|
}
|
153
resources/qml/Settings/SettingTextField.qml
Normal file
153
resources/qml/Settings/SettingTextField.qml
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
contents: Rectangle
|
||||||
|
{
|
||||||
|
id: control
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
property alias hovered: mouseArea.containsMouse;
|
||||||
|
|
||||||
|
border.width: base.style.controlBorderWidth;
|
||||||
|
border.color: !enabled ? base.style.controlDisabledBorderColor : hovered ? base.style.controlBorderHighlightColor : base.style.controlBorderColor
|
||||||
|
|
||||||
|
property variant parentValue: value //From parent loader
|
||||||
|
function notifyReset() {
|
||||||
|
input.text = format(parentValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
// color: {
|
||||||
|
// if (!enabled)
|
||||||
|
// {
|
||||||
|
// return base.style.controlDisabledColor
|
||||||
|
// }
|
||||||
|
// switch(definition.validationState) //From parent loader
|
||||||
|
// {
|
||||||
|
// case 0:
|
||||||
|
// return base.style.validationErrorColor;
|
||||||
|
// case 1:
|
||||||
|
// return base.style.validationErrorColor;
|
||||||
|
// case 2:
|
||||||
|
// return base.style.validationErrorColor;
|
||||||
|
// case 3:
|
||||||
|
// return base.style.validationWarningColor;
|
||||||
|
// case 4:
|
||||||
|
// return base.style.validationWarningColor;
|
||||||
|
// case 5:
|
||||||
|
// return base.style.validationOkColor;
|
||||||
|
//
|
||||||
|
// default:
|
||||||
|
// return base.style.controlTextColor;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
anchors.fill: parent;
|
||||||
|
anchors.margins: base.style.controlBorderWidth;
|
||||||
|
color: base.style.controlHighlightColor;
|
||||||
|
opacity: 0.35
|
||||||
|
// opacity: !control.hovered ? 0 : valid == 5 ? 1.0 : 0.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.rightMargin: base.style.unitRightMargin;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
|
||||||
|
text: definition.unit;
|
||||||
|
color: base.style.unitColor
|
||||||
|
font: base.style.unitFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea
|
||||||
|
{
|
||||||
|
id: mouseArea
|
||||||
|
anchors.fill: parent;
|
||||||
|
hoverEnabled: true;
|
||||||
|
cursorShape: Qt.IBeamCursor
|
||||||
|
}
|
||||||
|
|
||||||
|
TextInput
|
||||||
|
{
|
||||||
|
id: input
|
||||||
|
|
||||||
|
anchors
|
||||||
|
{
|
||||||
|
left: parent.left
|
||||||
|
leftMargin: base.style.unitRightMargin
|
||||||
|
right: parent.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onReleased:
|
||||||
|
{
|
||||||
|
text = text.replace(",", ".") // User convenience. We use dots for decimal values
|
||||||
|
if(parseFloat(text) != base.parentValue)
|
||||||
|
{
|
||||||
|
base.valueChanged(parseFloat(text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onEditingFinished:
|
||||||
|
{
|
||||||
|
if(parseFloat(text) != base.parentValue)
|
||||||
|
{
|
||||||
|
base.valueChanged(parseFloat(text));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
color: !enabled ? base.style.controlDisabledTextColor : base.style.controlTextColor;
|
||||||
|
font: base.style.controlFont;
|
||||||
|
|
||||||
|
selectByMouse: true;
|
||||||
|
|
||||||
|
maximumLength: 10;
|
||||||
|
|
||||||
|
validator: RegExpValidator { regExp: /[0-9.,-]{0,10}/ }
|
||||||
|
|
||||||
|
// Binding
|
||||||
|
// {
|
||||||
|
// target: input
|
||||||
|
// property: "text"
|
||||||
|
// value: format(base.parentValue)
|
||||||
|
// when: !input.activeFocus
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
//Rounds a floating point number to 4 decimals. This prevents floating
|
||||||
|
//point rounding errors.
|
||||||
|
//
|
||||||
|
//input: The number to round.
|
||||||
|
//decimals: The number of decimals (digits after the radix) to round to.
|
||||||
|
//return: The rounded number.
|
||||||
|
function roundFloat(input, decimals)
|
||||||
|
{
|
||||||
|
//First convert to fixed-point notation to round the number to 4 decimals and not introduce new floating point errors.
|
||||||
|
//Then convert to a string (is implicit). The fixed-point notation will be something like "3.200".
|
||||||
|
//Then remove any trailing zeroes and the radix.
|
||||||
|
return input.toFixed(decimals).replace(/\.?0*$/, ""); //Match on periods, if any ( \.? ), followed by any number of zeros ( 0* ), then the end of string ( $ ).
|
||||||
|
}
|
||||||
|
|
||||||
|
//Formats a value for display in the text field.
|
||||||
|
//
|
||||||
|
//This correctly handles formatting of float values.
|
||||||
|
//
|
||||||
|
//input: The string value to format.
|
||||||
|
//return: The formatted string.
|
||||||
|
function format(inputValue) {
|
||||||
|
return parseFloat(inputValue) ? roundFloat(parseFloat(inputValue), 4) : inputValue //If it's a float, round to four decimals.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
resources/qml/Settings/SettingUnknown.qml
Normal file
13
resources/qml/Settings/SettingUnknown.qml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Copyright (c) 2015 Ultimaker B.V.
|
||||||
|
// Uranium is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import QtQuick.Controls 1.1
|
||||||
|
|
||||||
|
SettingItem
|
||||||
|
{
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: value + " " + unit;
|
||||||
|
}
|
||||||
|
}
|
92
resources/qml/Settings/SettingView.qml
Normal file
92
resources/qml/Settings/SettingView.qml
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
// 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.1
|
||||||
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
|
||||||
|
import UM 1.2 as UM
|
||||||
|
|
||||||
|
ScrollView
|
||||||
|
{
|
||||||
|
id: base;
|
||||||
|
|
||||||
|
style: UM.Theme.styles.scrollview;
|
||||||
|
flickableItem.flickableDirection: Flickable.VerticalFlick;
|
||||||
|
|
||||||
|
property Action configureSettings;
|
||||||
|
signal showTooltip(Item item, point location, string text);
|
||||||
|
signal hideTooltip();
|
||||||
|
|
||||||
|
ListView
|
||||||
|
{
|
||||||
|
id: contents
|
||||||
|
spacing: UM.Theme.getSize("default_lining").height;
|
||||||
|
|
||||||
|
model: UM.SettingDefinitionsModel { id: definitionsModel; containerId: "fdmprinter" }
|
||||||
|
|
||||||
|
delegate: Loader
|
||||||
|
{
|
||||||
|
id: delegate
|
||||||
|
|
||||||
|
width: ListView.view.width
|
||||||
|
|
||||||
|
property var definition: model
|
||||||
|
property var settingDefinitionsModel: definitionsModel
|
||||||
|
|
||||||
|
source:
|
||||||
|
{
|
||||||
|
switch(model.type)
|
||||||
|
{
|
||||||
|
case "int":
|
||||||
|
return "SettingTextField.qml"
|
||||||
|
case "float":
|
||||||
|
return "SettingTextField.qml"
|
||||||
|
case "double":
|
||||||
|
return "SettingTextField.qml"
|
||||||
|
case "enum":
|
||||||
|
return "SettingComboBox.qml"
|
||||||
|
case "boolean":
|
||||||
|
return "SettingCheckBox.qml"
|
||||||
|
case "string":
|
||||||
|
return "SettingTextField.qml"
|
||||||
|
case "category":
|
||||||
|
return "SettingCategory.qml"
|
||||||
|
default:
|
||||||
|
return "SettingUnknown.qml"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: item
|
||||||
|
onContextMenuRequested: { contextMenu.key = model.key; contextMenu.popup() }
|
||||||
|
onShowTooltip: base.showTooltip(delegate, position, model.description)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UM.I18nCatalog { id: catalog; name: "uranium"; }
|
||||||
|
|
||||||
|
Menu
|
||||||
|
{
|
||||||
|
id: contextMenu;
|
||||||
|
|
||||||
|
property string key;
|
||||||
|
|
||||||
|
MenuItem
|
||||||
|
{
|
||||||
|
//: Settings context menu action
|
||||||
|
text: catalog.i18nc("@action:menu", "Hide this setting");
|
||||||
|
onTriggered: definitionsModel.hide(contextMenu.key);
|
||||||
|
}
|
||||||
|
MenuItem
|
||||||
|
{
|
||||||
|
//: Settings context menu action
|
||||||
|
text: catalog.i18nc("@action:menu", "Configure setting visiblity...");
|
||||||
|
|
||||||
|
onTriggered: if(base.configureSettings) base.configureSettings.trigger(contextMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
119
resources/qml/Settings/SettingsConfigurationPage.qml
Normal file
119
resources/qml/Settings/SettingsConfigurationPage.qml
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
// Copyright (c) 2015 Ultimaker B.V.
|
||||||
|
// Uranium is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.1
|
||||||
|
import QtQuick.Controls 1.1
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Dialogs 1.1
|
||||||
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
import QtQml 2.2
|
||||||
|
|
||||||
|
import UM 1.1 as UM
|
||||||
|
|
||||||
|
import "../Preferences"
|
||||||
|
|
||||||
|
PreferencesPage
|
||||||
|
{
|
||||||
|
//: Machine configuration page title.
|
||||||
|
title: catalog.i18nc("@title:tab","Machine");
|
||||||
|
id: base
|
||||||
|
|
||||||
|
contents: ColumnLayout
|
||||||
|
{
|
||||||
|
z: base.z
|
||||||
|
anchors.fill: parent;
|
||||||
|
UM.I18nCatalog { id: catalog; name:"uranium"}
|
||||||
|
RowLayout
|
||||||
|
{
|
||||||
|
//: Active machine combo box label
|
||||||
|
Label { text: catalog.i18nc("@label:listbox","Active Machine:"); }
|
||||||
|
ComboBox
|
||||||
|
{
|
||||||
|
id: machineCombo;
|
||||||
|
Layout.fillWidth: true;
|
||||||
|
model: UM.Models.machinesModel;
|
||||||
|
textRole: "name";
|
||||||
|
onActivated:
|
||||||
|
{
|
||||||
|
if(index != -1)
|
||||||
|
UM.Models.machinesModel.setActive(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
id: machineChange
|
||||||
|
target: UM.Application
|
||||||
|
onMachineChanged: machineCombo.currentIndex = machineCombo.find(UM.Application.machineName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: machineCombo.currentIndex = machineCombo.find(UM.Application.machineName);
|
||||||
|
}
|
||||||
|
//: Remove active machine button
|
||||||
|
Button { text: catalog.i18nc("@action:button","Remove"); onClicked: confirmRemoveDialog.open(); }
|
||||||
|
}
|
||||||
|
ScrollView
|
||||||
|
{
|
||||||
|
id: settingsScrollView
|
||||||
|
Layout.fillWidth: true;
|
||||||
|
Layout.fillHeight: true;
|
||||||
|
|
||||||
|
ListView
|
||||||
|
{
|
||||||
|
id: settingsListView
|
||||||
|
delegate: settingDelegate
|
||||||
|
model: UM.Models.settingsModel
|
||||||
|
x: 0
|
||||||
|
|
||||||
|
section.property: "category"
|
||||||
|
section.delegate: Label { text: section }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component
|
||||||
|
{
|
||||||
|
id: settingDelegate
|
||||||
|
CheckBox
|
||||||
|
{
|
||||||
|
z:0
|
||||||
|
id: settingCheckBox
|
||||||
|
text: model.name;
|
||||||
|
x: depth * 25
|
||||||
|
checked: model.visibility
|
||||||
|
onClicked: ListView.view.model.setVisibility(model.key, checked)
|
||||||
|
//enabled: !model.disabled
|
||||||
|
|
||||||
|
onHoveredChanged:
|
||||||
|
{
|
||||||
|
if(hovered)
|
||||||
|
{
|
||||||
|
var xPos = parent.x + settingCheckBox.width;
|
||||||
|
var yPos = parent.y;
|
||||||
|
toolTip.show(model.description, 1000, 200, undefined, undefined) //tooltip-text, hover-delay in msec, animation-length in msec, position X, position Y (both y en x == undefined: gives the tooltip a standard placement in the right corner)
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
toolTip.hide(0, 0)//hover-delay in msec, animation-length in msec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PreferencesToolTip
|
||||||
|
{
|
||||||
|
id: toolTip;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageDialog
|
||||||
|
{
|
||||||
|
id: confirmRemoveDialog;
|
||||||
|
|
||||||
|
icon: StandardIcon.Question;
|
||||||
|
//: Remove machine confirmation dialog title
|
||||||
|
title: catalog.i18nc("@title:window","Confirm Machine Deletion");
|
||||||
|
//: Remove machine confirmation dialog text
|
||||||
|
text: catalog.i18nc("@label","Are you sure you wish to remove the machine?");
|
||||||
|
standardButtons: StandardButton.Yes | StandardButton.No;
|
||||||
|
|
||||||
|
onYes: UM.Models.machinesModel.removeMachine(machineCombo.currentIndex);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user