Widgets.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_widgets Widgets
  21. * \ingroup ecma_scripts
  22. *
  23. * \brief This module contains ECMAScript implementations of various
  24. * user interface widgets.
  25. */
  26. include("scripts/EAction.js");
  27. /**
  28. * \class Widgets
  29. * \brief Base class for widget related tools.
  30. * \ingroup ecma_widgets
  31. */
  32. function Widgets(guiAction) {
  33. EAction.call(this, guiAction);
  34. }
  35. Widgets.prototype = new EAction();
  36. Widgets.includeBasePath = includeBasePath;
  37. Widgets.getMenu = function() {
  38. include("scripts/View/View.js");
  39. return View.getMenu();
  40. };
  41. Widgets.getToolBar = function() {
  42. return EAction.getToolBar(Widgets.getTitle(), "WidgetsToolBar", Qt.RightToolBarArea);
  43. };
  44. Widgets.getToolMatrixPanel = function() {
  45. RSettings.setValue("Widgets/VisibleInMatrixPanel", false, false);
  46. return EAction.getToolMatrixPanel(Widgets.getTitle(), "WidgetsMatrixPanel", 40);
  47. };
  48. Widgets.getTitle = function() {
  49. return qsTr("&Widgets");
  50. };
  51. Widgets.prototype.getTitle = function() {
  52. return Widgets.getTitle();
  53. };
  54. //Widgets.getListContextMenuCategory = function() {
  55. // return [qsTr("Lists")];
  56. //};
  57. Widgets.init = function() {
  58. Widgets.getToolBar();
  59. Widgets.getToolMatrixPanel();
  60. // add action for the sake of configurability (tool preferences):
  61. var appWin = EAction.getMainWindow();
  62. var action = new RGuiAction("", appWin);
  63. action.setScriptFile(Widgets.includeBasePath + "/Widgets.js");
  64. action.setGroupSortOrder(5);
  65. action.setSortOrder(100);
  66. action.setWidgetNames([]);
  67. };