CreateNewProjectPopup.qml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. //Copyright (C) 2022 Ultimaker B.V.
  2. //Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Window 2.2
  5. import QtQuick.Controls 2.3
  6. import UM 1.2 as UM
  7. import Cura 1.6 as Cura
  8. import DigitalFactory 1.0 as DF
  9. Popup
  10. {
  11. id: base
  12. padding: UM.Theme.getSize("default_margin").width
  13. closePolicy: Popup.CloseOnEscape
  14. focus: true
  15. modal: true
  16. background: Cura.RoundedRectangle
  17. {
  18. cornerSide: Cura.RoundedRectangle.Direction.All
  19. border.color: UM.Theme.getColor("lining")
  20. border.width: UM.Theme.getSize("default_lining").width
  21. radius: UM.Theme.getSize("default_radius").width
  22. width: parent.width
  23. height: parent.height
  24. color: UM.Theme.getColor("main_background")
  25. }
  26. Connections
  27. {
  28. target: manager
  29. function onCreatingNewProjectStatusChanged(status)
  30. {
  31. if (status == DF.RetrievalStatus.Success)
  32. {
  33. base.close();
  34. }
  35. }
  36. }
  37. onOpened:
  38. {
  39. newProjectNameTextField.text = ""
  40. newProjectNameTextField.focus = true
  41. }
  42. Label
  43. {
  44. id: createNewLibraryProjectLabel
  45. text: "Create new Library project"
  46. font: UM.Theme.getFont("medium")
  47. color: UM.Theme.getColor("small_button_text")
  48. anchors
  49. {
  50. top: parent.top
  51. left: parent.left
  52. right: parent.right
  53. }
  54. }
  55. Label
  56. {
  57. id: projectNameLabel
  58. text: "Project Name"
  59. font: UM.Theme.getFont("default")
  60. color: UM.Theme.getColor("text")
  61. anchors
  62. {
  63. top: createNewLibraryProjectLabel.bottom
  64. topMargin: UM.Theme.getSize("default_margin").width
  65. left: parent.left
  66. right: parent.right
  67. }
  68. }
  69. Cura.TextField
  70. {
  71. id: newProjectNameTextField
  72. width: parent.width
  73. anchors
  74. {
  75. top: projectNameLabel.bottom
  76. topMargin: UM.Theme.getSize("thin_margin").width
  77. left: parent.left
  78. right: parent.right
  79. }
  80. validator: RegExpValidator
  81. {
  82. regExp: /^[^\\\/\*\?\|\[\]]{0,99}$/
  83. }
  84. text: PrintInformation.jobName
  85. font: UM.Theme.getFont("default")
  86. placeholderText: "Enter a name for your new project."
  87. onAccepted:
  88. {
  89. if (verifyProjectCreationButton.enabled)
  90. {
  91. verifyProjectCreationButton.clicked()
  92. }
  93. }
  94. }
  95. Label
  96. {
  97. id: errorWhileCreatingProjectLabel
  98. text: manager.projectCreationErrorText
  99. width: parent.width
  100. wrapMode: Text.WordWrap
  101. font: UM.Theme.getFont("default")
  102. color: UM.Theme.getColor("error")
  103. visible: manager.creatingNewProjectStatus == DF.RetrievalStatus.Failed
  104. anchors
  105. {
  106. top: newProjectNameTextField.bottom
  107. left: parent.left
  108. right: parent.right
  109. }
  110. }
  111. Cura.SecondaryButton
  112. {
  113. id: cancelProjectCreationButton
  114. anchors.bottom: parent.bottom
  115. anchors.left: parent.left
  116. text: "Cancel"
  117. onClicked:
  118. {
  119. base.close()
  120. }
  121. busy: false
  122. }
  123. Cura.PrimaryButton
  124. {
  125. id: verifyProjectCreationButton
  126. anchors.bottom: parent.bottom
  127. anchors.right: parent.right
  128. text: "Create"
  129. enabled: newProjectNameTextField.text.length >= 2 && !busy
  130. onClicked:
  131. {
  132. manager.createLibraryProjectAndSetAsPreselected(newProjectNameTextField.text)
  133. }
  134. busy: manager.creatingNewProjectStatus == DF.RetrievalStatus.InProgress
  135. }
  136. }