MyScripts.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // MyScripts.js
  20. // All actions are derived from class EAction, so we need to
  21. // include this class definition here:
  22. include("scripts/EAction.js");
  23. // Constructor calls base class constructor:
  24. function MyScripts(guiAction) {
  25. EAction.call(this, guiAction);
  26. }
  27. // Derive class MyScripts from class EAction:
  28. MyScripts.prototype = new EAction();
  29. // This static function returns a new or existing QMenu object.
  30. MyScripts.getMenu = function() {
  31. // EAction.getMenu is a helper function that returns an existing
  32. // or new QMenu object with the given title and object name.
  33. // The object name (here "MyScriptMenu") must be unique.
  34. return EAction.getMenu(MyScripts.getTitle(), "MyScriptsMenu");
  35. };
  36. // This static function returns a new or existing QToolBar object.
  37. MyScripts.getToolBar = function() {
  38. // EAction.getToolBar is a helper function that returns an existing
  39. // or new QToolBar object with the given title and object name.
  40. // The object name (here "MyScriptsToolBar") must be unique.
  41. return EAction.getToolBar(MyScripts.getTitle(), "MyScriptsToolBar");
  42. };
  43. // This static function defines and returns the title of the menu
  44. // and toolbar.
  45. // The qsTr function marks the title as a translatable string.
  46. MyScripts.getTitle = function() {
  47. return qsTr("My Scripts");
  48. };
  49. // Init creates the menu and toolbar on start.
  50. MyScripts.init = function() {
  51. MyScripts.getMenu();
  52. MyScripts.getToolBar();
  53. };