<commit_before>// Copyright (c) 2016 <NAME>.
// Uranium is released under the terms of the AGPLv3 or higher.

import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Window 2.2

import UM 1.2 as UM
import Cura 1.0 as Cura
import ".."

Item {
    id: base;

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

    width: childrenRect.width;
    height: childrenRect.height;

    Column
    {
        id: items
        anchors.top: parent.top;
        anchors.left: parent.left;

        spacing: UM.Theme.getSize("default_margin").height

        Row
        {
            spacing: UM.Theme.getSize("default_margin").width
            Label
            {
                text: catalog.i18nc("@label", "Print object with")
                anchors.verticalCenter: extruderSelector.verticalCenter

                color: UM.Theme.getColor("setting_control_text")
                font: UM.Theme.getFont("default")
                visible: extruderSelector.visible
            }
            ComboBox
            {
                id: extruderSelector

                model: Cura.ExtrudersModel
                {
                    id: extruders_model
                    onRowsInserted: extruderSelector.visible = extruders_model.rowCount() > 1
                    onModelReset:   extruderSelector.visible = extruders_model.rowCount() > 1
                }
                visible: extruders_model.rowCount() > 1
                textRole: "name"
                width: UM.Theme.getSize("setting_control").width
                height: UM.Theme.getSize("section").height
                MouseArea
                {
                    anchors.fill: parent
                    acceptedButtons: Qt.NoButton
                    onWheel: wheel.accepted = true;
                }

                style: ComboBoxStyle
                {
                    background: Rectangle
                    {
                        color:
                        {
                            if(extruderSelector.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: UM.Theme.getColor("setting_control_border")
                    }
                    label: Item
                    {
                        Rectangle
                        {
                            id: swatch
                            height: UM.Theme.getSize("setting_control").height / 2
                            width: height
                            anchors.left: parent.left
                            anchors.leftMargin: UM.Theme.getSize("default_lining").width
                            anchors.verticalCenter: parent.verticalCenter

                            color: extruders_model.getItem(extruderSelector.currentIndex).colour
                            border.width: UM.Theme.getSize("default_lining").width
                            border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border")
                        }
                        Label
                        {
                            anchors.left: swatch.right
                            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: extruderSelector.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: UM.ActiveTool.setProperty("SelectedActiveExtruder", extruders_model.getItem(index).id);
                onModelChanged: updateCurrentIndex();

                function updateCurrentIndex()
                {
                    for(var i = 0; i < extruders_model.rowCount(); ++i)
                    {
                        if(extruders_model.getItem(i).id == UM.ActiveTool.properties.getValue("SelectedActiveExtruder"))
                        {
                            extruderSelector.currentIndex = i;
                            return;
                        }<commit_msg>Fix updating the Per Object Settings color swatch<commit_after>// Copyright (c) 2016 <NAME>.
// Uranium is released under the terms of the AGPLv3 or higher.

import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Window 2.2

import UM 1.2 as UM
import Cura 1.0 as Cura
import ".."

Item {
    id: base;

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

    width: childrenRect.width;
    height: childrenRect.height;

    Column
    {
        id: items
        anchors.top: parent.top;
        anchors.left: parent.left;

        spacing: UM.Theme.getSize("default_margin").height

        Row
        {
            spacing: UM.Theme.getSize("default_margin").width
            Label
            {
                text: catalog.i18nc("@label", "Print object with")
                anchors.verticalCenter: extruderSelector.verticalCenter

                color: UM.Theme.getColor("setting_control_text")
                font: UM.Theme.getFont("default")
                visible: extruderSelector.visible
            }
            ComboBox
            {
                id: extruderSelector

                model: Cura.ExtrudersModel
                {
                    id: extruders_model
                    onRowsInserted: extruderSelector.visible = extruders_model.rowCount() > 1
                    onModelReset:   extruderSelector.visible = extruders_model.rowCount() > 1
                    onModelChanged: extruderSelector.color = extruders_model.getItem(extruderSelector.currentIndex).colour
                }
                property string color: extruders_model.getItem(extruderSelector.currentIndex).colour
                visible: extruders_model.rowCount() > 1
                textRole: "name"
                width: UM.Theme.getSize("setting_control").width
                height: UM.Theme.getSize("section").height
                MouseArea
                {
                    anchors.fill: parent
                    acceptedButtons: Qt.NoButton
                    onWheel: wheel.accepted = true;
                }

                style: ComboBoxStyle
                {
                    background: Rectangle
                    {
                        color:
                        {
                            if(extruderSelector.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: UM.Theme.getColor("setting_control_border")
                    }
                    label: Item
                    {
                        Rectangle
                        {
                            id: swatch
                            height: UM.Theme.getSize("setting_control").height / 2
                            width: height
                            anchors.left: parent.left
                            anchors.leftMargin: UM.Theme.getSize("default_lining").width
                            anchors.verticalCenter: parent.verticalCenter

                            color: extruderSelector.color
                            border.width: UM.Theme.getSize("default_lining").width
                            border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border")
                        }
                        Label
                        {
                            anchors.left: swatch.right
                            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: extruderSelector.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: UM.ActiveTool.setProperty("SelectedActiveExtruder", extruders_model.getItem(index).id);
                onModelChanged: updateCurrentIndex();

                function updateCurrentIndex()
                {
                    for(var i = 0; i < extruders_model.rowCount(); ++i)
                    {
                        if(extruders_model.getItem(i).id == UM.ActiveTool.properties.getValue("SelectedActiveExtruder"))
                        {
                            extruderSelector.currentIndex = i;
                            extruderSelector.color = extruders_model.getItem(i).colour;
                            return;
                        }
{'fraction_non_alphanumeric': 0.07621404796449603, 'fraction_numerical': 0.004950072544166595, 'mean_word_length': 1.1071749685308399, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7388424', 'n_tokens_mistral': 2885, 'n_tokens_neox': 2615, 'n_words': 444}