View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0018064 | Scribus | General | public | 2026-11-04 16:48 | 2026-11-05 08:42 |
| Reporter | flagsoft | Assigned To | |||
| Priority | high | Severity | minor | Reproducibility | always |
| Status | new | Resolution | open | ||
| Summary | 0018064: [patch] Implementation of disableUndo() and enableUndo() - Patch | ||||
| Description | Add this to cmdmisc.h ``` /*! docstring */ PyDoc_STRVAR(scribus_disableundo__doc__, QT_TR_NOOP("disableUndo()\n\ \n\ Switches the undo system off. Actions performed afterwards are not recorded,\n\ which speeds up scripts that make many changes (e.g. in loops).\n\ Call enableUndo() when done. Does not clear the existing undo stack.\n\ ")); /*! Switches undo off. */ PyObject *scribus_disableundo(PyObject * /*self*/); /*! docstring */ PyDoc_STRVAR(scribus_enableundo__doc__, QT_TR_NOOP("enableUndo()\n\ \n\ Switches the undo system back on after disableUndo().\n\ ")); /*! Switches undo on. */ PyObject *scribus_enableundo(PyObject * /*self*/); /*! docstring */ PyDoc_STRVAR(scribus_isundoenabled__doc__, QT_TR_NOOP("isUndoEnabled() -> bool\n\ \n\ Returns True if the undo system is currently recording actions.\n\ ")); /*! Returns the undo state. */ PyObject *scribus_isundoenabled(PyObject * /*self*/); ``` And this to cmdmisc.cpp ``` #include "undomanager.h" PyObject *scribus_disableundo(PyObject * /*self*/) { UndoManager::instance()->setUndoEnabled(false); Py_RETURN_NONE; } PyObject *scribus_enableundo(PyObject * /*self*/) { UndoManager::instance()->setUndoEnabled(true); Py_RETURN_NONE; } PyObject *scribus_isundoenabled(PyObject * /*self*/) { return PyBool_FromLong(UndoManager::instance()->undoEnabled() ? 1 : 0); } ``` Test: ``` import scribus scribus.disableUndo() try: for i in range(1000): scribus.createRect(10, 10 + i, 50, 5) finally: scribus.enableUndo() ``` | ||||
| Tags | #patch_to_be_reviewed | ||||
| Patch | Yes | ||||
|
|
Add this to scriptplugin.cpp {const_cast<char*>("disableUndo"), (PyCFunction)scribus_disableundo, METH_NOARGS, tr(scribus_disableundo__doc__)}, {const_cast<char*>("enableUndo"), (PyCFunction)scribus_enableundo, METH_NOARGS, tr(scribus_enableundo__doc__)}, {const_cast<char*>("isUndoEnabled"), (PyCFunction)scribus_isundoenabled, METH_NOARGS, tr(scribus_isundoenabled__doc__)}, |
|
|
Hi flagsoft, Thanks for the patch. From what I can tell by skimming through it, iit looks Ok. If you need help for creating patches, you're welcome to ask for it in the Matrix (or irc) chat... - https://matrix.to/#/#scribus-general-chat:matrix.org - #scribus on LiberaChat (synced with the Matrix channel) |