1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 10:18:15 +09:00
ladybird/UI/Qt/LocationEdit.h
Timothy Flynn e084a86861 LibWebView+UI: Introduce a persistent settings object
This adds a WebView::Settings class to own persistent browser settings.
In this first pass, it now owns the new tab page URL and search engine
settings.

For simplicitly, we currently use a JSON format for these settings. They
are stored alongside the cookie database. As of this commit, the saved
JSON will have the form:

    {
        "newTabPageURL": "about:blank",
        "searchEngine": {
            "name": "Google"
        }
    }

(The search engine is an object to allow room for a future patch to
implement custom search engine URLs.)

For Qt, this replaces the management of these particular settings in the
Qt settings UI. We will have an internal browser page to control these
settings instead. In the future, we will want to port all settings to
this new class. We will also want to allow UI-specific settings (such as
whether the hamburger menu is displayed in Qt).
2025-03-22 17:27:45 +01:00

45 lines
988 B
C++

/*
* Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/OwnPtr.h>
#include <LibWebView/Settings.h>
#include <UI/Qt/AutoComplete.h>
#include <QLineEdit>
namespace Ladybird {
class LocationEdit final
: public QLineEdit
, public WebView::SettingsObserver {
Q_OBJECT
public:
explicit LocationEdit(QWidget*);
URL::URL url() const { return m_url; }
void set_url(URL::URL const&);
bool url_is_hidden() const { return m_url_is_hidden; }
void set_url_is_hidden(bool url_is_hidden) { m_url_is_hidden = url_is_hidden; }
private:
virtual void focusInEvent(QFocusEvent* event) override;
virtual void focusOutEvent(QFocusEvent* event) override;
virtual void search_engine_changed() override;
void update_placeholder();
void highlight_location();
AK::OwnPtr<AutoComplete> m_autocomplete;
URL::URL m_url;
bool m_url_is_hidden { false };
};
}