mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibGUI+FileSystemAccessServer: Avoid using dummy windows
Creates two new gatekept helpers for FilePicker and MessageBox to be used by FSAS to replace the "dummy window" approach to centering Dialogs. There was a slight delay in creating two windows, one a transparent intermediary hidden behind the second, to display FSAS Dialogs. Now we only need to make the window we actually see.
This commit is contained in:
parent
f76d24c2ec
commit
7323a54e59
6 changed files with 58 additions and 26 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/CommonLocationsProvider.h>
|
||||
#include <LibGUI/ConnectionToWindowServer.h>
|
||||
#include <LibGUI/FileIconProvider.h>
|
||||
#include <LibGUI/FilePicker.h>
|
||||
#include <LibGUI/FilePickerDialogGML.h>
|
||||
|
@ -36,6 +37,26 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
ErrorOr<Optional<String>> FilePicker::get_filepath(Badge<FileSystemAccessServer::ConnectionFromClient>, i32 window_server_client_id, i32 parent_window_id, Mode mode, StringView window_title, StringView file_basename, StringView path, Optional<Vector<FileTypeFilter>> allowed_file_types)
|
||||
{
|
||||
auto picker = TRY(FilePicker::try_create(nullptr, mode, file_basename, path, ScreenPosition::DoNotPosition, move(allowed_file_types)));
|
||||
auto parent_rect = ConnectionToWindowServer::the().get_window_rect_from_client(window_server_client_id, parent_window_id);
|
||||
picker->center_within(parent_rect);
|
||||
picker->constrain_to_desktop();
|
||||
if (!window_title.is_empty())
|
||||
picker->set_title(window_title);
|
||||
picker->show();
|
||||
ConnectionToWindowServer::the().set_window_parent_from_client(window_server_client_id, parent_window_id, picker->window_id());
|
||||
|
||||
if (picker->exec() == ExecResult::OK) {
|
||||
auto file_path = TRY(String::from_deprecated_string(picker->selected_file()));
|
||||
if (file_path.is_empty())
|
||||
return Optional<String> {};
|
||||
return file_path;
|
||||
}
|
||||
return Optional<String> {};
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> FilePicker::get_open_filepath(Window* parent_window, DeprecatedString const& window_title, StringView path, bool folder, ScreenPosition screen_position, Optional<Vector<FileTypeFilter>> allowed_file_types)
|
||||
{
|
||||
auto picker = FilePicker::construct(parent_window, folder ? Mode::OpenFolder : Mode::Open, ""sv, path, screen_position, move(allowed_file_types));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue