diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2023-05-16 08:39:06 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-17 06:47:57 +0200 |
commit | 19b8b9d18714c3534c68c7dc20e83a47888609f2 (patch) | |
tree | f95875075307dd9b9a04addd30be1c4319555044 /Userland/Applications/FontEditor | |
parent | c10b1e3aea997d84703d5e2641a371628ca5ca4e (diff) | |
download | serenity-19b8b9d18714c3534c68c7dc20e83a47888609f2.zip |
FontEditor: Show recently opened files in File menu
And update GlyphEditorWidget on initialize(). Fixes Editor not showing
the new active glyph when loading recent fonts from a menu.
Diffstat (limited to 'Userland/Applications/FontEditor')
-rw-r--r-- | Userland/Applications/FontEditor/GlyphEditorWidget.cpp | 1 | ||||
-rw-r--r-- | Userland/Applications/FontEditor/MainWidget.cpp | 20 | ||||
-rw-r--r-- | Userland/Applications/FontEditor/main.cpp | 1 |
3 files changed, 19 insertions, 3 deletions
diff --git a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp index 0afa466be5..103e120d2d 100644 --- a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp +++ b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp @@ -19,6 +19,7 @@ void GlyphEditorWidget::initialize(Gfx::BitmapFont* mutable_font) if (m_font == mutable_font) return; m_font = mutable_font; + update(); } void GlyphEditorWidget::set_glyph(int glyph) diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 6a3347a5be..305978cdec 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -158,9 +158,11 @@ ErrorOr<void> MainWidget::create_actions() auto response = FileSystemAccessClient::Client::the().save_file(window(), lexical_path.title(), lexical_path.extension()); if (response.is_error()) return; - - if (auto result = save_file(response.value().filename(), response.value().release_stream()); result.is_error()) - show_error(result.release_error(), "Saving"sv, response.value().filename()); + auto file = response.release_value(); + if (auto result = save_file(file.filename(), file.release_stream()); result.is_error()) + show_error(result.release_error(), "Saving"sv, file.filename()); + else + GUI::Application::the()->set_most_recently_open_file(file.filename()); }); m_cut_action = GUI::CommonActions::make_cut_action([this](auto&) { @@ -736,6 +738,16 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window) TRY(file_menu->try_add_action(*m_save_action)); TRY(file_menu->try_add_action(*m_save_as_action)); TRY(file_menu->try_add_separator()); + TRY(file_menu->add_recent_files_list([this](auto& action) { + if (!request_close()) + return; + auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(this->window(), action.text()); + if (response.is_error()) + return; + auto file = response.release_value(); + if (auto result = open_file(file.filename(), file.release_stream()); result.is_error()) + show_error(result.release_error(), "Opening"sv, file.filename()); + })); TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([this](auto&) { if (!request_close()) return; @@ -807,6 +819,8 @@ ErrorOr<void> MainWidget::open_file(StringView path, NonnullOwnPtr<Core::File> f auto mapped_file = TRY(Core::MappedFile::map_from_file(move(file), path)); auto unmasked_font = TRY(TRY(Gfx::BitmapFont::try_load_from_mapped_file(mapped_file))->unmasked_character_set()); TRY(initialize(path, move(unmasked_font))); + if (!path.is_empty()) + GUI::Application::the()->set_most_recently_open_file(TRY(String::from_utf8(path))); return {}; } diff --git a/Userland/Applications/FontEditor/main.cpp b/Userland/Applications/FontEditor/main.cpp index 3e04aea161..f19e035ece 100644 --- a/Userland/Applications/FontEditor/main.cpp +++ b/Userland/Applications/FontEditor/main.cpp @@ -21,6 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd thread rpath unix cpath wpath")); auto app = TRY(GUI::Application::create(arguments)); + app->set_config_domain(TRY("FontEditor"_string)); FontEditor::g_resources = FontEditor::Resources::create(); |