UI: Add disable push/pop to undo/redo stack

This allows disabling and re-enabling in certain situations where these
actions doing so might end up being used in recursion.
This commit is contained in:
jp9000
2021-05-12 21:18:36 -07:00
parent edc82eb7cf
commit 1afe092c6e
2 changed files with 39 additions and 6 deletions

View File

@@ -29,11 +29,16 @@ class undo_stack : public QObject {
ui_ptr ui;
std::deque<undo_redo_t> undo_items;
std::deque<undo_redo_t> redo_items;
int disable_refs = 0;
bool enabled = true;
bool last_is_repeatable = false;
QTimer repeat_reset_timer;
inline bool is_enabled() const { return !disable_refs && enabled; }
void enable_internal();
void disable_internal();
void clear_redo();
private slots:
@@ -44,6 +49,8 @@ public:
void enable();
void disable();
void push_disabled();
void pop_disabled();
void clear();
void add_action(const QString &name, undo_redo_cb undo,