<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 model 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: extrudersModel
                    onModelChanged: extruderSelector.color = extrudersModel.getItem(extruderSelector.currentIndex).color
                }
                property string color: extrudersModel.getItem(extruderSelector.currentIndex).color
                visible: machineExtruderCount.properties.value > 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", extrudersModel.getItem(index).id);
                    extruderSelector.color = extrudersModel.getItem(index).color;
                }
                onModelChanged: updateCurrentIndex();

                function updateCurrentIndex()
                {
                    for(var i = 0; i < extrudersModel.rowCount(); ++i)
                    {
                        if(extrudersModel.getItem(i).id == UM.ActiveTool.properties.getValue("SelectedActiveExtruder"))
                        {
                            extruderSelector.currentIndex = i;
                            extruderSelector.color = extrudersModel.getItem(i).color;
                            return;
                        }
                    }
                    extruderSelector.currentIndex = -1;
                }
            }
        }

        Column
        {
            spacing: UM.Theme.getSize("default_lining").height
            // This is to ensure that the panel is first increasing in size up to 200 and then shows a scrollbar.
            // It kinda looks ugly otherwise (big panel, no content on it)
            height: contents.count * UM.Theme.getSize("section").height < 200 ? contents.count * UM.Theme.getSize("section").height : 200
            ScrollView
            {
                height: parent.height
                width: UM.Theme.getSize("setting").width + UM.Theme.getSize("setting").height
                style: UM.Theme.styles.scrollview
                ListView
                {
                    id: contents

                    model: UM.SettingDefinitionsModel
                    {
                        id: addedSettingsModel;
                        containerId: Cura.MachineManager.activeDefinitionId
                        expanded: [ "*" ]

                        visibilityHandler: Cura.PerObjectSettingVisibilityHandler
                        {
                            selectedObjectId: UM.ActiveTool.properties.getValue("SelectedObjectId")
                        }
                    }

                    delegate: Row<commit_msg>Fix up layout of Per Model Settings panel<commit_after>// Copyright (c) 2016 <NAME>.V.
// 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 model 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: extrudersModel
                    onModelChanged: extruderSelector.color = extrudersModel.getItem(extruderSelector.currentIndex).color
                }
                property string color: extrudersModel.getItem(extruderSelector.currentIndex).color
                visible: machineExtruderCount.properties.value > 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", extrudersModel.getItem(index).id);
                    extruderSelector.color = extrudersModel.getItem(index).color;
                }
                onModelChanged: updateCurrentIndex();

                function updateCurrentIndex()
                {
                    for(var i = 0; i < extrudersModel.rowCount(); ++i)
                    {
                        if(extrudersModel.getItem(i).id == UM.ActiveTool.properties.getValue("SelectedActiveExtruder"))
                        {
                            extruderSelector.currentIndex = i;
                            extruderSelector.color = extrudersModel.getItem(i).color;
                            return;
                        }
                    }
                    extruderSelector.currentIndex = -1;
                }
            }
        }

        Column
        {
            // This is to ensure that the panel is first increasing in size up to 200 and then shows a scrollbar.
            // It kinda looks ugly otherwise (big panel, no content on it)
            property int maximumHeight: 200 * Screen.devicePixelRatio
            height: Math.min(contents.count * (UM.Theme.getSize("section").height + UM.Theme.getSize("default_lining").height), maximumHeight)

            ScrollView
            {
                height: parent.height
                width: UM.Theme.getSize("setting").width + UM.Theme.getSize("setting").height
                style: UM.Theme.styles.scrollview
                ListView
                {
                    id: contents
                    spacing: UM.Theme.getSize("default_lining").height

                    model: UM.SettingDefinitionsModel
                    {
                        id: addedSettingsModel;
                        containerId: Cura.MachineManager.activeDefinitionId
                        expanded: [ "*" ]

                        visibilityHandler: Cura.PerObjectSettingVisibilityHandler
                        {
                            selectedObjectId: UM.ActiveTool.properties.getValue("SelectedObjectId")
                        }
                    }

                    delegate: Row
{'fraction_non_alphanumeric': 0.07510204081632653, 'fraction_numerical': 0.004829931972789116, 'mean_word_length': 1.0989434608794975, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, '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': '5898068', 'n_tokens_mistral': 3552, 'n_tokens_neox': 3200, 'n_words': 577}