mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-16 12:52:46 +00:00
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.
This commit is contained in:
parent
95a03f8ed6
commit
851b887cd0
|
@ -341,6 +341,8 @@ bool GLContextWidget::load_file(String const& filename, NonnullOwnPtr<Core::File
|
|||
m_mesh = new_mesh.release_value();
|
||||
dbgln("3DFileViewer: mesh has {} triangles.", m_mesh->triangle_count());
|
||||
|
||||
window()->set_title(DeprecatedString::formatted("{} - 3D File Viewer", filename));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -382,10 +384,7 @@ ErrorOr<int> 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<int> 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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue