File: CreateNewProjectPopup.qml

package info (click to toggle)
cura 5.0.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 122,888 kB
  • sloc: python: 44,572; sh: 81; xml: 32; makefile: 16
file content (155 lines) | stat: -rw-r--r-- 3,665 bytes parent folder | download
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
153
154
155
//Copyright (C) 2022 Ultimaker B.V.
//Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.15
import QtQuick.Window 2.2
import QtQuick.Controls 2.3

import UM 1.5 as UM
import Cura 1.6 as Cura

import DigitalFactory 1.0 as DF


Popup
{
    id: base

    padding: UM.Theme.getSize("default_margin").width

    closePolicy: Popup.CloseOnEscape
    focus: true
    modal: true
    background: Cura.RoundedRectangle
    {
        cornerSide: Cura.RoundedRectangle.Direction.All
        border.color: UM.Theme.getColor("lining")
        border.width: UM.Theme.getSize("default_lining").width
        radius: UM.Theme.getSize("default_radius").width
        width: parent.width
        height: parent.height
        color: UM.Theme.getColor("main_background")
    }

    Connections
    {
        target: manager

        function onCreatingNewProjectStatusChanged(status)
        {
            if (status == DF.RetrievalStatus.Success)
            {
                base.close();
            }
        }
    }

    onOpened:
    {
        newProjectNameTextField.text = ""
        newProjectNameTextField.focus = true
    }

    Label
    {
        id: createNewLibraryProjectLabel
        text: "Create new Library project"
        font: UM.Theme.getFont("medium")
        color: UM.Theme.getColor("small_button_text")
        anchors
        {
            top: parent.top
            left: parent.left
            right: parent.right
        }
    }

    UM.Label
    {
        id: projectNameLabel
        text: "Project Name"
        anchors
        {
            top: createNewLibraryProjectLabel.bottom
            topMargin: UM.Theme.getSize("default_margin").width
            left: parent.left
            right: parent.right
        }
    }

    Cura.TextField
    {
        id: newProjectNameTextField
        width: parent.width
        anchors
        {
            top: projectNameLabel.bottom
            topMargin: UM.Theme.getSize("thin_margin").width
            left: parent.left
            right: parent.right
        }
        validator: RegularExpressionValidator
        {
            regularExpression: /^[^\\\/\*\?\|\[\]]{0,99}$/
        }

        text: PrintInformation.jobName
        font: UM.Theme.getFont("default")
        placeholderText: "Enter a name for your new project."
        onAccepted:
        {
            if (verifyProjectCreationButton.enabled)
            {
                verifyProjectCreationButton.clicked()
            }
        }
    }

    UM.Label
    {
        id: errorWhileCreatingProjectLabel
        text: manager.projectCreationErrorText
        width: parent.width
        wrapMode: Text.WordWrap
        color: UM.Theme.getColor("error")
        visible: manager.creatingNewProjectStatus == DF.RetrievalStatus.Failed
        anchors
        {
            top: newProjectNameTextField.bottom
            left: parent.left
            right: parent.right
        }
    }

    Cura.SecondaryButton
    {
        id: cancelProjectCreationButton

        anchors.bottom: parent.bottom
        anchors.left: parent.left

        text: "Cancel"

        onClicked:
        {
            base.close()
        }
        busy: false
    }

    Cura.PrimaryButton
    {
        id: verifyProjectCreationButton

        anchors.bottom: parent.bottom
        anchors.right: parent.right
        text: "Create"
        enabled: newProjectNameTextField.text.length >= 2 && !busy

        onClicked:
        {
            manager.createLibraryProjectAndSetAsPreselected(newProjectNameTextField.text)
        }
        busy: manager.creatingNewProjectStatus == DF.RetrievalStatus.InProgress
    }
}