Edit.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved.
  3. *
  4. * This file is part of the QCAD project.
  5. *
  6. * QCAD is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * QCAD is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with QCAD.
  18. */
  19. /**
  20. * \defgroup ecma_edit Editing Tools
  21. * \ingroup ecma_scripts
  22. *
  23. * \brief This module contains ECMAScript implementations of the editing tools
  24. * (copy, paste, undo, redo, delete, ...)
  25. */
  26. include("scripts/EAction.js");
  27. /**
  28. * \class Edit
  29. * \brief Base class for all editing tools.
  30. * \ingroup ecma_edit
  31. */
  32. function Edit(guiAction) {
  33. EAction.call(this, guiAction);
  34. }
  35. Edit.prototype = new EAction();
  36. Edit.includeBasePath = includeBasePath;
  37. Edit.prototype.beginEvent = function() {
  38. EAction.prototype.beginEvent.call(this);
  39. if (!isNull(this.getGuiAction()) && this.getGuiAction().objectName==="EditToolsPanelAction") {
  40. EAction.showCadToolBarPanel("EditToolsPanel");
  41. this.terminate();
  42. }
  43. };
  44. Edit.getMenu = function() {
  45. // var menu = EAction.getMenu(Edit.getTitle(), "EditMenu");
  46. // menu.setProperty("scriptFile", Edit.includeBasePath + "/Edit.js");
  47. // return menu;
  48. };
  49. Edit.getToolBar = function() {
  50. var tb = EAction.getToolBar(Edit.getTitle(), "EditToolBar");
  51. tb.visible = false;
  52. return tb;
  53. };
  54. Edit.getCadToolBarPanel = function() {
  55. var mtb = EAction.getMainCadToolBarPanel();
  56. var actionName = "EditToolsPanelAction";
  57. if (!isNull(mtb) && mtb.findChild(actionName)==undefined) {
  58. var action = new RGuiAction(qsTr("Edit Tools"), mtb);
  59. action.setScriptFile(Edit.includeBasePath + "/Edit.js");
  60. action.objectName = actionName;
  61. action.setRequiresDocument(false);
  62. action.setIcon(Edit.includeBasePath + "/Edit.svg");
  63. //action.setStatusTip(qsTr("Show edit tools"));
  64. action.setNoState();
  65. action.setDefaultCommands(["editmenu"]);
  66. action.setGroupSortOrder(10);
  67. action.setSortOrder(200);
  68. action.setWidgetNames(["!MainToolsPanel"]);
  69. }
  70. var tb = EAction.getCadToolBarPanel(
  71. Edit.getTitle(),
  72. "EditToolsPanel",
  73. true
  74. );
  75. return tb;
  76. };
  77. Edit.getToolMatrixPanel = function() {
  78. RSettings.setValue("Edit/VisibleInMatrixPanel", false, false);
  79. return EAction.getToolMatrixPanel(Edit.getTitle(), "EditMatrixPanel", 20);
  80. };
  81. Edit.getTitle = function() {
  82. return qsTr("&Edit");
  83. };
  84. Edit.prototype.getTitle = function() {
  85. return Edit.getTitle();
  86. };
  87. Edit.init = function() {
  88. Edit.getMenu();
  89. Edit.getToolBar();
  90. Edit.getCadToolBarPanel();
  91. Edit.getToolMatrixPanel();
  92. };