From 851b887cd07a81e38655737fde74d8f0203552e6 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Sat, 14 Jan 2023 20:39:39 -0500 Subject: [PATCH] 3DFileViewer: Set the window title name in `load_file()` This patch allows two things: - Factorizing code that was in main and the open action - Displaying the full path of non-unveiled paths Indeed, looking for the path of a fd is not allowed if the file isn't unveiled. By setting the title in `load_file()` we are actually relying on the value returned by `LibFSAC` who is actually authorized to retrieve the entire path. --- Userland/Applications/3DFileViewer/main.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index 96c5a6fd9d..f1d6e886f1 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -341,6 +341,8 @@ bool GLContextWidget::load_file(String const& filename, NonnullOwnPtrtriangle_count()); + window()->set_title(DeprecatedString::formatted("{} - 3D File Viewer", filename)); + return true; } @@ -382,10 +384,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return; auto file = response.release_value(); - if (widget->load_file(file.filename(), file.release_stream())) { - auto canonical_path = Core::DeprecatedFile::absolute_path(file.filename().to_deprecated_string()); - window->set_title(DeprecatedString::formatted("{} - 3D File Viewer", canonical_path)); - } + widget->load_file(file.filename(), file.release_stream()); })); file_menu.add_separator(); file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { @@ -571,10 +570,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->show(); auto filename = arguments.argc > 1 ? arguments.argv[1] : "/home/anon/Documents/3D Models/teapot.obj"; - if (widget->load_path(filename)) { - auto canonical_path = Core::DeprecatedFile::absolute_path(filename); - window->set_title(DeprecatedString::formatted("{} - 3D File Viewer", canonical_path)); - } + widget->load_path(filename); return app->exec(); }