CreateNewProjectPopup.qml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. //Copyright (C) 2022 Ultimaker B.V.
  2. //Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.15
  4. import QtQuick.Window 2.2
  5. import QtQuick.Controls 2.3
  6. import UM 1.5 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. UM.Label
  56. {
  57. id: projectNameLabel
  58. text: "Project Name"
  59. anchors
  60. {
  61. top: createNewLibraryProjectLabel.bottom
  62. topMargin: UM.Theme.getSize("default_margin").width
  63. left: parent.left
  64. right: parent.right
  65. }
  66. }
  67. Cura.TextField
  68. {
  69. id: newProjectNameTextField
  70. width: parent.width
  71. anchors
  72. {
  73. top: projectNameLabel.bottom
  74. topMargin: UM.Theme.getSize("thin_margin").width
  75. left: parent.left
  76. right: parent.right
  77. }
  78. validator: RegularExpressionValidator
  79. {
  80. regularExpression: /^[^\\\/\*\?\|\[\]]{0,99}$/
  81. }
  82. text: PrintInformation.jobName
  83. font: UM.Theme.getFont("default")
  84. placeholderText: "Enter a name for your new project."
  85. onAccepted:
  86. {
  87. if (verifyProjectCreationButton.enabled)
  88. {
  89. verifyProjectCreationButton.clicked()
  90. }
  91. }
  92. }
  93. UM.Label
  94. {
  95. id: errorWhileCreatingProjectLabel
  96. text: manager.projectCreationErrorText
  97. width: parent.width
  98. wrapMode: Text.WordWrap
  99. color: UM.Theme.getColor("error")
  100. visible: manager.creatingNewProjectStatus == DF.RetrievalStatus.Failed
  101. anchors
  102. {
  103. top: newProjectNameTextField.bottom
  104. left: parent.left
  105. right: parent.right
  106. }
  107. }
  108. Cura.SecondaryButton
  109. {
  110. id: cancelProjectCreationButton
  111. anchors.bottom: parent.bottom
  112. anchors.left: parent.left
  113. text: "Cancel"
  114. onClicked:
  115. {
  116. base.close()
  117. }
  118. busy: false
  119. }
  120. Cura.PrimaryButton
  121. {
  122. id: verifyProjectCreationButton
  123. anchors.bottom: parent.bottom
  124. anchors.right: parent.right
  125. text: "Create"
  126. enabled: newProjectNameTextField.text.length >= 2 && !busy
  127. onClicked:
  128. {
  129. manager.createLibraryProjectAndSetAsPreselected(newProjectNameTextField.text)
  130. }
  131. busy: manager.creatingNewProjectStatus == DF.RetrievalStatus.InProgress
  132. }
  133. }