This commit is contained in:
fieldOfView 2016-06-02 16:38:41 +02:00
commit 184247ced6
17 changed files with 312 additions and 265 deletions

View file

@ -0,0 +1,112 @@
// Copyright (c) 2016 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
import Cura 1.0 as Cura
SettingItem
{
id: base
contents: ComboBox
{
id: control
model: Cura.ExtrudersModel {
id: extruders_model
}
textRole: "name";
anchors.fill: parent
MouseArea
{
anchors.fill: parent;
acceptedButtons: Qt.NoButton;
onWheel: wheel.accepted = true;
}
style: ComboBoxStyle
{
background: Rectangle
{
color:
{
if (!enabled)
{
return UM.Theme.getColor("setting_control_disabled")
}
if(control.hovered || base.activeFocus)
{
return UM.Theme.getColor("setting_control_highlight")
}
else
{
return UM.Theme.getColor("setting_control")
}
}
border.width: UM.Theme.getSize("default_lining").width;
border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border");
}
label: Item
{
Label
{
anchors.left: parent.left;
anchors.leftMargin: UM.Theme.getSize("default_lining").width
anchors.right: downArrow.left;
anchors.rightMargin: UM.Theme.getSize("default_lining").width;
anchors.verticalCenter: parent.verticalCenter;
text: control.currentText;
font: UM.Theme.getFont("default");
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text");
elide: Text.ElideRight;
verticalAlignment: Text.AlignVCenter;
}
UM.RecolorImage
{
id: downArrow
anchors.right: parent.right;
anchors.rightMargin: UM.Theme.getSize("default_lining").width * 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: UM.Theme.getColor("setting_control_text");
}
}
}
onActivated: provider.setPropertyValue("value", extruders_model.getItem(index).index)
onModelChanged: updateCurrentIndex();
Connections
{
target: provider
onPropertiesChanged: control.updateCurrentIndex()
}
function updateCurrentIndex() {
for(var i = 0; i < extruders_model.rowCount(); ++i) {
if(extruders_model.getItem(i).index == provider.properties.value) {
currentIndex = i;
return;
}
}
currentIndex = -1;
}
}
}

View file

@ -18,6 +18,10 @@ Item {
property alias contents: controlContainer.children;
property alias hovered: mouse.containsMouse
property var showRevertButton: true
property var showInheritButton: true
property var doDepthIdentation: true
signal contextMenuRequested()
signal showTooltip(string text);
signal hideTooltip();
@ -93,7 +97,7 @@ Item {
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.leftMargin: doDepthIdentation ? (UM.Theme.getSize("section_icon_column").width + 5) + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width) : 0
anchors.right: settingControls.left;
anchors.verticalCenter: parent.verticalCenter
@ -124,7 +128,7 @@ Item {
{
id: revertButton;
visible: propertyProvider.stackLevel == 0
visible: propertyProvider.stackLevel == 0 && base.showRevertButton
height: parent.height;
width: height;
@ -151,7 +155,7 @@ Item {
id: inheritButton;
//visible: has_profile_value && base.has_inherit_function && base.is_enabled
visible: propertyProvider.properties.state == "InstanceState.User" && propertyProvider.stackLevel > 0
visible: propertyProvider.properties.state == "InstanceState.User" && propertyProvider.stackLevel > 0 && base.showInheritButton
height: parent.height;
width: height;

View file

@ -48,7 +48,7 @@ ScrollView
//Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989
//In addition, while it works for 5.5 and higher, the ordering of the actual combo box drop down changes,
//causing nasty issues when selecting differnt options. So disable asynchronous loading of enum type completely.
//causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely.
asynchronous: model.type != "enum"
active: model.type != undefined
@ -62,6 +62,8 @@ ScrollView
return "SettingTextField.qml"
case "enum":
return "SettingComboBox.qml"
case "extruder":
return "SettingExtruder.qml"
case "bool":
return "SettingCheckBox.qml"
case "str":