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

PreviewMenu.qml « PreviewStage « plugins - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b331ff69c510990d9b422a96548015c0397d760f (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.7

import QtQuick.Controls 2.4

import UM 1.3 as UM
import Cura 1.1 as Cura

Item
{
    id: previewMenu
    // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it.
    signal showTooltip(Item item, point location, string text)
    signal hideTooltip()

    property real itemHeight: height - 2 * UM.Theme.getSize("default_lining").width

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

    Rectangle
    {
        anchors.fill: stageMenu
        anchors.leftMargin: -radius
        radius: UM.Theme.getSize("default_radius").width
        color: UM.Theme.getColor("toolbar_background")
    }

    Item
    {
        id: stageMenu
        height: parent.height
        width: stageMenuRow.width + UM.Theme.getSize("default_margin").width
        anchors.horizontalCenter: parent.horizontalCenter
        Row
        {
            id: stageMenuRow
            anchors.centerIn: parent
            height: parent.height

            Cura.ExpandableComponent
            {
                id: viewSelector
                iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
                height: parent.height

                property var viewModel: UM.ViewModel { }

                property var activeView:
                {
                    for (var i = 0; i < viewModel.rowCount(); i++)
                    {
                        if (viewModel.getItem(i).active)
                        {
                            return viewModel.getItem(i)
                        }
                    }
                    // Nothing was active, so just return the first one (the list is sorted by priority, so the most
                    // important one should be returned)
                    return viewModel.getItem(0)
                }

                // Ensure that the controller is synced with whatever happend here.
                onActiveViewChanged: UM.Controller.setActiveView(activeView.id)

                headerItem: Label
                {
                    text: viewSelector.activeView.name
                    verticalAlignment: Text.AlignVCenter
                    height: parent.height
                    elide: Text.ElideRight
                    font: UM.Theme.getFont("default")
                    color: UM.Theme.getColor("text")
                }

                popupItem: Column
                {
                    id: viewSelectorPopup
                    width: viewSelector.width - 2 * UM.Theme.getSize("default_margin").width

                    // For some reason the height/width of the column gets set to 0 if this is not set...
                    Component.onCompleted:
                    {
                        height = implicitHeight
                        width = viewSelector.width - 2 * UM.Theme.getSize("default_margin").width
                    }

                    Repeater
                    {
                        id: viewsList
                        model: viewSelector.viewModel
                        RoundButton
                        {
                            text: name
                            radius: UM.Theme.getSize("default_radius").width
                            checkable: true
                            checked: active
                            onClicked:
                            {
                                viewSelector.togglePopup()
                                UM.Controller.setActiveView(id)
                            }
                        }
                    }

                }
            }

            // Separator line
            Rectangle
            {
                height: parent.height
                // If there is no viewPanel, we only need a single spacer, so hide this one.
                visible: viewPanel.source != ""
                width: visible ? UM.Theme.getSize("default_lining").width : 0

                color: UM.Theme.getColor("lining")
            }

            Loader
            {
                id: viewPanel
                height: parent.height
                width: childrenRect.width
                source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
            }

            // Separator line
            Rectangle
            {
                height: parent.height
                width: UM.Theme.getSize("default_lining").width
                color: UM.Theme.getColor("lining")
            }

            Item
            {
                id: printSetupSelectorItem
                // This is a work around to prevent the printSetupSelector from having to be re-loaded every time
                // a stage switch is done.
                children: [printSetupSelector]
                height: childrenRect.height
                width: childrenRect.width
            }
        }
    }
}