1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:47:35 +00:00

AK: Rename Time to Duration

That's what this class really is; in fact that's what the first line of
the comment says it is.

This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
This commit is contained in:
kleines Filmröllchen 2023-03-13 16:30:34 +01:00 committed by Jelle Raaijmakers
parent 82ddc813d5
commit 213025f210
140 changed files with 634 additions and 628 deletions

View file

@ -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<Time> last_unmodified_timestamp)
Dialog::ExecResult MessageBox::ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Duration> last_unmodified_timestamp)
{
return MUST(try_ask_about_unsaved_changes(parent_window, path, last_unmodified_timestamp));
}
ErrorOr<Dialog::ExecResult> MessageBox::try_ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Time> last_unmodified_timestamp)
ErrorOr<Dialog::ExecResult> MessageBox::try_ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Duration> 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 = (Time::now_monotonic() - *last_unmodified_timestamp).to_seconds();
auto age = (Duration::now_monotonic() - *last_unmodified_timestamp).to_seconds();
auto readable_time = human_readable_time(age);
TRY(builder.try_appendff("\nLast saved {} ago.", readable_time));
}

View file

@ -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<Time> last_unmodified_timestamp = {});
static ExecResult ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Duration> 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<Time> last_unmodified_timestamp = {});
static ErrorOr<ExecResult> try_ask_about_unsaved_changes(Window* parent_window, StringView path, Optional<Duration> last_unmodified_timestamp = {});
static ErrorOr<NonnullRefPtr<MessageBox>> create(Window* parent_window, StringView text, StringView title, Type type = Type::None, InputType input_type = InputType::OK);

View file

@ -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 = Time::now_monotonic();
m_timestamp = Duration::now_monotonic();
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 = Time::now_monotonic();
m_timestamp = Duration::now_monotonic();
return true;
}

View file

@ -26,7 +26,7 @@
namespace GUI {
constexpr Time COMMAND_COMMIT_TIME = Time::from_milliseconds(400);
constexpr Duration COMMAND_COMMIT_TIME = Duration::from_milliseconds(400);
struct TextDocumentSpan {
TextRange range;
@ -228,9 +228,9 @@ public:
}
protected:
bool commit_time_expired() const { return Time::now_monotonic() - m_timestamp >= COMMAND_COMMIT_TIME; }
bool commit_time_expired() const { return Duration::now_monotonic() - m_timestamp >= COMMAND_COMMIT_TIME; }
Time m_timestamp = Time::now_monotonic();
Duration m_timestamp = Duration::now_monotonic();
TextDocument& m_document;
TextDocument::Client const* m_client { nullptr };
};

View file

@ -81,7 +81,7 @@ void UndoStack::set_current_unmodified()
return;
m_clean_index = m_stack_index;
m_last_unmodified_timestamp = Time::now_monotonic();
m_last_unmodified_timestamp = Duration::now_monotonic();
if (on_state_change)
on_state_change();

View file

@ -31,7 +31,7 @@ public:
void set_current_unmodified();
bool is_current_modified() const;
Optional<Time> last_unmodified_timestamp() const { return m_last_unmodified_timestamp; }
Optional<Duration> 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<Time> m_last_unmodified_timestamp;
Optional<Duration> m_last_unmodified_timestamp;
};
}