OpenFilesIncludingProjectsDialog.qml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 UM 1.5 as UM
  7. import Cura 1.5 as Cura
  8. UM.Dialog
  9. {
  10. // This dialog asks the user whether he/she wants to open the project file we have detected or the model files.
  11. id: base
  12. title: catalog.i18nc("@title:window", "Open file(s)")
  13. width: UM.Theme.getSize("small_popup_dialog").width
  14. height: UM.Theme.getSize("small_popup_dialog").height
  15. maximumHeight: height
  16. maximumWidth: width
  17. minimumHeight: height
  18. minimumWidth: width
  19. modality: Qt.ApplicationModal
  20. property var fileUrls: []
  21. property var addToRecent: true
  22. function loadProjectFile(projectFile)
  23. {
  24. UM.WorkspaceFileHandler.readLocalFile(projectFile, base.addToRecent);
  25. }
  26. function loadModelFiles(fileUrls)
  27. {
  28. for (var i in fileUrls)
  29. {
  30. CuraApplication.readLocalFile(fileUrls[i], "open_as_model", base.addToRecent);
  31. }
  32. }
  33. onAccepted: loadModelFiles(base.fileUrls)
  34. UM.Label
  35. {
  36. 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?")
  37. anchors.left: parent.left
  38. anchors.right: parent.right
  39. }
  40. buttonSpacing: UM.Theme.getSize("thin_margin").width
  41. // Buttons
  42. rightButtons:
  43. [
  44. Cura.SecondaryButton
  45. {
  46. text: catalog.i18nc("@action:button", "Cancel");
  47. onClicked: base.reject()
  48. },
  49. Cura.PrimaryButton
  50. {
  51. text: catalog.i18nc("@action:button", "Import all as models");
  52. onClicked: base.accept()
  53. }
  54. ]
  55. }