mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibGUI: Make GUI::UndoStack remember time it was last set to unmodified
This can be used to determine how much time has passed since a document was saved. :^)
This commit is contained in:
parent
c08872f5da
commit
c4cc796f86
2 changed files with 5 additions and 0 deletions
|
@ -80,6 +80,7 @@ void UndoStack::set_current_unmodified()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_clean_index = m_stack_index;
|
m_clean_index = m_stack_index;
|
||||||
|
m_last_unmodified_timestamp = Time::now_monotonic();
|
||||||
|
|
||||||
if (on_state_change)
|
if (on_state_change)
|
||||||
on_state_change();
|
on_state_change();
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/NonnullOwnPtrVector.h>
|
#include <AK/NonnullOwnPtrVector.h>
|
||||||
|
#include <AK/Time.h>
|
||||||
#include <LibGUI/Forward.h>
|
#include <LibGUI/Forward.h>
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -28,6 +29,8 @@ public:
|
||||||
void set_current_unmodified();
|
void set_current_unmodified();
|
||||||
bool is_current_modified() const;
|
bool is_current_modified() const;
|
||||||
|
|
||||||
|
Optional<Time> last_unmodified_timestamp() const { return m_last_unmodified_timestamp; }
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
Optional<String> undo_action_text() const;
|
Optional<String> undo_action_text() const;
|
||||||
|
@ -39,6 +42,7 @@ private:
|
||||||
NonnullOwnPtrVector<Command> m_stack;
|
NonnullOwnPtrVector<Command> m_stack;
|
||||||
size_t m_stack_index { 0 };
|
size_t m_stack_index { 0 };
|
||||||
Optional<size_t> m_clean_index;
|
Optional<size_t> m_clean_index;
|
||||||
|
Optional<Time> m_last_unmodified_timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue