Skip to content

Commit

Permalink
Spreadsheet: Add list of recently-opened files
Browse files Browse the repository at this point in the history
  • Loading branch information
AtkinsSJ authored and awesomekling committed Apr 3, 2023
1 parent b85d24b commit 1e275dd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Userland/Applications/Spreadsheet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 12 additions & 0 deletions Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions Userland/Applications/Spreadsheet/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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"));
Expand Down

0 comments on commit 1e275dd

Please sign in to comment.