diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 2f149c8aeb..97dc1012eb 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -438,7 +438,7 @@ void BrowserWindow::build_menus() auto custom_user_agent = GUI::Action::create_checkable("Custom...", [this](auto& action) { DeprecatedString user_agent; - if (GUI::InputBox::show(this, user_agent, "Enter User Agent:"sv, "Custom User Agent"sv) != GUI::InputBox::ExecResult::OK || user_agent.is_empty() || user_agent.is_null()) { + if (GUI::InputBox::show(this, user_agent, "Enter User Agent:"sv, "Custom User Agent"sv, {}, GUI::InputType::NonemptyText) != GUI::InputBox::ExecResult::OK) { m_disable_user_agent_spoofing->activate(); return; } @@ -529,7 +529,7 @@ ErrorOr BrowserWindow::load_search_engines(GUI::Menu& settings_menu) auto custom_search_engine_action = GUI::Action::create_checkable("Custom...", [&](auto& action) { DeprecatedString search_engine; - if (GUI::InputBox::show(this, search_engine, "Enter URL template:"sv, "Custom Search Engine"sv, "https://host/search?q={}"sv) != GUI::InputBox::ExecResult::OK || search_engine.is_empty()) { + if (GUI::InputBox::show(this, search_engine, "Enter URL template:"sv, "Custom Search Engine"sv, "https://host/search?q={}"sv, GUI::InputType::NonemptyText) != GUI::InputBox::ExecResult::OK) { m_disable_search_engine_action->activate(); return; } diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp index 3604a6918d..81e743b6e7 100644 --- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp @@ -119,8 +119,7 @@ ContentFilterSettingsWidget::ContentFilterSettingsWidget() m_add_new_domain_button->on_click = [&](unsigned) { DeprecatedString text; - if (GUI::InputBox::show(window(), text, "Enter domain name"sv, "Add domain to Content Filter"sv) == GUI::Dialog::ExecResult::OK - && !text.is_empty()) { + if (GUI::InputBox::show(window(), text, "Enter domain name"sv, "Add domain to Content Filter"sv, {}, GUI::InputType::NonemptyText) == GUI::Dialog::ExecResult::OK) { m_domain_list_model->add_domain(move(text)); set_modified(true); } diff --git a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp index 108cae277f..f83179f3b4 100644 --- a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp +++ b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp @@ -70,7 +70,7 @@ CharacterMapWidget::CharacterMapWidget() m_go_to_glyph_action = GUI::Action::create("Go to glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { DeprecatedString input; - if (GUI::InputBox::show(window(), input, "Hexadecimal:"sv, "Go to glyph"sv) == GUI::InputBox::ExecResult::OK && !input.is_empty()) { + if (GUI::InputBox::show(window(), input, "Hexadecimal:"sv, "Go to glyph"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input); if (!maybe_code_point.has_value()) return; diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index 491ef9fe10..b20e8acb2c 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -577,7 +577,7 @@ void DirectoryView::setup_actions() { m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { DeprecatedString value; - if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New directory"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New directory"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto new_dir_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value)); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { @@ -589,7 +589,7 @@ void DirectoryView::setup_actions() m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { DeprecatedString value; - if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New file"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New file"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto new_file_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", path(), value)); struct stat st; int rc = stat(new_file_path.characters(), &st); diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index dd4ba1fa1e..0ec1781c73 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -243,7 +243,7 @@ ErrorOr MainWidget::create_actions() m_go_to_glyph_action = GUI::Action::create("&Go to Glyph...", { Mod_Ctrl, Key_G }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-to.png"sv)), [&](auto&) { DeprecatedString input; - if (GUI::InputBox::show(window(), input, "Hexadecimal:"sv, "Go to glyph"sv) == GUI::InputBox::ExecResult::OK && !input.is_empty()) { + if (GUI::InputBox::show(window(), input, "Hexadecimal:"sv, "Go to glyph"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input); if (!maybe_code_point.has_value()) return; diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index 80a879dfa3..b0d0da2459 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -100,7 +100,7 @@ HexEditorWidget::HexEditorWidget() m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { DeprecatedString value; - if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:"sv, "New file size"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:"sv, "New file size"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto file_size = value.to_uint(); if (!file_size.has_value()) { GUI::MessageBox::show(window(), "Invalid file size entered."sv, "Error"sv, GUI::MessageBox::Type::Error); @@ -243,7 +243,7 @@ HexEditorWidget::HexEditorWidget() m_fill_selection_action = GUI::Action::create("Fill &Selection...", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) { DeprecatedString value; - if (GUI::InputBox::show(window(), value, "Fill byte (hex):"sv, "Fill Selection"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Fill byte (hex):"sv, "Fill Selection"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto fill_byte = strtol(value.characters(), nullptr, 16); auto result = m_editor->fill_selection(fill_byte); if (result.is_error()) diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index 30a6dd77d3..780eb13d43 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -119,7 +119,7 @@ GalleryWidget::GalleryWidget() m_input_button->on_click = [&](auto) { DeprecatedString value; - if (GUI::InputBox::show(window(), value, "Enter input:"sv, "Input"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) + if (GUI::InputBox::show(window(), value, "Enter input:"sv, "Input"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) m_text_editor->set_text(value); }; diff --git a/Userland/Games/MasterWord/main.cpp b/Userland/Games/MasterWord/main.cpp index 0f9c296d6e..463279f02d 100644 --- a/Userland/Games/MasterWord/main.cpp +++ b/Userland/Games/MasterWord/main.cpp @@ -76,7 +76,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(settings_menu->try_add_action(GUI::Action::create("Set &Word Length", [&](auto&) { auto word_length = Config::read_i32("MasterWord"sv, ""sv, "word_length"sv, 5); auto word_length_string = DeprecatedString::number(word_length); - if (GUI::InputBox::show(window, word_length_string, "Word length:"sv, "MasterWord"sv) == GUI::InputBox::ExecResult::OK && !word_length_string.is_empty()) { + if (GUI::InputBox::show(window, word_length_string, "Word length:"sv, "MasterWord"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto maybe_word_length = word_length_string.template to_uint(); if (!maybe_word_length.has_value() || maybe_word_length.value() < shortest_word || maybe_word_length.value() > longest_word) { GUI::MessageBox::show(window, DeprecatedString::formatted("Please enter a number between {} and {}.", shortest_word, longest_word), "MasterWord"sv); @@ -92,7 +92,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(settings_menu->try_add_action(GUI::Action::create("Set &Number Of Guesses", [&](auto&) { auto max_guesses = Config::read_i32("MasterWord"sv, ""sv, "max_guesses"sv, 5); auto max_guesses_string = DeprecatedString::number(max_guesses); - if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:"sv, "MasterWord"sv) == GUI::InputBox::ExecResult::OK && !max_guesses_string.is_empty()) { + if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:"sv, "MasterWord"sv, {}, GUI::InputType::NonemptyText) == GUI::InputBox::ExecResult::OK) { auto maybe_max_guesses = max_guesses_string.template to_uint(); if (!maybe_max_guesses.has_value() || maybe_max_guesses.value() < 1 || maybe_max_guesses.value() > 20) { GUI::MessageBox::show(window, "Please enter a number between 1 and 20."sv, "MasterWord"sv); diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index d080187889..f24a74d2a6 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -163,7 +163,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St auto mkdir_action = Action::create( "New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [this](Action const&) { DeprecatedString value; - if (InputBox::show(this, value, "Enter name:"sv, "New directory"sv) == InputBox::ExecResult::OK && !value.is_empty()) { + if (InputBox::show(this, value, "Enter name:"sv, "New directory"sv, {}, GUI::InputType::NonemptyText) == InputBox::ExecResult::OK) { auto new_dir_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", m_model->root_path(), value)); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) {