Misc.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_misc Misc Examples and Scripts
  21. * \ingroup ecma_scripts
  22. *
  23. * \brief This module contains ECMAScript examples and uncategorized
  24. * scripts.
  25. */
  26. include("scripts/EAction.js");
  27. /**
  28. * \class Misc
  29. * \brief Base class for misc scripts.
  30. * \ingroup ecma_misc
  31. */
  32. function Misc(guiAction) {
  33. EAction.call(this, guiAction);
  34. }
  35. Misc.prototype = new EAction();
  36. Misc.includeBasePath = includeBasePath;
  37. Misc.prototype.beginEvent = function() {
  38. EAction.prototype.beginEvent.call(this);
  39. if (!isNull(this.getGuiAction()) && this.getGuiAction().objectName==="MiscToolsPanelAction") {
  40. EAction.showCadToolBarPanel("MiscToolsPanel");
  41. this.terminate();
  42. }
  43. };
  44. Misc.getMenu = function() {
  45. // var menu = EAction.getMenu(Misc.getTitle(), "MiscMenu");
  46. // menu.setProperty("scriptFile", Misc.includeBasePath + "/Misc.js");
  47. // return menu;
  48. };
  49. Misc.getCadToolBarPanel = function() {
  50. var mtb = EAction.getMainCadToolBarPanel();
  51. var actionName = "MiscToolsPanelAction";
  52. if (!isNull(mtb) && mtb.findChild(actionName)==undefined) {
  53. var action = new RGuiAction(qsTr("Misc Tools"), mtb);
  54. action.setScriptFile(Misc.includeBasePath + "/Misc.js");
  55. action.objectName = actionName;
  56. action.setRequiresDocument(false);
  57. action.setIcon(Misc.includeBasePath + "/Misc.svg");
  58. //action.setStatusTip(qsTr("Show misc tools"));
  59. action.setNoState();
  60. action.setDefaultCommands(["miscmenu"]);
  61. action.setGroupSortOrder(80);
  62. action.setSortOrder(100);
  63. action.setWidgetNames(["!MainToolsPanel"]);
  64. }
  65. var tb = EAction.getCadToolBarPanel(
  66. Misc.getTitle(),
  67. "MiscToolsPanel",
  68. true
  69. );
  70. return tb;
  71. };
  72. Misc.getContextMenuCategory = function() {
  73. return [qsTr("Misc")];
  74. };
  75. Misc.getTitle = function() {
  76. return qsTr("&Misc");
  77. };
  78. Misc.prototype.getTitle = function() {
  79. return Misc.getTitle();
  80. };
  81. Misc.init = function() {
  82. Misc.getMenu();
  83. Misc.getCadToolBarPanel();
  84. };