FlushBackLog.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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("scripts/EAction.js");
  20. /**
  21. * This action reloads all linetypes from
  22. */
  23. function FlushBackLog(guiAction) {
  24. EAction.call(this, guiAction);
  25. }
  26. FlushBackLog.prototype = new EAction();
  27. FlushBackLog.prototype.beginEvent = function() {
  28. EAction.prototype.beginEvent.call(this);
  29. var di = this.getDocumentInterface();
  30. if (!isNull(di)) {
  31. var buttons = makeQMessageBoxStandardButtons(QMessageBox.Yes, QMessageBox.Cancel);
  32. var ret = QMessageBox.warning(EAction.getMainWindow(),
  33. qsTr("Flush Undo History"),
  34. qsTr("Are you sure that you want to flush the undo / redo transaction history?") + " " +
  35. qsTr("This cannot be undone."),
  36. buttons
  37. );
  38. if (ret===QMessageBox.Yes) {
  39. di.flushTransactions();
  40. }
  41. }
  42. this.terminate();
  43. };
  44. FlushBackLog.init = function(basePath) {
  45. var action = new RGuiAction(qsTr("Flush &Undo History"), RMainWindowQt.getMainWindow());
  46. action.setRequiresDocument(true);
  47. action.setRequiresSelection(false);
  48. action.setScriptFile(basePath + "/FlushBackLog.js");
  49. action.setGroupSortOrder(56100);
  50. action.setSortOrder(400);
  51. action.setWidgetNames(["MiscModifyMenu", "!MiscModifyToolBar", "!MiscModifyToolsPanel"]);
  52. };