diff options
author | Kemal Zebari <kemalzebra@gmail.com> | 2023-01-20 11:21:40 -0800 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-02-02 01:18:33 +0100 |
commit | 5d7331b4ed76b1dff6681964ce534d64cf986ac3 (patch) | |
tree | 545e92d6bc04cfec638f93050f4e6e1c34f02cfe | |
parent | 24ab91f4d31440b3710d676e432edbafccd57b32 (diff) | |
download | serenity-5d7331b4ed76b1dff6681964ce534d64cf986ac3.zip |
Browser: Disallow empty URLs in the bookmark editor
When an empty URL is given to `BookmarkEditor`, it will now
disable the button that saves the bookmark change since an empty
URL is an invalid URL.
-rw-r--r-- | Userland/Applications/Browser/BookmarksBarWidget.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Userland/Applications/Browser/BookmarksBarWidget.cpp b/Userland/Applications/Browser/BookmarksBarWidget.cpp index efaef4a5f6..e3e02a2bd1 100644 --- a/Userland/Applications/Browser/BookmarksBarWidget.cpp +++ b/Userland/Applications/Browser/BookmarksBarWidget.cpp @@ -58,15 +58,19 @@ private: m_title_textbox->set_focus(true); m_title_textbox->select_all(); - m_url_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("url_textbox"); - m_url_textbox->set_text(url); - auto& ok_button = *widget->find_descendant_of_type_named<GUI::Button>("ok_button"); ok_button.on_click = [this](auto) { done(ExecResult::OK); }; ok_button.set_default(true); + m_url_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("url_textbox"); + m_url_textbox->set_text(url); + m_url_textbox->on_change = [this, &ok_button]() { + auto has_url = !m_url_textbox->text().is_empty(); + ok_button.set_enabled(has_url); + }; + auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button"); cancel_button.on_click = [this](auto) { done(ExecResult::Cancel); |