Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Sidebar.qml « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 23ddfe4ed7758c0f937d3ccc791dfc5a1b773b06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright (c) 2015 Ultimaker B.V.
// Cura 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.0 as UM

Rectangle {
    id: base;

    property Action addMachineAction;
    property Action configureMachinesAction;
    property alias saveAction: saveButton.saveAction;

    color: UM.Theme.colors.sidebar;

    function showTooltip(item, position, text) {
        tooltip.text = text;
        position = item.mapToItem(base, position.x, position.y / 2);
        tooltip.show(position);
    }

    function hideTooltip() {
        tooltip.hide();
    }

    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.AllButtons;

        onWheel: {
            wheel.accepted = true;
        }
    }

    ColumnLayout {
        anchors.fill: parent;
        anchors.topMargin: UM.Theme.sizes.default_margin.height;

        spacing: UM.Theme.sizes.default_margin.height;

        SidebarHeader {
            id: header;

            Layout.fillWidth: true;

            addMachineAction: base.addMachineAction;
            configureMachinesAction: base.configureMachinesAction;
            modesModel: modesListModel;

            currentModeIndex: {
                var index = parseInt(UM.Preferences.getValue("cura/active_mode"))
                if(index) {
                    return index;
                }
                return 0;
            }
            onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex);
        }

        Loader {
            id: sidebarContents;

            Layout.fillWidth: true;
            Layout.fillHeight: true;

            source: modesListModel.get(header.currentModeIndex).file;

            property Item sidebar: base;

            onLoaded:
            {
                if(item)
                {
                    item.configureSettings = base.configureMachinesAction;
                    if(item.onShowTooltip != undefined)
                    {
                        item.showTooltip.connect(base.showTooltip)
                    }
                    if(item.onHideTooltip != undefined)
                    {
                        item.hideTooltip.connect(base.hideTooltip)
                    }
                }
            }
        }

        SaveButton {
            id: saveButton;
            implicitWidth: base.width
            implicitHeight: UM.Theme.sizes.save_button_text_margin.height * 2 + UM.Theme.sizes.save_button_slicing_bar.height + UM.Theme.sizes.save_button_save_to_button.height +  UM.Theme.sizes.default_margin.height
        }
    }

    SidebarTooltip {
        id: tooltip;
    }

    ListModel {
        id: modesListModel;
        //: Simple configuration mode option
        ListElement { text: QT_TR_NOOP("Simple"); file: "SidebarSimple.qml" }
        //: Advanced configuration mode option
        ListElement { text: QT_TR_NOOP("Advanced"); file: "SidebarAdvanced.qml" }
    }

    Component.onCompleted: {
        for(var i = 0; i < modesListModel.count; ++i)
        {
            modesListModel.setProperty(i, "text", qsTr(modesListModel.get(i).text));
        }
    }
}