mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
LibGUI: Add parent window argument to FilePicker functions
Since FilePicker almost always should be modal, add the parent window as mandatory first argument.
This commit is contained in:
parent
9844088964
commit
6568765e8f
14 changed files with 27 additions and 26 deletions
|
@ -42,9 +42,9 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
Optional<String> FilePicker::get_open_filepath(const String& window_title, Options options)
|
||||
Optional<String> FilePicker::get_open_filepath(Window* parent_window, const String& window_title, Options options)
|
||||
{
|
||||
auto picker = FilePicker::construct(Mode::Open, options);
|
||||
auto picker = FilePicker::construct(parent_window, Mode::Open, options);
|
||||
|
||||
if (!window_title.is_null())
|
||||
picker->set_title(window_title);
|
||||
|
@ -60,9 +60,9 @@ Optional<String> FilePicker::get_open_filepath(const String& window_title, Optio
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<String> FilePicker::get_save_filepath(const String& title, const String& extension, Options options)
|
||||
Optional<String> FilePicker::get_save_filepath(Window* parent_window, const String& title, const String& extension, Options options)
|
||||
{
|
||||
auto picker = FilePicker::construct(Mode::Save, options, String::format("%s.%s", title.characters(), extension.characters()));
|
||||
auto picker = FilePicker::construct(parent_window, Mode::Save, options, String::format("%s.%s", title.characters(), extension.characters()));
|
||||
|
||||
if (picker->exec() == Dialog::ExecOK) {
|
||||
String file_path = picker->selected_file().string();
|
||||
|
@ -75,7 +75,7 @@ Optional<String> FilePicker::get_save_filepath(const String& title, const String
|
|||
return {};
|
||||
}
|
||||
|
||||
FilePicker::FilePicker(Mode mode, Options options, const StringView& file_name, const StringView& path, Window* parent_window)
|
||||
FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const StringView& file_name, const StringView& path)
|
||||
: Dialog(parent_window)
|
||||
, m_model(FileSystemModel::create())
|
||||
, m_mode(mode)
|
||||
|
|
|
@ -49,12 +49,12 @@ public:
|
|||
DisablePreview = (1 << 0)
|
||||
};
|
||||
|
||||
static Optional<String> get_open_filepath(Options options)
|
||||
static Optional<String> get_open_filepath(Window* parent_window, Options options)
|
||||
{
|
||||
return get_open_filepath({}, options);
|
||||
return get_open_filepath(parent_window, {}, options);
|
||||
}
|
||||
static Optional<String> get_open_filepath(const String& window_title = {}, Options options = Options::None);
|
||||
static Optional<String> get_save_filepath(const String& title, const String& extension, Options options = Options::None);
|
||||
static Optional<String> get_open_filepath(Window* parent_window, const String& window_title = {}, Options options = Options::None);
|
||||
static Optional<String> get_save_filepath(Window* parent_window, const String& title, const String& extension, Options options = Options::None);
|
||||
static bool file_exists(const StringView& path);
|
||||
|
||||
virtual ~FilePicker() override;
|
||||
|
@ -69,7 +69,7 @@ private:
|
|||
|
||||
virtual void on_model_update(unsigned) override;
|
||||
|
||||
FilePicker(Mode type = Mode::Open, Options = Options::None, const StringView& file_name = "Untitled", const StringView& path = Core::StandardPaths::home_directory(), Window* parent_window = nullptr);
|
||||
FilePicker(Window* parent_window, Mode type = Mode::Open, Options = Options::None, const StringView& file_name = "Untitled", const StringView& path = Core::StandardPaths::home_directory());
|
||||
|
||||
static String ok_button_name(Mode mode)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue