mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:37:34 +00:00
Everywhere: Use MonotonicTime instead of Duration
This is easily identifiable by anyone who uses Duration::now_monotonic, and any downstream users of that data.
This commit is contained in:
parent
b2e7b8cdff
commit
fc5cab5c21
29 changed files with 79 additions and 80 deletions
|
@ -63,12 +63,12 @@ ErrorOr<Dialog::ExecResult> MessageBox::try_show_error(Window* parent_window, St
|
|||
return TRY(try_show(parent_window, text, "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK));
|
||||
}
|
||||
|
||||
Dialog::ExecResult MessageBox::ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Duration> last_unmodified_timestamp)
|
||||
Dialog::ExecResult MessageBox::ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<MonotonicTime> last_unmodified_timestamp)
|
||||
{
|
||||
return MUST(try_ask_about_unsaved_changes(parent_window, path, last_unmodified_timestamp));
|
||||
return MUST(try_ask_about_unsaved_changes(parent_window, path, move(last_unmodified_timestamp)));
|
||||
}
|
||||
|
||||
ErrorOr<Dialog::ExecResult> MessageBox::try_ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Duration> last_unmodified_timestamp)
|
||||
ErrorOr<Dialog::ExecResult> MessageBox::try_ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<MonotonicTime> last_unmodified_timestamp)
|
||||
{
|
||||
StringBuilder builder;
|
||||
TRY(builder.try_append("Save changes to "sv));
|
||||
|
@ -79,7 +79,7 @@ ErrorOr<Dialog::ExecResult> MessageBox::try_ask_about_unsaved_changes(Window* pa
|
|||
TRY(builder.try_append(" before closing?"sv));
|
||||
|
||||
if (!path.is_empty() && last_unmodified_timestamp.has_value()) {
|
||||
auto age = (Duration::now_monotonic() - *last_unmodified_timestamp).to_seconds();
|
||||
auto age = (MonotonicTime::now() - *last_unmodified_timestamp).to_seconds();
|
||||
auto readable_time = human_readable_time(age);
|
||||
TRY(builder.try_appendff("\nLast saved {} ago.", readable_time));
|
||||
}
|
||||
|
|
|
@ -40,12 +40,12 @@ public:
|
|||
|
||||
static ExecResult show(Window* parent_window, StringView text, StringView title, Type type = Type::None, InputType input_type = InputType::OK);
|
||||
static ExecResult show_error(Window* parent_window, StringView text);
|
||||
static ExecResult ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Duration> last_unmodified_timestamp = {});
|
||||
static ExecResult ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<MonotonicTime> last_unmodified_timestamp = {});
|
||||
|
||||
static ErrorOr<ExecResult> try_show(Badge<FileSystemAccessServer::ConnectionFromClient>, i32 window_server_client_id, i32 parent_window_id, StringView text, StringView title);
|
||||
static ErrorOr<ExecResult> try_show(Window* parent_window, StringView text, StringView title, Type type = Type::None, InputType input_type = InputType::OK);
|
||||
static ErrorOr<ExecResult> try_show_error(Window* parent_window, StringView text);
|
||||
static ErrorOr<ExecResult> try_ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Duration> last_unmodified_timestamp = {});
|
||||
static ErrorOr<ExecResult> try_ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<MonotonicTime> last_unmodified_timestamp = {});
|
||||
|
||||
static ErrorOr<NonnullRefPtr<MessageBox>> create(Window* parent_window, StringView text, StringView title, Type type = Type::None, InputType input_type = InputType::OK);
|
||||
|
||||
|
|
|
@ -894,7 +894,7 @@ bool InsertTextCommand::merge_with(GUI::Command const& other)
|
|||
m_text = builder.to_deprecated_string();
|
||||
m_range.set_end(typed_other.m_range.end());
|
||||
|
||||
m_timestamp = Duration::now_monotonic();
|
||||
m_timestamp = MonotonicTime::now();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -994,7 +994,7 @@ bool RemoveTextCommand::merge_with(GUI::Command const& other)
|
|||
m_text = builder.to_deprecated_string();
|
||||
m_range.set_start(typed_other.m_range.start());
|
||||
|
||||
m_timestamp = Duration::now_monotonic();
|
||||
m_timestamp = MonotonicTime::now();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,9 +228,9 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
bool commit_time_expired() const { return Duration::now_monotonic() - m_timestamp >= COMMAND_COMMIT_TIME; }
|
||||
bool commit_time_expired() const { return MonotonicTime::now() - m_timestamp >= COMMAND_COMMIT_TIME; }
|
||||
|
||||
Duration m_timestamp = Duration::now_monotonic();
|
||||
MonotonicTime m_timestamp = MonotonicTime::now();
|
||||
TextDocument& m_document;
|
||||
TextDocument::Client const* m_client { nullptr };
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ void UndoStack::set_current_unmodified()
|
|||
return;
|
||||
|
||||
m_clean_index = m_stack_index;
|
||||
m_last_unmodified_timestamp = Duration::now_monotonic();
|
||||
m_last_unmodified_timestamp = MonotonicTime::now();
|
||||
|
||||
if (on_state_change)
|
||||
on_state_change();
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
void set_current_unmodified();
|
||||
bool is_current_modified() const;
|
||||
|
||||
Optional<Duration> last_unmodified_timestamp() const { return m_last_unmodified_timestamp; }
|
||||
Optional<MonotonicTime> last_unmodified_timestamp() const { return m_last_unmodified_timestamp; }
|
||||
|
||||
void clear();
|
||||
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
Vector<NonnullOwnPtr<Command>> m_stack;
|
||||
size_t m_stack_index { 0 };
|
||||
Optional<size_t> m_clean_index;
|
||||
Optional<Duration> m_last_unmodified_timestamp;
|
||||
Optional<MonotonicTime> m_last_unmodified_timestamp;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue