OpenFilesIncludingProjectsDialog.qml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 2.0
  5. import QtQuick.Layouts 1.1
  6. import QtQuick.Dialogs 1.1
  7. import QtQuick.Window 2.1
  8. import UM 1.3 as UM
  9. import Cura 1.0 as Cura
  10. UM.Dialog
  11. {
  12. // This dialog asks the user whether he/she wants to open the project file we have detected or the model files.
  13. id: base
  14. title: catalog.i18nc("@title:window", "Open file(s)")
  15. width: 420 * screenScaleFactor
  16. height: 170 * screenScaleFactor
  17. maximumHeight: height
  18. maximumWidth: width
  19. minimumHeight: height
  20. minimumWidth: width
  21. modality: Qt.WindowModal
  22. property var fileUrls: []
  23. property var addToRecent: true
  24. property int spacerHeight: 10 * screenScaleFactor
  25. function loadProjectFile(projectFile)
  26. {
  27. UM.WorkspaceFileHandler.readLocalFile(projectFile, base.addToRecent);
  28. }
  29. function loadModelFiles(fileUrls)
  30. {
  31. for (var i in fileUrls)
  32. {
  33. CuraApplication.readLocalFile(fileUrls[i], "open_as_model", base.addToRecent);
  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. UM.I18nCatalog
  59. {
  60. id: catalog
  61. name: "cura"
  62. }
  63. ButtonGroup
  64. {
  65. buttons: [cancelButton, importAllAsModelsButton]
  66. checkedButton: importAllAsModelsButton
  67. }
  68. }
  69. onAccepted: loadModelFiles(base.fileUrls)
  70. // Buttons
  71. rightButtons:
  72. [
  73. Button
  74. {
  75. id: cancelButton
  76. text: catalog.i18nc("@action:button", "Cancel");
  77. onClicked:
  78. {
  79. // cancel
  80. base.hide();
  81. }
  82. },
  83. Button
  84. {
  85. id: importAllAsModelsButton
  86. text: catalog.i18nc("@action:button", "Import all as models");
  87. onClicked:
  88. {
  89. // load models from all selected file
  90. loadModelFiles(base.fileUrls);
  91. base.hide();
  92. }
  93. }
  94. ]
  95. }