diff options
author | Tom <tomut@yahoo.com> | 2020-07-16 07:54:42 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-16 16:10:21 +0200 |
commit | 65a11fb5f913be1e403e47222fb7a696100b2323 (patch) | |
tree | 0d2d551bb772cac884ea758a41a79257fd10b913 /Applications/FileManager | |
parent | 27bd2eab2288c79206f3571bc2c46a20fc9a4254 (diff) | |
download | serenity-65a11fb5f913be1e403e47222fb7a696100b2323.zip |
LibGUI: Add InputBox::show with required parent window argument
Similar to MessageBox::show, this encourages passing in a window.
Diffstat (limited to 'Applications/FileManager')
-rw-r--r-- | Applications/FileManager/main.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index dc092ba5cf..4f3a7e3088 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -164,12 +164,12 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> config, String initial_location auto desktop_view_context_menu = GUI::Menu::construct("Directory View"); auto mkdir_action = GUI::Action::create("New directory...", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) { - auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window); - if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { + String value; + if (GUI::InputBox::show(value, window, "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path( String::format("%s/%s", model->root_path().characters(), - input_box->text_value().characters())); + value.characters())); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { GUI::MessageBox::show(window, String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); @@ -178,12 +178,12 @@ int run_in_desktop_mode(RefPtr<Core::ConfigFile> config, String initial_location }); auto touch_action = GUI::Action::create("New file...", {}, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) { - auto input_box = GUI::InputBox::construct("Enter name:", "New file", window); - if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { + String value; + if (GUI::InputBox::show(value, window, "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) { auto new_file_path = LexicalPath::canonicalized_path( String::format("%s/%s", model->root_path().characters(), - input_box->text_value().characters())); + value.characters())); struct stat st; int rc = stat(new_file_path.characters(), &st); if ((rc < 0 && errno != ENOENT)) { @@ -322,12 +322,12 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio }); auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) { - auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window); - if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { + String value; + if (GUI::InputBox::show(value, window, "Enter name:", "New directory") == GUI::InputBox::ExecOK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path( String::format("%s/%s", directory_view.path().characters(), - input_box->text_value().characters())); + value.characters())); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { GUI::MessageBox::show(window, String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); @@ -338,12 +338,12 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio }); auto touch_action = GUI::Action::create("New file...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) { - auto input_box = GUI::InputBox::construct("Enter name:", "New file", window); - if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { + String value; + if (GUI::InputBox::show(value, window, "Enter name:", "New file") == GUI::InputBox::ExecOK && !value.is_empty()) { auto new_file_path = LexicalPath::canonicalized_path( String::format("%s/%s", directory_view.path().characters(), - input_box->text_value().characters())); + value.characters())); struct stat st; int rc = stat(new_file_path.characters(), &st); if ((rc < 0 && errno != ENOENT)) { |