AppPreferences.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. include("../AbstractPreferences.js");
  20. /**
  21. * \class AppPreferences
  22. * \brief Shows the application preferences dialog.
  23. * \ingroup ecma_edit
  24. */
  25. function AppPreferences(guiAction, initialClassName) {
  26. AbstractPreferences.call(this, guiAction, true, initialClassName);
  27. }
  28. AppPreferences.prototype = new AbstractPreferences();
  29. AppPreferences.init = function(basePath) {
  30. var action;
  31. var gotPrefMenu = false;
  32. // macOS also has a preferences menu under the application menu
  33. // (only if macOS is configured to use the same language as the application):
  34. if (RS.getSystemId() === "osx") {
  35. var sysLang = QLocale.system().name();
  36. if (sysLang.length>=2) {
  37. sysLang = sysLang.substring(0,2);
  38. }
  39. var appLang = RSettings.getLocale();
  40. if (appLang.length>=2) {
  41. appLang = appLang.substring(0,2);
  42. }
  43. if (sysLang===appLang) {
  44. action = new RGuiAction("Preferences", RMainWindowQt.getMainWindow());
  45. action.menuRole = QAction.PreferencesRole;
  46. // preferences menu under macOS has no icon:
  47. action.disableIcon();
  48. action.setDefaultShortcut(new QKeySequence(QKeySequence.Preferences));
  49. action.setRequiresDocument(false);
  50. action.setScriptFile(basePath + "/AppPreferences.js");
  51. action.setNoState();
  52. action.setGroupSortOrder(0);
  53. action.setSortOrder(0);
  54. action.setWidgetNames(["EditMenu"]);
  55. gotPrefMenu = true;
  56. }
  57. }
  58. action = new RGuiAction(qsTr("Application &Preferences"), RMainWindowQt.getMainWindow());
  59. if (RS.getSystemId() === "osx" && !gotPrefMenu) {
  60. action.setDefaultShortcut(new QKeySequence(QKeySequence.Preferences));
  61. }
  62. else {
  63. action.setDefaultShortcut(new QKeySequence("Ctrl+,"));
  64. }
  65. action.setDefaultCommands(["preferences"]);
  66. action.setRequiresDocument(false);
  67. action.setScriptFile(basePath + "/AppPreferences.js");
  68. action.setIcon(basePath + "/AppPreferences.svg");
  69. action.setNoState();
  70. action.setGroupSortOrder(2800);
  71. action.setSortOrder(200);
  72. action.setWidgetNames(["EditMenu"]);
  73. };