OpenFilesIncludingProjectsDialog.qml 3.2 KB

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