1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:47:34 +00:00

LibGUI: Allow to specify FilePicker window position

This commit is contained in:
LuK1337 2021-07-14 12:04:46 +02:00 committed by Gunnar Beutner
parent 84ee95c346
commit ba119029dd
2 changed files with 9 additions and 9 deletions

View file

@ -30,9 +30,9 @@
namespace GUI { namespace GUI {
Optional<String> FilePicker::get_open_filepath(Window* parent_window, const String& window_title, const StringView& path, bool folder) Optional<String> FilePicker::get_open_filepath(Window* parent_window, const String& window_title, const StringView& path, bool folder, ScreenPosition screen_position)
{ {
auto picker = FilePicker::construct(parent_window, folder ? Mode::OpenFolder : Mode::Open, "", path); auto picker = FilePicker::construct(parent_window, folder ? Mode::OpenFolder : Mode::Open, "", path, screen_position);
if (!window_title.is_null()) if (!window_title.is_null())
picker->set_title(window_title); picker->set_title(window_title);
@ -48,9 +48,9 @@ Optional<String> FilePicker::get_open_filepath(Window* parent_window, const Stri
return {}; return {};
} }
Optional<String> FilePicker::get_save_filepath(Window* parent_window, const String& title, const String& extension, const StringView& path) Optional<String> FilePicker::get_save_filepath(Window* parent_window, const String& title, const String& extension, const StringView& path, ScreenPosition screen_position)
{ {
auto picker = FilePicker::construct(parent_window, Mode::Save, String::formatted("{}.{}", title, extension), path); auto picker = FilePicker::construct(parent_window, Mode::Save, String::formatted("{}.{}", title, extension), path, screen_position);
if (picker->exec() == Dialog::ExecOK) { if (picker->exec() == Dialog::ExecOK) {
String file_path = picker->selected_file(); String file_path = picker->selected_file();
@ -63,8 +63,8 @@ Optional<String> FilePicker::get_save_filepath(Window* parent_window, const Stri
return {}; return {};
} }
FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filename, const StringView& path) FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filename, const StringView& path, ScreenPosition screen_position)
: Dialog(parent_window) : Dialog(parent_window, screen_position)
, m_model(FileSystemModel::create(path)) , m_model(FileSystemModel::create(path))
, m_mode(mode) , m_mode(mode)
{ {

View file

@ -28,8 +28,8 @@ public:
Save Save
}; };
static Optional<String> get_open_filepath(Window* parent_window, const String& window_title = {}, const StringView& path = Core::StandardPaths::home_directory(), bool folder = false); static Optional<String> get_open_filepath(Window* parent_window, const String& window_title = {}, const StringView& path = Core::StandardPaths::home_directory(), bool folder = false, ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
static Optional<String> get_save_filepath(Window* parent_window, const String& title, const String& extension, const StringView& path = Core::StandardPaths::home_directory()); static Optional<String> get_save_filepath(Window* parent_window, const String& title, const String& extension, const StringView& path = Core::StandardPaths::home_directory(), ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
virtual ~FilePicker() override; virtual ~FilePicker() override;
@ -43,7 +43,7 @@ private:
// ^GUI::ModelClient // ^GUI::ModelClient
virtual void model_did_update(unsigned) override; virtual void model_did_update(unsigned) override;
FilePicker(Window* parent_window, Mode type = Mode::Open, const StringView& filename = "Untitled", const StringView& path = Core::StandardPaths::home_directory()); FilePicker(Window* parent_window, Mode type = Mode::Open, const StringView& filename = "Untitled", const StringView& path = Core::StandardPaths::home_directory(), ScreenPosition screen_position = Dialog::ScreenPosition::CenterWithinParent);
static String ok_button_name(Mode mode) static String ok_button_name(Mode mode)
{ {