mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:57:35 +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
|
@ -152,7 +152,7 @@ void DisplaySettingsWidget::create_frame()
|
|||
button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||
button.set_preferred_size(22, 22);
|
||||
button.on_click = [this](auto) {
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath("Select wallpaper from file system.");
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath(root_widget()->window(), "Select wallpaper from file system.");
|
||||
|
||||
if (!open_path.has_value())
|
||||
return;
|
||||
|
|
|
@ -54,6 +54,7 @@ int main(int argc, char** argv)
|
|||
auto instance = DisplaySettingsWidget::construct();
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
dbg() << "main window: " << window;
|
||||
window->set_title("Display settings");
|
||||
window->move_to(100, 100);
|
||||
window->resize(360, 390);
|
||||
|
|
|
@ -92,7 +92,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto& app_menu = menubar->add_menu("Font Editor");
|
||||
app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath();
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window);
|
||||
if (!open_path.has_value())
|
||||
return;
|
||||
|
||||
|
@ -112,7 +112,7 @@ int main(int argc, char** argv)
|
|||
app_menu.add_action(GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) {
|
||||
FontEditorWidget* editor = static_cast<FontEditorWidget*>(window->main_widget());
|
||||
LexicalPath lexical_path(editor->path());
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(lexical_path.title(), lexical_path.extension());
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, lexical_path.title(), lexical_path.extension());
|
||||
if (!save_path.has_value())
|
||||
return;
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
});
|
||||
|
||||
m_open_action = GUI::CommonActions::make_open_action([this](auto&) {
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath();
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window());
|
||||
|
||||
if (!open_path.has_value())
|
||||
return;
|
||||
|
@ -118,7 +118,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
});
|
||||
|
||||
m_save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GUI::Action&) {
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "bin" : m_extension);
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window(), m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "bin" : m_extension);
|
||||
if (!save_path.has_value())
|
||||
return;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ int main(int argc, char** argv)
|
|||
// Actions
|
||||
auto open_action = GUI::CommonActions::make_open_action(
|
||||
[&](auto&) {
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath("Open");
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open");
|
||||
if (path.has_value()) {
|
||||
keyboard_mapper_widget->load_from_file(path.value());
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
|||
auto save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"),
|
||||
[&](auto&) {
|
||||
String m_name = "Unnamed";
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(m_name, "json");
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window, m_name, "json");
|
||||
if (!save_path.has_value())
|
||||
return;
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager)
|
|||
m_open_button->set_focusable(false);
|
||||
m_open_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"));
|
||||
m_open_button->on_click = [this](auto) {
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath();
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window());
|
||||
if (!open_path.has_value())
|
||||
return;
|
||||
String error_string = m_track_manager.current_track().set_recorded_sample(open_path.value());
|
||||
|
|
|
@ -96,7 +96,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto& app_menu = menubar->add_menu("Piano");
|
||||
app_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) {
|
||||
save_path = GUI::FilePicker::get_save_filepath("Untitled", "wav");
|
||||
save_path = GUI::FilePicker::get_save_filepath(window, "Untitled", "wav");
|
||||
if (!save_path.has_value())
|
||||
return;
|
||||
wav_writer.set_file(save_path.value());
|
||||
|
|
|
@ -100,7 +100,7 @@ int main(int argc, char** argv)
|
|||
auto& app_menu = menubar->add_menu("PixelPaint");
|
||||
|
||||
app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath();
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window);
|
||||
|
||||
if (!open_path.has_value())
|
||||
return;
|
||||
|
|
|
@ -126,7 +126,7 @@ int main(int argc, char** argv)
|
|||
// Actions
|
||||
auto open_action = GUI::CommonActions::make_open_action(
|
||||
[&](auto&) {
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath("Open image...");
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open image...");
|
||||
if (path.has_value()) {
|
||||
widget.load_from_file(path.value());
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ int main(int argc, char** argv)
|
|||
});
|
||||
|
||||
app_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath("Open wav file...");
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open wav file...");
|
||||
if (path.has_value()) {
|
||||
player.open_file(path.value());
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
});
|
||||
|
||||
m_open_action = GUI::CommonActions::make_open_action([this](auto&) {
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath();
|
||||
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window());
|
||||
|
||||
if (!open_path.has_value())
|
||||
return;
|
||||
|
@ -321,7 +321,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
});
|
||||
|
||||
m_save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GUI::Action&) {
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "txt" : m_extension);
|
||||
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window(), m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "txt" : m_extension);
|
||||
if (!save_path.has_value())
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue