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

import QtQuick 2.1
import QtQuick.Controls 1.1
import QtQuick.Dialogs 1.2

import UM 1.2 as UM
import Cura 1.0 as Cura

UM.ManagementPage
{
    id: base;

    title: catalog.i18nc("@title:tab", "Profiles");
    property var extrudersModel: Cura.ExtrudersModel{}
    //Cura.ExtrudersModel { id: extrudersModel}

    model: UM.InstanceContainersModel
    {
        filter:
        {
            var result = { "type": "quality*", "extruder": null };
            if(Cura.MachineManager.filterQualityByMachine)
            {
                result.definition = Cura.MachineManager.activeDefinitionId;
                if(Cura.MachineManager.hasMaterials)
                {
                    result.material = Cura.MachineManager.allActiveMaterialIds[Cura.MachineManager.activeMachineId];
                }
            }
            else
            {
                result.definition = "fdmprinter"
            }
            return result
        }
    }

    section.property: "readOnly"
    section.delegate: Rectangle
    {
        height: childrenRect.height;

        Label
        {
            anchors.left: parent.left;
            anchors.leftMargin: UM.Theme.getSize("default_lining").width;
            text: section == "true" ? catalog.i18nc("@label", "Protected profiles") : catalog.i18nc("@label", "Custom profiles")
            font.bold: true
        }
    }

    activeId: Cura.MachineManager.activeQualityId
    activeIndex: {
        for(var i = 0; i < model.rowCount(); i++) {
            if (model.getItem(i).id == Cura.MachineManager.activeQualityId) {
                return i;
            }
        }
        return -1;
    }

    function canCreateProfile() {
        return base.currentItem && (base.currentItem.id == Cura.MachineManager.activeQualityId) && Cura.MachineManager.hasUserSettings;
    }

    buttons: [
        Button
        {
            text: catalog.i18nc("@action:button", "Activate");
            iconName: "list-activate";
            enabled: base.currentItem != null ? base.currentItem.id != Cura.MachineManager.activeQualityId : false;
            onClicked: Cura.MachineManager.setActiveQuality(base.currentItem.id)
        },

        // Create button
        Button
        {
            text: catalog.i18nc("@label", "Create")
            enabled: base.canCreateProfile()
            visible: base.canCreateProfile()
            iconName: "list-add";

            onClicked:
            {
                newNameDialog.object = base.currentItem != null ? base.currentItem.name : "";
                newNameDialog.open();
                newNameDialog.selectText();
            }
        },

        // Duplicate button
        Button
        {
            text: catalog.i18nc("@label", "Duplicate")
            enabled: ! base.canCreateProfile()
            visible: ! base.canCreateProfile()
            iconName: "list-add";

            onClicked:
            {
                newDuplicateNameDialog.object = base.currentItem.name;
                newDuplicateNameDialog.open();
                newDuplicateNameDialog.selectText();
            }
        },

        Button
        {
            text: catalog.i18nc("@action:button", "Remove");
            iconName: "list-remove";
            enabled: base.currentItem != null ? !base.currentItem.readOnly && !Cura.ContainerManager.isContainerUsed(base.currentItem.id) : false;
            onClicked: confirmDialog.open();
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Rename");
            iconName: "edit-rename";
            enabled: base.currentItem != null ? !base.currentItem.readOnly : false;
            onClicked:
            {
                renameDialog.open();
                renameDialog.selectText();
            }
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Import");
            iconName: "document-import";
            onClicked: importDialog.open();
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Export")
            iconName: "document-export"
            onClicked: exportDialog.open()
            enabled: currentItem != null
        }
    ]

    scrollviewCaption: catalog.i18nc("@label %1 is printer name","Printer: %1").arg(Cura.MachineManager.activeMachineName)

    signal showProfileNameDialog()
    onShowProfileNameDialog:
    {
        renameDialog.open();
        renameDialog.selectText();
    }

    signal selectContainer(string name)
    onSelectContainer:
    {
        objectList.currentIndex = objectList.model.find("name", name);
    }

    Item {
        visible: base.currentItem != null
        anchors.fill: parent

        Label {
            id: profileName
            text: base.currentItem ? base.currentItem.name r: ""
            font: UM.Theme.getFont("large")
            width: parent.width
            elide: Text.ElideRight
        }

        Row {
            id: currentSettingsActions
            visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId

            anchors.left: parent.left
            anchors.top: profileName.bottom
            anchors.topMargin: UM.Theme.getSize("default_margin").height

            Button
            {
                text: {
                    return catalog.i18nc("@action:button", "Update profile with current settings");
                }
                enabled: Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId)<commit_msg>fix typo<commit_after>// 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.Dialogs 1.2

import UM 1.2 as UM
import Cura 1.0 as Cura

UM.ManagementPage
{
    id: base;

    title: catalog.i18nc("@title:tab", "Profiles");
    property var extrudersModel: Cura.ExtrudersModel{}
    //Cura.ExtrudersModel { id: extrudersModel}

    model: UM.InstanceContainersModel
    {
        filter:
        {
            var result = { "type": "quality*", "extruder": null };
            if(Cura.MachineManager.filterQualityByMachine)
            {
                result.definition = Cura.MachineManager.activeDefinitionId;
                if(Cura.MachineManager.hasMaterials)
                {
                    result.material = Cura.MachineManager.allActiveMaterialIds[Cura.MachineManager.activeMachineId];
                }
            }
            else
            {
                result.definition = "fdmprinter"
            }
            return result
        }
    }

    section.property: "readOnly"
    section.delegate: Rectangle
    {
        height: childrenRect.height;

        Label
        {
            anchors.left: parent.left;
            anchors.leftMargin: UM.Theme.getSize("default_lining").width;
            text: section == "true" ? catalog.i18nc("@label", "Protected profiles") : catalog.i18nc("@label", "Custom profiles")
            font.bold: true
        }
    }

    activeId: Cura.MachineManager.activeQualityId
    activeIndex: {
        for(var i = 0; i < model.rowCount(); i++) {
            if (model.getItem(i).id == Cura.MachineManager.activeQualityId) {
                return i;
            }
        }
        return -1;
    }

    function canCreateProfile() {
        return base.currentItem && (base.currentItem.id == Cura.MachineManager.activeQualityId) && Cura.MachineManager.hasUserSettings;
    }

    buttons: [
        Button
        {
            text: catalog.i18nc("@action:button", "Activate");
            iconName: "list-activate";
            enabled: base.currentItem != null ? base.currentItem.id != Cura.MachineManager.activeQualityId : false;
            onClicked: Cura.MachineManager.setActiveQuality(base.currentItem.id)
        },

        // Create button
        Button
        {
            text: catalog.i18nc("@label", "Create")
            enabled: base.canCreateProfile()
            visible: base.canCreateProfile()
            iconName: "list-add";

            onClicked:
            {
                newNameDialog.object = base.currentItem != null ? base.currentItem.name : "";
                newNameDialog.open();
                newNameDialog.selectText();
            }
        },

        // Duplicate button
        Button
        {
            text: catalog.i18nc("@label", "Duplicate")
            enabled: ! base.canCreateProfile()
            visible: ! base.canCreateProfile()
            iconName: "list-add";

            onClicked:
            {
                newDuplicateNameDialog.object = base.currentItem.name;
                newDuplicateNameDialog.open();
                newDuplicateNameDialog.selectText();
            }
        },

        Button
        {
            text: catalog.i18nc("@action:button", "Remove");
            iconName: "list-remove";
            enabled: base.currentItem != null ? !base.currentItem.readOnly && !Cura.ContainerManager.isContainerUsed(base.currentItem.id) : false;
            onClicked: confirmDialog.open();
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Rename");
            iconName: "edit-rename";
            enabled: base.currentItem != null ? !base.currentItem.readOnly : false;
            onClicked:
            {
                renameDialog.open();
                renameDialog.selectText();
            }
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Import");
            iconName: "document-import";
            onClicked: importDialog.open();
        },
        Button
        {
            text: catalog.i18nc("@action:button", "Export")
            iconName: "document-export"
            onClicked: exportDialog.open()
            enabled: currentItem != null
        }
    ]

    scrollviewCaption: catalog.i18nc("@label %1 is printer name","Printer: %1").arg(Cura.MachineManager.activeMachineName)

    signal showProfileNameDialog()
    onShowProfileNameDialog:
    {
        renameDialog.open();
        renameDialog.selectText();
    }

    signal selectContainer(string name)
    onSelectContainer:
    {
        objectList.currentIndex = objectList.model.find("name", name);
    }

    Item {
        visible: base.currentItem != null
        anchors.fill: parent

        Label {
            id: profileName
            text: base.currentItem ? base.currentItem.name: ""
            font: UM.Theme.getFont("large")
            width: parent.width
            elide: Text.ElideRight
        }

        Row {
            id: currentSettingsActions
            visible: currentItem && currentItem.id == Cura.MachineManager.activeQualityId

            anchors.left: parent.left
            anchors.top: profileName.bottom
            anchors.topMargin: UM.Theme.getSize("default_margin").height

            Button
            {
                text: {
                    return catalog.i18nc("@action:button", "Update profile with current settings");
                }
                enabled: Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId)
{'fraction_non_alphanumeric': 0.10748407643312102, 'fraction_numerical': 0.007607926397735315, 'mean_word_length': 1.764734653949621, 'pattern_counts': {'":': 4, '<': 6, '<?xml version=': 0, '>': 4, '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': '4141515', 'n_tokens_mistral': 3156, 'n_tokens_neox': 3020, 'n_words': 548}