Browse Source

Browser: Show a message when attempting to search with no search engine

Previously, it just showed an error message saying that "" failed to
load, which made me think that search engines were broken.
Sam Atkins 4 years ago
parent
commit
5de7775d22
1 changed files with 6 additions and 0 deletions
  1. 6 0
      Userland/Applications/Browser/Tab.cpp

+ 6 - 0
Userland/Applications/Browser/Tab.cpp

@@ -21,6 +21,7 @@
 #include <LibGUI/Button.h>
 #include <LibGUI/Button.h>
 #include <LibGUI/Clipboard.h>
 #include <LibGUI/Clipboard.h>
 #include <LibGUI/Menu.h>
 #include <LibGUI/Menu.h>
+#include <LibGUI/MessageBox.h>
 #include <LibGUI/Statusbar.h>
 #include <LibGUI/Statusbar.h>
 #include <LibGUI/TextBox.h>
 #include <LibGUI/TextBox.h>
 #include <LibGUI/Toolbar.h>
 #include <LibGUI/Toolbar.h>
@@ -145,6 +146,11 @@ Tab::Tab(BrowserWindow& window, Type type)
     m_location_box->set_placeholder("Address");
     m_location_box->set_placeholder("Address");
 
 
     m_location_box->on_return_pressed = [this] {
     m_location_box->on_return_pressed = [this] {
+        if (m_location_box->text().starts_with('?') && g_search_engine.is_empty()) {
+            GUI::MessageBox::show(&this->window(), "Select a search engine in the Settings menu before searching.", "No search engine selected", GUI::MessageBox::Type::Information);
+            return;
+        }
+
         auto url = url_from_user_input(m_location_box->text());
         auto url = url_from_user_input(m_location_box->text());
         load(url);
         load(url);
         view().set_focus(true);
         view().set_focus(true);