CreateNewProjectPopup.qml 3.8 KB

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