diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-04-03 17:50:11 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-03 21:16:26 +0200 |
commit | 1e275dd942024a8c1781729ae3248ff067f8d514 (patch) | |
tree | 5441b7a614ab94efc5eeeafac8f836d3d9e07997 /Userland/Applications/Spreadsheet | |
parent | b85d24b1f40c31a2f14757aaf8ac6b9d356209ad (diff) | |
download | serenity-1e275dd942024a8c1781729ae3248ff067f8d514.zip |
Spreadsheet: Add list of recently-opened files
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r-- | Userland/Applications/Spreadsheet/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp | 12 | ||||
-rw-r--r-- | Userland/Applications/Spreadsheet/main.cpp | 4 |
3 files changed, 17 insertions, 1 deletions
diff --git a/Userland/Applications/Spreadsheet/CMakeLists.txt b/Userland/Applications/Spreadsheet/CMakeLists.txt index e4affa4cb4..f800fd4288 100644 --- a/Userland/Applications/Spreadsheet/CMakeLists.txt +++ b/Userland/Applications/Spreadsheet/CMakeLists.txt @@ -42,7 +42,7 @@ set(GENERATED_SOURCES ) serenity_app(Spreadsheet ICON app-spreadsheet) -target_link_libraries(Spreadsheet PRIVATE LibCore LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibJS LibMain LibMarkdown LibSyntax LibWebView LibWeb) +target_link_libraries(Spreadsheet PRIVATE LibConfig LibCore LibFileSystem LibFileSystemAccessClient LibGfx LibGUI LibJS LibMain LibMarkdown LibSyntax LibWebView LibWeb) serenity_test(Writers/Test/TestXSVWriter.cpp Spreadsheet) diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index a663d68633..c2f1b1bffa 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -502,6 +502,7 @@ void SpreadsheetWidget::save(String const& filename, Core::File& file) } undo_stack().set_current_unmodified(); window()->set_modified(false); + GUI::Application::the()->set_most_recently_open_file(filename); } void SpreadsheetWidget::load_file(String const& filename, Core::File& file) @@ -521,6 +522,7 @@ void SpreadsheetWidget::load_file(String const& filename, Core::File& file) setup_tabs(m_workbook->sheets()); update_window_title(); + GUI::Application::the()->set_most_recently_open_file(filename); } void SpreadsheetWidget::import_sheets(String const& filename, Core::File& file) @@ -654,6 +656,16 @@ void SpreadsheetWidget::initialize_menubar(GUI::Window& window) file_menu.add_separator(); file_menu.add_action(*m_import_action); file_menu.add_separator(); + file_menu.add_recent_files_list([&](auto& action) { + if (!request_close()) + return; + + auto response = FileSystemAccessClient::Client::the().request_file_read_only_approved(&window, action.text()); + if (response.is_error()) + return; + load_file(response.value().filename(), response.value().stream()); + }) + .release_value_but_fixme_should_propagate_errors(); file_menu.add_action(*m_quit_action); auto& edit_menu = window.add_menu("&Edit"); diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index bd1cc8a8a0..5ae81a6aeb 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -9,6 +9,7 @@ #include "SpreadsheetWidget.h" #include <AK/ScopeGuard.h> #include <AK/Try.h> +#include <LibConfig/Client.h> #include <LibCore/ArgsParser.h> #include <LibCore/System.h> #include <LibFileSystem/FileSystem.h> @@ -40,6 +41,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } } + Config::pledge_domain("Spreadsheet"); + app->set_config_domain(TRY("Spreadsheet"_string)); + TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw")); TRY(Core::System::unveil("/tmp/session/%sid/portal/webcontent", "rw")); TRY(Core::System::unveil("/etc", "r")); |