Ladybird: Make LocationEdit its own class

Also make return key behave more like other browsers when editing
This commit is contained in:
Cameron Youell 2023-01-19 01:12:13 +11:00 committed by Andrew Kaster
parent 926e61dec6
commit b97f9f5809
Notes: sideshowbarker 2024-07-19 01:59:31 +09:00
5 changed files with 39 additions and 2 deletions

View File

@ -83,6 +83,7 @@ set(SOURCES
BrowserWindow.cpp
ConsoleWidget.cpp
InspectorWidget.cpp
LocationEdit.cpp
ModelTranslator.cpp
Settings.cpp
SettingsDialog.cpp

16
Ladybird/LocationEdit.cpp Normal file
View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "LocationEdit.h"
#include "Tab.h"
LocationEdit::LocationEdit(Tab* tab)
: QLineEdit(tab)
{
connect(this, &QLineEdit::returnPressed, this, [&] {
clearFocus();
});
}

19
Ladybird/LocationEdit.h Normal file
View File

@ -0,0 +1,19 @@
/*
* Copyright (c) 2023, Cameron Youell <cameronyouell@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#define AK_DONT_REPLACE_STD
#include <QLineEdit>
class Tab;
class LocationEdit final : public QLineEdit {
Q_OBJECT
public:
explicit LocationEdit(Tab*);
};

View File

@ -30,7 +30,7 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path)
m_view = new WebContentView(webdriver_content_ipc_path);
m_toolbar = new QToolBar(this);
m_location_edit = new QLineEdit(this);
m_location_edit = new LocationEdit(this);
m_hover_label = new QLabel(this);
m_hover_label->hide();

View File

@ -9,6 +9,7 @@
#define AK_DONT_REPLACE_STD
#include "LocationEdit.h"
#include "WebContentView.h"
#include <Browser/History.h>
#include <QBoxLayout>
@ -55,7 +56,7 @@ private:
QBoxLayout* m_layout;
QToolBar* m_toolbar { nullptr };
QLineEdit* m_location_edit { nullptr };
LocationEdit* m_location_edit { nullptr };
WebContentView* m_view { nullptr };
BrowserWindow* m_window { nullptr };
Browser::History m_history;