ApplicationSwitcherPopup.qml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // Copyright (c) 2021 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.10
  4. import QtQuick.Controls 2.3
  5. import QtQuick.Layouts 1.15
  6. import UM 1.4 as UM
  7. import Cura 1.1 as Cura
  8. Popup
  9. {
  10. id: applicationSwitcherPopup
  11. closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
  12. opacity: opened ? 1 : 0
  13. Behavior on opacity { NumberAnimation { duration: 100 } }
  14. padding: UM.Theme.getSize("wide_margin").width
  15. contentItem: Grid
  16. {
  17. id: ultimakerPlatformLinksGrid
  18. columns: 3
  19. spacing: UM.Theme.getSize("default_margin").width
  20. Repeater
  21. {
  22. model:
  23. [
  24. {
  25. displayName: catalog.i18nc("@label:button", "My printers"),
  26. thumbnail: UM.Theme.getIcon("PrinterTriple", "high"),
  27. description: catalog.i18nc("@tooltip:button", "Monitor printers in Ultimaker Digital Factory."),
  28. link: "https://digitalfactory.ultimaker.com/app/printers?utm_source=cura&utm_medium=software&utm_campaign=switcher-digital-factory-printers",
  29. permissionsRequired: ["digital-factory.printer.read"]
  30. },
  31. {
  32. displayName: "Digital Library", //Not translated, since it's a brand name.
  33. thumbnail: UM.Theme.getIcon("Library", "high"),
  34. description: catalog.i18nc("@tooltip:button", "Create print projects in Digital Library."),
  35. link: "https://digitalfactory.ultimaker.com/app/library?utm_source=cura&utm_medium=software&utm_campaign=switcher-library",
  36. permissionsRequired: ["digital-factory.project.read.shared"]
  37. },
  38. {
  39. displayName: catalog.i18nc("@label:button", "Print jobs"),
  40. thumbnail: UM.Theme.getIcon("Nozzle"),
  41. description: catalog.i18nc("@tooltip:button", "Monitor print jobs and reprint from your print history."),
  42. link: "https://digitalfactory.ultimaker.com/app/print-jobs?utm_source=cura&utm_medium=software&utm_campaign=switcher-digital-factory-printjobs",
  43. permissionsRequired: ["digital-factory.print-job.read"]
  44. },
  45. {
  46. displayName: "UltiMaker Marketplace", //Not translated, since it's a brand name.
  47. thumbnail: UM.Theme.getIcon("Shop", "high"),
  48. description: catalog.i18nc("@tooltip:button", "Extend UltiMaker Cura with plugins and material profiles."),
  49. link: "https://marketplace.ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-marketplace-materials",
  50. permissionsRequired: []
  51. },
  52. {
  53. displayName: catalog.i18nc("@label:button", "Sponsor Cura"),
  54. thumbnail: UM.Theme.getIcon("Heart"),
  55. description: catalog.i18nc("@tooltip:button", "Show your support for Cura with a donation."),
  56. link: "https://ultimaker.com/software/ultimaker-cura/sponsor/",
  57. permissionsRequired: []
  58. },
  59. {
  60. displayName: catalog.i18nc("@label:button", "UltiMaker support"),
  61. thumbnail: UM.Theme.getIcon("Help", "high"),
  62. description: catalog.i18nc("@tooltip:button", "Learn how to get started with UltiMaker Cura."),
  63. link: "https://support.ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-support",
  64. permissionsRequired: []
  65. },
  66. {
  67. displayName: catalog.i18nc("@label:button", "Ask a question"),
  68. thumbnail: UM.Theme.getIcon("Speak", "high"),
  69. description: catalog.i18nc("@tooltip:button", "Consult the UltiMaker Community."),
  70. link: "https://community.ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-community",
  71. permissionsRequired: []
  72. },
  73. {
  74. displayName: catalog.i18nc("@label:button", "Report a bug"),
  75. thumbnail: UM.Theme.getIcon("Bug", "high"),
  76. description: catalog.i18nc("@tooltip:button", "Let developers know that something is going wrong."),
  77. link: "https://github.com/Ultimaker/Cura/issues/new/choose",
  78. permissionsRequired: []
  79. },
  80. {
  81. displayName: "Ultimaker.com", //Not translated, since it's a URL.
  82. thumbnail: UM.Theme.getIcon("Browser"),
  83. description: catalog.i18nc("@tooltip:button", "Visit the UltiMaker website."),
  84. link: "https://ultimaker.com/?utm_source=cura&utm_medium=software&utm_campaign=switcher-umwebsite",
  85. permissionsRequired: []
  86. }
  87. ]
  88. delegate: ApplicationButton
  89. {
  90. displayName: modelData.displayName
  91. iconSource: modelData.thumbnail
  92. tooltipText: modelData.description
  93. isExternalLink: true
  94. visible:
  95. {
  96. try
  97. {
  98. modelData.permissionsRequired.forEach(function(permission)
  99. {
  100. if(!Cura.API.account.isLoggedIn || !Cura.API.account.permissions.includes(permission)) //This required permission is not in the account.
  101. {
  102. throw "No permission to use this application."; //Can't return from within this lambda. Throw instead.
  103. }
  104. });
  105. }
  106. catch(e)
  107. {
  108. return false;
  109. }
  110. return true;
  111. }
  112. onClicked: Qt.openUrlExternally(modelData.link)
  113. }
  114. }
  115. }
  116. background: UM.PointingRectangle
  117. {
  118. color: UM.Theme.getColor("tool_panel_background")
  119. borderColor: UM.Theme.getColor("lining")
  120. borderWidth: UM.Theme.getSize("default_lining").width
  121. // Move the target by the default margin so that the arrow isn't drawn exactly on the corner
  122. target: Qt.point(width - UM.Theme.getSize("default_margin").width - (applicationSwitcherButton.width / 2), -10)
  123. arrowSize: UM.Theme.getSize("default_arrow").width
  124. }
  125. }