PointDisplaySettings.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. function PointDisplaySettings() {
  20. }
  21. PointDisplaySettings.getPreferencesCategory = function(appPreferences) {
  22. if (appPreferences) {
  23. return [ qsTr("Defaults for New Drawings"), qsTr("Point Display") ];
  24. }
  25. return [ qsTr("General"), qsTr("Point Display") ];
  26. };
  27. PointDisplaySettings.initPreferences = function(pageWidget, calledByPrefDialog, document, preferencesAction) {
  28. var widgets = getWidgets(pageWidget);
  29. var modeEdit = pageWidget.findChild("Mode");
  30. var pdmode = undefined;
  31. if (!isNull(document)) {
  32. pdmode = document.getKnownVariable(RS.PDMODE, 0)
  33. }
  34. else {
  35. pdmode = RSettings.getIntValue("PointDisplaySettings/Mode", 0);
  36. }
  37. if (!isNull(pdmode)) {
  38. modeEdit.text = pdmode.toString();
  39. var w = pageWidget.findChild("Button" + pdmode);
  40. if (!isNull(w)) {
  41. w.checked = true;
  42. }
  43. }
  44. var sizeEdit = pageWidget.findChild("Size");
  45. var pdsize = undefined;
  46. if (!isNull(pdsize)) {
  47. if (!isNull(document)) {
  48. pdsize = document.getKnownVariable(RS.PDSIZE, 0);
  49. }
  50. else {
  51. pdsize = RSettings.getIntValue("PointDisplaySettings/Size", 0);
  52. }
  53. sizeEdit.text = pdsize.toString();
  54. }
  55. var values = [ 0, 1, 2, 3, 4,
  56. 32,33,34,35,36,
  57. 64,65,66,67,68,
  58. 96,97,98,99,100];
  59. for (var i=0; i<values.length; i++) {
  60. var f = function() { modeEdit.text = values[arguments.callee.i].toString(); };
  61. f.i = i;
  62. widgets["Button" + values[i]]["clicked"].connect(f);
  63. }
  64. };
  65. PointDisplaySettings.savePreferences = function(pageWidget, calledByPrefDialog, document, transaction) {
  66. var modeEdit = pageWidget.findChild("Mode");
  67. var sizeEdit = pageWidget.findChild("Size");
  68. if (!isNull(document)) {
  69. document.setKnownVariable(RS.PDMODE, parseInt(modeEdit.text), transaction);
  70. document.setKnownVariable(RS.PDSIZE, parseInt(sizeEdit.text), transaction);
  71. }
  72. };