mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
UI/Qt: Show search engine name in location bar
The placeholder text shows "Search or enter web address" which doesn't tell the user about *how* the search will be performed. Other popular open source browsers show the search engine that will be used. For example: Chromium: "Search **engine** or type a URL" Firefox: "Search with **engine** or enter address" This change changes the placeholder text of the location bar to show "Search with **engine** or enter web address".
This commit is contained in:
parent
e9001da8d6
commit
637ccbec35
Notes:
sideshowbarker
2024-07-19 16:48:55 +09:00
Author: https://github.com/hughdavenport Commit: https://github.com/LadybirdBrowser/ladybird/commit/637ccbec352 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/140 Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 19 additions and 4 deletions
|
@ -19,10 +19,10 @@ namespace Ladybird {
|
|||
LocationEdit::LocationEdit(QWidget* parent)
|
||||
: QLineEdit(parent)
|
||||
{
|
||||
if (Settings::the()->enable_search())
|
||||
setPlaceholderText("Search or enter web address");
|
||||
else
|
||||
setPlaceholderText("Enter web address");
|
||||
update_placeholder();
|
||||
QObject::connect(Settings::the(), &Settings::enable_search_changed, this, &LocationEdit::update_placeholder);
|
||||
QObject::connect(Settings::the(), &Settings::search_engine_changed, this, &LocationEdit::update_placeholder);
|
||||
|
||||
m_autocomplete = make<AutoComplete>(this);
|
||||
this->setCompleter(m_autocomplete);
|
||||
|
||||
|
@ -76,6 +76,16 @@ void LocationEdit::focusOutEvent(QFocusEvent* event)
|
|||
highlight_location();
|
||||
}
|
||||
|
||||
void LocationEdit::update_placeholder()
|
||||
{
|
||||
if (Settings::the()->enable_search())
|
||||
setPlaceholderText(qstring_from_ak_string(
|
||||
MUST(String::formatted("Search with {} or enter web address",
|
||||
Settings::the()->search_engine().name))));
|
||||
else
|
||||
setPlaceholderText("Enter web address");
|
||||
}
|
||||
|
||||
void LocationEdit::highlight_location()
|
||||
{
|
||||
auto url = ak_string_from_qstring(text());
|
||||
|
|
|
@ -27,6 +27,7 @@ private:
|
|||
virtual void focusInEvent(QFocusEvent* event) override;
|
||||
virtual void focusOutEvent(QFocusEvent* event) override;
|
||||
|
||||
void update_placeholder();
|
||||
void highlight_location();
|
||||
AK::OwnPtr<AutoComplete> m_autocomplete;
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ void Settings::set_search_engine(WebView::SearchEngine search_engine)
|
|||
{
|
||||
m_qsettings->setValue("search_engine_name", qstring_from_ak_string(search_engine.name));
|
||||
m_search_engine = move(search_engine);
|
||||
emit search_engine_changed(m_search_engine);
|
||||
}
|
||||
|
||||
Settings::EngineProvider Settings::autocomplete_engine()
|
||||
|
@ -109,6 +110,7 @@ bool Settings::enable_search()
|
|||
void Settings::set_enable_search(bool enable)
|
||||
{
|
||||
m_qsettings->setValue("enable_search", enable);
|
||||
emit enable_search_changed(enable);
|
||||
}
|
||||
|
||||
bool Settings::show_menubar()
|
||||
|
|
|
@ -63,6 +63,8 @@ public:
|
|||
|
||||
signals:
|
||||
void show_menubar_changed(bool show_menubar);
|
||||
void enable_search_changed(bool enable);
|
||||
void search_engine_changed(WebView::SearchEngine engine);
|
||||
|
||||
protected:
|
||||
Settings();
|
||||
|
|
Loading…
Add table
Reference in a new issue