OpenFilesIncludingProjectsDialog.qml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Controls.Styles 1.1
  6. import QtQuick.Layouts 1.1
  7. import QtQuick.Dialogs 1.1
  8. import QtQuick.Window 2.1
  9. import UM 1.3 as UM
  10. import Cura 1.0 as Cura
  11. UM.Dialog
  12. {
  13. // This dialog asks the user whether he/she wants to open the project file we have detected or the model files.
  14. id: base
  15. title: catalog.i18nc("@title:window", "Open file(s)")
  16. width: 420 * screenScaleFactor
  17. height: 170 * screenScaleFactor
  18. maximumHeight: height
  19. maximumWidth: width
  20. minimumHeight: height
  21. minimumWidth: width
  22. modality: Qt.WindowModal
  23. property var fileUrls: []
  24. property var addToRecent: true
  25. property int spacerHeight: 10 * screenScaleFactor
  26. function loadProjectFile(projectFile)
  27. {
  28. UM.WorkspaceFileHandler.readLocalFile(projectFile, base.addToRecent);
  29. }
  30. function loadModelFiles(fileUrls)
  31. {
  32. for (var i in fileUrls)
  33. {
  34. CuraApplication.readLocalFile(fileUrls[i], "open_as_model", base.addToRecent);
  35. }
  36. }
  37. Column
  38. {
  39. anchors.fill: parent
  40. anchors.leftMargin: 20 * screenScaleFactor
  41. anchors.rightMargin: 20 * screenScaleFactor
  42. anchors.bottomMargin: 20 * screenScaleFactor
  43. anchors.left: parent.left
  44. anchors.right: parent.right
  45. spacing: 10 * screenScaleFactor
  46. Label
  47. {
  48. text: catalog.i18nc("@text:window", "We have found one or more project file(s) within the files you have selected. You can open only one project file at a time. We suggest to only import models from those files. Would you like to proceed?")
  49. anchors.left: parent.left
  50. anchors.right: parent.right
  51. font: UM.Theme.getFont("default")
  52. wrapMode: Text.WordWrap
  53. }
  54. Item // Spacer
  55. {
  56. height: base.spacerHeight
  57. width: height
  58. }
  59. // Buttons
  60. Item
  61. {
  62. anchors.right: parent.right
  63. anchors.left: parent.left
  64. height: childrenRect.height
  65. Button
  66. {
  67. id: cancelButton
  68. text: catalog.i18nc("@action:button", "Cancel");
  69. anchors.right: importAllAsModelsButton.left
  70. onClicked:
  71. {
  72. // cancel
  73. base.hide();
  74. }
  75. }
  76. Button
  77. {
  78. id: importAllAsModelsButton
  79. text: catalog.i18nc("@action:button", "Import all as models");
  80. anchors.right: parent.right
  81. isDefault: true
  82. onClicked:
  83. {
  84. // load models from all selected file
  85. loadModelFiles(base.fileUrls);
  86. base.hide();
  87. }
  88. }
  89. }
  90. UM.I18nCatalog
  91. {
  92. id: catalog
  93. name: "cura"
  94. }
  95. }
  96. }