OpenFilesIncludingProjectsDialog.qml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 int spacerHeight: 10 * screenScaleFactor
  25. function loadProjectFile(projectFile)
  26. {
  27. UM.WorkspaceFileHandler.readLocalFile(projectFile);
  28. }
  29. function loadModelFiles(fileUrls)
  30. {
  31. for (var i in fileUrls)
  32. {
  33. CuraApplication.readLocalFile(fileUrls[i], "open_as_model");
  34. }
  35. }
  36. Column
  37. {
  38. anchors.fill: parent
  39. anchors.leftMargin: 20 * screenScaleFactor
  40. anchors.rightMargin: 20 * screenScaleFactor
  41. anchors.bottomMargin: 20 * screenScaleFactor
  42. anchors.left: parent.left
  43. anchors.right: parent.right
  44. spacing: 10 * screenScaleFactor
  45. Label
  46. {
  47. 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?")
  48. anchors.left: parent.left
  49. anchors.right: parent.right
  50. font: UM.Theme.getFont("default")
  51. wrapMode: Text.WordWrap
  52. }
  53. Item // Spacer
  54. {
  55. height: base.spacerHeight
  56. width: height
  57. }
  58. // Buttons
  59. Item
  60. {
  61. anchors.right: parent.right
  62. anchors.left: parent.left
  63. height: childrenRect.height
  64. Button
  65. {
  66. id: cancelButton
  67. text: catalog.i18nc("@action:button", "Cancel");
  68. anchors.right: importAllAsModelsButton.left
  69. onClicked:
  70. {
  71. // cancel
  72. base.hide();
  73. }
  74. }
  75. Button
  76. {
  77. id: importAllAsModelsButton
  78. text: catalog.i18nc("@action:button", "Import all as models");
  79. anchors.right: parent.right
  80. isDefault: true
  81. onClicked:
  82. {
  83. // load models from all selected file
  84. loadModelFiles(base.fileUrls);
  85. base.hide();
  86. }
  87. }
  88. }
  89. UM.I18nCatalog
  90. {
  91. id: catalog
  92. name: "cura"
  93. }
  94. }
  95. }